-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
op-batcher: extract state pruning, block fetching and progress checki…
…ng into a single pure function (#13060) * remove lastStoredBlock and lastL1Tip from BatchSubmitter state We can use the channelManager's state to infer lastStoredBlock. And lastL1Tip is actually unused. * change log line wording * fix typo * remove unecessary method * WIP first pass at computeSyncActions * computeSyncAction takes a ChannelStatuser interface also report fully inclusive range of blocks to load * add happy path test case * clearState is a pointer we can use nil value to signal no state clearing should be performed * add more test cases * add another test case * computeSyncActions only takes prevCurrentL1, not prevSyncStatus * add batcher restart case * safe chain reorg case * failed to make progress case * simplify log messages, print entire struct * add godoc * wire up computeSyncActions * cache prevCurrentL1 on BatchSubmitter * document stages * fix loadBlocksIntoState range interpretation * pass syncStatus, not pointer to syncStatus and add test case for no progress * check unsafe status before trying to get more blocks * do not panic on invalid block ranges return an error instead. This error is ultimated swallowed, matching existing behaviour. * test: add assetions and mock data about blockID passed to clearState * add readme section on max channel duration * add back unit tests for pruning methods * fix pruneBlocks behaviour when blockCursor pointed at block which is now pruned * rename waitForNodeSync to sequencerOutOfSync * Introduce SeqOutOfSyncError * move SyncActions code to a separate file * ChannelStatuser -> channelStatuser * SeqOutOfSyncError -> ErrSeqOutOfSync * move ctx to first position in fn signature * do not update cached prevCurrentL1 value if there is an ErrSeqOutOfSync * Always warn log when computeSyncActions returns an error * move sync actions test to separate file * computeSyncActions returns a bool, not an error There is only ever one kind of error returned * SyncActions -> syncActions * define local variables to aid readability * organise computeSyncActions and introduce startAfresh syncAction Add comments explaining logical flow: the checks get increasingly deep and we return early where possible. * undo changes to submodule * move test utils to sync_actions_test.go file * ensure pruneChannels clears currentChannel when appropriate * fix submodule" * don't try to get number of block if none exists * improve log * Update op-batcher/batcher/driver.go Co-authored-by: Sebastian Stammler <seb@oplabs.co> * use struct for block range, not array * use startAfresh in one more place * add test case for multiple channels also set HeadL1 to more realistic values (generally ahead of currentL1 due to nonzero confirmation depth) * print value of *struct in Stringer * add test case when there are no blocks in state * Update op-batcher/batcher/sync_actions.go Co-authored-by: Sebastian Stammler <seb@oplabs.co> * tighten up log messages and test descriptions --------- Co-authored-by: Sebastian Stammler <seb@oplabs.co>
- Loading branch information
Showing
7 changed files
with
591 additions
and
242 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.