Skip to content

Blob state#911

Open
Kukoomomo wants to merge 3 commits intomainfrom
blob_state
Open

Blob state#911
Kukoomomo wants to merge 3 commits intomainfrom
blob_state

Conversation

@Kukoomomo
Copy link
Contributor

@Kukoomomo Kukoomomo commented Mar 13, 2026

Summary by CodeRabbit

  • New Features

    • Added commitState to allow re-committing batch state using stored blob hashes without re-uploading blob data.
    • SDK/bindings expose a VERSION read method for the verifier contract.
  • Updates

    • Batch commitment workflow now reuses stored blob hashes when available.
    • Finalization cleans up stored blob-hash state automatically.
  • Tests

    • Test utilities extended to support pre-storing blob-hash state for commit scenarios.

- Add _setStoredBlobHash helper and BATCH_BLOB_VERSIONED_HASHES_SLOT in L1MessageBaseTest
- Preset batchBlobVersionedHashes in tests so commitBatch succeeds without blob tx
- test_commitAndFinalizeWithL1Messages_succeeds: set stored blob hash for batch 1 and 2
- test_commitBatches_succeeds: set stored blob hash for batch 1
- test_revertBatch_succeeds: set stored blob hash for batch 1 and 2
- Remove duplicate ZERO_VERSIONED_HASH from RollupCommitBatchWithProofTest

Made-with: Cursor
@Kukoomomo Kukoomomo requested a review from a team as a code owner March 13, 2026 07:02
@Kukoomomo Kukoomomo requested review from r3aker86 and removed request for a team March 13, 2026 07:02
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 13, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 87880f34-48e9-42d9-a25c-e9f49991df52

📥 Commits

Reviewing files that changed from the base of the PR and between 8513bea and 6bf30f9.

📒 Files selected for processing (6)
  • bindings/bin/rollup_deployed.hex
  • bindings/bin/zkevmverifierv1_deployed.hex
  • bindings/bindings/rollup.go
  • bindings/bindings/rollup_more.go
  • bindings/bindings/zkevmverifierv1.go
  • bindings/bindings/zkevmverifierv1_more.go

📝 Walkthrough

Walkthrough

Adds a new commitState entrypoint and per-batch batchBlobVersionedHashes storage to Rollup, updates commit flows to reuse stored blob hashes (avoiding blob upload), initializes and cleans up stored hashes during genesis/finalize, and extends tests and bindings accordingly.

Changes

Cohort / File(s) Summary
Interface Addition
contracts/contracts/l1/rollup/IRollup.sol
Added external commitState(BatchDataInput calldata, BatchSignatureInput calldata) to IRollup.
Core Implementation
contracts/contracts/l1/rollup/Rollup.sol
Added mapping(uint256 => bytes32) public batchBlobVersionedHashes; new commitState function; updated commitBatch and commitBatchWithProof to call _commitBatchWithBatchData(..., requireBlobWhenNoStoredHash); init writes stored hash on genesis import; finalize deletes prior batch hash; internal logic chooses stored hash or computes/requires blob accordingly.
Tests — utilities
contracts/contracts/test/base/L1MessageBase.t.sol
Added BATCH_BLOB_VERSIONED_HASHES_SLOT, ZERO_VERSIONED_HASH, and _setStoredBlobHash helper to pre-populate rollup storage with a versioned blob hash for tests.
Tests — scenarios
contracts/contracts/test/Rollup.t.sol
Removed test ZERO_VERSIONED_HASH usage and inserted _setStoredBlobHash(...) calls to set expected stored blob-hash state before commits.
Bindings — deployed bytecode
bindings/bin/rollup_deployed.hex, bindings/bin/zkevmverifierv1_deployed.hex
Replaced stored deployed bytecode hex blobs with updated bytecode payloads (deployed binaries changed).
Bindings — Go wrappers
bindings/bindings/zkevmverifierv1.go, bindings/bindings/zkevmverifierv1_more.go
Added VERSION call binding (returns string) to verifier Go bindings and replaced ZkEvmVerifierV1DeployedBin hex payload.

Sequence Diagram(s)

