Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nebula
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
exchain
nebula
Commits
2eb66797
Commit
2eb66797
authored
May 08, 2023
by
Joshua Gutow
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
op-node: Don't invoke p2p unsafe sync for old L2 blocks
parent
c8ee624e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
0 deletions
+22
-0
node.go
op-node/node/node.go
+9
-0
node_test.go
op-node/node/node_test.go
+13
-0
No files found.
op-node/node/node.go
View file @
2eb66797
...
...
@@ -378,12 +378,21 @@ func (n *OpNode) RequestL2Range(ctx context.Context, start, end eth.L2BlockRef)
return
n
.
rpcSync
.
RequestL2Range
(
ctx
,
start
,
end
)
}
if
n
.
p2pNode
!=
nil
&&
n
.
p2pNode
.
AltSyncEnabled
()
{
if
unixTimeStale
(
start
.
Time
,
12
*
time
.
Hour
)
{
n
.
log
.
Debug
(
"ignoring request to sync L2 range, timestamp is too old for p2p"
,
"start"
,
start
,
"end"
,
end
,
"start_time"
,
start
.
Time
)
return
nil
}
return
n
.
p2pNode
.
RequestL2Range
(
ctx
,
start
,
end
)
}
n
.
log
.
Debug
(
"ignoring request to sync L2 range, no sync method available"
,
"start"
,
start
,
"end"
,
end
)
return
nil
}
// unixTimeStale returns true if the unix timestamp is before the current time minus the supplied duration.
func
unixTimeStale
(
timestamp
uint64
,
duration
time
.
Duration
)
bool
{
return
time
.
Unix
(
int64
(
timestamp
),
0
)
.
Before
(
time
.
Now
()
.
Add
(
-
1
*
duration
))
}
func
(
n
*
OpNode
)
P2P
()
p2p
.
Node
{
return
n
.
p2pNode
}
...
...
op-node/node/node_test.go
0 → 100644
View file @
2eb66797
package
node
import
(
"testing"
"time"
"github.com/stretchr/testify/require"
)
func
TestUnixTimeStale
(
t
*
testing
.
T
)
{
require
.
True
(
t
,
unixTimeStale
(
1
_600_000_000
,
1
*
time
.
Hour
))
require
.
False
(
t
,
unixTimeStale
(
uint64
(
time
.
Now
()
.
Unix
()),
1
*
time
.
Hour
))
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment