Skip to content

Conversation

@tomip01
Copy link
Contributor

@tomip01 tomip01 commented Dec 10, 2025

Motivation

We want to upgrade the network (sequencer + prover) without downtime. For this we associate the version of the sequencer when committing a batch. This allows to run provers with different versions and each will only prove batches that match with the same version as the one when committed

Description

  • Added a commitHash field to BatchCommitmentInfo.
  • Introduced a mapping verificationKeys keyed by commit hash and verifier type (SP1/RISC0), and an event VerificationKeysUpdated for tracking verification key updates per commit.
  • Updated contract initialization and batch commitment functions to require and store the commit hash, and to validate that appropriate verification keys exist for the given commit hash.
  • Modified verification logic to use the verification key associated with the batch's commit hash, rather than a global verification key, for both SP1 and RISC0 proofs.
  • Updated deployment logic in deployer.rs to compute the git commit hash, keccak it, and pass it as an argument when initializing contracts and batch commitments.

@github-actions
Copy link

Lines of code report

Total lines added: 12
Total lines removed: 4
Total lines changed: 16

Detailed view
+----------------------------------------------------+-------+------+
| File                                               | Lines | Diff |
+----------------------------------------------------+-------+------+
| ethrex/cmd/ethrex/l2/deployer.rs                   | 1489  | +4   |
+----------------------------------------------------+-------+------+
| ethrex/crates/l2/prover/src/prover.rs              | 152   | +1   |
+----------------------------------------------------+-------+------+
| ethrex/crates/l2/sdk/contract_utils/src/compile.rs | 98    | +3   |
+----------------------------------------------------+-------+------+
| ethrex/crates/l2/sequencer/l1_committer.rs         | 1240  | +4   |
+----------------------------------------------------+-------+------+
| ethrex/crates/l2/sequencer/proof_coordinator.rs    | 472   | -4   |
+----------------------------------------------------+-------+------+

@tomip01 tomip01 changed the title Prove batch per version feat(l2): enable prover and sequencer versions per batch Dec 10, 2025
@github-actions github-actions bot added the L2 Rollup client label Dec 10, 2025
@tomip01 tomip01 marked this pull request as ready for review December 10, 2025 19:38
Copilot AI review requested due to automatic review settings December 10, 2025 19:39
@tomip01 tomip01 requested review from a team, avilagaston9 and jrchatruc as code owners December 10, 2025 19:39
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR implements version tracking per batch to enable zero-downtime upgrades of the sequencer and prover. Each committed batch now stores the git commit hash of the sequencer build that created it, and verification keys are associated with specific commit hashes rather than being global. This allows different prover versions to coexist and prove only batches matching their version.

Key Changes:

  • Added commitHash field to BatchCommitmentInfo struct to track the sequencer version per batch
  • Introduced verificationKeys mapping keyed by commit hash and verifier type (SP1/RISC0) to support multiple verification keys simultaneously
  • Updated batch commitment and verification logic to use version-specific verification keys
  • Modified prover coordination to gracefully handle version mismatches

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 27 comments.

Show a summary per file
File Description
docs/l2/fundamentals/upgrades.md New documentation explaining the upgrade process and how to register verification keys for new versions
crates/l2/tests/tests.rs Updated default OnChainProposer address constant
crates/l2/tee/quote-gen/src/sender.rs Renamed error variant from InvalidCodeVersion to NoBatchForVersion with updated error message
crates/l2/sequencer/proof_coordinator.rs Changed version mismatch from error to debug log; provers now receive NoBatchForVersion response when no matching batch exists
crates/l2/sequencer/l1_committer.rs Computes and includes commit hash in batch commitment transactions; updated function signatures
crates/l2/sdk/src/sdk.rs Updated default bridge address constant
crates/l2/sdk/contract_utils/src/compile.rs Added Solidity compiler optimization flags (--optimize with 50 runs)
crates/l2/prover/src/prover.rs Changed handling of NoBatchForVersion from error to warning with graceful return
crates/l2/contracts/src/l1/interfaces/IOnChainProposer.sol Updated interface signatures to include commit hash parameter in upgrade and commit functions; reordered commitBatch parameters
crates/l2/contracts/src/l1/based/interfaces/IOnChainProposer.sol Updated interface signatures to include commit hash parameter in upgrade and commit functions
crates/l2/contracts/src/l1/based/OnChainProposer.sol Implemented version-based verification key storage and retrieval; added validation for commit hash and verification key existence
crates/l2/contracts/src/l1/OnChainProposer.sol Implemented version-based verification key storage and retrieval; added validation for commit hash and verification key existence
cmd/ethrex/l2/deployer.rs Computes commit hash from git SHA and passes it during contract initialization

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +307 to +313
require(
(!REQUIRE_SP1_PROOF ||
verificationKeys[commitHash][VK_SP1] != bytes32(0)) &&
(!REQUIRE_RISC0_PROOF ||
verificationKeys[commitHash][VK_RISC0] != bytes32(0)),
"013" // missing verification key for commit hash
);
Copy link

Copilot AI Dec 10, 2025

Choose a reason for hiding this comment

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

The validation logic checks that verification keys exist for the commit hash when a batch is committed. However, if REQUIRE_SP1_PROOF and REQUIRE_RISC0_PROOF are both false, the condition will always pass even if no verification keys are registered. This might be intentional for testing or special modes, but should be documented or validated more explicitly.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

L2 Rollup client

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

2 participants