Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

op-batcher: extract state pruning, block fetching and progress checking into a single pure function #13060

Merged
merged 56 commits into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
cee17f7
remove lastStoredBlock and lastL1Tip from BatchSubmitter state
geoknee Nov 19, 2024
f86b9f9
change log line wording
geoknee Nov 19, 2024
a8fc922
fix typo
geoknee Nov 19, 2024
f81b505
remove unecessary method
geoknee Nov 21, 2024
434e559
WIP first pass at computeSyncActions
geoknee Nov 22, 2024
de4615c
computeSyncAction takes a ChannelStatuser interface
geoknee Nov 22, 2024
1e312d7
add happy path test case
geoknee Nov 22, 2024
24bdd1a
Merge branch 'gk/new-batcher-fix' into gk/compute-sync-actions
geoknee Nov 22, 2024
2a8081e
clearState is a pointer
geoknee Nov 22, 2024
8fab0c3
add more test cases
geoknee Nov 22, 2024
6859ff3
add another test case
geoknee Nov 22, 2024
8c7d76f
computeSyncActions only takes prevCurrentL1, not prevSyncStatus
geoknee Nov 22, 2024
e762352
add batcher restart case
geoknee Nov 22, 2024
7792f4a
safe chain reorg case
geoknee Nov 22, 2024
c705cdd
failed to make progress case
geoknee Nov 22, 2024
e3c0500
simplify log messages, print entire struct
geoknee Nov 22, 2024
0858079
add godoc
geoknee Nov 22, 2024
a5c5f6a
wire up computeSyncActions
geoknee Nov 22, 2024
a11d636
cache prevCurrentL1 on BatchSubmitter
geoknee Nov 22, 2024
1ff2a4d
document stages
geoknee Nov 22, 2024
9e9da9c
fix loadBlocksIntoState range interpretation
geoknee Nov 22, 2024
1615217
pass syncStatus, not pointer to syncStatus and add test case for no p…
geoknee Nov 22, 2024
8296dfe
check unsafe status before trying to get more blocks
geoknee Nov 22, 2024
ba378da
do not panic on invalid block ranges
geoknee Nov 25, 2024
09fc152
Merge remote-tracking branch 'origin/develop' into gk/compute-sync-ac…
geoknee Dec 2, 2024
b8a43b5
test: add assetions and mock data about blockID passed to clearState
geoknee Dec 2, 2024
ba62afe
add readme section on max channel duration
geoknee Dec 2, 2024
6d41fab
add back unit tests for pruning methods
geoknee Dec 2, 2024
d5afeff
fix pruneBlocks behaviour when blockCursor pointed at block which is …
geoknee Dec 2, 2024
4627f94
rename waitForNodeSync to sequencerOutOfSync
geoknee Dec 2, 2024
47578b2
Introduce SeqOutOfSyncError
geoknee Dec 2, 2024
0b22890
move SyncActions code to a separate file
geoknee Dec 4, 2024
c891505
ChannelStatuser -> channelStatuser
geoknee Dec 4, 2024
1ed9fff
SeqOutOfSyncError -> ErrSeqOutOfSync
geoknee Dec 4, 2024
e5dee34
move ctx to first position in fn signature
geoknee Dec 4, 2024
eca021c
do not update cached prevCurrentL1 value if there is an ErrSeqOutOfSync
geoknee Dec 4, 2024
b3337fb
Always warn log when computeSyncActions returns an error
geoknee Dec 4, 2024
4449b07
move sync actions test to separate file
geoknee Dec 4, 2024
8a0824c
computeSyncActions returns a bool, not an error
geoknee Dec 4, 2024
337a4ec
SyncActions -> syncActions
geoknee Dec 4, 2024
4a2cf69
define local variables to aid readability
geoknee Dec 4, 2024
8892aa5
organise computeSyncActions and introduce startAfresh syncAction
geoknee Dec 4, 2024
fa5fd37
undo changes to submodule
geoknee Dec 4, 2024
336f94f
move test utils to sync_actions_test.go file
geoknee Dec 4, 2024
a413728
ensure pruneChannels clears currentChannel when appropriate
geoknee Dec 4, 2024
9aefad7
fix submodule"
geoknee Dec 4, 2024
28fc914
don't try to get number of block if none exists
geoknee Dec 4, 2024
f4f766b
improve log
geoknee Dec 4, 2024
27c4fb2
Update op-batcher/batcher/driver.go
geoknee Dec 5, 2024
f588a00
use struct for block range, not array
geoknee Dec 5, 2024
c534f92
use startAfresh in one more place
geoknee Dec 5, 2024
4df01e1
add test case for multiple channels
geoknee Dec 5, 2024
b1f5fe7
print value of *struct in Stringer
geoknee Dec 5, 2024
95ebb10
add test case when there are no blocks in state
geoknee Dec 5, 2024
4766dcf
Update op-batcher/batcher/sync_actions.go
geoknee Dec 5, 2024
b069105
tighten up log messages and test descriptions
geoknee Dec 5, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion op-batcher/batcher/sync_actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ type syncActions struct {

func (s syncActions) String() string {
return fmt.Sprintf(
"SyncActions{blocksToPrune: %d, channelsToPrune: %d, clearState: %v, blocksToLoad: [%d, %d]}", s.blocksToPrune, s.channelsToPrune, s.clearState, s.blocksToLoad.start, s.blocksToLoad.end)
"SyncActions{blocksToPrune: %d, channelsToPrune: %d, clearState: %v, blocksToLoad: [%v]}", s.blocksToPrune, s.channelsToPrune, s.clearState, s.blocksToLoad)
geoknee marked this conversation as resolved.
Show resolved Hide resolved
}

// computeSyncActions determines the actions that should be taken based on the inputs provided. The inputs are the current
Expand Down
14 changes: 14 additions & 0 deletions op-batcher/batcher/sync_actions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,20 @@ func TestBatchSubmitter_computeSyncActions(t *testing.T) {
blocksToLoad: &inclusiveBlockRange{104, 109},
},
},
{name: "no blocks",
newSyncStatus: eth.SyncStatus{
HeadL1: eth.BlockRef{Number: 5},
CurrentL1: eth.BlockRef{Number: 2},
SafeL2: eth.L2BlockRef{Number: 103, Hash: block103.Hash()},
UnsafeL2: eth.L2BlockRef{Number: 109},
},
prevCurrentL1: eth.BlockRef{Number: 1},
blocks: queue.Queue[*types.Block]{},
channels: []channelStatuser{},
expected: syncActions{
blocksToLoad: &inclusiveBlockRange{104, 109},
},
},
{name: "happy path + multiple channels",
newSyncStatus: eth.SyncStatus{
HeadL1: eth.BlockRef{Number: 5},
Expand Down