Assessment reports>Cloak V1>Threat Model>commitBatch

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

  • version

    • Control: Sequencer (SEQUENCER_ROLE).

    • Constraints: N/A.

    • Impact: Encoded into the batch header.

  • parentBatchHash

    • Control: 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.

  • postStateRoot

    • Control: Sequencer (SEQUENCER_ROLE).

    • Constraints: Must be nonzero.

    • Impact: Encoded in the batch header and stored as the state root for the newly committed batch.

  • withdrawRoot

    • Control: Sequencer (SEQUENCER_ROLE).

    • Constraints: N/A.

    • Impact: Persisted to withdrawRoots for later withdrawal validation.

  • commitment

    • Control: Sequencer (SEQUENCER_ROLE).

    • Constraints: N/A.

    • Impact: Encoded in the batch header.

Branches and code coverage

Intended branches

  • Reverts when postStateRoot is zero (ErrorStateRootIsZero).

  • Reverts when parentBatchHash mismatches the latest committed hash (ErrorIncorrectBatchHash).

  • Successful commit stores the new batch.

Negative behavior

  • A caller without SEQUENCER_ROLE reverts via onlyRole.

  • 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 batchHeader is 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.

Zellic © 2025Back to top ↑