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
d36a4fd4
Unverified
Commit
d36a4fd4
authored
Oct 19, 2022
by
mergify[bot]
Committed by
GitHub
Oct 19, 2022
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3737 from ethereum-optimism/jg/fix_conf_depth
op-node: Skip conf depth check if L1 head is empty
parents
348505aa
815c7a85
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
14 deletions
+22
-14
conf_depth.go
op-node/rollup/driver/conf_depth.go
+4
-1
conf_depth_test.go
op-node/rollup/driver/conf_depth_test.go
+18
-13
No files found.
op-node/rollup/driver/conf_depth.go
View file @
d36a4fd4
...
...
@@ -6,6 +6,7 @@ import (
"github.com/ethereum-optimism/optimism/op-node/eth"
"github.com/ethereum-optimism/optimism/op-node/rollup/derive"
"github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/common"
)
// confDepth is an util that wraps the L1 input fetcher used in the pipeline,
...
...
@@ -30,7 +31,9 @@ func (c *confDepth) L1BlockRefByNumber(ctx context.Context, num uint64) (eth.L1B
// TODO: performance optimization: buffer the l1Unsafe, invalidate any reorged previous buffer content,
// and instantly return the origin by number from the buffer if we can.
if
num
==
0
||
c
.
depth
==
0
||
num
+
c
.
depth
<=
c
.
l1Head
()
.
Number
{
// Don't apply the conf depth is l1Head is empty (as it is during the startup case before the l1State is initialized).
l1Head
:=
c
.
l1Head
()
if
num
==
0
||
c
.
depth
==
0
||
num
+
c
.
depth
<=
l1Head
.
Number
||
l1Head
.
Hash
==
(
common
.
Hash
{})
{
return
c
.
L1Fetcher
.
L1BlockRefByNumber
(
ctx
,
num
)
}
return
eth
.
L1BlockRef
{},
ethereum
.
NotFound
...
...
op-node/rollup/driver/conf_depth_test.go
View file @
d36a4fd4
...
...
@@ -9,11 +9,15 @@ import (
"github.com/ethereum-optimism/optimism/op-node/eth"
"github.com/ethereum-optimism/optimism/op-node/testutils"
"github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/common"
)
var
exHash
=
common
.
Hash
{
0xff
}
type
confTest
struct
{
name
string
head
uint64
hash
common
.
Hash
// hash of head block
req
uint64
depth
uint64
pass
bool
...
...
@@ -21,7 +25,7 @@ type confTest struct {
func
(
ct
*
confTest
)
Run
(
t
*
testing
.
T
)
{
l1Fetcher
:=
&
testutils
.
MockL1Source
{}
l1Head
:=
eth
.
L1BlockRef
{
Number
:
ct
.
head
}
l1Head
:=
eth
.
L1BlockRef
{
Number
:
ct
.
head
,
Hash
:
ct
.
hash
}
l1HeadGetter
:=
func
()
eth
.
L1BlockRef
{
return
l1Head
}
cd
:=
NewConfDepth
(
ct
.
depth
,
l1HeadGetter
,
l1Fetcher
)
...
...
@@ -43,18 +47,19 @@ func TestConfDepth(t *testing.T) {
// note: we're not testing overflows.
// If a request is large enough to overflow the conf depth check, it's not returning anything anyway.
testCases
:=
[]
confTest
{
{
name
:
"zero conf future"
,
head
:
4
,
req
:
5
,
depth
:
0
,
pass
:
true
},
{
name
:
"zero conf present"
,
head
:
4
,
req
:
4
,
depth
:
0
,
pass
:
true
},
{
name
:
"zero conf past"
,
head
:
4
,
req
:
4
,
depth
:
0
,
pass
:
true
},
{
name
:
"one conf future"
,
head
:
4
,
req
:
5
,
depth
:
1
,
pass
:
false
},
{
name
:
"one conf present"
,
head
:
4
,
req
:
4
,
depth
:
1
,
pass
:
false
},
{
name
:
"one conf past"
,
head
:
4
,
req
:
3
,
depth
:
1
,
pass
:
true
},
{
name
:
"two conf future"
,
head
:
4
,
req
:
5
,
depth
:
2
,
pass
:
false
},
{
name
:
"two conf present"
,
head
:
4
,
req
:
4
,
depth
:
2
,
pass
:
false
},
{
name
:
"two conf not like 1"
,
head
:
4
,
req
:
3
,
depth
:
2
,
pass
:
false
},
{
name
:
"two conf pass"
,
head
:
4
,
req
:
2
,
depth
:
2
,
pass
:
true
},
{
name
:
"easy pass"
,
head
:
100
,
req
:
20
,
depth
:
5
,
pass
:
true
},
{
name
:
"genesis case"
,
head
:
0
,
req
:
0
,
depth
:
4
,
pass
:
true
},
{
name
:
"zero conf future"
,
head
:
4
,
hash
:
exHash
,
req
:
5
,
depth
:
0
,
pass
:
true
},
{
name
:
"zero conf present"
,
head
:
4
,
hash
:
exHash
,
req
:
4
,
depth
:
0
,
pass
:
true
},
{
name
:
"zero conf past"
,
head
:
4
,
hash
:
exHash
,
req
:
4
,
depth
:
0
,
pass
:
true
},
{
name
:
"one conf future"
,
head
:
4
,
hash
:
exHash
,
req
:
5
,
depth
:
1
,
pass
:
false
},
{
name
:
"one conf present"
,
head
:
4
,
hash
:
exHash
,
req
:
4
,
depth
:
1
,
pass
:
false
},
{
name
:
"one conf past"
,
head
:
4
,
hash
:
exHash
,
req
:
3
,
depth
:
1
,
pass
:
true
},
{
name
:
"two conf future"
,
head
:
4
,
hash
:
exHash
,
req
:
5
,
depth
:
2
,
pass
:
false
},
{
name
:
"two conf present"
,
head
:
4
,
hash
:
exHash
,
req
:
4
,
depth
:
2
,
pass
:
false
},
{
name
:
"two conf not like 1"
,
head
:
4
,
hash
:
exHash
,
req
:
3
,
depth
:
2
,
pass
:
false
},
{
name
:
"two conf pass"
,
head
:
4
,
hash
:
exHash
,
req
:
2
,
depth
:
2
,
pass
:
true
},
{
name
:
"easy pass"
,
head
:
100
,
hash
:
exHash
,
req
:
20
,
depth
:
5
,
pass
:
true
},
{
name
:
"genesis case"
,
head
:
0
,
hash
:
exHash
,
req
:
0
,
depth
:
4
,
pass
:
true
},
{
name
:
"no L1 state"
,
req
:
10
,
depth
:
4
,
pass
:
true
},
}
for
_
,
tc
:=
range
testCases
{
t
.
Run
(
tc
.
name
,
tc
.
Run
)
...
...
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