Skip to content

feat(prover): full morph-reth v1.5 integration, MPT witness soundness fix, node-aligned validation and faster host execution - #1101

Open
anylots wants to merge 14 commits into
mainfrom
prover-stateless-mpt
Open

anylots wants to merge 14 commits into
mainfrom
prover-stateless-mpt

Conversation

@anylots

@anylots anylots commented Dec 4, 2026

Copy link
Copy Markdown
Contributor

Summary

Three areas of changes:

  1. Full integration of morph-reth v1.5.
  2. A fix for how MPT data is used after deserialization: the guest now rebuilds state from a trusted root instead of trusting tries it deserializes.
  3. Validation aligned with the node (morph-geth / morph-reth), plus faster host-side execution.

1. Full integration of morph-reth v1.5

  • Use morph-reth tag v1.5.0 for morph-revm / morph-primitives / morph-chainspec / morph-evm / morph-rpc, replacing the port-sp1-zkvm-build-fixes branch.
  • Use reth v2.5.2-morph.1 (morph-l2/reth fork) for reth-evm / reth-execution-types / reth-storage-errors / reth-trie.
  • Upgrade SP1 from v6.2.0 to v6.4.0 and add execution-witness (debug_executionWitness) proving.
  • Remove the local primitives (types/{block,tx,authorization_list}, provider.rs). Blocks are now morph_primitives::Block with MorphTxEnvelope and MorphHeader, and are executed by MorphExecutor through the morph-reth chainspec and hardforks.
  • Workspace moves to edition = 2024, rust-version = 1.95.0, version 2.1.0. Drop the zstd patch and the rlp crate.
  • Update the verifier client ELF and the deployment verification key.

2. Fix for MPT data used after deserialization

Problem: the old prover-mpt (EthereumState) sent fully resolved MptNode trees from host to guest through serde. The guest used the deserialized tries as they arrived:

  • Nothing tied the deserialized tries to the trusted prev_state_root. The hash check (build_validated_tries) ran only on the host.
  • When an account had no entry in storage_tries, its storage root was computed from an empty trie, and a storage wipe was handled the same way. Both could give a wrong storage root.
  • update / delete used unwrap(), so a missing node panicked.

