diff --git a/Cargo.lock b/Cargo.lock index 7860a8d2..dc43d550 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1384,7 +1384,7 @@ checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] name = "plonky2" version = "0.1.4" -source = "git+https://github.com/mir-protocol/plonky2.git?rev=0b5ac312c0f9efdcc6d85c10256d2843d42215a2#0b5ac312c0f9efdcc6d85c10256d2843d42215a2" +source = "git+https://github.com/mir-protocol/plonky2.git?rev=762e6f07b834df04be8cd290f07465a28c392c6d#762e6f07b834df04be8cd290f07465a28c392c6d" dependencies = [ "ahash 0.8.3", "anyhow", @@ -1408,7 +1408,7 @@ dependencies = [ [[package]] name = "plonky2_evm" version = "0.1.1" -source = "git+https://github.com/mir-protocol/plonky2.git?rev=0b5ac312c0f9efdcc6d85c10256d2843d42215a2#0b5ac312c0f9efdcc6d85c10256d2843d42215a2" +source = "git+https://github.com/mir-protocol/plonky2.git?rev=762e6f07b834df04be8cd290f07465a28c392c6d#762e6f07b834df04be8cd290f07465a28c392c6d" dependencies = [ "anyhow", "bytes", @@ -1442,7 +1442,7 @@ dependencies = [ [[package]] name = "plonky2_field" version = "0.1.1" -source = "git+https://github.com/mir-protocol/plonky2.git?rev=0b5ac312c0f9efdcc6d85c10256d2843d42215a2#0b5ac312c0f9efdcc6d85c10256d2843d42215a2" +source = "git+https://github.com/mir-protocol/plonky2.git?rev=762e6f07b834df04be8cd290f07465a28c392c6d#762e6f07b834df04be8cd290f07465a28c392c6d" dependencies = [ "anyhow", "itertools", @@ -1457,7 +1457,7 @@ dependencies = [ [[package]] name = "plonky2_maybe_rayon" version = "0.1.1" -source = "git+https://github.com/mir-protocol/plonky2.git?rev=0b5ac312c0f9efdcc6d85c10256d2843d42215a2#0b5ac312c0f9efdcc6d85c10256d2843d42215a2" +source = "git+https://github.com/mir-protocol/plonky2.git?rev=762e6f07b834df04be8cd290f07465a28c392c6d#762e6f07b834df04be8cd290f07465a28c392c6d" dependencies = [ "rayon", ] @@ -1465,12 +1465,12 @@ dependencies = [ [[package]] name = "plonky2_util" version = "0.1.1" -source = "git+https://github.com/mir-protocol/plonky2.git?rev=0b5ac312c0f9efdcc6d85c10256d2843d42215a2#0b5ac312c0f9efdcc6d85c10256d2843d42215a2" +source = "git+https://github.com/mir-protocol/plonky2.git?rev=762e6f07b834df04be8cd290f07465a28c392c6d#762e6f07b834df04be8cd290f07465a28c392c6d" [[package]] name = "plonky_block_proof_gen" version = "0.1.0" -source = "git+https://github.com/mir-protocol/plonky-block-proof-gen.git?rev=6a64f9be4616931c042aaf932d2483529e1db9bf#6a64f9be4616931c042aaf932d2483529e1db9bf" +source = "git+https://github.com/mir-protocol/plonky-block-proof-gen.git?rev=73c3bcbaf3bfe913641c5b6817bc3ba5aa9859bc#73c3bcbaf3bfe913641c5b6817bc3ba5aa9859bc" dependencies = [ "ethereum-types", "log", @@ -1483,7 +1483,7 @@ dependencies = [ [[package]] name = "plonky_edge_block_trace_parser" version = "0.1.0" -source = "git+https://github.com/mir-protocol/plonky-edge-block-trace-parser.git?rev=0e5f70f673439434480ef74a1f4a7430859524b4#0e5f70f673439434480ef74a1f4a7430859524b4" +source = "git+https://github.com/mir-protocol/plonky-edge-block-trace-parser.git?rev=1bc20699b91201291294914772a30de84ffdcc58#1bc20699b91201291294914772a30de84ffdcc58" dependencies = [ "eth_trie_utils", "ethereum-types", diff --git a/Cargo.toml b/Cargo.toml index 6f5bc41c..251c4654 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,9 +6,9 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -plonky_edge_block_trace_parser = { git = "https://github.com/mir-protocol/plonky-edge-block-trace-parser.git", rev = "0e5f70f673439434480ef74a1f4a7430859524b4" } -plonky_block_proof_gen = { git = "https://github.com/mir-protocol/plonky-block-proof-gen.git", rev = "6a64f9be4616931c042aaf932d2483529e1db9bf" } -plonky2_evm = { git = "https://github.com/mir-protocol/plonky2.git", rev = "0b5ac312c0f9efdcc6d85c10256d2843d42215a2" } +plonky_edge_block_trace_parser = { git = "https://github.com/mir-protocol/plonky-edge-block-trace-parser.git", rev = "1bc20699b91201291294914772a30de84ffdcc58" } +plonky_block_proof_gen = { git = "https://github.com/mir-protocol/plonky-block-proof-gen.git", rev = "73c3bcbaf3bfe913641c5b6817bc3ba5aa9859bc" } +plonky2_evm = { git = "https://github.com/mir-protocol/plonky2.git", rev = "762e6f07b834df04be8cd290f07465a28c392c6d" } clap = { version = "4.4.6", features = ["derive"] } tracing = "0.1.37" tracing-subscriber = { version = "0.3.17", features = ["env-filter"] } diff --git a/src/prover_input.rs b/src/prover_input.rs index ad0f3f9f..355f46d0 100644 --- a/src/prover_input.rs +++ b/src/prover_input.rs @@ -1,21 +1,24 @@ use anyhow::Result; -use ethereum_types::{Address, Bloom, U256}; +use ethereum_types::{Address, Bloom, U256, H256}; use plonky2_evm::proof::BlockMetadata; use plonky_block_proof_gen::{ proof_gen::{generate_agg_proof, generate_block_proof, generate_txn_proof}, - proof_types::{BlockLevelData, GeneratedBlockProof}, + proof_types::{BlockLevelData, GeneratedBlockProof, OtherBlockData}, prover_state::ProverState, }; use plonky_edge_block_trace_parser::edge_payloads::EdgeBlockTrace; use serde::Deserialize; use tracing::debug; +const GENESIS_STATE_ROOT: H256 = H256::zero(); + #[derive(Debug, Deserialize)] #[serde(rename_all = "camelCase")] pub(crate) struct EdgeBlockMetadata { pub(crate) miner: Address, pub(crate) logs_bloom: Bloom, pub(crate) difficulty: U256, + pub(crate) mix_hash: H256, pub(crate) number: U256, pub(crate) gas_limit: U256, pub(crate) gas_used: U256, @@ -45,6 +48,7 @@ impl From for BlockMetadata { block_timestamp: v.timestamp, block_number: v.number, block_difficulty: v.difficulty, + block_random: v.mix_hash, block_gaslimit: v.gas_limit, block_chain_id: MATIC_CHAIN_ID.into(), block_base_fee: v.base_fee_per_gas, @@ -63,18 +67,24 @@ pub(crate) struct ProverInput { impl ProverInput { pub(crate) fn prove(self, p_state: &ProverState) -> Result { let number = self.metadata.number; + let b_data = BlockLevelData { b_meta: self.metadata.into(), b_hashes: Default::default(), }; - debug!("Proving block #{number}: {b_data:#?}"); + let other_data = OtherBlockData { + b_data, + genesis_state_trie_root: GENESIS_STATE_ROOT, + }; + + debug!("Proving block #{number}: {other_data:#?}"); let txs = self.trace.into_txn_proof_gen_payloads(number.as_u64())?; let mut txn_proofs = txs .into_iter() - .map(|tx| generate_txn_proof(p_state, tx, b_data.clone())); + .map(|tx| generate_txn_proof(p_state, tx, other_data.clone())); // We should have at least two txs in a block, given dummy padding in // `plonky_edge_block_trace_parser`. @@ -84,10 +94,10 @@ impl ProverInput { ); let agg_proof = txn_proofs.try_fold( - generate_agg_proof(p_state, &fst.into(), &snd.into(), b_data.clone())?, - |agg, tx| generate_agg_proof(p_state, &agg.into(), &tx?.into(), b_data.clone()), + generate_agg_proof(p_state, &fst.into(), &snd.into(), other_data.clone())?, + |agg, tx| generate_agg_proof(p_state, &agg.into(), &tx?.into(), other_data.clone()), )?; - Ok(generate_block_proof(p_state, None, &agg_proof, b_data)?) + Ok(generate_block_proof(p_state, None, &agg_proof, other_data)?) } }