sequenceDiagram
    actor Staker
    participant Rollup
    participant Storage as batchBlobVersionedHashes

    Note over Staker,Rollup: Initial commit with blob
    Staker->>Rollup: commitBatch(batchData, sig, blob)
    Rollup->>Rollup: _commitBatchWithBatchData(..., requireBlobWhenNoStoredHash=true)
    Rollup->>Rollup: extract blob versioned hash
    Rollup->>Storage: store batchBlobVersionedHashes[batchIndex] = hash
    Rollup-->>Staker: batch committed

    Note over Staker,Rollup: Re-commit after revert using stored hash
    Staker->>Rollup: commitState(batchData, sig)
    Rollup->>Storage: read batchBlobVersionedHashes[batchIndex]
    Storage-->>Rollup: return stored hash
    Rollup->>Rollup: use stored hash (no blob required)
    Rollup-->>Staker: state committed

    Note over Staker,Rollup: Finalize cleans up
    Staker->>Rollup: finalizeBatch()
    Rollup->>Storage: delete batchBlobVersionedHashes[batchIndex - 1]
    Rollup-->>Staker: finalized
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Suggested reviewers

  • r3aker86
  • twcctop
  • chengwenxi

Poem

🐇 I stored the hash in memory bright,

No blob to send through moonlit night.
Recommit with quiet cheer,
Finalize — the path is clear.
Hoppity hops, the state sits tight.

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title 'Blob state' is vague and generic, using a non-descriptive term that doesn't clearly convey the specific changes made in the changeset. Consider using a more descriptive title that clearly summarizes the main change, such as 'Add blob versioned hash storage and commitState function' or 'Implement blob state caching for batch commits'.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch blob_state
📝 Coding Plan
  • Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Tip

You can get early access to new features in CodeRabbit.

Enable the early_access setting to enable early access features such as new models, tools, and more.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (3)
contracts/contracts/test/Rollup.t.sol (1)

763-764: Add one end-to-end test for the new stored-hash lifecycle.

These fixtures manually seed batchBlobVersionedHashes, but they never verify the production flow: initial commit populates it, revertBatch() preserves it, commitState() reuses it, and commitBatch() still reverts when neither a stored hash nor blob is present. The new path can regress without any of these tests noticing.

Also applies to: 835-836, 994-995, 1032-1033, 1058-1059

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@contracts/contracts/test/Rollup.t.sol` around lines 763 - 764, Add a single
end-to-end test in Rollup.t.sol that exercises the stored-hash lifecycle: call
_setStoredBlobHash(1) (the initial commit path) and assert
batchBlobVersionedHashes is populated, call revertBatch() and assert the stored
hash remains unchanged, call commitState() and assert it reuses the stored hash
for state commitment, and finally ensure commitBatch() still reverts when
neither a stored hash nor an on-chain blob is present; apply the same pattern to
the other similar fixtures referenced around the _setStoredBlobHash usages so
the production flow (populate → preserve on revert → reuse on commitState →
revert if absent) is fully covered.
contracts/contracts/l1/rollup/Rollup.sol (1)

224-225: Confirm the rollout drains or backfills in-flight batches.

These are the only new write sites for batchBlobVersionedHashes. If a live proxy is upgraded while batches are already committed but not finalized, those historical indices stay zeroed and commitState() cannot reuse their blob hash after a revert. Please either roll this out with no pending batches or add a reinitializer/backfill for the current unfinalized range.

Also applies to: 347-347

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@contracts/contracts/l1/rollup/Rollup.sol` around lines 224 - 225, The new
write site for batchBlobVersionedHashes (via
BatchHeaderCodecV0.getBlobVersionedHash) can leave historical indices zero after
an upgrade if there are in-flight/unfinalized batches; add a
reinitializer/backfill to populate batchBlobVersionedHashes for the current
unfinalized index range so commitState() can reuse blob hashes. Implement a
function (e.g., backfillBatchBlobVersionedHashes(uint64 startIndex, uint64
endIndex)) that iterates the range, recomputes each blob hash from the stored
batch header using the same BatchHeaderCodecV0.getBlobVersionedHash logic,
writes into batchBlobVersionedHashes, protects the call with an appropriate
admin modifier (onlyOwner/onlyProxyAdmin) and guard so it can only run during
upgrade/deployment (or require no pending batches), and ensure your upgrade
script calls it for the unfinalized range when rolling out; alternatively,
document that the rollout must occur only when there are no pending batches.
contracts/contracts/test/base/L1MessageBase.t.sol (1)

49-57: Avoid a magic storage slot in the test helper.

