Repository navigation
Conversation
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
… EvmInput witness
|
Important Review skippedToo 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.
|
| #[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)]] |
Summary
Three areas of changes:
1. Full integration of morph-reth v1.5
v1.5.0formorph-revm/morph-primitives/morph-chainspec/morph-evm/morph-rpc, replacing theport-sp1-zkvm-build-fixesbranch.v2.5.2-morph.1(morph-l2/reth fork) forreth-evm/reth-execution-types/reth-storage-errors/reth-trie.v6.2.0tov6.4.0and add execution-witness (debug_executionWitness) proving.types/{block,tx,authorization_list},provider.rs). Blocks are nowmorph_primitives::BlockwithMorphTxEnvelopeandMorphHeader, and are executed byMorphExecutorthrough the morph-reth chainspec and hardforks.edition = 2024,rust-version = 1.95.0, version2.1.0. Drop thezstdpatch and therlpcrate.2. Fix for MPT data used after deserialization
Problem: the old
prover-mpt(EthereumState) sent fully resolvedMptNodetrees from host to guest through serde. The guest used the deserialized tries as they arrived:prev_state_root. The hash check (build_validated_tries) ran only on the host.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/deleteusedunwrap(), so a missing node panicked.Fix:
crates/stateless-mpt, an in-tree fork ofparadigmxyz/statelesszeth-mpt@b7c14668(reth-guest-v0.1.0-rc.9, seeFORK.md). It includes the upstream hardening (WIP: muti submitter #54 rejects over-long paths, upgrade go ethereum #61 rejects malformed nodes) and a fallibletry_insertthat returns an error on an unresolved node instead of panicking.crates/state(SparseState):keccak256computed in the guest. Nodes that are unreachable are ignored, and reachable nodes are checked as they are resolved.storage_root. Any access to a missing node returnsMptErrorinstead of panicking.apply_updates/apply_bundleproduce 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 followBundleAccount::was_destroyed, like upstream Check message index #64.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 itskeccak256, and contracts deployed during the batch come from execution.reachable_nodesto drop nodes the guest cannot reach.sp1_zkvm::io::read) instead of a JSON string.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):mix_hashanddifficultymust be zero, because the blob does not commit them.base_feemust be present and<= MAX_L2_BASE_FEE.gas_limitmust be within[MIN, MAX], and may change from the parent by less than 1/1024 of the parent's gas limit.validate_block_pre_execution, run on both host and guest:TxMorph::validateis applied.<= MORPH_MAX_TX_PAYLOAD_BYTES_PER_BLOCK.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:HOST_EXECUTE_CONCURRENCYat a time (default 1). Tasks are aborted if any block fails.BatchProver::generate_proofretries, classifies failures, and separates network and local implementations.Breaking changes
prover-mpt(replaced byprover-state+stateless-mpt).ExecutorInputnow containsevm: EvmInputinstead ofVec<BlockInput>. The guest ELF and vkey have changed.testdata/block_inputs/*.json. The oldtestdata/mpt,testdata/stateand thetests/{keccak256,zstd}crates are removed.Test plan
cargo test --workspace(includingsparse_state,evm_verifier,validation)block_inputs/*.json)BasicandExecutionWitness