-
Notifications
You must be signed in to change notification settings - Fork 131
feat(l2): generate batch prover input at commit and store it in db #5006
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
… batch witness data
Lines of code reportTotal lines added: Detailed view |
There was a problem hiding this 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 adds functionality to persist batch prover inputs to the L2 store, enabling recovery after unexpected shutdowns and supporting proofs for batches from older ethrex versions.
Key Changes:
- Added database schema and storage layer methods to store/retrieve batch prover inputs keyed by batch number and prover version
- Moved
ProverInputDatatoethrex-l2-commoncrate for cross-crate usage - Modified the committer to generate and persist batch prover inputs during commit operations
- Updated the proof coordinator to retrieve prover inputs from storage instead of regenerating them
Reviewed Changes
Copilot reviewed 15 out of 16 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| crates/l2/storage/src/store_db/sql.rs | Adds SQL table schema and implementation for storing/retrieving batch prover inputs |
| crates/l2/storage/src/store_db/in_memory.rs | Adds in-memory storage implementation for batch prover inputs |
| crates/l2/storage/src/store.rs | Adds public API methods for storing/retrieving batch prover inputs |
| crates/l2/storage/src/api.rs | Defines trait methods for batch prover input operations |
| crates/l2/storage/Cargo.toml | Adds rkyv dependency for serialization |
| crates/l2/sequencer/utils.rs | Adds utility function to fetch blocks for a given batch |
| crates/l2/sequencer/proof_coordinator.rs | Removes prover input generation logic and retrieves inputs from storage instead |
| crates/l2/sequencer/mod.rs | Removes unused dependencies from ProofCoordinator::spawn |
| crates/l2/sequencer/l1_committer.rs | Adds batch prover input generation and storage during commit operations |
| crates/l2/sequencer/errors.rs | Adds new error variants for missing prover inputs and witness generation failures |
| crates/l2/prover/src/prover.rs | Updates batch request to include binary version |
| crates/l2/l2.rs | Adds constants module |
| crates/l2/constants.rs | Defines binary version constant from package version |
| crates/l2/common/src/prover.rs | Moves ProverInputData definition here and adds rkyv serialization support |
| crates/l2/common/Cargo.toml | Adds rkyv and serde_with dependencies |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| prover_input: ProverInputData, | ||
| ) -> Result<(), RollupStoreError> { | ||
| let witness_bytes = rkyv::to_bytes::<rkyv::rancor::Error>(&prover_input) | ||
| .map_err(|e| RollupStoreError::Custom(format!("Failed to serialize witness: {}", e)))? |
Copilot
AI
Oct 23, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The error message says 'witness' but should say 'prover input' to match the actual data being serialized (ProverInputData).
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Motivation
We want to persist batch prover inputs to avoid having to regenerate them in case of an unexpected shutdown. We also want to store the version of the binary that generated them to be able to prove yet-unproven batches from older ethrex versions.
Description
This PR:
batch_prover_inputis created with rowsprover_input(actual rkyv-encodedProverInputData),batch_number, andprover_version, being the tuple of the last two the primary key.batch_prover_inputis created with key(batch_number, prover_version)and valuewitness(actual rkyv-encodedProverInputData).ProverInputDatais moved to theethrex-l2-commoncrate, as it is now a common data structure between different crates.Future work
With this new feature, an older prover should be able to retrieve data from an upgraded sequencer, as long as there are batches to be proven in that version. Currently it rejects any request from a different version.