Function: commitBatch(uint8 version, byte[32] parentBatchHash, byte[32] postStateRoot, byte[32] withdrawRoot, bytes commitment)
This is a sequencer entry point used to append the next batch header, enforcing continuity with the precedent committed batch.
Inputs
versionControl: Sequencer (
SEQUENCER_ROLE).Constraints: N/A.
Impact: Encoded into the batch header.
parentBatchHashControl: Sequencer (
SEQUENCER_ROLE).Constraints: Enforces batch continuity by matching the latest stored batch hash.
Impact: Any mismatch reverts — otherwise anchors the new batch to the prior one.
postStateRootControl: Sequencer (
SEQUENCER_ROLE).Constraints: Must be nonzero.
Impact: Encoded in the batch header and stored as the state root for the newly committed batch.
withdrawRootControl: Sequencer (
SEQUENCER_ROLE).Constraints: N/A.
Impact: Persisted to
withdrawRootsfor later withdrawal validation.
commitmentControl: Sequencer (
SEQUENCER_ROLE).Constraints: N/A.
Impact: Encoded in the batch header.
Branches and code coverage
Intended branches
Reverts when
postStateRootis zero (ErrorStateRootIsZero).Reverts when
parentBatchHashmismatches the latest committed hash (ErrorIncorrectBatchHash).Successful commit stores the new batch.
Negative behavior
A caller without
SEQUENCER_ROLEreverts viaonlyRole.Paused contract path exercised (
whenNotPaused).
Function call analysis
BatchHeaderValidiumV0Codec.encode(version, uint64(cachedLastCommittedBatchIndex), parentBatchHash, postStateRoot, withdrawRoot, commitment)What is controllable? All arguments besides the cached index are sequencer-controlled.
If the return value is controllable, how is it used and how can it go wrong? N/A.
What happens if it reverts, reenters or does other unusual control flow? N/A.
BatchHeaderValidiumV0Codec.computeBatchHash(batchHeader)What is controllable? Input
batchHeaderis fully determined by the sequencer-provided fields (encoded).If the return value is controllable, how is it used and how can it go wrong? Produces the hash stored in
committedBatches.What happens if it reverts, reenters or does other unusual control flow? N/A.