Skip to content

chore(l2): remove save state module #3119

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

Open
wants to merge 22 commits into
base: l2/remove_execute_cache
Choose a base branch
from

Conversation

xqft
Copy link
Contributor

@xqft xqft commented Jun 11, 2025

Motivation

The save state module was unnecessarily complex for what it achieved (storing incoming batch proofs). This PR replaces it with the rollup store.

Description

  • adds tables for storing batch proofs indexed by batch number and proof type to the rollup store
  • removes the save state module
  • all places that used the save state module now use the rollup storage
  • had to move the prover interface into ethex-l2-common because ethrex-storage-rollup can't depend on the prover because of cyclic dependencies
  • because of the previous point had to move the Value type into ethrex-l2-common because ethrex-l2-common can't depend on ethrex-sdk

@xqft xqft force-pushed the l2/remove_save_state branch from 5d03964 to f26f67a Compare June 11, 2025 14:45
Copy link

github-actions bot commented Jun 11, 2025

Lines of code report

Total lines added: 314
Total lines removed: 23
Total lines changed: 337

Detailed view
+---------------------------------------------------------+-------+------+
| File                                                    | Lines | Diff |
+---------------------------------------------------------+-------+------+
| ethrex/crates/l2/common/src/calldata.rs                 | 15    | +15  |
+---------------------------------------------------------+-------+------+
| ethrex/crates/l2/common/src/lib.rs                      | 5     | +2   |
+---------------------------------------------------------+-------+------+
| ethrex/crates/l2/common/src/prover.rs                   | 122   | +122 |
+---------------------------------------------------------+-------+------+
| ethrex/crates/l2/prover/src/backends/exec.rs            | 39    | +2   |
+---------------------------------------------------------+-------+------+
| ethrex/crates/l2/prover/src/prover.rs                   | 115   | -1   |
+---------------------------------------------------------+-------+------+
| ethrex/crates/l2/prover/zkvm/interface/src/execution.rs | 340   | -1   |
+---------------------------------------------------------+-------+------+
| ethrex/crates/l2/sdk/src/calldata.rs                    | 352   | -13  |
+---------------------------------------------------------+-------+------+
| ethrex/crates/l2/sdk/src/l1_to_l2_tx_data.rs            | 68    | +1   |
+---------------------------------------------------------+-------+------+
| ethrex/crates/l2/sdk/src/sdk.rs                         | 492   | +1   |
+---------------------------------------------------------+-------+------+
| ethrex/crates/l2/sequencer/errors.rs                    | 251   | -5   |
+---------------------------------------------------------+-------+------+
| ethrex/crates/l2/sequencer/l1_committer.rs              | 501   | +1   |
+---------------------------------------------------------+-------+------+
| ethrex/crates/l2/sequencer/l1_proof_sender.rs           | 309   | +19  |
+---------------------------------------------------------+-------+------+
| ethrex/crates/l2/sequencer/l1_proof_verifier.rs         | 185   | +21  |
+---------------------------------------------------------+-------+------+
| ethrex/crates/l2/sequencer/mod.rs                       | 109   | +3   |
+---------------------------------------------------------+-------+------+
| ethrex/crates/l2/sequencer/proof_coordinator.rs         | 521   | +8   |
+---------------------------------------------------------+-------+------+
| ethrex/crates/l2/sequencer/setup.rs                     | 98    | +1   |
+---------------------------------------------------------+-------+------+
| ethrex/crates/l2/storage/src/api.rs                     | 94    | +12  |
+---------------------------------------------------------+-------+------+
| ethrex/crates/l2/storage/src/store.rs                   | 293   | +20  |
+---------------------------------------------------------+-------+------+
| ethrex/crates/l2/storage/src/store_db/in_memory.rs      | 220   | +24  |
+---------------------------------------------------------+-------+------+
| ethrex/crates/l2/storage/src/store_db/libmdbx.rs        | 312   | +26  |
+---------------------------------------------------------+-------+------+
| ethrex/crates/l2/storage/src/store_db/redb.rs           | 319   | +32  |
+---------------------------------------------------------+-------+------+
| ethrex/crates/l2/tee/quote-gen/src/main.rs              | 104   | +3   |
+---------------------------------------------------------+-------+------+
| ethrex/crates/l2/tee/quote-gen/src/sender.rs            | 72    | -2   |
+---------------------------------------------------------+-------+------+
| ethrex/crates/l2/utils/mod.rs                           | 4     | -1   |
+---------------------------------------------------------+-------+------+
| ethrex/tooling/load_test/src/main.rs                    | 366   | +1   |
+---------------------------------------------------------+-------+------+

@xqft xqft marked this pull request as ready for review June 12, 2025 20:15
@xqft xqft requested a review from a team as a code owner June 12, 2025 20:15
Comment on lines +460 to +478
// Check if we have a proof for this batch and prover type
let prover_type = batch_proof.prover_type();
if state
.rollup_store
.get_proof_by_batch_and_type(batch_number, prover_type)
.await?
.is_some()
{
info!(
?batch_number,
?prover_type,
"A proof was received for a batch and type that is already stored"
);
} else {
write_state(batch_number, &StateType::BatchProof(batch_proof))?;
// If not, store it
state
.rollup_store
.store_proof_by_batch_and_type(batch_number, prover_type, batch_proof)
.await?;
Copy link
Contributor

Choose a reason for hiding this comment

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

This is just a question but is there any reason to not overwrite the proof with the new one we receive instead of checking if we already have one

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think so, both options are as valid, and this was the behavior before my changes

@xqft xqft force-pushed the l2/remove_save_state branch from 1e7b0ee to 5356d00 Compare June 12, 2025 22:02
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.

2 participants