• George Knee's avatar
    op-batcher: extract state pruning, block fetching and progress checking into a... · f9eaf1fc
    George Knee authored
    op-batcher: extract state pruning, block fetching and progress checking 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: default avatarSebastian 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: default avatarSebastian Stammler <seb@oplabs.co>
    
    * tighten up log messages and test descriptions
    
    ---------
    Co-authored-by: default avatarSebastian Stammler <seb@oplabs.co>
    f9eaf1fc
Name
Last commit
Last update
.circleci Loading commit data...
.github Loading commit data...
.semgrep Loading commit data...
.vscode Loading commit data...
bedrock-devnet Loading commit data...
cannon Loading commit data...
docs Loading commit data...
interop-devnet Loading commit data...
just Loading commit data...
op-alt-da Loading commit data...
op-batcher Loading commit data...
op-chain-ops Loading commit data...
op-challenger Loading commit data...
op-conductor Loading commit data...
op-deployer Loading commit data...
op-dispute-mon Loading commit data...
op-e2e Loading commit data...
op-node Loading commit data...
op-preimage Loading commit data...
op-program Loading commit data...
op-proposer Loading commit data...
op-service Loading commit data...
op-supervisor Loading commit data...
op-wheel Loading commit data...
ops Loading commit data...
ops-bedrock Loading commit data...
packages/contracts-bedrock Loading commit data...
.dockerignore Loading commit data...
.editorconfig Loading commit data...
.envrc.example Loading commit data...
.gitattributes Loading commit data...
.gitignore Loading commit data...
.gitmodules Loading commit data...
.semgrepignore Loading commit data...
.shellcheckrc Loading commit data...
CITATION.cff Loading commit data...
CONTRIBUTING.md Loading commit data...
LICENSE Loading commit data...
Makefile Loading commit data...
README.md Loading commit data...
SECURITY.md Loading commit data...
codecov.yml Loading commit data...
docker-bake.hcl Loading commit data...
go.mod Loading commit data...
go.sum Loading commit data...
justfile Loading commit data...
mise.toml Loading commit data...