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
7037cc6c
Unverified
Commit
7037cc6c
authored
Oct 20, 2022
by
mergify[bot]
Committed by
GitHub
Oct 20, 2022
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3751 from ethereum-optimism/jg/unit_test_for_reset_bug
op-node: Reset bug unit test
parents
438d3dab
eb9b6f53
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
60 additions
and
1 deletion
+60
-1
batch_queue_test.go
op-node/rollup/derive/batch_queue_test.go
+60
-1
No files found.
op-node/rollup/derive/batch_queue_test.go
View file @
7037cc6c
...
@@ -72,6 +72,66 @@ func L1Chain(l1Times []uint64) []eth.L1BlockRef {
...
@@ -72,6 +72,66 @@ func L1Chain(l1Times []uint64) []eth.L1BlockRef {
return
out
return
out
}
}
// TestBatchQueueNewOrigin tests that the batch queue properly saves the new origin
// when the safehead's origin is ahead of the pipeline's origin (as is after a reset).
// This issue was fixed in https://github.com/ethereum-optimism/optimism/pull/3694
func
TestBatchQueueNewOrigin
(
t
*
testing
.
T
)
{
log
:=
testlog
.
Logger
(
t
,
log
.
LvlCrit
)
l1
:=
L1Chain
([]
uint64
{
10
,
15
,
20
,
25
})
safeHead
:=
eth
.
L2BlockRef
{
Hash
:
mockHash
(
10
,
2
),
Number
:
0
,
ParentHash
:
common
.
Hash
{},
Time
:
20
,
L1Origin
:
l1
[
2
]
.
ID
(),
SequenceNumber
:
0
,
}
cfg
:=
&
rollup
.
Config
{
Genesis
:
rollup
.
Genesis
{
L2Time
:
10
,
},
BlockTime
:
2
,
MaxSequencerDrift
:
600
,
SeqWindowSize
:
2
,
}
input
:=
&
fakeBatchQueueInput
{
batches
:
[]
*
BatchData
{
nil
},
errors
:
[]
error
{
io
.
EOF
},
origin
:
l1
[
0
],
}
bq
:=
NewBatchQueue
(
log
,
cfg
,
input
)
_
=
bq
.
Reset
(
context
.
Background
(),
l1
[
0
])
require
.
Equal
(
t
,
[]
eth
.
L1BlockRef
{
l1
[
0
]},
bq
.
l1Blocks
)
// Prev Origin: 0; Safehead Origin: 2; Internal Origin: 0
// Should return no data but keep the same origin
data
,
err
:=
bq
.
NextBatch
(
context
.
Background
(),
safeHead
)
require
.
Nil
(
t
,
data
)
require
.
Equal
(
t
,
io
.
EOF
,
err
)
require
.
Equal
(
t
,
[]
eth
.
L1BlockRef
{
l1
[
0
]},
bq
.
l1Blocks
)
require
.
Equal
(
t
,
l1
[
0
],
bq
.
origin
)
// Prev Origin: 1; Safehead Origin: 2; Internal Origin: 0
// Should wipe l1blocks + advance internal origin
input
.
origin
=
l1
[
1
]
data
,
err
=
bq
.
NextBatch
(
context
.
Background
(),
safeHead
)
require
.
Nil
(
t
,
data
)
require
.
Equal
(
t
,
io
.
EOF
,
err
)
require
.
Empty
(
t
,
bq
.
l1Blocks
)
require
.
Equal
(
t
,
l1
[
1
],
bq
.
origin
)
// Prev Origin: 2; Safehead Origin: 2; Internal Origin: 1
// Should add to l1Blocks + advance internal origin
input
.
origin
=
l1
[
2
]
data
,
err
=
bq
.
NextBatch
(
context
.
Background
(),
safeHead
)
require
.
Nil
(
t
,
data
)
require
.
Equal
(
t
,
io
.
EOF
,
err
)
require
.
Equal
(
t
,
[]
eth
.
L1BlockRef
{
l1
[
2
]},
bq
.
l1Blocks
)
require
.
Equal
(
t
,
l1
[
2
],
bq
.
origin
)
}
// TestBatchQueueEager adds a bunch of contiguous batches and asserts that
// TestBatchQueueEager adds a bunch of contiguous batches and asserts that
// enough calls to `NextBatch` return all of those batches.
// enough calls to `NextBatch` return all of those batches.
func
TestBatchQueueEager
(
t
*
testing
.
T
)
{
func
TestBatchQueueEager
(
t
*
testing
.
T
)
{
...
@@ -205,5 +265,4 @@ func TestBatchQueueMissing(t *testing.T) {
...
@@ -205,5 +265,4 @@ func TestBatchQueueMissing(t *testing.T) {
require
.
Equal
(
t
,
b
.
Timestamp
,
uint64
(
18
))
require
.
Equal
(
t
,
b
.
Timestamp
,
uint64
(
18
))
require
.
Empty
(
t
,
b
.
BatchV1
.
Transactions
)
require
.
Empty
(
t
,
b
.
BatchV1
.
Transactions
)
require
.
Equal
(
t
,
rollup
.
Epoch
(
1
),
b
.
EpochNum
)
require
.
Equal
(
t
,
rollup
.
Epoch
(
1
),
b
.
EpochNum
)
}
}
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