Fix:

  • Add crates/stateless-mpt, an in-tree fork of paradigmxyz/stateless zeth-mpt @ b7c14668 (reth-guest-v0.1.0-rc.9, see FORK.md). It includes the upstream hardening (WIP: muti submitter #54 rejects over-long paths, upgrade go ethereum #61 rejects malformed nodes) and a fallible try_insert that returns an error on an unresolved node instead of panicking.
  • Add crates/state (SparseState):
    • It is built from the trusted root plus a pool of untrusted raw RLP nodes, indexed by keccak256 computed in the guest. Nodes that are unreachable are ignored, and reachable nodes are checked as they are resolved.
    • Storage tries are opened lazily from the account's storage_root. Any access to a missing node returns MptError instead of panicking.
    • apply_updates / apply_bundle produce the same result regardless of input order: destroyed accounts' storage is cleared first, then storage inserts are applied, then removals, then account deletions. Storage resets follow BundleAccount::was_destroyed, like upstream Check message index #64.
  • The witness is now batch-level: one EvmInput { chain_id, prev_state_root, blocks, witness: StateWitness { state_nodes, codes } } per batch, carrying only raw bytes so it serializes the same way every time. Bytecode is indexed by its keccak256, and contracts deployed during the batch come from execution.
  • The host uses reachable_nodes to drop nodes the guest cannot reach.
  • The guest reads input as bincode (sp1_zkvm::io::read) instead of a JSON string.
  • Tests: crates/state/tests/sparse_state.rs, plus a test that removes one witness node at a time and checks that verification either fails or returns the same result.

3. Validation aligned with the node, and execution performance

Validation (mirrors morph-geth validateL1Messages / misc.VerifyGaslimit / morph-consensus):

  • L1 message ordering (GHSA-fgxm-qqj4-jxv9): within a block, every L1 message must come before every L2 tx, and L1 queue indices must be consecutive across the batch.
  • mix_hash and difficulty must be zero, because the blob does not commit them.
  • base_fee must be present and <= MAX_L2_BASE_FEE. gas_limit must be within [MIN, MAX], and may change from the parent by less than 1/1024 of the parent's gas limit.
  • Block numbers must be consecutive and timestamps must not decrease.
  • validate_block_pre_execution, run on both host and guest:
    • MorphTx versions are rejected before their fork activates (emerald / jade / celadon), and TxMorph::validate is applied.
    • The L2 tx payload must be <= MORPH_MAX_TX_PAYLOAD_BYTES_PER_BLOCK.
  • Batch and blob: reject tx count and L1 message count overflows, and reject empty batches.
  • Empty blocks: the computed state root is still checked against the header.

Performance:

  • PreparedBatch / verify_batch(): native verification (EVM + DA) runs once, and its result feeds both the server's batch header and the SP1 input. This removes a duplicate execution in the queue path.
  • HostExecutor::execute_range:
    • The chain id and the batch parent header are fetched once per batch. Each block's parent header comes from the previous block in the range instead of a new RPC call.
    • Blocks are fetched and executed concurrently, up to HOST_EXECUTE_CONCURRENCY at a time (default 1). Tasks are aborted if any block fails.
  • Network proving: BatchProver::generate_proof retries, classifies failures, and separates network and local implementations.

Breaking changes

  • Removed crates: prover-mpt (replaced by prover-state + stateless-mpt).
  • ExecutorInput now contains evm: EvmInput instead of Vec<BlockInput>. The guest ELF and vkey have changed.
  • Testdata moved to testdata/block_inputs/*.json. The old testdata/mpt, testdata/state and the tests/{keccak256,zstd} crates are removed.

Test plan

  • cargo test --workspace (including sparse_state, evm_verifier, validation)
  • Native batch verification on mainnet / devnet testdata (block_inputs/*.json)
  • Generate the SP1 ELF and check that the vkey matches the deployed verifier
  • Shadow-prove one real batch end-to-end with both Basic and ExecutionWitness

Move proof generation into `BatchProver::generate_proof`, with separate network and local implementations.

Co-Authored-By: Claude Opus 5.5 <<EMAIL_ADDRESS>>
The batch DA commitments bind only the L1-only projection of the
transaction stream (data_hash) and the L2-only projection (blob), not
their interleaving inside a block. The guest executed transactions in
whatever order the witness supplied, so a single committed batch could
be proven with different postStateRoot / withdrawRoot values
(GHSA-fgxm-qqj4-jxv9).

Add validate_canonical_order before execution, mirroring the node's
validateL1Messages: within a block every L1 message must precede every
L2 transaction, and L1 queue indices must be consecutive across the
batch. Combined with the per-block num_l1_txs in the blob block
context, each block's transaction stream is now uniquely determined by
the committed data.

Co-Authored-By: Claude Opus 5.5 <<EMAIL_ADDRESS>>
mix_hash (PREVRANDAO) and difficulty (DIFFICULTY) feed the EVM block
environment but are not committed by the blob, so a prover could pick
arbitrary values and reach a state the L2 network never executed.
morph-geth builds L2 headers with both fields zero and always returns 0
for opcode 0x44; reject any other value before execution.

Co-Authored-By: Claude Opus 5.5 <<EMAIL_ADDRESS>>
- reject transaction and L1 message count overflows
- validate blocks explicitly before host and guest execution
- simplify blob construction using borrowed block iterators
Introduce PreparedBatch to run native batch verification once and reuse
the result for both the server's batch header and SP1 witness input,
eliminating a redundant EVM/DA verification pass in the queue path.

- Add verify_batch() returning VerifiedBatch (data_hash, blob_input,
  public_input_hash) alongside the existing verify() shim
- Wrap EVM errors in EvmVerificationError for downstream discrimination
- Replace gen_client_input() with prepare_batch_for_proving() that
  returns PreparedBatch instead of raw ExecutorInput
- Add BatchProver::prepare_batch() and prove_prepared() so the server
  can skip the second native execution
- Bump morph-reth deps to tag v1.5.0 and reth deps to v2.5.2-morph.1
@anylots
anylots requested review from a team and freefu-sec December 4, 2026 08:54
@coderabbitai

coderabbitai Bot commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Too many files!

This PR contains 145 files, which is 45 over the limit of 100.

To get a review, reduce the PR to 100 files or fewer by splitting it into smaller PRs or changing its base branch.

Upgrade to a paid plan to raise the limit.

This organization's CodeRabbit subscription is cancelled. Resubscribe in Billing to continue reviews beyond the free-tier limit.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 68cff62e-e805-4c6d-87bf-72b72f27bed1
Commits

Reviewing files that changed from the base of the PR and between b65aae4 and 3ae5ad7.

Files ignored due to path filters: 3

  • prover/Cargo.lock is excluded by !**/*.lock
  • prover/bin/challenge/Cargo.lock is excluded by !**/*.lock
  • prover/tests/zstd/host/abc.txt.zst is excluded by !**/*.zst
Files selected for processing: 145

  • .github/workflows/prover.yml
  • prover/.gitignore
  • prover/Cargo.toml
  • prover/Dockerfile.sp1-base
  • prover/Dockerfile.sp1-test
  • prover/Makefile
  • prover/README.md
  • prover/bin/challenge/Cargo.toml
  • prover/bin/client/Cargo.toml
  • prover/bin/client/elf/verifier-client
  • prover/bin/client/src/main.rs
  • prover/bin/host/Cargo.toml
  • prover/bin/host/src/evm.rs
  • prover/bin/host/src/execute.rs
  • prover/bin/host/src/lib.rs
  • prover/bin/host/src/main.rs
  • prover/bin/host/src/vkey.rs
  • prover/bin/server/Cargo.toml
  • prover/bin/server/src/lib.rs
  • prover/bin/server/src/main.rs
  • prover/bin/server/src/queue.rs
  • prover/bin/server/src/server.rs
  • prover/bin/shadow-prove/Cargo.toml
  • prover/bin/shadow-prove/contracts/README.md
  • prover/bin/shadow-prove/src/execute.rs
  • prover/bin/shadow-prove/src/lib.rs
  • prover/bin/shadow-prove/src/main.rs
  • prover/bin/shadow-prove/src/shadow_prove.rs
  • prover/bin/shadow-prove/src/shadow_rollup.rs
  • prover/contracts/README.md
  • prover/crates/executor/client/Cargo.toml
  • prover/crates/executor/client/src/lib.rs
  • prover/crates/executor/client/src/types/batch.rs
  • prover/crates/executor/client/src/types/error.rs
  • prover/crates/executor/client/src/types/input.rs
  • prover/crates/executor/client/src/verifier/blob_verifier.rs
  • prover/crates/executor/client/src/verifier/evm_verifier.rs
  • prover/crates/executor/core/Cargo.toml
  • prover/crates/executor/core/src/error.rs
  • prover/crates/executor/core/src/executor.rs
  • prover/crates/executor/core/src/lib.rs
  • prover/crates/executor/core/src/validation.rs
  • prover/crates/executor/host/Cargo.toml
  • prover/crates/executor/host/src/blob.rs
  • prover/crates/executor/host/src/execute.rs
  • prover/crates/executor/host/src/lib.rs
  • prover/crates/executor/host/src/trace.rs
  • prover/crates/executor/host/src/utils.rs
  • prover/crates/executor/host/src/witness.rs
  • prover/crates/mpt/Cargo.toml
  • prover/crates/mpt/src/execution_witness.rs
  • prover/crates/mpt/src/lib.rs
  • prover/crates/mpt/src/mpt.rs
  • prover/crates/primitives/Cargo.toml
  • prover/crates/primitives/src/lib.rs
  • prover/crates/primitives/src/predeployed.rs
  • prover/crates/primitives/src/types/authorization_list.rs
  • prover/crates/primitives/src/types/blob.rs
  • prover/crates/primitives/src/types/block.rs
  • prover/crates/primitives/src/types/mod.rs
  • prover/crates/primitives/src/types/tx.rs
  • prover/crates/state/Cargo.toml
  • prover/crates/state/clippy.toml
  • prover/crates/state/src/error.rs
  • prover/crates/state/src/lib.rs
  • prover/crates/state/src/state.rs
  • prover/crates/state/src/witness.rs
  • prover/crates/state/tests/sparse_state.rs
  • prover/crates/stateless-mpt/Cargo.toml
  • prover/crates/stateless-mpt/FORK.md
  • prover/crates/stateless-mpt/rustfmt.toml
  • prover/crates/stateless-mpt/src/lib.rs
  • prover/crates/stateless-mpt/src/mpt/children.rs
  • prover/crates/stateless-mpt/src/mpt/memoize.rs
  • prover/crates/stateless-mpt/src/mpt/mod.rs
  • prover/crates/stateless-mpt/src/mpt/nibbles.rs
  • prover/crates/stateless-mpt/src/mpt/node.rs
  • prover/crates/stateless-mpt/src/mpt/orphan.rs
  • prover/crates/stateless-mpt/src/mpt/rkyv.rs
  • prover/crates/stateless-mpt/src/mpt/rlp.rs
  • prover/crates/stateless-mpt/src/mpt/serde.rs
  • prover/crates/storage/rpc-db/Cargo.toml
  • prover/crates/storage/rpc-db/src/account_proof.rs
  • prover/crates/storage/rpc-db/src/basic_rpc_db.rs
  • prover/crates/storage/rpc-db/src/error.rs
  • prover/crates/storage/rpc-db/src/lib.rs
  • prover/crates/storage/rpc-db/src/witness_rpc_db.rs
  • prover/crates/storage/witness-db/Cargo.toml
  • prover/crates/storage/witness-db/src/lib.rs
  • prover/crates/utils/Cargo.toml
  • prover/crates/utils/src/lib.rs
  • prover/crates/utils/src/provider.rs
  • prover/crates/utils/src/witness.rs
  • prover/rustfmt.toml
  • prover/testdata/blob/blob_with_zstd_batch.data
  • prover/testdata/blob/blob_with_zstd_batch_holesky.data
  • prover/testdata/blob/mainnet_47561.data
  • prover/testdata/blob/sp1_batch.data
  • prover/testdata/block_inputs/devnet_53.json
  • prover/testdata/block_inputs/mainnet_1430.json
  • prover/testdata/block_inputs/mainnet_18762206.json
  • prover/testdata/block_inputs/mainnet_19137902.json
  • prover/testdata/block_inputs/mainnet_19137909.json
  • prover/testdata/block_inputs/mainnet_19266117.json
  • prover/testdata/block_inputs/mainnet_19720219.json
  • prover/testdata/block_inputs/mainnet_209.json
  • prover/testdata/block_inputs/mainnet_25215.json
  • prover/testdata/block_inputs/mainnet_30656709_30656768.json
  • prover/testdata/block_inputs/mainnet_809.json
  • prover/testdata/block_inputs/mainnet_898.json
  • prover/testdata/mpt/hostexecutoroutput
  • prover/testdata/mpt/local_transfer_eth.json
  • prover/testdata/mpt/mainnet_1430.json
  • prover/testdata/mpt/mainnet_16283373.data
  • prover/testdata/mpt/mainnet_165256.data
  • prover/testdata/mpt/mainnet_18762206.json
  • prover/testdata/mpt/mainnet_19137902.json
  • prover/testdata/mpt/mainnet_19137909.json
  • prover/testdata/mpt/mainnet_19266117.json
  • prover/testdata/mpt/mainnet_19720219.json
  • prover/testdata/mpt/mainnet_19720290.data
  • prover/testdata/mpt/mainnet_209.json
  • prover/testdata/mpt/mainnet_25215.json
  • prover/testdata/mpt/mainnet_809.json
  • prover/testdata/mpt/mainnet_898.json
  • prover/testdata/state/executor_input_19720290.data
  • prover/tests/algebra/client/Cargo.toml
  • prover/tests/algebra/host/Cargo.toml
  • prover/tests/algebra/host/sp1_test_proof.json
  • prover/tests/algebra/host/src/main.rs
  • prover/tests/bls12381/client/Cargo.toml
  • prover/tests/bls12381/host/Cargo.toml
  • prover/tests/bls12381/host/src/main.rs
  • prover/tests/keccak256/client/Cargo.toml
  • prover/tests/keccak256/client/elf/riscv32im-succinct-zkvm-elf
  • prover/tests/keccak256/client/src/main.rs
  • prover/tests/keccak256/host/Cargo.toml
  • prover/tests/keccak256/host/src/main.rs
  • prover/tests/zstd/client/Cargo.toml
  • prover/tests/zstd/client/elf/riscv32im-succinct-zkvm-elf
  • prover/tests/zstd/client/src/main.rs
  • prover/tests/zstd/host/Cargo.toml
  • prover/tests/zstd/host/compressed_batch.data
  • prover/tests/zstd/host/decoded_blob_with_compressed_batch.data
  • prover/tests/zstd/host/src/main.rs

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Warning

Billing warning: we have not been able to collect payment for this subscription for more than 72 hours. Please update the payment method or pay any pending invoices in Billing to avoid service interruption.

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

@anylots
anylots requested a review from dylanCai9 December 4, 2026 08:55
#[test]
fn accepts_canonical_order() {
let blocks = [
block(1, vec![l1(0), l1(1), l2(0), l2(1)]),
#[test]
fn accepts_canonical_order() {
let blocks = [
block(1, vec![l1(0), l1(1), l2(0), l2(1)]),
fn accepts_canonical_order() {
let blocks = [
block(1, vec![l1(0), l1(1), l2(0), l2(1)]),
block(2, vec![l2(2)]),
block(2, vec![l2(2)]),
block(3, vec![]),
block(4, vec![l1(2)]),
block(5, vec![l1(3), l2(3)]),

#[test]
fn rejects_l1_message_after_l2_tx() {
for txs in [vec![l2(0), l2(1), l1(0), l1(1)], vec![l1(0), l2(0), l1(1)], vec![l2(0), l1(0)]]

#[test]
fn rejects_l1_message_after_l2_tx() {
for txs in [vec![l2(0), l2(1), l1(0), l1(1)], vec![l1(0), l2(0), l1(1)], vec![l2(0), l1(0)]]

#[test]
fn rejects_l1_message_after_l2_tx() {
for txs in [vec![l2(0), l2(1), l1(0), l1(1)], vec![l1(0), l2(0), l1(1)], vec![l2(0), l1(0)]]

#[test]
fn rejects_l1_message_after_l2_tx() {
for txs in [vec![l2(0), l2(1), l1(0), l1(1)], vec![l1(0), l2(0), l1(1)], vec![l2(0), l1(0)]]
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