173 is coupled to the current linearized storage layout of Rollup and its OpenZeppelin bases. The next storage change will invalidate this helper, so please prefer a harness setter or a storage helper keyed off batchBlobVersionedHashes(uint256) instead.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@contracts/contracts/test/base/L1MessageBase.t.sol` around lines 49 - 57,
Replace the hard-coded storage slot approach in _setStoredBlobHash (which uses
BATCH_BLOB_VERSIONED_HASHES_SLOT = 173) with a deterministic, resilient setter:
add a test-only setter on the Rollup harness (e.g., function
setBatchBlobVersionedHash(uint256 batchIndex, bytes32 hash) external onlyTest or
in a RollupTestHarness) and call that from _setStoredBlobHash to write
ZERO_VERSIONED_HASH, or alternatively compute the mapping slot dynamically by
deriving the mapping's storage slot identifier from the Rollup contract (but
preferred is adding the harness setter). Update references to
BATCH_BLOB_VERSIONED_HASHES_SLOT and the hevm.store call to use the new harness
setter (target symbols: _setStoredBlobHash and ZERO_VERSIONED_HASH and
rollup.setBatchBlobVersionedHash).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@contracts/contracts/l1/rollup/Rollup.sol`:
- Around line 107-109: Stored blobVersionedHash in mapping
batchBlobVersionedHashes prevents replacing hashes for batches that were
reverted; modify commit paths to allow overwriting that entry when a batch has
been reverted (or otherwise not active/finalized). In practice, update
commitBatch() and commitBatchWithProof() to check batch status (use whatever
batch metadata/flag tracked by revertBatch(), e.g., a "reverted" or "finalized"
marker) and permit writing batchBlobVersionedHashes[batchIndex] = newHash when
the batch is marked reverted/not finalized (but keep existing protection when
the batch is active/finalized); also ensure revertBatch() sets the status flag
used to allow this replacement.

---

Nitpick comments:
In `@contracts/contracts/l1/rollup/Rollup.sol`:
- Around line 224-225: The new write site for batchBlobVersionedHashes (via
BatchHeaderCodecV0.getBlobVersionedHash) can leave historical indices zero after
an upgrade if there are in-flight/unfinalized batches; add a
reinitializer/backfill to populate batchBlobVersionedHashes for the current
unfinalized index range so commitState() can reuse blob hashes. Implement a
function (e.g., backfillBatchBlobVersionedHashes(uint64 startIndex, uint64
endIndex)) that iterates the range, recomputes each blob hash from the stored
batch header using the same BatchHeaderCodecV0.getBlobVersionedHash logic,
writes into batchBlobVersionedHashes, protects the call with an appropriate
admin modifier (onlyOwner/onlyProxyAdmin) and guard so it can only run during
upgrade/deployment (or require no pending batches), and ensure your upgrade
script calls it for the unfinalized range when rolling out; alternatively,
document that the rollout must occur only when there are no pending batches.

In `@contracts/contracts/test/base/L1MessageBase.t.sol`:
- Around line 49-57: Replace the hard-coded storage slot approach in
_setStoredBlobHash (which uses BATCH_BLOB_VERSIONED_HASHES_SLOT = 173) with a
deterministic, resilient setter: add a test-only setter on the Rollup harness
(e.g., function setBatchBlobVersionedHash(uint256 batchIndex, bytes32 hash)
external onlyTest or in a RollupTestHarness) and call that from
_setStoredBlobHash to write ZERO_VERSIONED_HASH, or alternatively compute the
mapping slot dynamically by deriving the mapping's storage slot identifier from
the Rollup contract (but preferred is adding the harness setter). Update
references to BATCH_BLOB_VERSIONED_HASHES_SLOT and the hevm.store call to use
the new harness setter (target symbols: _setStoredBlobHash and
ZERO_VERSIONED_HASH and rollup.setBatchBlobVersionedHash).

In `@contracts/contracts/test/Rollup.t.sol`:
- Around line 763-764: Add a single end-to-end test in Rollup.t.sol that
exercises the stored-hash lifecycle: call _setStoredBlobHash(1) (the initial
commit path) and assert batchBlobVersionedHashes is populated, call
revertBatch() and assert the stored hash remains unchanged, call commitState()
and assert it reuses the stored hash for state commitment, and finally ensure
commitBatch() still reverts when neither a stored hash nor an on-chain blob is
present; apply the same pattern to the other similar fixtures referenced around
the _setStoredBlobHash usages so the production flow (populate → preserve on
revert → reuse on commitState → revert if absent) is fully covered.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: b4b81342-9dfa-407e-87a9-6a13d34757ee

📥 Commits

Reviewing files that changed from the base of the PR and between 31059df and 8513bea.

📒 Files selected for processing (4)
  • contracts/contracts/l1/rollup/IRollup.sol
  • contracts/contracts/l1/rollup/Rollup.sol
  • contracts/contracts/test/Rollup.t.sol
  • contracts/contracts/test/base/L1MessageBase.t.sol

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant