Skip to content
This repository has been archived by the owner on Jun 20, 2024. It is now read-only.

Commit

Permalink
Updated deps
Browse files Browse the repository at this point in the history
  • Loading branch information
BGluth committed Oct 11, 2023
1 parent 662691a commit b4d1f7c
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 17 deletions.
14 changes: 7 additions & 7 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"] }
Expand Down
24 changes: 17 additions & 7 deletions src/prover_input.rs
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -45,6 +48,7 @@ impl From<EdgeBlockMetadata> 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,
Expand All @@ -63,18 +67,24 @@ pub(crate) struct ProverInput {
impl ProverInput {
pub(crate) fn prove(self, p_state: &ProverState) -> Result<GeneratedBlockProof> {
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`.
Expand All @@ -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)?)
}
}

0 comments on commit b4d1f7c

Please sign in to comment.