From 88fbecab83a1dd14d97f9d36097e25dd60a4e22e Mon Sep 17 00:00:00 2001 From: Brechtpd Date: Tue, 12 Mar 2024 16:55:12 +0100 Subject: [PATCH 01/10] Switch to alloy (most things working at least) --- .vscode/settings.json | 6 +- Cargo.lock | 48 ++++-- Cargo.toml | 2 - lib/Cargo.toml | 4 + lib/src/builder/execute/taiko.rs | 220 +++++++++++++++++++++++--- lib/src/builder/finalize.rs | 8 +- lib/src/builder/initialize.rs | 2 +- lib/src/builder/mod.rs | 8 +- lib/src/builder/prepare.rs | 24 ++- lib/src/input.rs | 22 +-- lib/src/protocol_instance.rs | 13 +- lib/src/taiko_utils.rs | 162 +++++++++++++++++-- primitives/Cargo.toml | 2 +- primitives/src/block.rs | 176 --------------------- primitives/src/ethers.rs | 34 ---- primitives/src/lib.rs | 1 - raiko-guests/risc0/build.rs | 1 + raiko-guests/succinct/Cargo.lock | 50 +++++- raiko-host/Cargo.toml | 7 +- raiko-host/build.rs | 1 + raiko-host/src/host/host.rs | 118 +++++++++----- raiko-host/src/host/provider_db.rs | 14 +- raiko-host/src/host/taiko_provider.rs | 10 ++ raiko-host/src/prover/execution.rs | 24 ++- risc0-driver/Cargo.lock | 98 ++++++------ risc0-driver/Cargo.toml | 4 +- rust-toolchain | 2 +- 27 files changed, 646 insertions(+), 415 deletions(-) delete mode 100644 primitives/src/block.rs diff --git a/.vscode/settings.json b/.vscode/settings.json index 968ea307..1b642a05 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,10 +1,6 @@ { - "rust-analyzer.cargo.features": "all", + "rust-analyzer.cargo.features": "", "rust-analyzer.linkedProjects": [ "./Cargo.toml", - "./raiko-guests/succinct/Cargo.toml", - "./raiko-guests/risc0/Cargo.toml", - "./raiko-guests/risc0/bin/Cargo.toml", - "./risc0-driver/Cargo.toml", ] } diff --git a/Cargo.lock b/Cargo.lock index 18034f76..9ca596d9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -89,6 +89,18 @@ dependencies = [ "strum 0.26.1", ] +[[package]] +name = "alloy-consensus" +version = "0.1.0" +source = "git+https://github.com/brechtpd/alloy?branch=header-serialize#14381350e57921a71292304875e87dfbfd33c3b5" +dependencies = [ + "alloy-eips 0.1.0 (git+https://github.com/brechtpd/alloy?branch=header-serialize)", + "alloy-network", + "alloy-primitives", + "alloy-rlp", + "serde", +] + [[package]] name = "alloy-dyn-abi" version = "0.6.4" @@ -107,7 +119,7 @@ dependencies = [ [[package]] name = "alloy-eips" version = "0.1.0" -source = "git+https://github.com/brechtpd/alloy?branch=r170#8ed5684f69f3d6ed8dfe99549f93a6ecac1dee14" +source = "git+https://github.com/brechtpd/alloy?branch=header-serialize#e77a49aad28ca01624bbb9cc3ee0f1daaceb1869" dependencies = [ "alloy-primitives", "alloy-rlp", @@ -149,7 +161,7 @@ dependencies = [ [[package]] name = "alloy-json-rpc" version = "0.1.0" -source = "git+https://github.com/brechtpd/alloy?branch=r170#8ed5684f69f3d6ed8dfe99549f93a6ecac1dee14" +source = "git+https://github.com/brechtpd/alloy?branch=header-serialize#e77a49aad28ca01624bbb9cc3ee0f1daaceb1869" dependencies = [ "alloy-primitives", "serde", @@ -160,9 +172,9 @@ dependencies = [ [[package]] name = "alloy-network" version = "0.1.0" -source = "git+https://github.com/brechtpd/alloy?branch=r170#8ed5684f69f3d6ed8dfe99549f93a6ecac1dee14" +source = "git+https://github.com/brechtpd/alloy?branch=header-serialize#e77a49aad28ca01624bbb9cc3ee0f1daaceb1869" dependencies = [ - "alloy-eips 0.1.0 (git+https://github.com/brechtpd/alloy?branch=r170)", + "alloy-eips 0.1.0 (git+https://github.com/brechtpd/alloy?branch=header-serialize)", "alloy-json-rpc", "alloy-primitives", "alloy-rlp", @@ -195,13 +207,13 @@ dependencies = [ [[package]] name = "alloy-providers" version = "0.1.0" -source = "git+https://github.com/brechtpd/alloy?branch=r170#8ed5684f69f3d6ed8dfe99549f93a6ecac1dee14" +source = "git+https://github.com/brechtpd/alloy?branch=header-serialize#e77a49aad28ca01624bbb9cc3ee0f1daaceb1869" dependencies = [ "alloy-network", "alloy-primitives", "alloy-rpc-client", - "alloy-rpc-trace-types 0.1.0 (git+https://github.com/brechtpd/alloy?branch=r170)", - "alloy-rpc-types 0.1.0 (git+https://github.com/brechtpd/alloy?branch=r170)", + "alloy-rpc-trace-types 0.1.0 (git+https://github.com/brechtpd/alloy?branch=header-serialize)", + "alloy-rpc-types 0.1.0 (git+https://github.com/brechtpd/alloy?branch=header-serialize)", "alloy-transport", "alloy-transport-http", "async-stream", @@ -241,7 +253,7 @@ dependencies = [ [[package]] name = "alloy-rpc-client" version = "0.1.0" -source = "git+https://github.com/brechtpd/alloy?branch=r170#8ed5684f69f3d6ed8dfe99549f93a6ecac1dee14" +source = "git+https://github.com/brechtpd/alloy?branch=header-serialize#e77a49aad28ca01624bbb9cc3ee0f1daaceb1869" dependencies = [ "alloy-json-rpc", "alloy-transport", @@ -274,10 +286,10 @@ dependencies = [ [[package]] name = "alloy-rpc-trace-types" version = "0.1.0" -source = "git+https://github.com/brechtpd/alloy?branch=r170#8ed5684f69f3d6ed8dfe99549f93a6ecac1dee14" +source = "git+https://github.com/brechtpd/alloy?branch=header-serialize#e77a49aad28ca01624bbb9cc3ee0f1daaceb1869" dependencies = [ "alloy-primitives", - "alloy-rpc-types 0.1.0 (git+https://github.com/brechtpd/alloy?branch=r170)", + "alloy-rpc-types 0.1.0 (git+https://github.com/brechtpd/alloy?branch=header-serialize)", "serde", "serde_json", ] @@ -296,7 +308,7 @@ dependencies = [ [[package]] name = "alloy-rpc-types" version = "0.1.0" -source = "git+https://github.com/brechtpd/alloy?branch=r170#8ed5684f69f3d6ed8dfe99549f93a6ecac1dee14" +source = "git+https://github.com/brechtpd/alloy?branch=header-serialize#e77a49aad28ca01624bbb9cc3ee0f1daaceb1869" dependencies = [ "alloy-primitives", "alloy-rlp", @@ -362,7 +374,7 @@ dependencies = [ [[package]] name = "alloy-transport" version = "0.1.0" -source = "git+https://github.com/brechtpd/alloy?branch=r170#8ed5684f69f3d6ed8dfe99549f93a6ecac1dee14" +source = "git+https://github.com/brechtpd/alloy?branch=header-serialize#e77a49aad28ca01624bbb9cc3ee0f1daaceb1869" dependencies = [ "alloy-json-rpc", "base64 0.21.7", @@ -378,7 +390,7 @@ dependencies = [ [[package]] name = "alloy-transport-http" version = "0.1.0" -source = "git+https://github.com/brechtpd/alloy?branch=r170#8ed5684f69f3d6ed8dfe99549f93a6ecac1dee14" +source = "git+https://github.com/brechtpd/alloy?branch=header-serialize#e77a49aad28ca01624bbb9cc3ee0f1daaceb1869" dependencies = [ "alloy-json-rpc", "alloy-transport", @@ -4209,9 +4221,10 @@ checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" name = "raiko-host" version = "0.1.0" dependencies = [ + "alloy-consensus", "alloy-primitives", "alloy-providers", - "alloy-rpc-types 0.1.0 (git+https://github.com/brechtpd/alloy?branch=r170)", + "alloy-rpc-types 0.1.0 (git+https://github.com/brechtpd/alloy?branch=header-serialize)", "alloy-sol-types", "alloy-transport-http", "anyhow", @@ -5951,7 +5964,7 @@ version = "0.1.0" dependencies = [ "env_logger", "gobuild", - "hex 0.4.3", + "hex 0.3.2", "log", "serde", "serde_json", @@ -7005,9 +7018,12 @@ dependencies = [ name = "zeth-lib" version = "0.1.0" dependencies = [ + "alloy-consensus", + "alloy-network", "alloy-primitives", "alloy-rlp", "alloy-rlp-derive", + "alloy-rpc-types 0.1.0 (git+https://github.com/brechtpd/alloy?branch=header-serialize)", "alloy-sol-types", "anyhow", "bincode", @@ -7041,7 +7057,7 @@ dependencies = [ "alloy-primitives", "alloy-rlp", "alloy-rlp-derive", - "alloy-rpc-types 0.1.0 (git+https://github.com/brechtpd/alloy?branch=r170)", + "alloy-rpc-types 0.1.0 (git+https://github.com/brechtpd/alloy?branch=header-serialize)", "alloy-sol-types", "anyhow", "bincode", diff --git a/Cargo.toml b/Cargo.toml index 61b92727..d6a5c6da 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -37,8 +37,6 @@ opt-level = 3 [workspace.dependencies] bonsai-sdk = "0.5" hashbrown = { version = "0.14", features = ["inline-more"] } -risc0-build = "0.19" -risc0-zkvm = { version = "0.19", default-features = false } revm-primitives = { git = "https://github.com/ceciliaz030/revm.git", branch = "sync-taiko-v3.5", default_features = false } revm = { git = "https://github.com/ceciliaz030/revm.git", branch = "sync-taiko-v3.5", default-features = false, features = [ "serde", diff --git a/lib/Cargo.toml b/lib/Cargo.toml index e2bf5736..bc763717 100644 --- a/lib/Cargo.toml +++ b/lib/Cargo.toml @@ -15,6 +15,9 @@ alloy-primitives = { version = "0.6", default-features = false, features = [ "std", "tiny-keccak", ] } +alloy-rpc-types = { git = "https://github.com/brechtpd/alloy", branch = "header-serialize", version = "0.1.0" } +alloy-consensus = { git = "https://github.com/brechtpd/alloy", branch = "header-serialize", version = "0.1.0" } +alloy-network = { git = "https://github.com/brechtpd/alloy", branch = "header-serialize", version = "0.1.0", features = ["k256"] } bytes = {version = "1.5", default-features = false} hashbrown = { workspace = true } libflate = { version = "2.0.0", optional = true } @@ -27,6 +30,7 @@ zeth-primitives = { path = "../primitives", features = ["revm"] } hex = { version = "0.4.3", default-features = false, optional = true } url = "2.5.0" ethers-core = { git = "https://github.com/smtmfft/ethers-rs", branch = "ethers-core-2.0.10" } +#reth-primitives = { git = "https://github.com/paradigmxyz/reth.git" } # [target.'cfg(feature = "std")'.dependencies] thiserror = {version = "1.0", optional = true} diff --git a/lib/src/builder/execute/taiko.rs b/lib/src/builder/execute/taiko.rs index d5fd493d..147124d4 100644 --- a/lib/src/builder/execute/taiko.rs +++ b/lib/src/builder/execute/taiko.rs @@ -14,6 +14,9 @@ use core::{fmt::Debug, mem::take, str::from_utf8}; +use alloy_consensus::{TxEnvelope, TxKind}; +use alloy_consensus::TxEip4844Variant::TxEip4844; +use alloy_consensus::TxEip4844Variant; use anyhow::{anyhow, bail, Context, Result}; #[cfg(feature = "std")] use log::debug; @@ -36,6 +39,7 @@ use zeth_primitives::{ }; use super::TxExecStrategy; +use crate::taiko_utils::generate_transactions_alloy; use crate::{ builder::BlockBuilder, consts::{self, ChainSpec, GWEI_TO_WEI}, @@ -68,9 +72,15 @@ impl TxExecStrategy for TkoTxExecStrategy { let chain_id = block_builder.chain_spec.chain_id(); // generate the transactions from the tx list - let mut transactions = generate_transactions_2( + let mut transactions = generate_transactions_alloy( &block_builder.input.taiko.tx_list, - block_builder.input.taiko.anchor_tx.clone().unwrap(), + serde_json::from_str(&block_builder.input.taiko.anchor_tx_alloy.clone()).unwrap(), + ); + + // generate the transactions from the tx list + let mut transactions_ether = generate_transactions_2( + &block_builder.input.taiko.tx_list, + block_builder.input.taiko.anchor_tx.clone().unwrap().clone(), ); #[cfg(feature = "std")] @@ -87,7 +97,7 @@ impl TxExecStrategy for TkoTxExecStrategy { info!(" Transactions: {}", transactions.len()); info!(" Fee Recipient: {:?}", block_builder.input.beneficiary); info!(" Gas limit: {}", block_builder.input.gas_limit); - info!(" Base fee per gas: {}", header.base_fee_per_gas); + info!(" Base fee per gas: {}", header.base_fee_per_gas.unwrap()); info!(" Extra data: {:?}", block_builder.input.extra_data); } @@ -102,11 +112,11 @@ impl TxExecStrategy for TkoTxExecStrategy { // set the EVM block environment blk_env.number = U256::from(header.number); blk_env.coinbase = block_builder.input.beneficiary; - blk_env.timestamp = header.timestamp; + blk_env.timestamp = header.timestamp.try_into().unwrap(); blk_env.difficulty = U256::ZERO; blk_env.prevrandao = Some(header.mix_hash); - blk_env.basefee = header.base_fee_per_gas; - blk_env.gas_limit = block_builder.input.gas_limit; + blk_env.basefee = header.base_fee_per_gas.unwrap().try_into().unwrap(); + blk_env.gas_limit = block_builder.input.gas_limit.try_into().unwrap(); }) .with_db(block_builder.db.take().unwrap()) .append_handler_register(taiko::handler_register::taiko_handle_register) @@ -115,7 +125,7 @@ impl TxExecStrategy for TkoTxExecStrategy { // bloom filter over all transaction logs let mut logs_bloom = Bloom::default(); // keep track of the gas used over all transactions - let mut cumulative_gas_used = consts::ZERO; + let mut cumulative_gas_used = 0u64; // process all the transactions let mut tx_trie = MptNode::default(); @@ -126,8 +136,56 @@ impl TxExecStrategy for TkoTxExecStrategy { // anchor transaction must be executed successfully let is_anchor = tx_no == 0; + let tx_hash = match &tx { + TxEnvelope::Legacy(tx) => { + tx.hash() + } + TxEnvelope::TaggedLegacy(tx) => { + tx.hash() + } + TxEnvelope::Eip2930(tx) => { + tx.hash() + } + TxEnvelope::Eip1559(tx) => { + tx.hash() + } + TxEnvelope::Eip4844(tx) => { + tx.hash() + } + }; + println!("**** hash: {:?}", tx_hash); + + let from = match &tx { + TxEnvelope::Legacy(tx) => { + tx.recover_signer() + } + TxEnvelope::TaggedLegacy(tx) => { + tx.recover_signer() + } + TxEnvelope::Eip2930(tx) => { + tx.recover_signer() + } + TxEnvelope::Eip1559(tx) => { + tx.recover_signer() + } + TxEnvelope::Eip4844(tx) => { + tx.recover_signer() + } + }; + + println!("**** from: {:?}", from); + + let tx_type = match tx.tx_type() { + alloy_consensus::TxType::Legacy => 0, + alloy_consensus::TxType::Eip2930 => 1, + alloy_consensus::TxType::Eip1559 => 2, + alloy_consensus::TxType::Eip4844 => 3, + }; + + //println!("**** tx_type: {:?}", tx_type); + // verify the transaction signature - let tx_from = match tx.recover_from() { + let tx_from = match from { Ok(tx_from) => tx_from, Err(err) => { if is_anchor { @@ -144,7 +202,8 @@ impl TxExecStrategy for TkoTxExecStrategy { }; // verify the anchor tx - if is_anchor { + // TODO(Brecht): reenable with alloy tx + /*if is_anchor { check_anchor_tx( &block_builder.input, &tx, @@ -152,31 +211,43 @@ impl TxExecStrategy for TkoTxExecStrategy { &block_builder.input.taiko.chain_spec_name, ) .expect("invalid anchor tx"); - } + }*/ #[cfg(feature = "std")] { - let tx_hash = tx.hash(); + //let tx_hash = tx.hash(); debug!("Tx no. {tx_no} (hash: {tx_hash})"); - debug!(" Type: {}", tx.essence.tx_type()); + debug!(" Type: {}", tx_type); debug!(" Fr: {tx_from:?}"); - debug!(" To: {:?}", tx.essence.to().unwrap_or_default()); + //debug!(" To: {:?}", tx.to().unwrap_or_default()); } // verify transaction gas let block_available_gas = block_builder.input.gas_limit - cumulative_gas_used; - if block_available_gas < tx.essence.gas_limit() { - bail!("Error at transaction {tx_no}: gas exceeds block limit"); - } + // TODO(Brecht): reenable + //if block_available_gas < tx.gas_limit().try_into().unwrap() { + // bail!("Error at transaction {tx_no}: gas exceeds block limit"); + //} + + println!("**** fill"); + + /*fill_eth_tx_env( + &block_builder.input.taiko.chain_spec_name, + &mut evm.env().tx, + &transactions_ether[0].clone().essence, + tx_from, + is_anchor, + );*/ // setup the transaction - fill_eth_tx_env( + fill_eth_tx_env_alloy( &block_builder.input.taiko.chain_spec_name, &mut evm.env().tx, - &tx.essence, + &tx, tx_from, is_anchor, ); + //println!("**** transact: {:?}", evm.env().tx); // process the transaction let ResultAndState { result, state } = match evm.transact() { Ok(result) => result, @@ -201,6 +272,8 @@ impl TxExecStrategy for TkoTxExecStrategy { } }; + //println!("**** transact done"); + // anchor tx needs to succeed if is_anchor && !result.is_success() { bail!( @@ -217,9 +290,9 @@ impl TxExecStrategy for TkoTxExecStrategy { // create the receipt from the EVM result let receipt = Receipt::new( - tx.essence.tx_type(), + tx_type, result.is_success(), - cumulative_gas_used, + cumulative_gas_used.try_into().unwrap(), result.logs().into_iter().map(|log| log.into()).collect(), ); @@ -259,7 +332,15 @@ impl TxExecStrategy for TkoTxExecStrategy { // Add receipt and tx to tries let trie_key = actual_tx_no.to_rlp(); - tx_trie.insert_rlp(&trie_key, tx)?; + + //tx_trie.insert_rlp(&trie_key, tx)?; + + //if is_anchor { + tx_trie.insert_rlp(&trie_key, transactions_ether[tx_no].clone())?; + //} else { + // tx_trie.insert_rlp(&trie_key, tx)?; + //}; + receipt_trie.insert_rlp(&trie_key, receipt)?; actual_tx_no += 1; } @@ -295,7 +376,7 @@ impl TxExecStrategy for TkoTxExecStrategy { header.transactions_root = tx_trie.hash(); header.receipts_root = receipt_trie.hash(); header.logs_bloom = logs_bloom; - header.gas_used = cumulative_gas_used; + header.gas_used = cumulative_gas_used.try_into().unwrap() ; header.withdrawals_root = if spec_id < SpecId::SHANGHAI { None } else { @@ -389,6 +470,101 @@ pub fn fill_eth_tx_env( }; } +pub fn fill_eth_tx_env_alloy( + chain_name: &str, + tx_env: &mut TxEnv, + tx: &TxEnvelope, + caller: Address, + is_anchor: bool, +) { + // claim the anchor + tx_env.taiko.is_anchor = is_anchor; + // set the treasury address + tx_env.taiko.treasury = get_contracts(chain_name).unwrap().1; + + tx_env.caller = caller; + match tx { + TxEnvelope::Legacy(tx) => { + tx_env.gas_limit = tx.gas_limit.try_into().unwrap(); + tx_env.gas_price = tx.gas_price.try_into().unwrap(); + tx_env.gas_priority_fee = None; + tx_env.transact_to = if let TxKind::Call(to_addr) = tx.to { + TransactTo::Call(to_addr) + } else { + TransactTo::create() + }; + tx_env.value = tx.value; + tx_env.data = tx.input.clone(); + tx_env.chain_id = tx.chain_id; + tx_env.nonce = Some(tx.nonce); + tx_env.access_list.clear(); + } + TxEnvelope::TaggedLegacy(tx) => { + tx_env.gas_limit = tx.gas_limit.try_into().unwrap(); + tx_env.gas_price = tx.gas_price.try_into().unwrap(); + tx_env.gas_priority_fee = None; + tx_env.transact_to = if let TxKind::Call(to_addr) = tx.to { + TransactTo::Call(to_addr) + } else { + TransactTo::create() + }; + tx_env.value = tx.value; + tx_env.data = tx.input.clone(); + tx_env.chain_id = tx.chain_id; + tx_env.nonce = Some(tx.nonce); + tx_env.access_list.clear(); + } + TxEnvelope::Eip2930(tx) => { + tx_env.gas_limit = tx.gas_limit.try_into().unwrap(); + tx_env.gas_price = tx.gas_price.try_into().unwrap(); + tx_env.gas_priority_fee = None; + tx_env.transact_to = if let TxKind::Call(to_addr) = tx.to { + TransactTo::Call(to_addr) + } else { + TransactTo::create() + }; + tx_env.value = tx.value; + tx_env.data = tx.input.clone(); + tx_env.chain_id = Some(tx.chain_id); + tx_env.nonce = Some(tx.nonce); + tx_env.access_list = tx.access_list.clone().into_flattened(); + } + TxEnvelope::Eip1559(tx) => { + tx_env.caller = caller; + tx_env.gas_limit = tx.gas_limit.try_into().unwrap(); + tx_env.gas_price = tx.max_fee_per_gas.try_into().unwrap(); + tx_env.gas_priority_fee = Some(tx.max_priority_fee_per_gas.try_into().unwrap()); + tx_env.transact_to = if let TxKind::Call(to_addr) = tx.to { + TransactTo::Call(to_addr) + } else { + TransactTo::create() + }; + tx_env.value = tx.value; + tx_env.data = tx.input.clone(); + tx_env.chain_id = Some(tx.chain_id); + tx_env.nonce = Some(tx.nonce); + tx_env.access_list = tx.access_list.clone().into_flattened(); + } + TxEnvelope::Eip4844(tx) => { + let tx = tx.tx().tx(); + tx_env.gas_limit = tx.gas_limit.try_into().unwrap(); + tx_env.gas_price = tx.max_fee_per_gas.try_into().unwrap(); + tx_env.gas_priority_fee = Some(tx.max_priority_fee_per_gas.try_into().unwrap()); + tx_env.transact_to = if let TxKind::Call(to_addr) = tx.to { + TransactTo::Call(to_addr) + } else { + TransactTo::create() + }; + tx_env.value = tx.value; + tx_env.data = tx.input.clone(); + tx_env.chain_id = Some(tx.chain_id); + tx_env.nonce = Some(tx.nonce); + tx_env.access_list = tx.access_list.clone().into_flattened(); + } + }; +} + + pub fn increase_account_balance( db: &mut D, address: Address, diff --git a/lib/src/builder/finalize.rs b/lib/src/builder/finalize.rs index b5513073..4870ac4a 100644 --- a/lib/src/builder/finalize.rs +++ b/lib/src/builder/finalize.rs @@ -17,11 +17,11 @@ use core::mem; use anyhow::Result; use revm::{Database, DatabaseCommit}; use zeth_primitives::{ - block::Header, keccak::keccak, mpt::{MptNode, StateAccount}, transactions::TxEssence, }; +use alloy_consensus::Header as AlloyConsensusHeader; use crate::{ builder::BlockBuilder, @@ -34,7 +34,7 @@ where D: Database + DatabaseCommit, ::Error: core::fmt::Debug, { - fn finalize(block_builder: BlockBuilder) -> Result<(Header, MptNode)> + fn finalize(block_builder: BlockBuilder) -> Result<(AlloyConsensusHeader, MptNode)> where E: TxEssence; } @@ -44,8 +44,8 @@ pub struct MemDbBlockFinalizeStrategy {} impl BlockFinalizeStrategy for MemDbBlockFinalizeStrategy { fn finalize( mut block_builder: BlockBuilder, - ) -> Result<(Header, MptNode)> { - let db = block_builder.db.take().expect("DB not initialized"); + ) -> Result<(AlloyConsensusHeader, MptNode)> { + let db: MemDb = block_builder.db.take().expect("DB not initialized"); // apply state updates let mut state_trie = mem::take(&mut block_builder.input.parent_state_trie); diff --git a/lib/src/builder/initialize.rs b/lib/src/builder/initialize.rs index 8e5f6838..4cfa99e8 100644 --- a/lib/src/builder/initialize.rs +++ b/lib/src/builder/initialize.rs @@ -31,7 +31,7 @@ use crate::{ builder::BlockBuilder, consts::MAX_BLOCK_HASH_AGE, guest_mem_forget, - mem_db::{AccountState, DbAccount, MemDb}, + mem_db::{AccountState, DbAccount, MemDb}, taiko_utils::HeaderHasher, }; pub trait DbInitStrategy diff --git a/lib/src/builder/mod.rs b/lib/src/builder/mod.rs index 748fb6e7..6c6745d0 100644 --- a/lib/src/builder/mod.rs +++ b/lib/src/builder/mod.rs @@ -15,7 +15,6 @@ use anyhow::Result; use revm::{Database, DatabaseCommit}; use zeth_primitives::{ - block::Header, mpt::MptNode, transactions::{ethereum::EthereumTxEssence, TxEssence}, }; @@ -32,6 +31,7 @@ use crate::{ input::GuestInput, mem_db::MemDb, }; +use alloy_consensus::Header as AlloyConsensusHeader; mod execute; mod finalize; @@ -44,7 +44,7 @@ pub struct BlockBuilder { pub(crate) chain_spec: ChainSpec, pub(crate) input: GuestInput, pub(crate) db: Option, - pub(crate) header: Option
, + pub(crate) header: Option, } impl BlockBuilder @@ -85,7 +85,7 @@ where } /// Finalizes the block building and returns the header and the state trie. - pub fn finalize>(self) -> Result<(Header, MptNode)> { + pub fn finalize>(self) -> Result<(AlloyConsensusHeader, MptNode)> { T::finalize(self) } @@ -110,7 +110,7 @@ pub trait BlockBuilderStrategy { type BlockFinalizeStrategy: BlockFinalizeStrategy; /// Builds a block from the given input. - fn build_from(input: &GuestInput) -> Result<(Header, MptNode)> { + fn build_from(input: &GuestInput) -> Result<(AlloyConsensusHeader, MptNode)> { BlockBuilder::::new(input) .initialize_database::()? .prepare_header::()? diff --git a/lib/src/builder/prepare.rs b/lib/src/builder/prepare.rs index 3ac1e119..58b121ec 100644 --- a/lib/src/builder/prepare.rs +++ b/lib/src/builder/prepare.rs @@ -16,9 +16,10 @@ use core::fmt::Debug; use anyhow::{bail, Context, Result}; use revm::{Database, DatabaseCommit}; -use zeth_primitives::{block::Header, transactions::TxEssence}; +use zeth_primitives::transactions::TxEssence; +use alloy_consensus::Header as AlloyConsensusHeader; -use crate::{builder::BlockBuilder, consts::MAX_EXTRA_DATA_BYTES, taiko_utils::BLOCK_GAS_LIMIT}; +use crate::{builder::BlockBuilder, consts::MAX_EXTRA_DATA_BYTES, taiko_utils::{HeaderHasher, BLOCK_GAS_LIMIT}}; pub trait HeaderPrepStrategy { fn prepare_header(block_builder: BlockBuilder) -> Result> @@ -38,15 +39,16 @@ impl HeaderPrepStrategy for TaikoHeaderPrepStrategy { E: TxEssence, { // Validate gas limit - if block_builder.input.gas_limit != *BLOCK_GAS_LIMIT { + if block_builder.input.gas_limit != BLOCK_GAS_LIMIT { bail!( "Invalid gas limit: expected == {}, got {}", - *BLOCK_GAS_LIMIT, + BLOCK_GAS_LIMIT, block_builder.input.gas_limit, ); } // Validate timestamp - if block_builder.input.timestamp < block_builder.input.parent_header.timestamp { + let timestamp: u64 = block_builder.input.timestamp.try_into().unwrap(); + if timestamp < block_builder.input.parent_header.timestamp { bail!( "Invalid timestamp: expected >= {}, got {}", block_builder.input.parent_header.timestamp, @@ -63,16 +65,12 @@ impl HeaderPrepStrategy for TaikoHeaderPrepStrategy { ) } // Derive header - block_builder.header = Some(Header { + let number: u64 = block_builder.input.parent_header.number; + block_builder.header = Some(AlloyConsensusHeader { // Initialize fields that we can compute from the parent parent_hash: block_builder.input.parent_header.hash(), - number: block_builder - .input - .parent_header - .number - .checked_add(1) - .with_context(|| "Invalid block number: too large")?, - base_fee_per_gas: block_builder.input.base_fee_per_gas, + number: number.checked_add(1).with_context(|| "Invalid block number: too large")?, + base_fee_per_gas: Some(block_builder.input.base_fee_per_gas), // Initialize metadata from input beneficiary: block_builder.input.beneficiary, gas_limit: block_builder.input.gas_limit, diff --git a/lib/src/input.rs b/lib/src/input.rs index b516b788..aaf9b63a 100644 --- a/lib/src/input.rs +++ b/lib/src/input.rs @@ -14,17 +14,18 @@ use core::fmt::Debug; use alloy_sol_types::{sol, SolCall, SolType}; +use alloy_consensus::Header as AlloyConsensusHeader; use anyhow::{anyhow, Result}; use ethers_core::types::H256; use hashbrown::HashMap; use serde::{Deserialize, Serialize}; use zeth_primitives::{ - block::Header, mpt::MptNode, transactions::{Transaction, TxEssence}, withdrawal::Withdrawal, Address, Bytes, FixedBytes, B256, U256, }; +use alloy_rpc_types::Transaction as AlloyTransaction; /// Represents the state of an account's storage. /// The storage trie together with the used storage slots allow us to reconstruct all the @@ -32,18 +33,18 @@ use zeth_primitives::{ pub type StorageEntry = (MptNode, Vec); /// External block input. -#[derive(Debug, Clone, Default, Deserialize, Serialize)] +#[derive(Debug, Clone, Deserialize, Serialize)] pub struct GuestInput { /// Block hash - for reference! pub block_hash: H256, /// Previous block header - pub parent_header: Header, + pub parent_header: AlloyConsensusHeader, /// Address to which all priority fees in this block are transferred. pub beneficiary: Address, /// Scalar equal to the current limit of gas expenditure per block. - pub gas_limit: U256, + pub gas_limit: u64, /// Scalar corresponding to the seconds since Epoch at this block's inception. - pub timestamp: U256, + pub timestamp: u64, /// Arbitrary byte array containing data relevant for this block. pub extra_data: Bytes, /// Hash previously used for the PoW now containing the RANDAO value. @@ -59,19 +60,20 @@ pub struct GuestInput { /// The code of all unique contracts. pub contracts: Vec, /// List of at most 256 previous block headers - pub ancestor_headers: Vec
, + pub ancestor_headers: Vec, /// Base fee per gas - pub base_fee_per_gas: U256, + pub base_fee_per_gas: u64, /// Taiko specific data pub taiko: TaikoGuestInput, } -#[derive(Clone, Debug, Default, Serialize, Deserialize)] +#[derive(Clone, Debug, Serialize, Deserialize)] pub struct TaikoGuestInput { pub chain_spec_name: String, - pub l1_header: Header, + pub l1_header: AlloyConsensusHeader, pub tx_list: Vec, pub anchor_tx: Option>, + pub anchor_tx_alloy: String, pub block_proposed: BlockProposed, pub prover_data: TaikoProverData, pub tx_blob_hash: Option, @@ -85,7 +87,7 @@ pub struct TaikoProverData { #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] pub enum GuestOutput { - Success((Header, FixedBytes<32>)), + Success((AlloyConsensusHeader, FixedBytes<32>)), Failure, } diff --git a/lib/src/protocol_instance.rs b/lib/src/protocol_instance.rs index e2cdeb28..c38b8194 100644 --- a/lib/src/protocol_instance.rs +++ b/lib/src/protocol_instance.rs @@ -1,10 +1,11 @@ use alloy_primitives::{Address, TxHash, B256}; use alloy_sol_types::SolValue; use anyhow::{ensure, Result}; -use zeth_primitives::{block::Header, keccak::keccak, transactions::ethereum::EthereumTxEssence}; +use zeth_primitives::{keccak::keccak, transactions::ethereum::EthereumTxEssence}; +use alloy_consensus::Header as AlloyConsensusHeader; use super::taiko_utils::ANCHOR_GAS_LIMIT; -use crate::input::{BlockMetadata, EthDeposit, GuestInput, Transition}; +use crate::{input::{BlockMetadata, EthDeposit, GuestInput, Transition}, taiko_utils::HeaderHasher}; #[derive(Debug)] pub struct ProtocolInstance { @@ -68,7 +69,7 @@ pub enum EvidenceType { // TODO(cecilia): rewrite pub fn assemble_protocol_instance( input: &GuestInput, - header: &Header, + header: &AlloyConsensusHeader, ) -> Result { let blob_used = input.taiko.block_proposed.meta.blobUsed; let tx_list_hash = if blob_used { @@ -96,9 +97,7 @@ pub fn assemble_protocol_instance( graffiti: input.taiko.prover_data.graffiti, }, block_metadata: BlockMetadata { - // TODO(Brecht): fix L1 block hash calculation in cancun - // l1Hash: input.taiko.l1_header.hash(), - l1Hash: input.taiko.block_proposed.meta.l1Hash, + l1Hash: input.taiko.l1_header.hash(), difficulty: input.taiko.block_proposed.meta.difficulty, blobHash: tx_list_hash, extraData: bytes_to_bytes32(&header.extra_data).into(), @@ -107,7 +106,7 @@ pub fn assemble_protocol_instance( id: header.number, gasLimit: (gas_limit - ANCHOR_GAS_LIMIT) as u32, timestamp: header.timestamp.try_into().unwrap(), - l1Height: input.taiko.l1_header.number, + l1Height: input.taiko.l1_header.number.try_into().unwrap(), txListByteOffset: 0u32, txListByteSize: input.taiko.tx_list.len() as u32, minTier: input.taiko.block_proposed.meta.minTier, diff --git a/lib/src/taiko_utils.rs b/lib/src/taiko_utils.rs index 642df14d..89fb6ee8 100644 --- a/lib/src/taiko_utils.rs +++ b/lib/src/taiko_utils.rs @@ -1,20 +1,25 @@ use core::str::FromStr; -use alloy_primitives::{uint, Address, U256}; +use alloy_primitives::{uint, Address, U256, Signature}; use anyhow::{anyhow, bail, ensure, Context, Result}; use ethers_core::types::Transaction as EthersTransaction; use once_cell::unsync::Lazy; -use rlp::{Decodable, DecoderError, Rlp}; -use zeth_primitives::transactions::{ +use rlp::{decode_list, Decodable, DecoderError, Rlp}; +use zeth_primitives::{keccak256, transactions::{ ethereum::{EthereumTxEssence, TransactionKind}, EthereumTransaction, Transaction, TxEssence, -}; +}, B256}; +use alloy_rlp::*; +use alloy_rpc_types::{AccessList, Header as AlloyHeader}; +use alloy_consensus::{Header as AlloyConsensusHeader, TxEip1559, TxEnvelope, TxKind}; +use alloy_rpc_types::{Block as AlloyBlock, BlockTransactions, Transaction as AlloyTransaction}; +use alloy_network::Signed; use crate::input::{decode_anchor, GuestInput}; pub const ANCHOR_GAS_LIMIT: u64 = 250_000; pub const MAX_TX_LIST_BYTES: usize = 120_000; -pub const BLOCK_GAS_LIMIT: Lazy = Lazy::new(|| uint!(15250000_U256)); +pub const BLOCK_GAS_LIMIT: u64 = 15250000; pub const GOLDEN_TOUCH_ACCOUNT: Lazy
= Lazy::new(|| { Address::from_str("0x0000777735367b36bC9B61C50022d9D0700dB4Ec") .expect("invalid golden touch account") @@ -118,6 +123,98 @@ pub fn generate_transactions_2( transactions } +/*fn decode(buf: &mut &[u8]) -> Result> { + let mut bytes = Header::decode_bytes(buf, true)?; + let mut vec = Vec::new(); + let payload_view = &mut bytes; + while !payload_view.is_empty() { + vec.push(TxEnvelope::decode(payload_view)?); + } + Ok(vec) +}*/ + +// TODO(Brecht): really need to switch to alloy for everything... +pub fn generate_transactions_alloy( + tx_list: &[u8], + anchor_tx: AlloyTransaction, +) -> Vec { + // Decode all the transactions in the tx list + //let transactions: Vec = Vec::::decode_list(tx_list); + + //println!("decoding... {:?} {}", tx_list, tx_list.len()); + + let eip1559_tx: TxEip1559 = TxEip1559 { + chain_id: anchor_tx.chain_id.unwrap().try_into().unwrap(), + nonce: anchor_tx.nonce.try_into().unwrap(), + gas_limit: anchor_tx.gas.try_into().unwrap(), + max_fee_per_gas: anchor_tx.max_fee_per_gas.unwrap().try_into().unwrap(), + max_priority_fee_per_gas: anchor_tx.max_priority_fee_per_gas.unwrap().try_into().unwrap(), + to: TxKind::Call(anchor_tx.to.unwrap()), + value: anchor_tx.value.try_into().unwrap(), + access_list: Default::default(), + input: anchor_tx.input, + }; + + let parity = anchor_tx.signature.unwrap().y_parity.unwrap(); + println!("parity: {:?}", parity); + + let signed_eip1559_tx = Signed::::new_unchecked( + eip1559_tx, + Signature::from_rs_and_parity(anchor_tx.signature.unwrap().r, anchor_tx.signature.unwrap().s, false).unwrap(), + anchor_tx.hash, + ); + + let b = &mut &tx_list.to_owned()[..]; + let mut transactions: Vec = alloy_rlp::Decodable::decode(b).unwrap_or_default(); + //let transactions: Vec = decode_tx_list(&tx_list).unwrap_or_default(); + + println!("alloy decoded transactions: {:?}", transactions); + + println!("num decoded: {:?}", transactions.len()); + + /*let hash = match &transactions[0] { + TxEnvelope::Legacy(tx) => { + tx.hash() + } + TxEnvelope::TaggedLegacy(tx) => { + tx.hash() + } + TxEnvelope::Eip2930(tx) => { + tx.hash() + } + TxEnvelope::Eip1559(tx) => { + tx.hash() + } + TxEnvelope::Eip4844(tx) => { + tx.hash() + } + }; + println!("**** hash: {:?}", hash); + + let from = match &transactions[0] { + TxEnvelope::Legacy(tx) => { + tx.recover_signer() + } + TxEnvelope::TaggedLegacy(tx) => { + tx.recover_signer() + } + TxEnvelope::Eip2930(tx) => { + tx.recover_signer() + } + TxEnvelope::Eip1559(tx) => { + tx.recover_signer() + } + TxEnvelope::Eip4844(tx) => { + tx.recover_signer() + } + }; + println!("***** from: {:?}", from);*/ + + // Insert the anchor transactions generated by the node (which needs to be verified!) + transactions.insert(0, TxEnvelope::from(signed_eip1559_tx)); + transactions +} + const GX1: Lazy = Lazy::new(|| uint!(0x79BE667EF9DCBBAC55A06295CE870B07029BFCDB2DCE28D959F2815B16F81798_U256)); const N: Lazy = @@ -194,22 +291,20 @@ pub fn check_anchor_tx( ); // Check needs to have the base fee set to the block base fee ensure!( - tx.max_fee_per_gas == input.base_fee_per_gas, + tx.max_fee_per_gas == input.base_fee_per_gas.try_into().unwrap(), "anchor transaction gas mismatch" ); // Okay now let's decode the anchor tx to verify the inputs let anchor_call = decode_anchor(anchor.essence.data())?; - // TODO(Brecht): fix L1 block hash calculation in cancun - // TODO(Brecht): needs dynamic hash calculation based on L1 block number println!("anchor: {:?}", anchor_call.l1Hash); println!("expected: {:?}", input.taiko.l1_header.hash()); // The L1 blockhash needs to match the expected value - // ensure!( - // anchor_call.l1Hash == input.taiko.l1_header.hash(), - // "L1 hash mismatch" - //); + ensure!( + anchor_call.l1Hash == input.taiko.l1_header.hash(), + "L1 hash mismatch" + ); if chain_name != "testnet" { ensure!( anchor_call.l1SignalRoot == input.taiko.l1_header.state_root, @@ -222,7 +317,7 @@ pub fn check_anchor_tx( ); // The parent gas used input needs to match the gas used value of the parent block ensure!( - U256::from(anchor_call.parentGasUsed) == input.parent_header.gas_used, + anchor_call.parentGasUsed == input.parent_header.gas_used as u32, "parentGasUsed mismatch" ); } @@ -233,3 +328,44 @@ pub fn check_anchor_tx( Ok(()) } + +pub fn hash_header(header: &AlloyConsensusHeader) -> B256 { + let mut out = Vec::::new(); + header.encode(&mut out); + keccak256(&out) +} + +pub trait HeaderHasher { + fn hash(&self)-> B256; +} + +impl HeaderHasher for AlloyConsensusHeader { + fn hash(&self)-> B256 { + hash_header(self) + } +} + +pub fn to_header(header: &AlloyHeader) -> AlloyConsensusHeader { + AlloyConsensusHeader { + parent_hash: header.parent_hash, + ommers_hash: header.uncles_hash, + beneficiary: header.miner, + state_root: header.state_root, + transactions_root: header.transactions_root, + receipts_root: header.receipts_root, + logs_bloom: header.logs_bloom, + difficulty: header.difficulty, + number: header.number.unwrap().try_into().unwrap(), + gas_limit: header.gas_limit.try_into().unwrap(), + gas_used: header.gas_used.try_into().unwrap(), + timestamp: header.timestamp.try_into().unwrap(), + extra_data: header.extra_data.clone(), + mix_hash: header.mix_hash.unwrap(), + nonce: u64::from_be_bytes(header.nonce.unwrap().0), + base_fee_per_gas: Some(header.base_fee_per_gas.unwrap().try_into().unwrap()), + withdrawals_root: header.withdrawals_root, + blob_gas_used: header.blob_gas_used.map(|x| x.try_into().unwrap()), + excess_blob_gas: header.excess_blob_gas.map(|x| x.try_into().unwrap()), + parent_beacon_block_root: header.parent_beacon_block_root, + } +} diff --git a/primitives/Cargo.toml b/primitives/Cargo.toml index 047845fd..50d67e51 100644 --- a/primitives/Cargo.toml +++ b/primitives/Cargo.toml @@ -12,7 +12,7 @@ alloy-sol-types = { version = "0.6", default-features = false, optional = true } alloy-dyn-abi = { version = "0.6",default-features = false, optional = true } alloy-rlp = { version = "0.3", default-features = false } alloy-rlp-derive = { version = "0.3", default-features = false } -alloy-rpc-types = { git = "https://github.com/brechtpd/alloy", branch = "r170", version = "0.1.0" } +alloy-rpc-types = { git = "https://github.com/brechtpd/alloy", branch = "header-serialize", version = "0.1.0" } anyhow = { version = "1.0", default-features = false } bytes = { version = "1.5", default-features = false } ethers-core = { git = "https://github.com/smtmfft/ethers-rs", branch = "ethers-core-2.0.10" } diff --git a/primitives/src/block.rs b/primitives/src/block.rs deleted file mode 100644 index 38c72501..00000000 --- a/primitives/src/block.rs +++ /dev/null @@ -1,176 +0,0 @@ -// Copyright 2023 RISC Zero, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -use core::option::Option::*; - -use alloy_primitives::{b256, Address, BlockHash, BlockNumber, Bloom, Bytes, B256, B64, U256}; -use alloy_rlp_derive::RlpEncodable; -use serde::{Deserialize, Serialize}; - -use crate::{keccak::keccak, mpt::EMPTY_ROOT, transactions::EthereumTransaction}; - -/// Keccak-256 hash of the RLP of an empty list. -pub const EMPTY_LIST_HASH: B256 = - b256!("1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347"); - -#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, RlpEncodable)] -#[rlp(trailing)] -pub struct Header { - /// Hash of the parent block's header. - pub parent_hash: BlockHash, - /// Unused 256-bit hash, always [EMPTY_LIST_HASH]. - pub ommers_hash: B256, - /// Address that receives the priority fees of each transaction in the block. - pub beneficiary: Address, - /// Root hash of the state trie after all transactions in the block are executed. - pub state_root: B256, - /// Root hash of the trie containing all transactions in the block. - pub transactions_root: B256, - /// Root hash of the trie containing the receipts of each transaction in the block. - pub receipts_root: B256, - /// Bloom filter for log entries in the block. - pub logs_bloom: Bloom, - /// Always set to `0` as it's unused. - pub difficulty: U256, - /// The block number in the chain. - pub number: BlockNumber, - /// Maximum amount of gas that can be used in this block. - pub gas_limit: U256, - /// Total amount of gas used by all transactions in this block. - pub gas_used: U256, - /// Value corresponding to the seconds since Epoch at this block's inception. - pub timestamp: U256, - /// Arbitrary byte array containing extra data related to the block. - pub extra_data: Bytes, - /// Hash previously used for the PoW now containing the RANDAO value. - pub mix_hash: B256, - /// Unused 64-bit hash, always zero. - pub nonce: B64, - /// Base fee paid by all transactions in the block. - pub base_fee_per_gas: U256, - /// Root hash of the trie containing all withdrawals in the block. Present after the - /// Shanghai update. - #[serde(default)] - pub withdrawals_root: Option, - #[rlp(skip)] - #[serde(skip)] - pub transactions: Vec, -} - -impl Default for Header { - /// Provides default values for a block header. - fn default() -> Self { - Header { - parent_hash: B256::ZERO, - ommers_hash: EMPTY_LIST_HASH, - beneficiary: Address::ZERO, - state_root: EMPTY_ROOT, - transactions_root: EMPTY_ROOT, - receipts_root: EMPTY_ROOT, - logs_bloom: Bloom::default(), - difficulty: U256::ZERO, - number: 0, - gas_limit: U256::ZERO, - gas_used: U256::ZERO, - timestamp: U256::ZERO, - extra_data: Bytes::new(), - mix_hash: B256::ZERO, - nonce: B64::ZERO, - base_fee_per_gas: U256::ZERO, - withdrawals_root: None, - transactions: Default::default(), - } - } -} - -impl Header { - /// Computes the hash of the block header. - pub fn hash(&self) -> BlockHash { - keccak(alloy_rlp::encode(self)).into() - } -} - -#[cfg(test)] -mod tests { - use alloc::string::ToString; - - use serde_json::json; - - use super::*; - - #[test] - fn paris() { - // first block after the Paris network upgrade - let value = json!({ - "parent_hash":"0x55b11b918355b1ef9c5db810302ebad0bf2544255b530cdce90674d5887bb286", - "ommers_hash": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", - "beneficiary": "0xeee27662c2b8eba3cd936a23f039f3189633e4c8", - "state_root": "0x40c07091e16263270f3579385090fea02dd5f061ba6750228fcc082ff762fda7", - "transactions_root": "0x1ea1746468686159ce730c1cc49a886721244e5d1fa9a06d6d4196b6f013c82c", - "receipts_root": "0x928073fb98ce316265ea35d95ab7e2e1206cecd85242eb841dbbcc4f568fca4b", - "logs_bloom": "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", - "difficulty": "0x0", - "number": 15537394, - "gas_limit": "0x1c9c380", - "gas_used": "0x1c9811e", - "timestamp": "0x6322c973", - "extra_data": "0x", - "mix_hash": "0xa86c2e601b6c44eb4848f7d23d9df3113fbcac42041c49cbed5000cb4f118777", - "nonce": "0x0000000000000000", - "base_fee_per_gas": "0xb5d68e0a3" - }); - let header: Header = serde_json::from_value(value).unwrap(); - - // verify that bincode serialization works - let _: Header = bincode::deserialize(&bincode::serialize(&header).unwrap()).unwrap(); - - assert_eq!( - "0x56a9bb0302da44b8c0b3df540781424684c3af04d0b7a38d72842b762076a664", - header.hash().to_string() - ) - } - - #[test] - fn shanghai() { - // first block after the Shanghai network upgrade - let value = json!({ - "parent_hash": "0xc2558f8143d5f5acb8382b8cb2b8e2f1a10c8bdfeededad850eaca048ed85d8f", - "ommers_hash": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", - "beneficiary": "0x388c818ca8b9251b393131c08a736a67ccb19297", - "state_root": "0x7fd42f5027bc18315b3781e65f19e4c8828fd5c5fce33410f0fb4fea0b65541f", - "transactions_root": "0x6f235d618461c08943aa5c23cc751310d6177ab8a9b9a7b66ffa637d988680e6", - "receipts_root": "0xe0ac34bafdd757bcca2dea27a3fc5870dd0836998877e29361c1fc55e19416ec", - "logs_bloom": "0xb06769bc11f4d7a51a3bc4bed59367b75c32d1bd79e5970e73732ac0eed0251af0e2abc8811fc1b4c5d45a4a4eb5c5af9e73cc9a8be6ace72faadc03536d6b69fcdf80116fd89f7efbdbf38ff957e8f6ae83ccac60cf4b7c8b1c9487bebfa8ed6e42297e17172d5b678dd3f283b22f49bbf4a0565eb93d9d797b2f9a0adaff9813af53d6fffa71d5a6fb056ab73ca87659dc97c19f99839c6c3138e527161b4dfee8b1f64d42f927abc745f3ff168e8e9510e2e079f4868ba8ff94faf37c9a7947a43c1b4c931dfbef88edeb2d7ede5ceaebc85095cfbbd206646def0138683b687fa63fdf22898260d616bc714d698bc5748c7a5bff0a4a32dd797596a794a0", - "difficulty": "0x0", - "number": 17034870, - "gas_limit": "0x1c9c380", - "gas_used": "0x1c9bfe2", - "timestamp": "0x6437306f", - "extra_data": "0xd883010b05846765746888676f312e32302e32856c696e7578", - "mix_hash": "0x812ed704cc408c435c7baa6e86296c1ac654a139ae8c4a26d6460742b951d4f9", - "nonce": "0x0000000000000000", - "base_fee_per_gas": "0x42fbae6d5", - "withdrawals_root": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421" - }); - let header: Header = serde_json::from_value(value).unwrap(); - - // verify that bincode serialization works - let _: Header = bincode::deserialize(&bincode::serialize(&header).unwrap()).unwrap(); - - assert_eq!( - "0xe22c56f211f03baadcc91e4eb9a24344e6848c5df4473988f893b58223f5216c", - header.hash().to_string() - ) - } -} diff --git a/primitives/src/ethers.rs b/primitives/src/ethers.rs index 7b0fa594..4c972ba3 100644 --- a/primitives/src/ethers.rs +++ b/primitives/src/ethers.rs @@ -44,7 +44,6 @@ use ethers_core::types::{ use crate::{ access_list::{AccessList, AccessListItem}, - block::Header, receipt::{Log, Receipt, ReceiptPayload}, transactions::{ ethereum::{ @@ -118,39 +117,6 @@ impl From> for TransactionKind { } } -/// Conversion from `EthersBlock` to the local [Header]. -/// This conversion may fail if certain expected fields are missing. -impl TryFrom> for Header { - type Error = anyhow::Error; - - fn try_from(block: EthersBlock) -> Result { - Ok(Header { - parent_hash: from_ethers_h256(block.parent_hash), - ommers_hash: from_ethers_h256(block.uncles_hash), - beneficiary: from_ethers_h160(block.author.context("author missing")?), - state_root: from_ethers_h256(block.state_root), - transactions_root: from_ethers_h256(block.transactions_root), - receipts_root: from_ethers_h256(block.receipts_root), - logs_bloom: Bloom::from_slice( - block.logs_bloom.context("logs_bloom missing")?.as_bytes(), - ), - difficulty: from_ethers_u256(block.difficulty), - number: block.number.context("number missing")?.as_u64(), - gas_limit: from_ethers_u256(block.gas_limit), - gas_used: from_ethers_u256(block.gas_used), - timestamp: from_ethers_u256(block.timestamp), - extra_data: block.extra_data.0.into(), - mix_hash: block.mix_hash.context("mix_hash missing")?.0.into(), - nonce: block.nonce.context("nonce missing")?.0.into(), - base_fee_per_gas: from_ethers_u256( - block.base_fee_per_gas.context("base_fee_per_gas missing")?, - ), - withdrawals_root: block.withdrawals_root.map(from_ethers_h256), - transactions: Default::default(), - }) - } -} - /// Conversion from `EthersTransaction` to the local [Transaction]. /// This conversion may fail if certain expected fields are missing. impl> TryFrom for Transaction { diff --git a/primitives/src/lib.rs b/primitives/src/lib.rs index 08047441..094236fd 100644 --- a/primitives/src/lib.rs +++ b/primitives/src/lib.rs @@ -19,7 +19,6 @@ extern crate core; pub use alloc::{vec, vec::Vec}; pub mod access_list; -pub mod block; pub mod ethers; pub mod keccak; pub mod mpt; diff --git a/raiko-guests/risc0/build.rs b/raiko-guests/risc0/build.rs index a4aa2563..9b912833 100644 --- a/raiko-guests/risc0/build.rs +++ b/raiko-guests/risc0/build.rs @@ -13,5 +13,6 @@ // limitations under the License. fn main() { + #[cfg(feature = "risc0")] risc0_build::embed_methods(); } diff --git a/raiko-guests/succinct/Cargo.lock b/raiko-guests/succinct/Cargo.lock index 7c1a48f4..364daa28 100644 --- a/raiko-guests/succinct/Cargo.lock +++ b/raiko-guests/succinct/Cargo.lock @@ -35,6 +35,52 @@ version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5" +[[package]] +name = "alloy-consensus" +version = "0.1.0" +source = "git+https://github.com/brechtpd/alloy?branch=header-serialize#e77a49aad28ca01624bbb9cc3ee0f1daaceb1869" +dependencies = [ + "alloy-eips", + "alloy-network", + "alloy-primitives", + "alloy-rlp", + "serde", +] + +[[package]] +name = "alloy-eips" +version = "0.1.0" +source = "git+https://github.com/brechtpd/alloy?branch=header-serialize#e77a49aad28ca01624bbb9cc3ee0f1daaceb1869" +dependencies = [ + "alloy-primitives", + "alloy-rlp", + "serde", + "thiserror", +] + +[[package]] +name = "alloy-json-rpc" +version = "0.1.0" +source = "git+https://github.com/brechtpd/alloy?branch=header-serialize#e77a49aad28ca01624bbb9cc3ee0f1daaceb1869" +dependencies = [ + "alloy-primitives", + "serde", + "serde_json", + "thiserror", +] + +[[package]] +name = "alloy-network" +version = "0.1.0" +source = "git+https://github.com/brechtpd/alloy?branch=header-serialize#e77a49aad28ca01624bbb9cc3ee0f1daaceb1869" +dependencies = [ + "alloy-eips", + "alloy-json-rpc", + "alloy-primitives", + "alloy-rlp", + "serde", +] + [[package]] name = "alloy-primitives" version = "0.6.3" @@ -82,7 +128,7 @@ dependencies = [ [[package]] name = "alloy-rpc-types" version = "0.1.0" -source = "git+https://github.com/brechtpd/alloy?branch=r170#8ed5684f69f3d6ed8dfe99549f93a6ecac1dee14" +source = "git+https://github.com/brechtpd/alloy?branch=header-serialize#e77a49aad28ca01624bbb9cc3ee0f1daaceb1869" dependencies = [ "alloy-primitives", "alloy-rlp", @@ -2487,9 +2533,11 @@ dependencies = [ name = "zeth-lib" version = "0.1.0" dependencies = [ + "alloy-consensus", "alloy-primitives", "alloy-rlp", "alloy-rlp-derive", + "alloy-rpc-types", "alloy-sol-types", "anyhow", "bytes", diff --git a/raiko-host/Cargo.toml b/raiko-host/Cargo.toml index 41c7c139..c78a70d8 100644 --- a/raiko-host/Cargo.toml +++ b/raiko-host/Cargo.toml @@ -7,9 +7,10 @@ edition = "2021" anyhow = "1.0" alloy-sol-types = { version = "0.6" } alloy-primitives = { version = "0.6", default-features = false } -alloy-rpc-types = { git = "https://github.com/brechtpd/alloy", branch = "r170", version = "0.1.0" } -alloy-providers = { git = "https://github.com/brechtpd/alloy", branch = "r170", version = "0.1.0" } -alloy-transport-http = { git = "https://github.com/brechtpd/alloy", branch = "r170", version = "0.1.0" } +alloy-rpc-types = { git = "https://github.com/brechtpd/alloy", branch = "header-serialize", version = "0.1.0" } +alloy-providers = { git = "https://github.com/brechtpd/alloy", branch = "header-serialize", version = "0.1.0" } +alloy-transport-http = { git = "https://github.com/brechtpd/alloy", branch = "header-serialize", version = "0.1.0" } +alloy-consensus = { git = "https://github.com/brechtpd/alloy", branch = "header-serialize", version = "0.1.0" } bincode = "1.3.3" bytemuck = "1.13" clap = { version = "4.0", features = ["derive"] } diff --git a/raiko-host/build.rs b/raiko-host/build.rs index fb8abb9b..2e11e202 100644 --- a/raiko-host/build.rs +++ b/raiko-host/build.rs @@ -1,3 +1,4 @@ +#[cfg(feature = "succinct")] use sp1_helper::build_program; fn main() { diff --git a/raiko-host/src/host/host.rs b/raiko-host/src/host/host.rs index f84e300d..3fc1a01c 100644 --- a/raiko-host/src/host/host.rs +++ b/raiko-host/src/host/host.rs @@ -1,6 +1,11 @@ use std::path::PathBuf; use alloy_sol_types::SolCall; +use alloy_rpc_types::{Block as AlloyBlock, BlockTransactions}; +use alloy_providers::tmp::{HttpProvider, TempProvider}; +use alloy_transport_http::Http; +use url::Url; + use anyhow::{anyhow, ensure, Context, Result}; use ethers_core::types::Transaction as EthersTransaction; use hashbrown::HashSet; @@ -14,10 +19,9 @@ use zeth_lib::{ decode_propose_block_call_params, proposeBlockCall, BlockMetadata, GuestInput, TaikoGuestInput, TaikoProverData, }, - taiko_utils::{generate_transactions, MAX_TX_LIST_BYTES}, + taiko_utils::{generate_transactions, generate_transactions_alloy, MAX_TX_LIST_BYTES, to_header}, }; use zeth_primitives::{ - block::Header, ethers::{from_ethers_h160, from_ethers_h256, from_ethers_u256}, mpt::proofs_to_tries, transactions::ethereum::EthereumTxEssence, @@ -35,6 +39,26 @@ pub struct HostArgs { pub l2_rpc: Option, } +pub fn get_block_alloy(rpc_url: String, block_number: u64, full: bool) -> Result { + let http = Http::new(Url::parse(&rpc_url).expect("invalid rpc url")); + let provider: HttpProvider = HttpProvider::new(http); + + //info!("Querying RPC for full block: {query:?}"); + + let tokio_handle = tokio::runtime::Handle::current(); + + let response = tokio_handle.block_on(async { + provider + .get_block_by_number((block_number).into(), full) + .await + })?; + + match response { + Some(out) => Ok(out), + None => Err(anyhow!("No data for {block_number:?}")), + } +} + pub fn taiko_run_preflight( l1_rpc_url: Option, l2_rpc_url: Option, @@ -52,7 +76,7 @@ pub fn taiko_run_preflight( )?; // Fetch the parent block - let parent_block = tp.l2_provider.get_partial_block(&BlockQuery { + /*let parent_block = tp.l2_provider.get_partial_block(&BlockQuery { block_no: l2_block_no - 1, })?; @@ -63,34 +87,44 @@ pub fn taiko_run_preflight( parent_block.number.unwrap(), parent_block.hash.unwrap() ); - let parent_header: Header = parent_block.try_into().context("invalid parent block")?; + let parent_header: Header = parent_block.try_into().context("invalid parent block")?;*/ + + let parent_block = get_block_alloy(l2_rpc_url.clone().unwrap(), l2_block_no - 1, false).unwrap(); + println!("*** alloy parent block ***:{:?}", parent_block); + + let block_alloy = get_block_alloy(l2_rpc_url.clone().unwrap(), l2_block_no, true).unwrap(); + println!("*** alloy block ***:{:?}", block_alloy); // Fetch the target block - let mut block = tp.l2_provider.get_full_block(&BlockQuery { + let mut block_ethers = tp.l2_provider.get_full_block(&BlockQuery { block_no: l2_block_no, })?; - let (anchor_tx, anchor_call) = tp.get_anchor(&block)?; - println!("block.hash: {:?}", block.hash.unwrap()); - println!("block.parent_hash: {:?}", block.parent_hash); - println!("block: {:?}", block); + let (anchor_tx_ethers, anchor_call_ethers) = tp.get_anchor(&block_ethers)?; + let (anchor_tx_alloy, anchor_call_alloy) = tp.get_anchor_alloy(&block_alloy)?; + println!("block.hash: {:?}", block_alloy.header.hash.unwrap()); + println!("block.parent_hash: {:?}", block_alloy.header.parent_hash); + println!("block: {:?}", block_ethers); - println!("anchor L1 block id: {:?}", anchor_call.l1Height); - println!("anchor L1 state root: {:?}", anchor_call.l1SignalRoot); + println!("anchor L1 block id: {:?}", anchor_call_ethers.l1Height); + println!("anchor L1 state root: {:?}", anchor_call_ethers.l1SignalRoot); - let l1_state_block_no = anchor_call.l1Height; + let l1_state_block_no = anchor_call_ethers.l1Height; let l1_inclusion_block_no = l1_state_block_no + 1; println!("l1_state_block_no: {:?}", l1_state_block_no); + let l1_state_root_block_alloy = get_block_alloy(l1_rpc_url.clone().unwrap(), l1_state_block_no, false).unwrap(); + println!("*** alloy block ***:{:?}", l1_state_root_block_alloy); + // Get the L1 state block header so that we can prove the L1 state root // Fetch the parent block - let l1_state_root_block = tp.l1_provider.get_partial_block(&BlockQuery { + /*let l1_state_root_block = tp.l1_provider.get_partial_block(&BlockQuery { block_no: l1_state_block_no, - })?; + })?;*/ // println!("l1_state_root_block: {:?}", l1_state_root_block); println!( "l1_state_root_block hash: {:?}", - l1_state_root_block.hash.unwrap() + l1_state_root_block_alloy.header.hash.unwrap() ); // let l1_propose_block = tp.l1_provider.get_partial_block(&BlockQuery { @@ -150,48 +184,50 @@ pub fn taiko_run_preflight( // println!("tx_list: {:?}", tx_list); // Create the transactions for the proposed tx list - let transactions: Vec = generate_transactions(&tx_list, anchor_tx.clone()); + let transactions_ethers: Vec = generate_transactions(&tx_list, anchor_tx_ethers.clone()); + - println!("Block valid transactions: {:?}", block.transactions.len()); + let transactions_alloy = generate_transactions_alloy(&tx_list, anchor_tx_alloy.clone()); + + println!("Block valid transactions: {:?}", block_alloy.transactions.len()); assert!( - transactions.len() >= block.transactions.len(), + transactions_ethers.len() >= block_alloy.transactions.len(), "unexpected number of transactions" ); // Set the original transactions on the block - block.transactions = transactions.clone(); + //block_alloy.transactions = BlockTransactions::default(); info!( "Final block number: {:?} ({:?})", - block.number.unwrap(), - block.hash.unwrap() + block_alloy.header.number.unwrap(), + block_alloy.header.hash.unwrap() ); - println!("Transaction count: {:?}", block.transactions.len()); + println!("Transaction count: {:?}", block_alloy.transactions.len()); let taiko_guest_input = TaikoGuestInput { chain_spec_name: chain_spec_name.to_string(), - l1_header: l1_state_root_block - .try_into() - .expect("Failed to convert ethers block to zeth block"), + l1_header: to_header(&l1_state_root_block_alloy.header), tx_list, - anchor_tx: Some(anchor_tx.try_into().unwrap()), + anchor_tx: Some(anchor_tx_ethers.try_into().unwrap()), + anchor_tx_alloy: serde_json::to_string(&anchor_tx_alloy).unwrap(), tx_blob_hash, block_proposed: proposal_event, prover_data, }; // convert each transaction - let transactions = transactions + /*let transactions = transactions_ethers .into_iter() .enumerate() .map(|(i, tx)| { tx.try_into() .map_err(|err| anyhow!("transaction {i} invalid: {err:?}")) }) - .collect::, _>>()?; + .collect::, _>>()?;*/ // convert each withdrawal - let withdrawals = block + let withdrawals = block_ethers .withdrawals .unwrap_or_default() .into_iter() @@ -204,27 +240,25 @@ pub fn taiko_run_preflight( // Create the input struct without the block data set let input = GuestInput { - block_hash: block.hash.unwrap(), - beneficiary: from_ethers_h160(block.author.context("author missing")?), - gas_limit: from_ethers_u256(block.gas_limit), - timestamp: from_ethers_u256(block.timestamp), - extra_data: block.extra_data.0.into(), - mix_hash: from_ethers_h256(block.mix_hash.context("mix_hash missing")?), - transactions, + block_hash: block_alloy.header.hash.unwrap().0.try_into().unwrap(), + beneficiary: block_alloy.header.miner, + gas_limit: block_alloy.header.gas_limit.try_into().unwrap(), + timestamp: block_alloy.header.timestamp.try_into().unwrap(), + extra_data: block_alloy.header.extra_data.0.into(), + mix_hash: block_alloy.header.mix_hash.unwrap(), + transactions: Vec::new(), withdrawals, parent_state_trie: Default::default(), parent_storage: Default::default(), contracts: Default::default(), - parent_header: parent_header.clone(), + parent_header: to_header(&parent_block.header), ancestor_headers: Default::default(), - base_fee_per_gas: from_ethers_u256( - block.base_fee_per_gas.context("base_fee_per_gas missing")?, - ), + base_fee_per_gas: block_alloy.header.base_fee_per_gas.unwrap().try_into().unwrap(), taiko: taiko_guest_input, }; // Create the provider DB - let provider_db = ProviderDb::new(tp.l2_provider, parent_header.number); + let provider_db = ProviderDb::new(tp.l2_provider, parent_block.header.number.unwrap().try_into().unwrap()); println!("execute block"); @@ -245,7 +279,7 @@ pub fn taiko_run_preflight( proofs_to_tries(input.parent_header.state_root, parent_proofs, proofs)?; // Gather proofs for block history - let ancestor_headers = provider_db.get_ancestor_headers()?; + let ancestor_headers = provider_db.get_ancestor_headers(l2_rpc_url.unwrap())?; // Get the contracts from the initial db. let mut contracts = HashSet::new(); diff --git a/raiko-host/src/host/provider_db.rs b/raiko-host/src/host/provider_db.rs index 91f387d7..4f46da12 100644 --- a/raiko-host/src/host/provider_db.rs +++ b/raiko-host/src/host/provider_db.rs @@ -20,12 +20,14 @@ use revm::{ primitives::{Account, AccountInfo, Bytecode}, Database, DatabaseCommit, }; -use zeth_lib::mem_db::{DbError, MemDb}; +use zeth_lib::{taiko_utils::to_header, mem_db::{DbError, MemDb}}; use zeth_primitives::{ - block::Header, ethers::{from_ethers_bytes, from_ethers_u256}, Address, B256, U256, }; +use alloy_rpc_types::Header as AlloyHeader; +use alloy_consensus::Header as AlloyConsensusHeader; +use crate::host::host::get_block_alloy; use super::provider::{AccountQuery, BlockQuery, ProofQuery, Provider, StorageQuery}; @@ -107,7 +109,7 @@ impl ProviderDb { self.get_proofs(self.block_no + 1, storage_keys) } - pub fn get_ancestor_headers(&mut self) -> Result, anyhow::Error> { + pub fn get_ancestor_headers(&mut self, rpc_url: String) -> Result, anyhow::Error> { let earliest_block = self .initial_db .block_hashes @@ -117,11 +119,7 @@ impl ProviderDb { let headers = (*earliest_block..self.block_no) .rev() .map(|block_no| { - self.provider - .get_partial_block(&BlockQuery { block_no }) - .expect("Failed to retrieve ancestor block") - .try_into() - .expect("Failed to convert ethers block to zeth block") + to_header(&get_block_alloy(rpc_url.clone(), block_no, false).unwrap().header) }) .collect(); Ok(headers) diff --git a/raiko-host/src/host/taiko_provider.rs b/raiko-host/src/host/taiko_provider.rs index 7baf2e66..21d64a99 100644 --- a/raiko-host/src/host/taiko_provider.rs +++ b/raiko-host/src/host/taiko_provider.rs @@ -1,5 +1,6 @@ use std::path::PathBuf; +use alloy_rpc_types::{Block as AlloyBlock, BlockTransactions, Transaction as AlloyTransaction}; use anyhow::{anyhow, bail, Context, Result}; use ethers_core::types::{Block, Transaction}; use zeth_lib::{ @@ -55,6 +56,15 @@ impl TaikoProvider { Ok((tx, call)) } + pub fn get_anchor_alloy(&self, block: &AlloyBlock) -> Result<(AlloyTransaction, anchorCall)> { + let anchor_tx = match &block.transactions { + BlockTransactions::Full(txs) => txs[0].to_owned(), + _ => unreachable!(), + }; + let call = decode_anchor(anchor_tx.input.as_ref())?; + Ok((anchor_tx, call)) + } + pub fn get_proposal( &mut self, l1_block_no: u64, diff --git a/raiko-host/src/prover/execution.rs b/raiko-host/src/prover/execution.rs index c24bd5db..fcaa918d 100644 --- a/raiko-host/src/prover/execution.rs +++ b/raiko-host/src/prover/execution.rs @@ -6,6 +6,7 @@ use zeth_lib::{ input::{GuestInput, GuestOutput, TaikoProverData}, protocol_instance::{assemble_protocol_instance, EvidenceType}, EthereumTxEssence, + taiko_utils::HeaderHasher, }; use zeth_primitives::Address; @@ -98,7 +99,28 @@ pub async fn execute( let resp = execute_risc0(input, output, ctx, instance).await?; ProofResponse::Risc0(resp) } - ProofType::Native => ProofResponse::Native(output), + ProofType::Native => { + // Make sure the binary serialization of the input works + let encoded: Vec = bincode::serialize(&input).unwrap(); + let input = bincode::deserialize(&encoded[..]).unwrap(); + // Build the block + let build_result = TaikoStrategy::build_from(&input); + match &build_result { + Ok((header, mpt_node)) => { + // Make sure the blockhash from the node matches the one from the builder + assert_eq!( + header.hash().0, + input.block_hash.to_fixed_bytes(), + "block hash unexpected" + ); + ProofResponse::Native(output) + } + Err(_) => { + warn!("Proving bad block construction!"); + ProofResponse::Native(GuestOutput::Failure) + } + } + } }; let time_elapsed = Instant::now().duration_since(start); println!( diff --git a/risc0-driver/Cargo.lock b/risc0-driver/Cargo.lock index 4391b9ac..ef17659d 100644 --- a/risc0-driver/Cargo.lock +++ b/risc0-driver/Cargo.lock @@ -71,6 +71,52 @@ version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5" +[[package]] +name = "alloy-consensus" +version = "0.1.0" +source = "git+https://github.com/brechtpd/alloy?branch=header-serialize#e77a49aad28ca01624bbb9cc3ee0f1daaceb1869" +dependencies = [ + "alloy-eips", + "alloy-network", + "alloy-primitives", + "alloy-rlp", + "serde", +] + +[[package]] +name = "alloy-eips" +version = "0.1.0" +source = "git+https://github.com/brechtpd/alloy?branch=header-serialize#e77a49aad28ca01624bbb9cc3ee0f1daaceb1869" +dependencies = [ + "alloy-primitives", + "alloy-rlp", + "serde", + "thiserror", +] + +[[package]] +name = "alloy-json-rpc" +version = "0.1.0" +source = "git+https://github.com/brechtpd/alloy?branch=header-serialize#e77a49aad28ca01624bbb9cc3ee0f1daaceb1869" +dependencies = [ + "alloy-primitives", + "serde", + "serde_json", + "thiserror", +] + +[[package]] +name = "alloy-network" +version = "0.1.0" +source = "git+https://github.com/brechtpd/alloy?branch=header-serialize#e77a49aad28ca01624bbb9cc3ee0f1daaceb1869" +dependencies = [ + "alloy-eips", + "alloy-json-rpc", + "alloy-primitives", + "alloy-rlp", + "serde", +] + [[package]] name = "alloy-primitives" version = "0.6.3" @@ -118,7 +164,7 @@ dependencies = [ [[package]] name = "alloy-rpc-types" version = "0.1.0" -source = "git+https://github.com/brechtpd/alloy?branch=r170#8ed5684f69f3d6ed8dfe99549f93a6ecac1dee14" +source = "git+https://github.com/brechtpd/alloy?branch=header-serialize#e77a49aad28ca01624bbb9cc3ee0f1daaceb1869" dependencies = [ "alloy-primitives", "alloy-rlp", @@ -769,20 +815,6 @@ dependencies = [ "serde", ] -[[package]] -name = "cargo_metadata" -version = "0.17.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7daec1a2a2129eeba1644b220b4647ec537b0b5d4bfd6876fcc5a540056b592" -dependencies = [ - "camino", - "cargo-platform", - "semver 1.0.22", - "serde", - "serde_json", - "thiserror", -] - [[package]] name = "cargo_metadata" version = "0.18.1" @@ -1142,12 +1174,6 @@ version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fea41bba32d969b513997752735605054bc0dfa92b4c56bf1189f2e174be7a10" -[[package]] -name = "docker-generate" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ccf673e0848ef09fa4aeeba78e681cf651c0c7d35f76ee38cec8e55bc32fa111" - [[package]] name = "downcast-rs" version = "1.2.0" @@ -1445,7 +1471,7 @@ checksum = "aab3cef6cc1c9fd7f787043c81ad3052eff2b96a3878ef1526aa446311bdbfc9" dependencies = [ "arrayvec", "bytes", - "cargo_metadata 0.18.1", + "cargo_metadata", "chrono", "const-hex", "elliptic-curve", @@ -3252,24 +3278,6 @@ dependencies = [ "tracing", ] -[[package]] -name = "risc0-build" -version = "0.20.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a636849a58335ebece68161006a53d5590a6698092c3ca8e8a40a7c0aa8a20fb" -dependencies = [ - "anyhow", - "cargo-platform", - "cargo_metadata 0.17.0", - "docker-generate", - "risc0-binfmt", - "risc0-zkp", - "risc0-zkvm-platform", - "serde", - "serde_json", - "tempfile", -] - [[package]] name = "risc0-build-kernel" version = "0.20.1" @@ -3372,7 +3380,6 @@ dependencies = [ "hex", "log", "predicates", - "risc0-guest", "risc0-zkvm", "rstest", "serde", @@ -3384,13 +3391,6 @@ dependencies = [ "zeth-primitives", ] -[[package]] -name = "risc0-guest" -version = "0.1.0" -dependencies = [ - "risc0-build", -] - [[package]] name = "risc0-sys" version = "0.20.1" @@ -5033,9 +5033,11 @@ dependencies = [ name = "zeth-lib" version = "0.1.0" dependencies = [ + "alloy-consensus", "alloy-primitives", "alloy-rlp", "alloy-rlp-derive", + "alloy-rpc-types", "alloy-sol-types", "anyhow", "bytes", diff --git a/risc0-driver/Cargo.toml b/risc0-driver/Cargo.toml index 62df9338..7cb51627 100644 --- a/risc0-driver/Cargo.toml +++ b/risc0-driver/Cargo.toml @@ -21,13 +21,13 @@ ethers-core = { git = "https://github.com/smtmfft/ethers-rs", branch = "ethers-c ethers-providers = { version = "2.0" } hex = "0.4.3" log = "0.4" -risc0-zkvm = { version = "0.20.1", features = ["prove"] } +risc0-zkvm = { version = "0.20.1", features = ["prove"], optional = true } serde = "1.0" tempfile = "3.6" tokio = { version = "^1.23", features = ["full"] } tracing = { version = "0.1", features = ["log"] } typetag = "0.2.15" -risc0-guest = { path = "../raiko-guests/risc0" } +#risc0-guest = { path = "../raiko-guests/risc0", optional = true } zeth-lib = { path = "../lib", features = ["taiko", "std"]} zeth-primitives = { path = "../primitives", features = ["taiko", "std"]} diff --git a/rust-toolchain b/rust-toolchain index 723cc0e5..14f42591 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1,5 +1,5 @@ [toolchain] -channel = "nightly-2024-01-25" +channel = "nightly-2024-02-25" components = ["clippy", "rustfmt", "rust-src"] profile = "minimal" From 7003c1fa5584825145b8c857d241ba4aec4cae1b Mon Sep 17 00:00:00 2001 From: brechtpd Date: Thu, 14 Mar 2024 06:36:28 +0300 Subject: [PATCH 02/10] fix alloy issues --- Cargo.lock | 79 ++++-------------------------- Cargo.toml | 2 +- lib/Cargo.toml | 6 +-- lib/src/builder/execute/taiko.rs | 19 ++++++-- lib/src/builder/prepare.rs | 10 +--- lib/src/consts.rs | 5 -- lib/src/taiko_utils.rs | 4 +- primitives/Cargo.toml | 2 +- primitives/src/mpt.rs | 5 ++ raiko-guests/risc0/src/lib.rs | 1 + raiko-host/Cargo.toml | 8 ++-- raiko-host/src/host/host.rs | 82 +++++++++++++++++--------------- 12 files changed, 84 insertions(+), 139 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9ca596d9..f71e2534 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -119,7 +119,7 @@ dependencies = [ [[package]] name = "alloy-eips" version = "0.1.0" -source = "git+https://github.com/brechtpd/alloy?branch=header-serialize#e77a49aad28ca01624bbb9cc3ee0f1daaceb1869" +source = "git+https://github.com/brechtpd/alloy?branch=header-serialize#14381350e57921a71292304875e87dfbfd33c3b5" dependencies = [ "alloy-primitives", "alloy-rlp", @@ -161,7 +161,7 @@ dependencies = [ [[package]] name = "alloy-json-rpc" version = "0.1.0" -source = "git+https://github.com/brechtpd/alloy?branch=header-serialize#e77a49aad28ca01624bbb9cc3ee0f1daaceb1869" +source = "git+https://github.com/brechtpd/alloy?branch=header-serialize#14381350e57921a71292304875e87dfbfd33c3b5" dependencies = [ "alloy-primitives", "serde", @@ -172,7 +172,7 @@ dependencies = [ [[package]] name = "alloy-network" version = "0.1.0" -source = "git+https://github.com/brechtpd/alloy?branch=header-serialize#e77a49aad28ca01624bbb9cc3ee0f1daaceb1869" +source = "git+https://github.com/brechtpd/alloy?branch=header-serialize#14381350e57921a71292304875e87dfbfd33c3b5" dependencies = [ "alloy-eips 0.1.0 (git+https://github.com/brechtpd/alloy?branch=header-serialize)", "alloy-json-rpc", @@ -207,7 +207,7 @@ dependencies = [ [[package]] name = "alloy-providers" version = "0.1.0" -source = "git+https://github.com/brechtpd/alloy?branch=header-serialize#e77a49aad28ca01624bbb9cc3ee0f1daaceb1869" +source = "git+https://github.com/brechtpd/alloy?branch=header-serialize#14381350e57921a71292304875e87dfbfd33c3b5" dependencies = [ "alloy-network", "alloy-primitives", @@ -253,7 +253,7 @@ dependencies = [ [[package]] name = "alloy-rpc-client" version = "0.1.0" -source = "git+https://github.com/brechtpd/alloy?branch=header-serialize#e77a49aad28ca01624bbb9cc3ee0f1daaceb1869" +source = "git+https://github.com/brechtpd/alloy?branch=header-serialize#14381350e57921a71292304875e87dfbfd33c3b5" dependencies = [ "alloy-json-rpc", "alloy-transport", @@ -286,7 +286,7 @@ dependencies = [ [[package]] name = "alloy-rpc-trace-types" version = "0.1.0" -source = "git+https://github.com/brechtpd/alloy?branch=header-serialize#e77a49aad28ca01624bbb9cc3ee0f1daaceb1869" +source = "git+https://github.com/brechtpd/alloy?branch=header-serialize#14381350e57921a71292304875e87dfbfd33c3b5" dependencies = [ "alloy-primitives", "alloy-rpc-types 0.1.0 (git+https://github.com/brechtpd/alloy?branch=header-serialize)", @@ -308,7 +308,7 @@ dependencies = [ [[package]] name = "alloy-rpc-types" version = "0.1.0" -source = "git+https://github.com/brechtpd/alloy?branch=header-serialize#e77a49aad28ca01624bbb9cc3ee0f1daaceb1869" +source = "git+https://github.com/brechtpd/alloy?branch=header-serialize#14381350e57921a71292304875e87dfbfd33c3b5" dependencies = [ "alloy-primitives", "alloy-rlp", @@ -374,7 +374,7 @@ dependencies = [ [[package]] name = "alloy-transport" version = "0.1.0" -source = "git+https://github.com/brechtpd/alloy?branch=header-serialize#e77a49aad28ca01624bbb9cc3ee0f1daaceb1869" +source = "git+https://github.com/brechtpd/alloy?branch=header-serialize#14381350e57921a71292304875e87dfbfd33c3b5" dependencies = [ "alloy-json-rpc", "base64 0.21.7", @@ -390,7 +390,7 @@ dependencies = [ [[package]] name = "alloy-transport-http" version = "0.1.0" -source = "git+https://github.com/brechtpd/alloy?branch=header-serialize#e77a49aad28ca01624bbb9cc3ee0f1daaceb1869" +source = "git+https://github.com/brechtpd/alloy?branch=header-serialize#14381350e57921a71292304875e87dfbfd33c3b5" dependencies = [ "alloy-json-rpc", "alloy-transport", @@ -1842,19 +1842,6 @@ dependencies = [ "syn 2.0.52", ] -[[package]] -name = "env_logger" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4cd405aab171cb85d6735e5c8d9db038c17d3ca007a4d2c25f337935c3d90580" -dependencies = [ - "humantime", - "is-terminal", - "log", - "regex", - "termcolor", -] - [[package]] name = "equivalent" version = "1.0.1" @@ -2392,15 +2379,6 @@ dependencies = [ "wasm-bindgen", ] -[[package]] -name = "gobuild" -version = "0.1.0-alpha.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71e156a4ddbf3deb5e8116946c111413bd9a5679bdc1536c78a60618a7a9ac9e" -dependencies = [ - "cc", -] - [[package]] name = "group" version = "0.13.0" @@ -2585,12 +2563,6 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f58b778a5761513caf593693f8951c97a5b610841e754788400f32102eefdff1" -[[package]] -name = "humantime" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" - [[package]] name = "hyper" version = "0.14.28" @@ -2768,17 +2740,6 @@ version = "2.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f518f335dce6725a761382244631d86cf0ccb2863413590b31338feb467f9c3" -[[package]] -name = "is-terminal" -version = "0.4.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f23ff5ef2b80d608d61efee834934d862cd92461afc0560dedf493e4c033738b" -dependencies = [ - "hermit-abi 0.3.9", - "libc", - "windows-sys 0.52.0", -] - [[package]] name = "itertools" version = "0.10.5" @@ -5943,34 +5904,12 @@ dependencies = [ "windows-sys 0.52.0", ] -[[package]] -name = "termcolor" -version = "1.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755" -dependencies = [ - "winapi-util", -] - [[package]] name = "termtree" version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3369f5ac52d5eb6ab48c6b4ffdc8efbcad6b89c765749064ba298f2c68a16a76" -[[package]] -name = "tests" -version = "0.1.0" -dependencies = [ - "env_logger", - "gobuild", - "hex 0.3.2", - "log", - "serde", - "serde_json", - "zeth-primitives", -] - [[package]] name = "textwrap" version = "0.11.0" diff --git a/Cargo.toml b/Cargo.toml index d6a5c6da..df819b80 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,7 +9,7 @@ members = [ # "raiko-guests/succinct", "raiko-host", "sgx-ra", - "tests/*", + # "tests/*", ] diff --git a/lib/Cargo.toml b/lib/Cargo.toml index bc763717..16650a97 100644 --- a/lib/Cargo.toml +++ b/lib/Cargo.toml @@ -15,9 +15,9 @@ alloy-primitives = { version = "0.6", default-features = false, features = [ "std", "tiny-keccak", ] } -alloy-rpc-types = { git = "https://github.com/brechtpd/alloy", branch = "header-serialize", version = "0.1.0" } -alloy-consensus = { git = "https://github.com/brechtpd/alloy", branch = "header-serialize", version = "0.1.0" } -alloy-network = { git = "https://github.com/brechtpd/alloy", branch = "header-serialize", version = "0.1.0", features = ["k256"] } +alloy-rpc-types = { git = "https://github.com/brechtpd/alloy", branch = "header-serialize" } +alloy-consensus = { git = "https://github.com/brechtpd/alloy", branch = "header-serialize" } +alloy-network = { git = "https://github.com/brechtpd/alloy", branch = "header-serialize", features = ["k256"] } bytes = {version = "1.5", default-features = false} hashbrown = { workspace = true } libflate = { version = "2.0.0", optional = true } diff --git a/lib/src/builder/execute/taiko.rs b/lib/src/builder/execute/taiko.rs index 147124d4..4e8ee1c7 100644 --- a/lib/src/builder/execute/taiko.rs +++ b/lib/src/builder/execute/taiko.rs @@ -17,6 +17,7 @@ use core::{fmt::Debug, mem::take, str::from_utf8}; use alloy_consensus::{TxEnvelope, TxKind}; use alloy_consensus::TxEip4844Variant::TxEip4844; use alloy_consensus::TxEip4844Variant; +use alloy_rlp::Encodable; use anyhow::{anyhow, bail, Context, Result}; #[cfg(feature = "std")] use log::debug; @@ -247,13 +248,13 @@ impl TxExecStrategy for TkoTxExecStrategy { tx_from, is_anchor, ); - //println!("**** transact: {:?}", evm.env().tx); + println!("**** transact: {:?}", evm.env().tx); // process the transaction let ResultAndState { result, state } = match evm.transact() { Ok(result) => result, Err(err) => { if is_anchor { - bail!("Error at transaction {}: {:?}", tx_no, err); + bail!("Anchor tx failed to execute successfully: {:?}", err); } // only continue for invalid tx errors, not db errors (because those can be // manipulated by the prover) @@ -266,7 +267,7 @@ impl TxExecStrategy for TkoTxExecStrategy { } _ => { // any other error is not allowed - bail!("Invalid tx at {}: {:?}", tx_no, err); + bail!("Error at tx {}: {:?}", tx_no, err); } } } @@ -336,11 +337,21 @@ impl TxExecStrategy for TkoTxExecStrategy { //tx_trie.insert_rlp(&trie_key, tx)?; //if is_anchor { - tx_trie.insert_rlp(&trie_key, transactions_ether[tx_no].clone())?; + let tx_rlp = tx.to_rlp(); + tx_trie.insert_rlp_encoded(&trie_key, tx_rlp[tx_rlp.len() - tx.inner_length() - 1..].to_vec())?; //} else { // tx_trie.insert_rlp(&trie_key, tx)?; //}; + println!("ethers: {:?}", transactions_ether[tx_no].to_rlp()); + println!("alloy: {:?}", tx.to_rlp()); + let mut buf = vec![]; + tx.encode(&mut buf); + println!("alloy: {:?}", buf); + println!("alloy inner length: {:?}", tx.inner_length()); + println!("alloy length: {:?}", tx.length()); + println!("fixed: {:?}", tx_rlp[tx_rlp.len() - tx.inner_length() - 1..].to_vec()); + receipt_trie.insert_rlp(&trie_key, receipt)?; actual_tx_no += 1; } diff --git a/lib/src/builder/prepare.rs b/lib/src/builder/prepare.rs index 58b121ec..1ae0c064 100644 --- a/lib/src/builder/prepare.rs +++ b/lib/src/builder/prepare.rs @@ -19,7 +19,7 @@ use revm::{Database, DatabaseCommit}; use zeth_primitives::transactions::TxEssence; use alloy_consensus::Header as AlloyConsensusHeader; -use crate::{builder::BlockBuilder, consts::MAX_EXTRA_DATA_BYTES, taiko_utils::{HeaderHasher, BLOCK_GAS_LIMIT}}; +use crate::{builder::BlockBuilder, consts::MAX_EXTRA_DATA_BYTES, taiko_utils::HeaderHasher}; pub trait HeaderPrepStrategy { fn prepare_header(block_builder: BlockBuilder) -> Result> @@ -38,14 +38,6 @@ impl HeaderPrepStrategy for TaikoHeaderPrepStrategy { ::Error: Debug, E: TxEssence, { - // Validate gas limit - if block_builder.input.gas_limit != BLOCK_GAS_LIMIT { - bail!( - "Invalid gas limit: expected == {}, got {}", - BLOCK_GAS_LIMIT, - block_builder.input.gas_limit, - ); - } // Validate timestamp let timestamp: u64 = block_builder.input.timestamp.try_into().unwrap(); if timestamp < block_builder.input.parent_header.timestamp { diff --git a/lib/src/consts.rs b/lib/src/consts.rs index ec879a7c..f0c6edc5 100644 --- a/lib/src/consts.rs +++ b/lib/src/consts.rs @@ -28,11 +28,6 @@ pub const ZERO: U256 = U256::ZERO; /// U256 representation of 1. pub const ONE: U256 = uint!(1_U256); -/// The bound divisor of the gas limit, -pub const GAS_LIMIT_BOUND_DIVISOR: U256 = uint!(1024_U256); -/// Minimum the gas limit may ever be. -pub const MIN_GAS_LIMIT: U256 = uint!(5000_U256); - /// Maximum size of extra data. pub const MAX_EXTRA_DATA_BYTES: usize = 32; diff --git a/lib/src/taiko_utils.rs b/lib/src/taiko_utils.rs index 89fb6ee8..522bb086 100644 --- a/lib/src/taiko_utils.rs +++ b/lib/src/taiko_utils.rs @@ -18,8 +18,6 @@ use alloy_network::Signed; use crate::input::{decode_anchor, GuestInput}; pub const ANCHOR_GAS_LIMIT: u64 = 250_000; -pub const MAX_TX_LIST_BYTES: usize = 120_000; -pub const BLOCK_GAS_LIMIT: u64 = 15250000; pub const GOLDEN_TOUCH_ACCOUNT: Lazy
= Lazy::new(|| { Address::from_str("0x0000777735367b36bC9B61C50022d9D0700dB4Ec") .expect("invalid golden touch account") @@ -160,7 +158,7 @@ pub fn generate_transactions_alloy( let signed_eip1559_tx = Signed::::new_unchecked( eip1559_tx, - Signature::from_rs_and_parity(anchor_tx.signature.unwrap().r, anchor_tx.signature.unwrap().s, false).unwrap(), + Signature::from_rs_and_parity(anchor_tx.signature.unwrap().r, anchor_tx.signature.unwrap().s, parity.0).unwrap(), anchor_tx.hash, ); diff --git a/primitives/Cargo.toml b/primitives/Cargo.toml index 50d67e51..77a72292 100644 --- a/primitives/Cargo.toml +++ b/primitives/Cargo.toml @@ -12,7 +12,7 @@ alloy-sol-types = { version = "0.6", default-features = false, optional = true } alloy-dyn-abi = { version = "0.6",default-features = false, optional = true } alloy-rlp = { version = "0.3", default-features = false } alloy-rlp-derive = { version = "0.3", default-features = false } -alloy-rpc-types = { git = "https://github.com/brechtpd/alloy", branch = "header-serialize", version = "0.1.0" } +alloy-rpc-types = { git = "https://github.com/brechtpd/alloy", branch = "header-serialize" } anyhow = { version = "1.0", default-features = false } bytes = { version = "1.5", default-features = false } ethers-core = { git = "https://github.com/smtmfft/ethers-rs", branch = "ethers-core-2.0.10" } diff --git a/primitives/src/mpt.rs b/primitives/src/mpt.rs index b6a7df2a..c32863ea 100644 --- a/primitives/src/mpt.rs +++ b/primitives/src/mpt.rs @@ -658,6 +658,11 @@ impl MptNode { self.insert_internal(&to_nibs(key), value.to_rlp()) } + #[inline] + pub fn insert_rlp_encoded(&mut self, key: &[u8], value: Vec) -> Result { + self.insert_internal(&to_nibs(key), value) + } + fn insert_internal(&mut self, key_nibs: &[u8], value: Vec) -> Result { match &mut self.data { MptNodeData::Null => { diff --git a/raiko-guests/risc0/src/lib.rs b/raiko-guests/risc0/src/lib.rs index ae9d61e6..e5b8a13a 100644 --- a/raiko-guests/risc0/src/lib.rs +++ b/raiko-guests/risc0/src/lib.rs @@ -12,4 +12,5 @@ // See the License for the specific language governing permissions and // limitations under the License. +#[cfg(feature = "risc0")] include!(concat!(env!("OUT_DIR"), "/methods.rs")); diff --git a/raiko-host/Cargo.toml b/raiko-host/Cargo.toml index c78a70d8..503231d0 100644 --- a/raiko-host/Cargo.toml +++ b/raiko-host/Cargo.toml @@ -7,10 +7,10 @@ edition = "2021" anyhow = "1.0" alloy-sol-types = { version = "0.6" } alloy-primitives = { version = "0.6", default-features = false } -alloy-rpc-types = { git = "https://github.com/brechtpd/alloy", branch = "header-serialize", version = "0.1.0" } -alloy-providers = { git = "https://github.com/brechtpd/alloy", branch = "header-serialize", version = "0.1.0" } -alloy-transport-http = { git = "https://github.com/brechtpd/alloy", branch = "header-serialize", version = "0.1.0" } -alloy-consensus = { git = "https://github.com/brechtpd/alloy", branch = "header-serialize", version = "0.1.0" } +alloy-rpc-types = { git = "https://github.com/brechtpd/alloy", branch = "header-serialize" } +alloy-providers = { git = "https://github.com/brechtpd/alloy", branch = "header-serialize" } +alloy-transport-http = { git = "https://github.com/brechtpd/alloy", branch = "header-serialize" } +alloy-consensus = { git = "https://github.com/brechtpd/alloy", branch = "header-serialize" } bincode = "1.3.3" bytemuck = "1.13" clap = { version = "4.0", features = ["derive"] } diff --git a/raiko-host/src/host/host.rs b/raiko-host/src/host/host.rs index 3fc1a01c..1acd7554 100644 --- a/raiko-host/src/host/host.rs +++ b/raiko-host/src/host/host.rs @@ -1,16 +1,17 @@ -use std::path::PathBuf; +use std::{path::PathBuf, sync::Arc}; use alloy_sol_types::SolCall; use alloy_rpc_types::{Block as AlloyBlock, BlockTransactions}; use alloy_providers::tmp::{HttpProvider, TempProvider}; use alloy_transport_http::Http; +use c_kzg::{Blob, KzgCommitment}; use url::Url; use anyhow::{anyhow, ensure, Context, Result}; -use ethers_core::types::Transaction as EthersTransaction; +use ethers_core::types::{Transaction as EthersTransaction, U256}; use hashbrown::HashSet; use log::info; -use reth_primitives::eip4844::kzg_to_versioned_hash; +use reth_primitives::{constants::eip4844::MAINNET_KZG_TRUSTED_SETUP, eip4844::kzg_to_versioned_hash}; use rlp::Rlp; use serde::{Deserialize, Serialize}; use zeth_lib::{ @@ -19,7 +20,7 @@ use zeth_lib::{ decode_propose_block_call_params, proposeBlockCall, BlockMetadata, GuestInput, TaikoGuestInput, TaikoProverData, }, - taiko_utils::{generate_transactions, generate_transactions_alloy, MAX_TX_LIST_BYTES, to_header}, + taiko_utils::{generate_transactions, generate_transactions_alloy, to_header}, }; use zeth_primitives::{ ethers::{from_ethers_h160, from_ethers_h256, from_ethers_u256}, @@ -141,13 +142,6 @@ pub fn taiko_run_preflight( let proposal_call = proposeBlockCall::abi_decode(&proposal_tx.input, false).unwrap(); // .with_context(|| "failed to decode propose block call")?; - // Make sure to also do the preflight on the tx_list transactions so we have the necessary - // data for invalid transactions. - ensure!( - proposal_call.txList.len() <= MAX_TX_LIST_BYTES, - "tx list bytes must be not more than MAX_TX_LIST_BYTES" - ); - // blobUsed == (txList.length == 0) according to TaikoL1 let blob_used = proposal_call.txList.is_empty(); let (tx_list, tx_blob_hash) = if blob_used { @@ -167,7 +161,10 @@ pub fn taiko_run_preflight( let tx_blobs: Vec = blobs .data .iter() - .filter(|blob| blob_hash.as_fixed_bytes() == &calc_blob_hash(&blob.kzg_commitment)) + .filter(|blob: &&GetBlobData| { + // calculate from plain blob + blob_hash.as_fixed_bytes() == &calc_blob_versioned_hash(&blob.blob) + }) .cloned() .collect::>(); let blob_data = decode_blob_data(&tx_blobs[0].blob); @@ -181,17 +178,16 @@ pub fn taiko_run_preflight( (proposal_call.txList.clone(), None) }; - // println!("tx_list: {:?}", tx_list); + println!("tx_list: {:?}", tx_list); // Create the transactions for the proposed tx list let transactions_ethers: Vec = generate_transactions(&tx_list, anchor_tx_ethers.clone()); - - let transactions_alloy = generate_transactions_alloy(&tx_list, anchor_tx_alloy.clone()); + assert!(transactions_ethers.len() == transactions_alloy.len()); println!("Block valid transactions: {:?}", block_alloy.transactions.len()); assert!( - transactions_ethers.len() >= block_alloy.transactions.len(), + transactions_alloy.len() >= block_alloy.transactions.len(), "unexpected number of transactions" ); @@ -216,16 +212,6 @@ pub fn taiko_run_preflight( prover_data, }; - // convert each transaction - /*let transactions = transactions_ethers - .into_iter() - .enumerate() - .map(|(i, tx)| { - tx.try_into() - .map_err(|err| anyhow!("transaction {i} invalid: {err:?}")) - }) - .collect::, _>>()?;*/ - // convert each withdrawal let withdrawals = block_ethers .withdrawals @@ -307,25 +293,43 @@ pub fn taiko_run_preflight( }) } + +const BLOB_FIELD_ELEMENT_NUM: usize = 4096; +const BLOB_FIELD_ELEMENT_BYTES: usize = 32; +const BLOB_DATA_LEN: usize = BLOB_FIELD_ELEMENT_NUM * BLOB_FIELD_ELEMENT_BYTES; + fn decode_blob_data(blob: &str) -> Vec { let origin_blob = hex::decode(blob.to_lowercase().trim_start_matches("0x")).unwrap(); - assert!(origin_blob.len() == 4096 * 32); + let header: U256 = U256::from_big_endian(&origin_blob[0..BLOB_FIELD_ELEMENT_BYTES]); // first element is the length + let expected_len = header.as_usize(); + + assert!(origin_blob.len() == BLOB_DATA_LEN); + // the first 32 bytes is the length of the blob + // every first 1 byte is reserved. + assert!(expected_len <= (BLOB_FIELD_ELEMENT_NUM - 1) * (BLOB_FIELD_ELEMENT_BYTES - 1)); let mut chunk: Vec> = Vec::new(); - let mut last_seg_found = false; - for i in (0..4096).rev() { - let segment = &origin_blob[i * 32 + 1..(i + 1) * 32]; - if segment.iter().any(|&x| x != 0) || last_seg_found { - chunk.push(segment.to_vec()); - last_seg_found = true; - } + let mut decoded_len = 0; + let mut i = 1; + while decoded_len < expected_len && i < BLOB_FIELD_ELEMENT_NUM { + let segment_len = if expected_len - decoded_len >= 31 { + 31 + } else { + expected_len - decoded_len + }; + let segment = &origin_blob + [i * BLOB_FIELD_ELEMENT_BYTES + 1..i * BLOB_FIELD_ELEMENT_BYTES + 1 + segment_len]; + i += 1; + decoded_len += segment_len; + chunk.push(segment.to_vec()); } - chunk.reverse(); chunk.iter().flatten().cloned().collect() } -fn calc_blob_hash(commitment: &str) -> [u8; 32] { - let commit_bytes = hex::decode(commitment.to_lowercase().trim_start_matches("0x")).unwrap(); - let kzg_commit = c_kzg::KzgCommitment::from_bytes(&commit_bytes).unwrap(); +fn calc_blob_versioned_hash(blob_str: &str) -> [u8; 32] { + let blob_bytes = hex::decode(blob_str.to_lowercase().trim_start_matches("0x")).unwrap(); + let kzg_settings = Arc::clone(&*MAINNET_KZG_TRUSTED_SETUP); + let blob = Blob::from_bytes(&blob_bytes).unwrap(); + let kzg_commit = KzgCommitment::blob_to_kzg_commitment(&blob, &kzg_settings).unwrap(); let version_hash: [u8; 32] = kzg_to_versioned_hash(kzg_commit).0; version_hash -} +} \ No newline at end of file From 300284889b9e24242e5b2d56848697db3d2395b8 Mon Sep 17 00:00:00 2001 From: brechtpd Date: Sun, 17 Mar 2024 11:48:43 +0000 Subject: [PATCH 03/10] everything working with alloy + removed lots of ethers code --- Cargo.lock | 2 + lib/src/builder/execute/mod.rs | 5 +- lib/src/builder/execute/taiko.rs | 151 +---- lib/src/builder/finalize.rs | 9 +- lib/src/builder/initialize.rs | 11 +- lib/src/builder/mod.rs | 21 +- lib/src/builder/prepare.rs | 9 +- lib/src/input.rs | 23 +- lib/src/lib.rs | 2 - lib/src/protocol_instance.rs | 4 +- lib/src/taiko_utils.rs | 141 +---- primitives/src/access_list.rs | 55 -- primitives/src/ethers.rs | 284 --------- primitives/src/lib.rs | 2 - primitives/src/revm.rs | 28 +- primitives/src/transactions/ethereum.rs | 733 ----------------------- primitives/src/transactions/mod.rs | 192 ------ raiko-guests/risc0/guest/src/main.rs | 3 +- raiko-guests/sgx/src/one_shot.rs | 1 - raiko-guests/succinct/src/main.rs | 3 +- raiko-host/Cargo.toml | 2 + raiko-host/src/host/host.rs | 231 ++++--- raiko-host/src/host/mod.rs | 3 +- raiko-host/src/host/provider/mod.rs | 77 --- raiko-host/src/host/provider_db.rs | 209 +++---- raiko-host/src/host/taiko_provider.rs | 109 ---- raiko-host/src/prover/execution.rs | 5 +- raiko-host/src/prover/proof/mod.rs | 5 +- raiko-host/src/prover/proof/risc0/mod.rs | 5 +- raiko-host/src/prover/proof/succinct.rs | 3 +- 30 files changed, 320 insertions(+), 2008 deletions(-) delete mode 100644 primitives/src/access_list.rs delete mode 100644 primitives/src/ethers.rs delete mode 100644 primitives/src/transactions/ethereum.rs delete mode 100644 raiko-host/src/host/taiko_provider.rs diff --git a/Cargo.lock b/Cargo.lock index f71e2534..0a4accc8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4185,6 +4185,8 @@ dependencies = [ "alloy-consensus", "alloy-primitives", "alloy-providers", + "alloy-rlp", + "alloy-rlp-derive", "alloy-rpc-types 0.1.0 (git+https://github.com/brechtpd/alloy?branch=header-serialize)", "alloy-sol-types", "alloy-transport-http", diff --git a/lib/src/builder/execute/mod.rs b/lib/src/builder/execute/mod.rs index f7db51c5..25105c41 100644 --- a/lib/src/builder/execute/mod.rs +++ b/lib/src/builder/execute/mod.rs @@ -16,14 +16,13 @@ use core::fmt::Debug; use anyhow::Result; use revm::{Database, DatabaseCommit}; -use zeth_primitives::transactions::TxEssence; use super::BlockBuilder; pub(super) mod taiko; -pub trait TxExecStrategy { - fn execute_transactions(block_builder: BlockBuilder) -> Result> +pub trait TxExecStrategy { + fn execute_transactions(block_builder: BlockBuilder) -> Result> where D: Database + DatabaseCommit, ::Error: Debug; diff --git a/lib/src/builder/execute/taiko.rs b/lib/src/builder/execute/taiko.rs index 4e8ee1c7..0b17bb2d 100644 --- a/lib/src/builder/execute/taiko.rs +++ b/lib/src/builder/execute/taiko.rs @@ -32,10 +32,6 @@ use ruint::aliases::U256; use zeth_primitives::{ mpt::MptNode, receipt::Receipt, - transactions::{ - ethereum::{EthereumTxEssence, TransactionKind}, - TxEssence, - }, Bloom, RlpBytes, }; @@ -45,7 +41,7 @@ use crate::{ builder::BlockBuilder, consts::{self, ChainSpec, GWEI_TO_WEI}, guest_mem_forget, - taiko_utils::{check_anchor_tx, generate_transactions, generate_transactions_2, get_contracts}, + taiko_utils::{check_anchor_tx, get_contracts}, }; /// Minimum supported protocol version: Bedrock (Block no. 105235063). @@ -53,10 +49,10 @@ const MIN_SPEC_ID: SpecId = SpecId::SHANGHAI /*change*/; pub struct TkoTxExecStrategy {} -impl TxExecStrategy for TkoTxExecStrategy { +impl TxExecStrategy for TkoTxExecStrategy { fn execute_transactions( - mut block_builder: BlockBuilder, - ) -> Result> + mut block_builder: BlockBuilder, + ) -> Result> where D: Database + DatabaseCommit, ::Error: Debug, @@ -78,12 +74,6 @@ impl TxExecStrategy for TkoTxExecStrategy { serde_json::from_str(&block_builder.input.taiko.anchor_tx_alloy.clone()).unwrap(), ); - // generate the transactions from the tx list - let mut transactions_ether = generate_transactions_2( - &block_builder.input.taiko.tx_list, - block_builder.input.taiko.anchor_tx.clone().unwrap().clone(), - ); - #[cfg(feature = "std")] { use chrono::{TimeZone, Utc}; @@ -137,21 +127,21 @@ impl TxExecStrategy for TkoTxExecStrategy { // anchor transaction must be executed successfully let is_anchor = tx_no == 0; - let tx_hash = match &tx { + let (tx_gas_limit, tx_hash) = match &tx { TxEnvelope::Legacy(tx) => { - tx.hash() + (tx.gas_limit, tx.hash()) } TxEnvelope::TaggedLegacy(tx) => { - tx.hash() + (tx.gas_limit, tx.hash()) } TxEnvelope::Eip2930(tx) => { - tx.hash() + (tx.gas_limit, tx.hash()) } TxEnvelope::Eip1559(tx) => { - tx.hash() + (tx.gas_limit, tx.hash()) } TxEnvelope::Eip4844(tx) => { - tx.hash() + (tx.tx().tx().gas_limit, tx.hash()) } }; println!("**** hash: {:?}", tx_hash); @@ -204,7 +194,7 @@ impl TxExecStrategy for TkoTxExecStrategy { // verify the anchor tx // TODO(Brecht): reenable with alloy tx - /*if is_anchor { + if is_anchor { check_anchor_tx( &block_builder.input, &tx, @@ -212,7 +202,7 @@ impl TxExecStrategy for TkoTxExecStrategy { &block_builder.input.taiko.chain_spec_name, ) .expect("invalid anchor tx"); - }*/ + } #[cfg(feature = "std")] { @@ -225,20 +215,9 @@ impl TxExecStrategy for TkoTxExecStrategy { // verify transaction gas let block_available_gas = block_builder.input.gas_limit - cumulative_gas_used; - // TODO(Brecht): reenable - //if block_available_gas < tx.gas_limit().try_into().unwrap() { - // bail!("Error at transaction {tx_no}: gas exceeds block limit"); - //} - - println!("**** fill"); - - /*fill_eth_tx_env( - &block_builder.input.taiko.chain_spec_name, - &mut evm.env().tx, - &transactions_ether[0].clone().essence, - tx_from, - is_anchor, - );*/ + if block_available_gas < tx_gas_limit.try_into().unwrap() { + bail!("Error at transaction {tx_no}: gas exceeds block limit"); + } // setup the transaction fill_eth_tx_env_alloy( @@ -248,7 +227,7 @@ impl TxExecStrategy for TkoTxExecStrategy { tx_from, is_anchor, ); - println!("**** transact: {:?}", evm.env().tx); + //println!("**** transact: {:?}", evm.env().tx); // process the transaction let ResultAndState { result, state } = match evm.transact() { Ok(result) => result, @@ -273,8 +252,6 @@ impl TxExecStrategy for TkoTxExecStrategy { } }; - //println!("**** transact done"); - // anchor tx needs to succeed if is_anchor && !result.is_success() { bail!( @@ -343,14 +320,14 @@ impl TxExecStrategy for TkoTxExecStrategy { // tx_trie.insert_rlp(&trie_key, tx)?; //}; - println!("ethers: {:?}", transactions_ether[tx_no].to_rlp()); - println!("alloy: {:?}", tx.to_rlp()); - let mut buf = vec![]; - tx.encode(&mut buf); - println!("alloy: {:?}", buf); - println!("alloy inner length: {:?}", tx.inner_length()); - println!("alloy length: {:?}", tx.length()); - println!("fixed: {:?}", tx_rlp[tx_rlp.len() - tx.inner_length() - 1..].to_vec()); + //println!("ethers: {:?}", transactions_ether[tx_no].to_rlp()); + //println!("alloy: {:?}", tx.to_rlp()); + //let mut buf = vec![]; + //tx.encode(&mut buf); + //println!("alloy: {:?}", buf); + //println!("alloy inner length: {:?}", tx.inner_length()); + //println!("alloy length: {:?}", tx.length()); + //println!("fixed: {:?}", tx_rlp[tx_rlp.len() - tx.inner_length() - 1..].to_vec()); receipt_trie.insert_rlp(&trie_key, receipt)?; actual_tx_no += 1; @@ -401,86 +378,6 @@ impl TxExecStrategy for TkoTxExecStrategy { } } -pub fn fill_eth_tx_env( - chain_name: &str, - tx_env: &mut TxEnv, - essence: &EthereumTxEssence, - caller: Address, - is_anchor: bool, -) { - // claim the anchor - tx_env.taiko.is_anchor = is_anchor; - // set the treasury address - tx_env.taiko.treasury = get_contracts(chain_name).unwrap().1; - - match essence { - EthereumTxEssence::Legacy(tx) => { - tx_env.caller = caller; - tx_env.gas_limit = tx.gas_limit.try_into().unwrap(); - tx_env.gas_price = tx.gas_price; - tx_env.gas_priority_fee = None; - tx_env.transact_to = if let TransactionKind::Call(to_addr) = tx.to { - TransactTo::Call(to_addr) - } else { - TransactTo::create() - }; - tx_env.value = tx.value; - tx_env.data = tx.data.clone(); - tx_env.chain_id = tx.chain_id; - tx_env.nonce = Some(tx.nonce); - tx_env.access_list.clear(); - } - EthereumTxEssence::Eip2930(tx) => { - tx_env.caller = caller; - tx_env.gas_limit = tx.gas_limit.try_into().unwrap(); - tx_env.gas_price = tx.gas_price; - tx_env.gas_priority_fee = None; - tx_env.transact_to = if let TransactionKind::Call(to_addr) = tx.to { - TransactTo::Call(to_addr) - } else { - TransactTo::create() - }; - tx_env.value = tx.value; - tx_env.data = tx.data.clone(); - tx_env.chain_id = Some(tx.chain_id); - tx_env.nonce = Some(tx.nonce); - tx_env.access_list = tx.access_list.clone().into(); - } - EthereumTxEssence::Eip1559(tx) => { - tx_env.caller = caller; - tx_env.gas_limit = tx.gas_limit.try_into().unwrap(); - tx_env.gas_price = tx.max_fee_per_gas; - tx_env.gas_priority_fee = Some(tx.max_priority_fee_per_gas); - tx_env.transact_to = if let TransactionKind::Call(to_addr) = tx.to { - TransactTo::Call(to_addr) - } else { - TransactTo::create() - }; - tx_env.value = tx.value; - tx_env.data = tx.data.clone(); - tx_env.chain_id = Some(tx.chain_id); - tx_env.nonce = Some(tx.nonce); - tx_env.access_list = tx.access_list.clone().into(); - } - EthereumTxEssence::Eip4844(tx) => { - tx_env.caller = caller; - tx_env.gas_limit = tx.gas_limit.try_into().unwrap(); - tx_env.gas_price = tx.max_fee_per_gas; - tx_env.gas_priority_fee = Some(tx.max_priority_fee_per_gas); - tx_env.transact_to = if let TransactionKind::Call(to_addr) = tx.to { - TransactTo::Call(to_addr) - } else { - TransactTo::create() - }; - tx_env.value = tx.value; - tx_env.data = tx.data.clone(); - tx_env.chain_id = Some(tx.chain_id); - tx_env.nonce = Some(tx.nonce); - tx_env.access_list = tx.access_list.clone().into(); - } - }; -} - pub fn fill_eth_tx_env_alloy( chain_name: &str, tx_env: &mut TxEnv, diff --git a/lib/src/builder/finalize.rs b/lib/src/builder/finalize.rs index 4870ac4a..b555c82b 100644 --- a/lib/src/builder/finalize.rs +++ b/lib/src/builder/finalize.rs @@ -19,7 +19,6 @@ use revm::{Database, DatabaseCommit}; use zeth_primitives::{ keccak::keccak, mpt::{MptNode, StateAccount}, - transactions::TxEssence, }; use alloy_consensus::Header as AlloyConsensusHeader; @@ -34,16 +33,14 @@ where D: Database + DatabaseCommit, ::Error: core::fmt::Debug, { - fn finalize(block_builder: BlockBuilder) -> Result<(AlloyConsensusHeader, MptNode)> - where - E: TxEssence; + fn finalize(block_builder: BlockBuilder) -> Result<(AlloyConsensusHeader, MptNode)>; } pub struct MemDbBlockFinalizeStrategy {} impl BlockFinalizeStrategy for MemDbBlockFinalizeStrategy { - fn finalize( - mut block_builder: BlockBuilder, + fn finalize( + mut block_builder: BlockBuilder, ) -> Result<(AlloyConsensusHeader, MptNode)> { let db: MemDb = block_builder.db.take().expect("DB not initialized"); diff --git a/lib/src/builder/initialize.rs b/lib/src/builder/initialize.rs index 4cfa99e8..647478a3 100644 --- a/lib/src/builder/initialize.rs +++ b/lib/src/builder/initialize.rs @@ -23,7 +23,6 @@ use revm::{ use zeth_primitives::{ keccak::{keccak, KECCAK_EMPTY}, mpt::StateAccount, - transactions::TxEssence, Bytes, }; @@ -39,17 +38,15 @@ where D: Database + DatabaseCommit, ::Error: core::fmt::Debug, { - fn initialize_database(block_builder: BlockBuilder) -> Result> - where - E: TxEssence; + fn initialize_database(block_builder: BlockBuilder) -> Result>; } pub struct MemDbInitStrategy {} impl DbInitStrategy for MemDbInitStrategy { - fn initialize_database( - mut block_builder: BlockBuilder, - ) -> Result> { + fn initialize_database( + mut block_builder: BlockBuilder, + ) -> Result> { // Verify state trie root if block_builder.input.parent_state_trie.hash() != block_builder.input.parent_header.state_root diff --git a/lib/src/builder/mod.rs b/lib/src/builder/mod.rs index 6c6745d0..7e4bb6a2 100644 --- a/lib/src/builder/mod.rs +++ b/lib/src/builder/mod.rs @@ -16,7 +16,6 @@ use anyhow::Result; use revm::{Database, DatabaseCommit}; use zeth_primitives::{ mpt::MptNode, - transactions::{ethereum::EthereumTxEssence, TxEssence}, }; pub use self::execute::taiko::TkoTxExecStrategy; @@ -40,21 +39,20 @@ pub mod prepare; /// A generic builder for building a block. #[derive(Clone, Debug)] -pub struct BlockBuilder { +pub struct BlockBuilder { pub(crate) chain_spec: ChainSpec, - pub(crate) input: GuestInput, + pub(crate) input: GuestInput, pub(crate) db: Option, pub(crate) header: Option, } -impl BlockBuilder +impl BlockBuilder where D: Database + DatabaseCommit, ::Error: core::fmt::Debug, - E: TxEssence, { /// Creates a new block builder. - pub fn new(input: &GuestInput) -> BlockBuilder { + pub fn new(input: &GuestInput) -> BlockBuilder { BlockBuilder { chain_spec: get_chain_spec(&input.taiko.chain_spec_name), db: None, @@ -80,7 +78,7 @@ where } /// Executes all input transactions. - pub fn execute_transactions>(self) -> Result { + pub fn execute_transactions(self) -> Result { T::execute_transactions(self) } @@ -102,16 +100,14 @@ where /// A bundle of strategies for building a block using [BlockBuilder]. pub trait BlockBuilderStrategy { - type TxEssence: TxEssence; - type DbInitStrategy: DbInitStrategy; type HeaderPrepStrategy: HeaderPrepStrategy; - type TxExecStrategy: TxExecStrategy; + type TxExecStrategy: TxExecStrategy; type BlockFinalizeStrategy: BlockFinalizeStrategy; /// Builds a block from the given input. - fn build_from(input: &GuestInput) -> Result<(AlloyConsensusHeader, MptNode)> { - BlockBuilder::::new(input) + fn build_from(input: &GuestInput) -> Result<(AlloyConsensusHeader, MptNode)> { + BlockBuilder::::new(input) .initialize_database::()? .prepare_header::()? .execute_transactions::()? @@ -122,7 +118,6 @@ pub trait BlockBuilderStrategy { /// The [BlockBuilderStrategy] for building a Taiko block. pub struct TaikoStrategy {} impl BlockBuilderStrategy for TaikoStrategy { - type TxEssence = EthereumTxEssence; type DbInitStrategy = MemDbInitStrategy; type HeaderPrepStrategy = TaikoHeaderPrepStrategy; type TxExecStrategy = TkoTxExecStrategy; diff --git a/lib/src/builder/prepare.rs b/lib/src/builder/prepare.rs index 1ae0c064..079e7823 100644 --- a/lib/src/builder/prepare.rs +++ b/lib/src/builder/prepare.rs @@ -16,27 +16,24 @@ use core::fmt::Debug; use anyhow::{bail, Context, Result}; use revm::{Database, DatabaseCommit}; -use zeth_primitives::transactions::TxEssence; use alloy_consensus::Header as AlloyConsensusHeader; use crate::{builder::BlockBuilder, consts::MAX_EXTRA_DATA_BYTES, taiko_utils::HeaderHasher}; pub trait HeaderPrepStrategy { - fn prepare_header(block_builder: BlockBuilder) -> Result> + fn prepare_header(block_builder: BlockBuilder) -> Result> where D: Database + DatabaseCommit, - ::Error: core::fmt::Debug, - E: TxEssence; + ::Error: core::fmt::Debug; } pub struct TaikoHeaderPrepStrategy {} impl HeaderPrepStrategy for TaikoHeaderPrepStrategy { - fn prepare_header(mut block_builder: BlockBuilder) -> Result> + fn prepare_header(mut block_builder: BlockBuilder) -> Result> where D: Database + DatabaseCommit, ::Error: Debug, - E: TxEssence, { // Validate timestamp let timestamp: u64 = block_builder.input.timestamp.try_into().unwrap(); diff --git a/lib/src/input.rs b/lib/src/input.rs index aaf9b63a..3912ceb3 100644 --- a/lib/src/input.rs +++ b/lib/src/input.rs @@ -21,11 +21,9 @@ use hashbrown::HashMap; use serde::{Deserialize, Serialize}; use zeth_primitives::{ mpt::MptNode, - transactions::{Transaction, TxEssence}, - withdrawal::Withdrawal, Address, Bytes, FixedBytes, B256, U256, }; -use alloy_rpc_types::Transaction as AlloyTransaction; +use alloy_rpc_types::Withdrawal as AlloyWithdrawal; /// Represents the state of an account's storage. /// The storage trie together with the used storage slots allow us to reconstruct all the @@ -34,7 +32,7 @@ pub type StorageEntry = (MptNode, Vec); /// External block input. #[derive(Debug, Clone, Deserialize, Serialize)] -pub struct GuestInput { +pub struct GuestInput { /// Block hash - for reference! pub block_hash: H256, /// Previous block header @@ -50,9 +48,9 @@ pub struct GuestInput { /// Hash previously used for the PoW now containing the RANDAO value. pub mix_hash: B256, /// List of transactions for execution - pub transactions: Vec>, + //pub transactions: Vec>, /// List of stake withdrawals for execution - pub withdrawals: Vec, + pub withdrawals: Vec, /// State trie of the parent block. pub parent_state_trie: MptNode, /// Maps each address with its storage trie and the used storage slots. @@ -64,15 +62,14 @@ pub struct GuestInput { /// Base fee per gas pub base_fee_per_gas: u64, /// Taiko specific data - pub taiko: TaikoGuestInput, + pub taiko: TaikoGuestInput, } #[derive(Clone, Debug, Serialize, Deserialize)] -pub struct TaikoGuestInput { +pub struct TaikoGuestInput { pub chain_spec_name: String, pub l1_header: AlloyConsensusHeader, pub tx_list: Vec, - pub anchor_tx: Option>, pub anchor_tx_alloy: String, pub block_proposed: BlockProposed, pub prover_data: TaikoProverData, @@ -329,13 +326,11 @@ impl From for BlockProposed { mod tests { use alloc::vec; - use zeth_primitives::transactions::ethereum::EthereumTxEssence; - use super::*; #[test] fn input_serde_roundtrip() { - let input = GuestInput:: { + let input = GuestInput { block_hash: Default::default(), parent_header: Default::default(), beneficiary: Default::default(), @@ -343,7 +338,7 @@ mod tests { timestamp: Default::default(), extra_data: Default::default(), mix_hash: Default::default(), - transactions: vec![], + //transactions: vec![], withdrawals: vec![], parent_state_trie: Default::default(), parent_storage: Default::default(), @@ -352,7 +347,7 @@ mod tests { base_fee_per_gas: Default::default(), taiko: Default::default(), }; - let _: GuestInput = + let _: GuestInput = bincode::deserialize(&bincode::serialize(&input).unwrap()).unwrap(); } } diff --git a/lib/src/lib.rs b/lib/src/lib.rs index c0147f0e..3081a680 100644 --- a/lib/src/lib.rs +++ b/lib/src/lib.rs @@ -26,8 +26,6 @@ pub mod mem_db; pub mod protocol_instance; pub mod taiko_utils; -pub use zeth_primitives::transactions::ethereum::EthereumTxEssence; - /// call forget only if running inside the guest pub fn guest_mem_forget(_t: T) { #[cfg(target_os = "zkvm")] // TODO: seperate for risc0 diff --git a/lib/src/protocol_instance.rs b/lib/src/protocol_instance.rs index c38b8194..a2f41888 100644 --- a/lib/src/protocol_instance.rs +++ b/lib/src/protocol_instance.rs @@ -1,7 +1,7 @@ use alloy_primitives::{Address, TxHash, B256}; use alloy_sol_types::SolValue; use anyhow::{ensure, Result}; -use zeth_primitives::{keccak::keccak, transactions::ethereum::EthereumTxEssence}; +use zeth_primitives::{keccak::keccak}; use alloy_consensus::Header as AlloyConsensusHeader; use super::taiko_utils::ANCHOR_GAS_LIMIT; @@ -68,7 +68,7 @@ pub enum EvidenceType { // TODO(cecilia): rewrite pub fn assemble_protocol_instance( - input: &GuestInput, + input: &GuestInput, header: &AlloyConsensusHeader, ) -> Result { let blob_used = input.taiko.block_proposed.meta.blobUsed; diff --git a/lib/src/taiko_utils.rs b/lib/src/taiko_utils.rs index 522bb086..d7d07f40 100644 --- a/lib/src/taiko_utils.rs +++ b/lib/src/taiko_utils.rs @@ -2,17 +2,12 @@ use core::str::FromStr; use alloy_primitives::{uint, Address, U256, Signature}; use anyhow::{anyhow, bail, ensure, Context, Result}; -use ethers_core::types::Transaction as EthersTransaction; use once_cell::unsync::Lazy; -use rlp::{decode_list, Decodable, DecoderError, Rlp}; -use zeth_primitives::{keccak256, transactions::{ - ethereum::{EthereumTxEssence, TransactionKind}, - EthereumTransaction, Transaction, TxEssence, -}, B256}; +use zeth_primitives::{keccak256, B256}; use alloy_rlp::*; -use alloy_rpc_types::{AccessList, Header as AlloyHeader}; +use alloy_rpc_types::Header as AlloyHeader; use alloy_consensus::{Header as AlloyConsensusHeader, TxEip1559, TxEnvelope, TxKind}; -use alloy_rpc_types::{Block as AlloyBlock, BlockTransactions, Transaction as AlloyTransaction}; +use alloy_rpc_types::Transaction as AlloyTransaction; use alloy_network::Signed; use crate::input::{decode_anchor, GuestInput}; @@ -57,7 +52,7 @@ pub mod internal_devnet_a { use super::*; pub const CHAIN_ID: u64 = 167001; pub const L1_CONTRACT: Lazy
= Lazy::new(|| { - Address::from_str("0xC069c3d2a9f2479F559AD34485698ad5199C555f") + Address::from_str("0x78155FaC733356cbA069245A435Eb114e7fd815d") .expect("invalid l1 contract address") }); pub const L2_CONTRACT: Lazy
= Lazy::new(|| { @@ -79,59 +74,6 @@ pub mod internal_devnet_b { }); } -fn decode_tx_list(tx_list: &[u8]) -> Result, DecoderError> -where - T: Decodable, -{ - Rlp::new(tx_list).as_list() -} - -pub fn generate_transactions( - tx_list: &[u8], - anchor_tx: EthersTransaction, -) -> Vec { - // Decode all the transactions in the tx list - let mut transactions: Vec = decode_tx_list(&tx_list).unwrap_or_default(); - // Insert the anchor transactions generated by the node (which needs to be verified!) - transactions.insert(0, anchor_tx); - transactions -} - -// TODO(Brecht): really need to switch to alloy for everything... -pub fn generate_transactions_2( - tx_list: &[u8], - anchor_tx: Transaction, -) -> Vec> { - // Decode all the transactions in the tx list - let transactions: Vec = decode_tx_list(&tx_list).unwrap_or_default(); - - // convert each transaction - let mut transactions = transactions - .into_iter() - .enumerate() - .map(|(i, tx)| { - tx.try_into() - .map_err(|err| anyhow!("transaction {i} invalid: {err:?}")) - }) - .collect::, _>>() - .unwrap_or_default(); - - // Insert the anchor transactions generated by the node (which needs to be verified!) - transactions.insert(0, anchor_tx); - transactions -} - -/*fn decode(buf: &mut &[u8]) -> Result> { - let mut bytes = Header::decode_bytes(buf, true)?; - let mut vec = Vec::new(); - let payload_view = &mut bytes; - while !payload_view.is_empty() { - vec.push(TxEnvelope::decode(payload_view)?); - } - Ok(vec) -}*/ - -// TODO(Brecht): really need to switch to alloy for everything... pub fn generate_transactions_alloy( tx_list: &[u8], anchor_tx: AlloyTransaction, @@ -154,7 +96,7 @@ pub fn generate_transactions_alloy( }; let parity = anchor_tx.signature.unwrap().y_parity.unwrap(); - println!("parity: {:?}", parity); + //println!("parity: {:?}", parity); let signed_eip1559_tx = Signed::::new_unchecked( eip1559_tx, @@ -166,48 +108,10 @@ pub fn generate_transactions_alloy( let mut transactions: Vec = alloy_rlp::Decodable::decode(b).unwrap_or_default(); //let transactions: Vec = decode_tx_list(&tx_list).unwrap_or_default(); - println!("alloy decoded transactions: {:?}", transactions); + //println!("alloy decoded transactions: {:?}", transactions); println!("num decoded: {:?}", transactions.len()); - /*let hash = match &transactions[0] { - TxEnvelope::Legacy(tx) => { - tx.hash() - } - TxEnvelope::TaggedLegacy(tx) => { - tx.hash() - } - TxEnvelope::Eip2930(tx) => { - tx.hash() - } - TxEnvelope::Eip1559(tx) => { - tx.hash() - } - TxEnvelope::Eip4844(tx) => { - tx.hash() - } - }; - println!("**** hash: {:?}", hash); - - let from = match &transactions[0] { - TxEnvelope::Legacy(tx) => { - tx.recover_signer() - } - TxEnvelope::TaggedLegacy(tx) => { - tx.recover_signer() - } - TxEnvelope::Eip2930(tx) => { - tx.recover_signer() - } - TxEnvelope::Eip1559(tx) => { - tx.recover_signer() - } - TxEnvelope::Eip4844(tx) => { - tx.recover_signer() - } - }; - println!("***** from: {:?}", from);*/ - // Insert the anchor transactions generated by the node (which needs to be verified!) transactions.insert(0, TxEnvelope::from(signed_eip1559_tx)); transactions @@ -223,14 +127,14 @@ const GX2: Lazy = Lazy::new(|| uint!(0xc6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee5_U256)); /// check the anchor signature with fixed K value -fn check_anchor_signature(anchor: &EthereumTransaction) -> Result<()> { - let sign = &anchor.signature; - if sign.r == *GX1 { +fn check_anchor_signature(anchor: &Signed) -> Result<()> { + let sign = anchor.signature(); + if sign.r() == *GX1 { return Ok(()); } - let msg_hash = anchor.essence.signing_hash(); + let msg_hash = anchor.signature_hash(); let msg_hash: U256 = msg_hash.into(); - if sign.r == *GX2 { + if sign.r() == *GX2 { // when r == GX2 require s == 0 if k == 1 // alias: when r == GX2 require N == msg_hash + *GX1_MUL_PRIVATEKEY if *N != msg_hash + *GX1_MUL_PRIVATEKEY { @@ -243,26 +147,25 @@ fn check_anchor_signature(anchor: &EthereumTransaction) -> Result<()> { } Err(anyhow!( "r != *GX1 && r != GX2, r: {}, *GX1: {}, GX2: {}", - sign.r, + sign.r(), *GX1, *GX2 )) } pub fn check_anchor_tx( - input: &GuestInput, - anchor: &EthereumTransaction, + input: &GuestInput, + anchor: &TxEnvelope, from: &Address, chain_name: &str, ) -> Result<()> { - // Check the signature - check_anchor_signature(anchor).context(anyhow!("failed to check anchor signature"))?; + match anchor { + TxEnvelope::Eip1559(tx) => { + // Check the signature + check_anchor_signature(tx).context(anyhow!("failed to check anchor signature"))?; - // Check the data - match &anchor.essence { - EthereumTxEssence::Eip1559(tx) => { // Extract the `to` address - let to = if let TransactionKind::Call(to_addr) = tx.to { + let to = if let TxKind::Call(to_addr) = tx.to { to_addr } else { panic!("anchor tx not a smart contract call") @@ -284,7 +187,7 @@ pub fn check_anchor_tx( ); // Tx needs to have the expected gas limit ensure!( - tx.gas_limit == U256::from(ANCHOR_GAS_LIMIT), + tx.gas_limit == ANCHOR_GAS_LIMIT, "anchor transaction gas price mismatch" ); // Check needs to have the base fee set to the block base fee @@ -294,7 +197,7 @@ pub fn check_anchor_tx( ); // Okay now let's decode the anchor tx to verify the inputs - let anchor_call = decode_anchor(anchor.essence.data())?; + let anchor_call = decode_anchor(&tx.input)?; println!("anchor: {:?}", anchor_call.l1Hash); println!("expected: {:?}", input.taiko.l1_header.hash()); @@ -323,7 +226,7 @@ pub fn check_anchor_tx( panic!("invalid anchor tx type"); } } - + Ok(()) } diff --git a/primitives/src/access_list.rs b/primitives/src/access_list.rs deleted file mode 100644 index a3b25074..00000000 --- a/primitives/src/access_list.rs +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright 2023 RISC Zero, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -extern crate alloc; -extern crate core; - -pub use alloc::{ - boxed::Box, - format, - string::{String, ToString}, - vec, - vec::Vec, -}; -pub use core::{ - convert::From, - default::Default, - option::{Option, Option::*}, - result::{Result, Result::*}, -}; - -use alloy_primitives::{Address, StorageKey}; -use alloy_rlp_derive::{RlpEncodable, RlpEncodableWrapper}; -use serde::{Deserialize, Serialize}; - -/// Represents an access list as defined in EIP-2930. -/// -/// An access list is a list of addresses and storage keys that a transaction will access, -/// allowing for gas optimizations. This structure is introduced to improve the gas cost -/// calculations by making certain accesses cheaper if they are declared in this list. -#[derive(Debug, Clone, PartialEq, Eq, Default, Serialize, Deserialize, RlpEncodableWrapper)] -pub struct AccessList(pub Vec); - -/// Represents an item in the [AccessList]. -/// -/// Each item specifies an Ethereum address and a set of storage keys that the transaction -/// will access. By providing this information up front, the transaction can benefit from -/// gas cost optimizations. -#[derive(Debug, Clone, PartialEq, Eq, Default, RlpEncodable, Serialize, Deserialize)] -pub struct AccessListItem { - /// The Ethereum address that the transaction will access. - pub address: Address, - /// A list of storage keys associated with the given address that the transaction will - /// access. - pub storage_keys: Vec, -} diff --git a/primitives/src/ethers.rs b/primitives/src/ethers.rs deleted file mode 100644 index 4c972ba3..00000000 --- a/primitives/src/ethers.rs +++ /dev/null @@ -1,284 +0,0 @@ -// Copyright 2023 RISC Zero, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -//! Convert from Ethers types. -extern crate alloc; -extern crate core; - -pub use alloc::{ - boxed::Box, - format, - string::{String, ToString}, - vec, - vec::Vec, -}; -pub use core::{ - convert::From, - default::Default, - num::TryFromIntError, - option::{Option, Option::*}, - result::{Result, Result::*}, -}; - -use alloy_primitives::{Address, Bloom, Bytes, B256, U256}; -use anyhow::{anyhow, Context}; -use ethers_core::types::{ - transaction::eip2930::{ - AccessList as EthersAccessList, AccessListItem as EthersAccessListItem, - }, - Block as EthersBlock, Bytes as EthersBytes, Transaction as EthersTransaction, - TransactionReceipt as EthersReceipt, Withdrawal as EthersWithdrawal, H160 as EthersH160, - H256 as EthersH256, U256 as EthersU256, U64, -}; - -use crate::{ - access_list::{AccessList, AccessListItem}, - receipt::{Log, Receipt, ReceiptPayload}, - transactions::{ - ethereum::{ - EthereumTxEssence, TransactionKind, TxEssenceEip1559, TxEssenceEip2930, - TxEssenceEip4844, TxEssenceLegacy, - }, - signature::TxSignature, - Transaction, TxEssence, - }, - withdrawal::Withdrawal, -}; - -/// Convert an `EthersU256` type to the `U256` type. -#[inline] -pub fn from_ethers_u256(v: EthersU256) -> U256 { - U256::from_limbs(v.0) -} - -/// Convert an `U256` type to the `EthersU256` type. -#[inline] -pub fn to_ethers_u256(v: U256) -> EthersU256 { - EthersU256(v.into_limbs()) -} - -/// Convert an `EthersH160` type to the `Address` type. -#[inline] -pub fn from_ethers_h160(v: EthersH160) -> Address { - v.0.into() -} - -/// Convert an `EthersH256` type to the `B256` type. -#[inline] -pub fn from_ethers_h256(v: EthersH256) -> B256 { - v.0.into() -} - -/// Convert an `EthersBytes` type to the `Bytes` type. -#[inline] -pub fn from_ethers_bytes(v: EthersBytes) -> Bytes { - v.0.into() -} - -/// Conversion from `EthersAccessListItem` to the local [AccessListItem]. -impl From for AccessListItem { - fn from(item: EthersAccessListItem) -> Self { - AccessListItem { - address: item.address.0.into(), - storage_keys: item - .storage_keys - .into_iter() - .map(|key| key.0.into()) - .collect(), - } - } -} - -/// Conversion from `EthersAccessList` to the local [AccessList]. -impl From for AccessList { - fn from(list: EthersAccessList) -> Self { - AccessList(list.0.into_iter().map(|item| item.into()).collect()) - } -} - -/// Convert an optional `EthersH160` to the local [TransactionKind]. -impl From> for TransactionKind { - fn from(addr: Option) -> Self { - match addr { - Some(address) => TransactionKind::Call(address.0.into()), - None => TransactionKind::Create, - } - } -} - -/// Conversion from `EthersTransaction` to the local [Transaction]. -/// This conversion may fail if certain expected fields are missing. -impl> TryFrom for Transaction { - type Error = >::Error; - - fn try_from(value: EthersTransaction) -> Result { - let signature = TxSignature { - v: value.v.as_u64(), - r: from_ethers_u256(value.r), - s: from_ethers_u256(value.s), - }; - let essence = value.try_into()?; - - Ok(Transaction { essence, signature }) - } -} - -/// Conversion from `EthersTransaction` to the local [EthereumTxEssence]. -/// This conversion may fail if certain expected fields are missing. -impl TryFrom for EthereumTxEssence { - type Error = anyhow::Error; - - fn try_from(tx: EthersTransaction) -> Result { - let essence = match tx.transaction_type.map(|t| t.as_u64()) { - None | Some(0) => EthereumTxEssence::Legacy(TxEssenceLegacy { - chain_id: match tx.chain_id { - None => None, - Some(chain_id) => Some( - chain_id - .try_into() - .map_err(|err| anyhow!("invalid chain_id: {err}"))?, - ), - }, - nonce: tx - .nonce - .try_into() - .map_err(|err| anyhow!("invalid nonce: {err}"))?, - gas_price: from_ethers_u256(tx.gas_price.context("gas_price missing")?), - gas_limit: from_ethers_u256(tx.gas), - to: tx.to.into(), - value: from_ethers_u256(tx.value), - data: tx.input.0.into(), - }), - Some(1) => EthereumTxEssence::Eip2930(TxEssenceEip2930 { - chain_id: tx - .chain_id - .context("chain_id missing")? - .try_into() - .map_err(|err| anyhow!("invalid chain_id: {err}"))?, - nonce: tx - .nonce - .try_into() - .map_err(|err| anyhow!("invalid nonce: {err}"))?, - gas_price: from_ethers_u256(tx.gas_price.context("gas_price missing")?), - gas_limit: from_ethers_u256(tx.gas), - to: tx.to.into(), - value: from_ethers_u256(tx.value), - access_list: tx.access_list.context("access_list missing")?.into(), - data: tx.input.0.into(), - }), - Some(2) => EthereumTxEssence::Eip1559(TxEssenceEip1559 { - chain_id: tx - .chain_id - .context("chain_id missing")? - .try_into() - .map_err(|err| anyhow!("invalid chain_id: {err}"))?, - nonce: tx - .nonce - .try_into() - .map_err(|err| anyhow!("invalid nonce: {err}"))?, - max_priority_fee_per_gas: from_ethers_u256( - tx.max_priority_fee_per_gas - .context("max_priority_fee_per_gas missing")?, - ), - max_fee_per_gas: from_ethers_u256( - tx.max_fee_per_gas.context("max_fee_per_gas missing")?, - ), - gas_limit: from_ethers_u256(tx.gas), - to: tx.to.into(), - value: from_ethers_u256(tx.value), - access_list: tx.access_list.context("access_list missing")?.into(), - data: tx.input.0.into(), - }), - Some(3) => EthereumTxEssence::Eip4844(TxEssenceEip4844 { - chain_id: tx - .chain_id - .context("chain_id missing")? - .try_into() - .map_err(|err| anyhow!("invalid chain_id: {}", err))?, - nonce: tx - .nonce - .try_into() - .map_err(|err| anyhow!("invalid nonce: {}", err))?, - max_priority_fee_per_gas: from_ethers_u256( - tx.max_priority_fee_per_gas - .context("max_priority_fee_per_gas missing")?, - ), - max_fee_per_gas: from_ethers_u256( - tx.max_fee_per_gas.context("max_fee_per_gas missing")?, - ), - gas_limit: from_ethers_u256(tx.gas), - to: tx.to.into(), - value: from_ethers_u256(tx.value), - access_list: tx.access_list.context("access_list missing")?.into(), - data: tx.input.0.into(), - blob_versioned_hashes: Default::default(), - max_fee_per_blob_gas: Default::default(), - }), - _ => unreachable!(), - }; - Ok(essence) - } -} - -/// Conversion from `EthersWithdrawal` to the local [Withdrawal]. -/// This conversion may fail if certain expected fields are missing. -impl TryFrom for Withdrawal { - type Error = anyhow::Error; - - fn try_from(withdrawal: EthersWithdrawal) -> Result { - Ok(Withdrawal { - index: withdrawal.index.as_u64(), - validator_index: withdrawal.validator_index.as_u64(), - address: withdrawal.address.0.into(), - amount: withdrawal - .amount - .try_into() - .map_err(|err| anyhow!("invalid amount: {err}"))?, - }) - } -} - -impl TryFrom for Receipt { - type Error = anyhow::Error; - - fn try_from(receipt: EthersReceipt) -> Result { - Ok(Receipt { - tx_type: receipt - .transaction_type - .context("transaction_type missing")? - .as_u64() - .try_into() - .context("invalid transaction_type")?, - payload: ReceiptPayload { - success: receipt.status.context("status missing")? == U64::one(), - cumulative_gas_used: from_ethers_u256(receipt.cumulative_gas_used), - logs_bloom: Bloom::from_slice(receipt.logs_bloom.as_bytes()), - logs: receipt - .logs - .into_iter() - .map(|log| { - let address = log.address.0.into(); - let topics = log.topics.into_iter().map(from_ethers_h256).collect(); - let data = log.data.0.into(); - Log { - address, - topics, - data, - } - }) - .collect(), - }, - }) - } -} diff --git a/primitives/src/lib.rs b/primitives/src/lib.rs index 094236fd..1b0ad4cf 100644 --- a/primitives/src/lib.rs +++ b/primitives/src/lib.rs @@ -18,8 +18,6 @@ extern crate core; pub use alloc::{vec, vec::Vec}; -pub mod access_list; -pub mod ethers; pub mod keccak; pub mod mpt; pub mod receipt; diff --git a/primitives/src/revm.rs b/primitives/src/revm.rs index 2cee7a4e..de85a64b 100644 --- a/primitives/src/revm.rs +++ b/primitives/src/revm.rs @@ -31,35 +31,9 @@ pub use core::{ result::{Result, Result::*}, }; -use alloy_primitives::{Address, U256}; use revm_primitives::Log as RevmLog; -use crate::{ - access_list::{AccessList, AccessListItem}, - receipt::Log, -}; - -/// Provides a conversion from [AccessListItem] to a tuple of `Address` and a vector of -/// `U256`. -impl From for (Address, Vec) { - fn from(item: AccessListItem) -> (Address, Vec) { - ( - item.address, - item.storage_keys - .into_iter() - .map(|item| item.into()) - .collect(), - ) - } -} - -/// Provides a conversion from [AccessList] to a vector of tuples containing `Address` and -/// a vector of `U256`. -impl From for Vec<(Address, Vec)> { - fn from(list: AccessList) -> Vec<(Address, Vec)> { - list.0.into_iter().map(|item| item.into()).collect() - } -} +use crate::receipt::Log; /// Provides a conversion from `RevmLog` to the local [Log]. impl From for Log { diff --git a/primitives/src/transactions/ethereum.rs b/primitives/src/transactions/ethereum.rs deleted file mode 100644 index 4f1b5b1d..00000000 --- a/primitives/src/transactions/ethereum.rs +++ /dev/null @@ -1,733 +0,0 @@ -// Copyright 2023 RISC Zero, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -extern crate alloc; -extern crate core; - -pub use alloc::{ - boxed::Box, - format, - string::{String, ToString}, - vec, - vec::Vec, -}; -pub use core::{ - convert::From, - default::Default, - option::{Option, Option::*}, - result::{Result, Result::*}, -}; - -use alloy_primitives::{Address, Bytes, ChainId, TxNumber, B256, U256}; -use alloy_rlp::{Encodable, EMPTY_STRING_CODE}; -use alloy_rlp_derive::RlpEncodable; -use anyhow::{anyhow, Context}; -use k256::{ - ecdsa::{RecoveryId, Signature as K256Signature, VerifyingKey as K256VerifyingKey}, - elliptic_curve::sec1::ToEncodedPoint, - PublicKey as K256PublicKey, -}; -use serde::{Deserialize, Serialize}; -use thiserror::Error as ThisError; - -use super::signature::TxSignature; -use crate::{access_list::AccessList, keccak::keccak, transactions::TxEssence}; - -/// Represents a legacy Ethereum transaction as detailed in [EIP-155](https://eips.ethereum.org/EIPS/eip-155). -/// -/// The `TxEssenceLegacy` struct encapsulates the core components of a traditional -/// Ethereum transaction prior to the introduction of more recent transaction types. It -/// adheres to the specifications set out in EIP-155. -#[derive(Debug, Clone, PartialEq, Eq, Default, Serialize, Deserialize)] -pub struct TxEssenceLegacy { - /// The network's chain ID introduced in EIP-155 to prevent replay attacks across - /// different chains. - pub chain_id: Option, - /// A numeric value representing the total number of transactions previously sent by - /// the sender. - pub nonce: TxNumber, - /// The price, in Wei, that the sender is willing to pay per unit of gas for the - /// transaction's execution. - pub gas_price: U256, - /// The maximum amount of gas allocated for the transaction's execution. - pub gas_limit: U256, - /// The 160-bit address of the intended recipient for a message call or - /// [TransactionKind::Create] for contract creation. - pub to: TransactionKind, - /// The amount, in Wei, to be transferred to the recipient of the message call. - pub value: U256, - /// The transaction's payload, represented as a variable-length byte array. - pub data: Bytes, -} - -impl TxEssenceLegacy { - /// Computes the length of the RLP-encoded payload in bytes. - /// - /// This method calculates the combined length of all the individual fields - /// of the transaction when they are RLP-encoded. - pub fn payload_length(&self) -> usize { - self.nonce.length() - + self.gas_price.length() - + self.gas_limit.length() - + self.to.length() - + self.value.length() - + self.data.length() - } - - /// Encodes the transaction essence into the provided `out` buffer for the purpose of - /// signing. - /// - /// According to EIP-155, if `chain_id` is present, `(chain_id, 0, 0)` must be - /// appended to the regular RLP encoding when computing the hash of a transaction for - /// the purposes of signing. - pub fn signing_encode(&self, out: &mut dyn alloy_rlp::BufMut) { - let mut payload_length = self.payload_length(); - // append chain ID according to EIP-155 if present - if let Some(chain_id) = self.chain_id { - payload_length += chain_id.length() + 1 + 1; - } - alloy_rlp::Header { - list: true, - payload_length, - } - .encode(out); - self.nonce.encode(out); - self.gas_price.encode(out); - self.gas_limit.encode(out); - self.to.encode(out); - self.value.encode(out); - self.data.encode(out); - if let Some(chain_id) = self.chain_id { - chain_id.encode(out); - out.put_u8(alloy_rlp::EMPTY_STRING_CODE); - out.put_u8(alloy_rlp::EMPTY_STRING_CODE); - } - } - - /// Computes the length of the RLP-encoded transaction essence in bytes, specifically - /// for signing. - /// - /// This method calculates the total length of the transaction when it is RLP-encoded, - /// including any additional bytes required for the encoding format. - pub fn signing_length(&self) -> usize { - let mut payload_length = self.payload_length(); - // append chain ID according to EIP-155 if present - if let Some(chain_id) = self.chain_id { - payload_length += chain_id.length() + 1 + 1; - } - payload_length + alloy_rlp::length_of_length(payload_length) - } -} - -// Implement the Encodable trait for `TxEssenceLegacy`. -// Ensures that the `chain_id` is always ignored during the RLP encoding process. -impl Encodable for TxEssenceLegacy { - /// Encodes the [TxEssenceLegacy] instance into the provided `out` buffer. - /// - /// This method follows the RLP encoding scheme, but intentionally omits the - /// `chain_id` to ensure compatibility with legacy transactions. - #[inline] - fn encode(&self, out: &mut dyn alloy_rlp::BufMut) { - alloy_rlp::Header { - list: true, - payload_length: self.payload_length(), - } - .encode(out); - self.nonce.encode(out); - self.gas_price.encode(out); - self.gas_limit.encode(out); - self.to.encode(out); - self.value.encode(out); - self.data.encode(out); - } - - /// Computes the length of the RLP-encoded [TxEssenceLegacy] instance in bytes. - /// - /// This method calculates the total length of the transaction when it is RLP-encoded, - /// excluding the `chain_id`. - #[inline] - fn length(&self) -> usize { - let payload_length = self.payload_length(); - payload_length + alloy_rlp::length_of_length(payload_length) - } -} - -/// Represents an Ethereum transaction with an access list, as detailed in [EIP-2930](https://eips.ethereum.org/EIPS/eip-2930). -/// -/// The `TxEssenceEip2930` struct encapsulates the core components of an Ethereum -/// transaction that includes an access list. Access lists are a feature introduced in -/// EIP-2930 to specify a list of addresses and storage keys that the transaction will -/// access, allowing for more predictable gas costs. -#[derive(Debug, Clone, PartialEq, Eq, Default, Serialize, Deserialize, RlpEncodable)] -pub struct TxEssenceEip2930 { - /// The network's chain ID, ensuring the transaction is valid on the intended chain. - pub chain_id: ChainId, - /// A numeric value representing the total number of transactions previously sent by - /// the sender. - pub nonce: TxNumber, - /// The price, in Wei, that the sender is willing to pay per unit of gas for the - /// transaction's execution. - pub gas_price: U256, - /// The maximum amount of gas allocated for the transaction's execution. - pub gas_limit: U256, - /// The 160-bit address of the intended recipient for a message call. For contract - /// creation transactions, this is null. - pub to: TransactionKind, - /// The amount, in Wei, to be transferred to the recipient of the message call. - pub value: U256, - /// The transaction's payload, represented as a variable-length byte array. - pub data: Bytes, - /// A list of addresses and storage keys that the transaction will access, helping in - /// gas optimization. - pub access_list: AccessList, -} - -/// Represents an Ethereum transaction with a priority fee, as detailed in [EIP-1559](https://eips.ethereum.org/EIPS/eip-1559). -/// -/// The `TxEssenceEip1559` struct encapsulates the core components of an Ethereum -/// transaction that incorporates the priority fee mechanism introduced in EIP-1559. This -/// mechanism aims to improve the predictability of gas fees and enhance the overall user -/// experience. -#[derive(Debug, Clone, PartialEq, Eq, Default, Serialize, Deserialize, RlpEncodable)] -pub struct TxEssenceEip1559 { - /// The network's chain ID, ensuring the transaction is valid on the intended chain, - /// as introduced in EIP-155. - pub chain_id: ChainId, - /// A numeric value representing the total number of transactions previously sent by - /// the sender. - pub nonce: TxNumber, - /// The maximum priority fee per unit of gas that the sender is willing to pay to the - /// miner. - pub max_priority_fee_per_gas: U256, - /// The combined maximum fee (base + priority) per unit of gas that the sender is - /// willing to pay for the transaction's execution. - pub max_fee_per_gas: U256, - /// The maximum amount of gas allocated for the transaction's execution. - pub gas_limit: U256, - /// The 160-bit address of the intended recipient for a message call. For contract - /// creation transactions, this is null. - pub to: TransactionKind, - /// The amount, in Wei, to be transferred to the recipient of the message call. - pub value: U256, - /// The transaction's payload, represented as a variable-length byte array. - pub data: Bytes, - /// A list of addresses and storage keys that the transaction will access, aiding in - /// gas optimization. - pub access_list: AccessList, -} - -#[derive(Debug, Clone, PartialEq, Eq, Default, Serialize, Deserialize, RlpEncodable)] -pub struct TxEssenceEip4844 { - /// The network's chain ID, ensuring the transaction is valid on the intended chain, - /// as introduced in EIP-155. - pub chain_id: ChainId, - /// A numeric value representing the total number of transactions previously sent by - /// the sender. - pub nonce: TxNumber, - /// The maximum priority fee per unit of gas that the sender is willing to pay to the - /// miner. - pub max_priority_fee_per_gas: U256, - /// The combined maximum fee (base + priority) per unit of gas that the sender is - /// willing to pay for the transaction's execution. - pub max_fee_per_gas: U256, - /// The maximum amount of gas allocated for the transaction's execution. - pub gas_limit: U256, - /// The 160-bit address of the intended recipient for a message call. For contract - /// creation transactions, this is null. - pub to: TransactionKind, - /// The amount, in Wei, to be transferred to the recipient of the message call. - pub value: U256, - /// The transaction's payload, represented as a variable-length byte array. - pub data: Bytes, - /// A list of addresses and storage keys that the transaction will access, aiding in - /// gas optimization. - pub access_list: AccessList, - - /// It contains a vector of fixed size hash(32 bytes) - pub blob_versioned_hashes: Vec, - - /// Max fee per data gas - /// - /// aka BlobFeeCap or blobGasFeeCap - pub max_fee_per_blob_gas: U256, -} - -/// Represents the type of an Ethereum transaction: either a contract creation or a call -/// to an existing contract. -/// -/// This enum is used to distinguish between the two primary types of Ethereum -/// transactions. It avoids using an [Option] for this purpose because options get RLP -/// encoded into lists. -#[derive(Debug, Clone, Copy, PartialEq, Eq, Default, Serialize, Deserialize)] -pub enum TransactionKind { - /// Indicates that the transaction is for creating a new contract on the Ethereum - /// network. - #[default] - Create, - /// Indicates that the transaction is a call to an existing contract, identified by - /// its 160-bit address. - Call(Address), -} - -/// Provides a conversion from [TransactionKind] to `Option
`. -/// -/// This implementation allows for a straightforward extraction of the Ethereum address -/// from a [TransactionKind]. If the transaction kind is a `Call`, the address is wrapped -/// in a `Some`. If it's a `Create`, the result is `None`. -impl From for Option
{ - /// Converts a [TransactionKind] into an `Option
`. - /// - /// - If the transaction kind is `Create`, this returns `None`. - /// - If the transaction kind is `Call`, this returns the address wrapped in a `Some`. - fn from(value: TransactionKind) -> Self { - match value { - TransactionKind::Create => None, - TransactionKind::Call(addr) => Some(addr), - } - } -} - -/// Provides RLP encoding functionality for the [TransactionKind] enum. -/// -/// This implementation ensures that each variant of the [TransactionKind] enum can be -/// RLP-encoded. -/// - The `Call` variant is encoded as the address it contains. -/// - The `Create` variant is encoded as an empty string. -impl Encodable for TransactionKind { - /// Encodes the [TransactionKind] enum variant into the provided `out` buffer. - /// - /// If the transaction kind is `Call`, the Ethereum address is encoded directly. - /// If the transaction kind is `Create`, an empty string code is added to the buffer. - #[inline] - fn encode(&self, out: &mut dyn alloy_rlp::BufMut) { - match self { - TransactionKind::Call(addr) => addr.encode(out), - TransactionKind::Create => out.put_u8(EMPTY_STRING_CODE), - } - } - - /// Computes the length of the RLP-encoded [TransactionKind] enum variant in bytes. - /// - /// If the transaction kind is `Call`, this returns the length of the Ethereum - /// address. If the transaction kind is `Create`, this returns 1 (length of the - /// empty string code). - #[inline] - fn length(&self) -> usize { - match self { - TransactionKind::Call(addr) => addr.length(), - TransactionKind::Create => 1, - } - } -} - -/// Represents the core essence of an Ethereum transaction, specifically the portion that -/// gets signed. -/// -/// The [EthereumTxEssence] enum provides a way to handle different types of Ethereum -/// transactions. -#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] -pub enum EthereumTxEssence { - /// Represents a legacy Ethereum transaction, which follows the original transaction - /// format. - Legacy(TxEssenceLegacy), - /// Represents an Ethereum transaction that includes an access list, as introduced in [EIP-2930](https://eips.ethereum.org/EIPS/eip-2930). - /// Access lists specify a list of addresses and storage keys that the transaction - /// will access, allowing for more predictable gas costs. - Eip2930(TxEssenceEip2930), - /// Represents an Ethereum transaction that incorporates a priority fee mechanism, as detailed in [EIP-1559](https://eips.ethereum.org/EIPS/eip-1559). - /// This mechanism aims to improve the predictability of gas fees and enhances the - /// overall user experience. - Eip1559(TxEssenceEip1559), - Eip4844(TxEssenceEip4844), -} - -impl Encodable for EthereumTxEssence { - /// Encodes the [EthereumTxEssence] enum variant into the provided `out` buffer. - /// - /// Depending on the variant of the [EthereumTxEssence] enum, this method will - /// delegate the encoding process to the appropriate transaction type's encoding - /// method. - #[inline] - fn encode(&self, out: &mut dyn alloy_rlp::BufMut) { - match self { - EthereumTxEssence::Legacy(tx) => tx.encode(out), - EthereumTxEssence::Eip2930(tx) => tx.encode(out), - EthereumTxEssence::Eip1559(tx) => tx.encode(out), - EthereumTxEssence::Eip4844(tx) => tx.encode(out), - } - } - - /// Computes the length of the RLP-encoded [EthereumTxEssence] enum variant in bytes. - /// - /// Depending on the variant of the [EthereumTxEssence] enum, this method will - /// delegate the length computation to the appropriate transaction type's length - /// method. - #[inline] - fn length(&self) -> usize { - match self { - EthereumTxEssence::Legacy(tx) => tx.length(), - EthereumTxEssence::Eip2930(tx) => tx.length(), - EthereumTxEssence::Eip1559(tx) => tx.length(), - EthereumTxEssence::Eip4844(tx) => tx.length(), - } - } -} - -impl EthereumTxEssence { - /// Computes the signing hash for the transaction essence. - /// - /// This method calculates the Keccak hash of the data that needs to be signed - /// for the transaction, ensuring the integrity and authenticity of the transaction. - pub fn signing_hash(&self) -> B256 { - keccak(self.signing_data()).into() - } - - /// Retrieves the data that should be signed for the transaction essence. - /// - /// Depending on the variant of the [EthereumTxEssence] enum, this method prepares the - /// appropriate data for signing. For EIP-2930 and EIP-1559 transactions, a specific - /// prefix byte is added before the transaction data. - fn signing_data(&self) -> Vec { - match self { - EthereumTxEssence::Legacy(tx) => { - let mut buf = Vec::with_capacity(tx.signing_length()); - tx.signing_encode(&mut buf); - buf - } - EthereumTxEssence::Eip2930(tx) => { - let mut buf = Vec::with_capacity(tx.length() + 1); - buf.push(0x01); - tx.encode(&mut buf); - buf - } - EthereumTxEssence::Eip1559(tx) => { - let mut buf = Vec::with_capacity(tx.length() + 1); - buf.push(0x02); - tx.encode(&mut buf); - buf - } - EthereumTxEssence::Eip4844(tx) => { - let mut buf = Vec::with_capacity(tx.length() + 1); - buf.push(0x03); - tx.encode(&mut buf); - buf - } - } - } - - /// Returns the parity of the y-value of the curve point for which `signature.r` is - /// the x-value. This is encoded in the `v` field of the signature. - /// - /// It returns `None` if the parity cannot be determined. - fn is_y_odd(&self, signature: &TxSignature) -> Option { - match self { - EthereumTxEssence::Legacy(TxEssenceLegacy { chain_id: None, .. }) => { - checked_bool(signature.v - 27) - } - EthereumTxEssence::Legacy(TxEssenceLegacy { - chain_id: Some(chain_id), - .. - }) => checked_bool(signature.v - 35 - 2 * chain_id), - _ => checked_bool(signature.v), - } - } -} - -/// Converts a given value into a boolean based on its parity. -fn checked_bool(v: u64) -> Option { - match v { - 0 => Some(false), - 1 => Some(true), - _ => None, - } -} - -impl TxEssence for EthereumTxEssence { - /// Returns the EIP-2718 transaction type or `0x00` for Legacy transactions. - fn tx_type(&self) -> u8 { - match self { - EthereumTxEssence::Legacy(_) => 0x00, - EthereumTxEssence::Eip2930(_) => 0x01, - EthereumTxEssence::Eip1559(_) => 0x02, - EthereumTxEssence::Eip4844(_) => 0x03, - } - } - /// Returns the gas limit set for the transaction. - fn gas_limit(&self) -> U256 { - match self { - EthereumTxEssence::Legacy(tx) => tx.gas_limit, - EthereumTxEssence::Eip2930(tx) => tx.gas_limit, - EthereumTxEssence::Eip1559(tx) => tx.gas_limit, - EthereumTxEssence::Eip4844(tx) => tx.gas_limit, - } - } - /// Returns the recipient address of the transaction, if available. - fn to(&self) -> Option
{ - match self { - EthereumTxEssence::Legacy(tx) => tx.to.into(), - EthereumTxEssence::Eip2930(tx) => tx.to.into(), - EthereumTxEssence::Eip1559(tx) => tx.to.into(), - EthereumTxEssence::Eip4844(tx) => tx.to.into(), - } - } - /// Recovers the Ethereum address of the sender from the transaction's signature. - fn recover_from(&self, signature: &TxSignature) -> anyhow::Result
{ - let is_y_odd = self.is_y_odd(signature).context("v invalid")?; - let signature = - K256Signature::from_scalars(signature.r.to_be_bytes(), signature.s.to_be_bytes()) - .map_err(|e| anyhow!(EcdsaError::from(e))) - .context("r, s invalid")?; - - let verify_key = K256VerifyingKey::recover_from_prehash( - self.signing_hash().as_slice(), - &signature, - RecoveryId::new(is_y_odd, false), - ) - .map_err(|e| anyhow!(EcdsaError::from(e))) - .context("invalid signature")?; - - let public_key = K256PublicKey::from(&verify_key); - let public_key = public_key.to_encoded_point(false); - let public_key = public_key.as_bytes(); - debug_assert_eq!(public_key[0], 0x04); - let hash = keccak(&public_key[1..]); - - Ok(Address::from_slice(&hash[12..])) - } - /// Returns the length of the RLP-encoding payload in bytes. - fn payload_length(&self) -> usize { - match self { - EthereumTxEssence::Legacy(tx) => tx.payload_length(), - EthereumTxEssence::Eip2930(tx) => tx._alloy_rlp_payload_length(), - EthereumTxEssence::Eip1559(tx) => tx._alloy_rlp_payload_length(), - EthereumTxEssence::Eip4844(tx) => tx._alloy_rlp_payload_length(), - } - } - /// Returns a reference to the transaction's call data - fn data(&self) -> &Bytes { - match self { - EthereumTxEssence::Legacy(tx) => &tx.data, - EthereumTxEssence::Eip2930(tx) => &tx.data, - EthereumTxEssence::Eip1559(tx) => &tx.data, - EthereumTxEssence::Eip4844(tx) => &tx.data, - } - } -} - -#[derive(ThisError, Debug)] -#[error(transparent)] -struct EcdsaError(#[from] k256::ecdsa::Error); - -#[cfg(test)] -mod tests { - use alloy_primitives::{address, b256}; - use serde_json::json; - - use super::*; - use crate::transactions::EthereumTransaction; - - #[test] - fn legacy() { - // Tx: 0x5c504ed432cb51138bcf09aa5e8a410dd4a1e204ef84bfed1be16dfba1b22060 - let tx = json!({ - "Legacy": { - "nonce": 0, - "gas_price": "0x2d79883d2000", - "gas_limit": "0x5208", - "to": { "Call": "0x5df9b87991262f6ba471f09758cde1c0fc1de734" }, - "value": "0x7a69", - "data": "0x" - } - }); - let essence: EthereumTxEssence = serde_json::from_value(tx).unwrap(); - - let signature: TxSignature = serde_json::from_value(json!({ - "v": 28, - "r": "0x88ff6cf0fefd94db46111149ae4bfc179e9b94721fffd821d38d16464b3f71d0", - "s": "0x45e0aff800961cfce805daef7016b9b675c137a6a41a548f7b60a3484c06a33a" - })) - .unwrap(); - let transaction = EthereumTransaction { essence, signature }; - - // verify that bincode serialization works - let _: EthereumTransaction = - bincode::deserialize(&bincode::serialize(&transaction).unwrap()).unwrap(); - - assert_eq!( - transaction.hash(), - b256!("5c504ed432cb51138bcf09aa5e8a410dd4a1e204ef84bfed1be16dfba1b22060") - ); - let recovered = transaction.recover_from().unwrap(); - assert_eq!( - recovered, - address!("a1e4380a3b1f749673e270229993ee55f35663b4") - ); - } - - #[test] - fn eip155() { - // Tx: 0x4540eb9c46b1654c26353ac3c65e56451f711926982ce1b02f15c50e7459caf7 - let tx = json!({ - "Legacy": { - "nonce": 537760, - "gas_price": "0x03c49bfa04", - "gas_limit": "0x019a28", - "to": { "Call": "0xf0ee707731d1be239f9f482e1b2ea5384c0c426f" }, - "value": "0x06df842eaa9fb800", - "data": "0x", - "chain_id": 1 - } - }); - let essence: EthereumTxEssence = serde_json::from_value(tx).unwrap(); - - let signature: TxSignature = serde_json::from_value(json!({ - "v": 38, - "r": "0xcadd790a37b78e5613c8cf44dc3002e3d7f06a5325d045963c708efe3f9fdf7a", - "s": "0x1f63adb9a2d5e020c6aa0ff64695e25d7d9a780ed8471abe716d2dc0bf7d4259" - })) - .unwrap(); - let transaction = EthereumTransaction { essence, signature }; - - // verify that bincode serialization works - let _: EthereumTransaction = - bincode::deserialize(&bincode::serialize(&transaction).unwrap()).unwrap(); - - assert_eq!( - transaction.hash(), - b256!("4540eb9c46b1654c26353ac3c65e56451f711926982ce1b02f15c50e7459caf7") - ); - let recovered = transaction.recover_from().unwrap(); - assert_eq!( - recovered, - address!("974caa59e49682cda0ad2bbe82983419a2ecc400") - ); - } - - #[test] - fn eip2930() { - // Tx: 0xbe4ef1a2244e99b1ef518aec10763b61360be22e3b649dcdf804103719b1faef - let tx = json!({ - "Eip2930": { - "chain_id": 1, - "nonce": 93847, - "gas_price": "0xf46a5a9d8", - "gas_limit": "0x21670", - "to": { "Call": "0xc11ce44147c9f6149fbe54adb0588523c38718d7" }, - "value": "0x10d1471", - "data": "0x050000000002b8809aef26206090eafd7d5688615d48197d1c5ce09be6c30a33be4c861dee44d13f6dd33c2e8c5cad7e2725f88a8f0000000002d67ca5eb0e5fb6", - "access_list": [ - { - "address": "0xd6e64961ba13ba42858ad8a74ed9a9b051a4957d", - "storage_keys": [ - "0x0000000000000000000000000000000000000000000000000000000000000008", - "0x0b4b38935f88a7bddbe6be76893de2a04640a55799d6160729a82349aff1ffae", - "0xc59ee2ee2ba599569b2b1f06989dadbec5ee157c8facfe64f36a3e33c2b9d1bf" - ] - }, - { - "address": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", - "storage_keys": [ - "0x7635825e4f8dfeb20367f8742c8aac958a66caa001d982b3a864dcc84167be80", - "0x42555691810bdf8f236c31de88d2cc9407a8ff86cd230ba3b7029254168df92a", - "0x29ece5a5f4f3e7751868475502ab752b5f5fa09010960779bf7204deb72f5dde" - ] - }, - { - "address": "0x4c861dee44d13f6dd33c2e8c5cad7e2725f88a8f", - "storage_keys": [ - "0x000000000000000000000000000000000000000000000000000000000000000c", - "0x0000000000000000000000000000000000000000000000000000000000000008", - "0x0000000000000000000000000000000000000000000000000000000000000006", - "0x0000000000000000000000000000000000000000000000000000000000000007" - ] - }, - { - "address": "0x90eafd7d5688615d48197d1c5ce09be6c30a33be", - "storage_keys": [ - "0x0000000000000000000000000000000000000000000000000000000000000001", - "0x9c04773acff4c5c42718bd0120c72761f458e43068a3961eb935577d1ed4effb", - "0x0000000000000000000000000000000000000000000000000000000000000008", - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000004" - ] - } - ] - } - }); - let essence: EthereumTxEssence = serde_json::from_value(tx).unwrap(); - - let signature: TxSignature = serde_json::from_value(json!({ - "v": 1, - "r": "0xf86aa2dfde99b0d6a41741e96cfcdee0c6271febd63be4056911db19ae347e66", - "s": "0x601deefbc4835cb15aa1af84af6436fc692dea3428d53e7ff3d34a314cefe7fc" - })) - .unwrap(); - let transaction = EthereumTransaction { essence, signature }; - - // verify that bincode serialization works - let _: EthereumTransaction = - bincode::deserialize(&bincode::serialize(&transaction).unwrap()).unwrap(); - - assert_eq!( - transaction.hash(), - b256!("be4ef1a2244e99b1ef518aec10763b61360be22e3b649dcdf804103719b1faef") - ); - let recovered = transaction.recover_from().unwrap(); - assert_eq!( - recovered, - address!("79b7a69d90c82e014bf0315e164208119b510fa0") - ); - } - - #[test] - fn eip1559() { - // Tx: 0x2bcdc03343ca9c050f8dfd3c87f32db718c762ae889f56762d8d8bdb7c5d69ff - let tx = json!({ - "Eip1559": { - "chain_id": 1, - "nonce": 32, - "max_priority_fee_per_gas": "0x3b9aca00", - "max_fee_per_gas": "0x89d5f3200", - "gas_limit": "0x5b04", - "to": { "Call": "0xa9d1e08c7793af67e9d92fe308d5697fb81d3e43" }, - "value": "0x1dd1f234f68cde2", - "data": "0x", - "access_list": [] - } - }); - let essence: EthereumTxEssence = serde_json::from_value(tx).unwrap(); - - let signature: TxSignature = serde_json::from_value(json!({ - "v": 0, - "r": "0x2bdf47562da5f2a09f09cce70aed35ec9ac62f5377512b6a04cc427e0fda1f4d", - "s": "0x28f9311b515a5f17aa3ad5ea8bafaecfb0958801f01ca11fd593097b5087121b" - })) - .unwrap(); - let transaction = EthereumTransaction { essence, signature }; - - // verify that bincode serialization works - let _: EthereumTransaction = - bincode::deserialize(&bincode::serialize(&transaction).unwrap()).unwrap(); - - assert_eq!( - transaction.hash(), - b256!("2bcdc03343ca9c050f8dfd3c87f32db718c762ae889f56762d8d8bdb7c5d69ff") - ); - let recovered = transaction.recover_from().unwrap(); - assert_eq!( - recovered, - address!("4b9f4114d50e7907bff87728a060ce8d53bf4cf7") - ); - } -} diff --git a/primitives/src/transactions/mod.rs b/primitives/src/transactions/mod.rs index cab9746c..e953d967 100644 --- a/primitives/src/transactions/mod.rs +++ b/primitives/src/transactions/mod.rs @@ -11,197 +11,5 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. -use core::clone::Clone; -use alloy_primitives::{Address, Bytes, TxHash}; -use alloy_rlp::Encodable; -use serde::{Deserialize, Serialize}; - -use self::signature::TxSignature; -use crate::{keccak::keccak, transactions::ethereum::EthereumTxEssence, U256}; - -pub mod ethereum; pub mod signature; - -pub type EthereumTransaction = Transaction; - -/// Represents a complete transaction, encompassing its core essence and the associated -/// signature. -/// -/// The `Transaction` struct encapsulates both the core details of the transaction (the -/// essence) and its cryptographic signature. The signature ensures the authenticity and -/// integrity of the transaction, confirming it was issued by the rightful sender. -#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] -pub struct Transaction { - /// The core details of the transaction, which includes the data that is signed. - pub essence: E, - /// The cryptographic signature associated with the transaction, generated by signing - /// the transaction essence. - pub signature: TxSignature, -} - -/// Represents the core details of a [Transaction], specifically the portion that gets -/// signed. -pub trait TxEssence: Encodable + Clone { - /// Returns the EIP-2718 transaction type or `0x00` for Legacy transactions. - fn tx_type(&self) -> u8; - /// Returns the gas limit set for the transaction. - /// - /// The gas limit represents the maximum amount of gas units that the transaction - /// is allowed to consume. It ensures that transactions don't run indefinitely. - fn gas_limit(&self) -> U256; - /// Returns the recipient address of the transaction, if available. - /// - /// For contract creation transactions, this method returns `None` as there's no - /// recipient address. - fn to(&self) -> Option
; - /// Recovers the Ethereum address of the sender from the transaction's signature. - /// - /// This method uses the ECDSA recovery mechanism to derive the sender's public key - /// and subsequently their Ethereum address. If the recovery is unsuccessful, an - /// error is returned. - fn recover_from(&self, signature: &TxSignature) -> anyhow::Result
; - /// Returns the length of the RLP-encoding payload in bytes. - /// - /// This method calculates the combined length of all the individual fields - /// of the transaction when they are RLP-encoded. - fn payload_length(&self) -> usize; - /// Returns a reference to the transaction's call data - fn data(&self) -> &Bytes; -} - -/// Provides RLP encoding functionality for [Transaction]. -impl Encodable for Transaction { - /// Encodes the [Transaction] struct into the provided `out` buffer. - /// - /// The encoding process starts by prepending the EIP-2718 transaction type, if - /// applicable. It then joins the RLP lists of the transaction essence and the - /// signature into a single list. This approach optimizes the encoding process by - /// reusing as much of the generated RLP code as possible. - #[inline] - fn encode(&self, out: &mut dyn alloy_rlp::BufMut) { - let tx_type = self.essence.tx_type(); - // prepend the EIP-2718 transaction type for non-legacy transactions - if tx_type != 0 { - out.put_u8(tx_type); - } - - // join the essence lists and the signature list into one - // this allows to reuse as much of the generated RLP code as possible - rlp_join_lists(&self.essence, &self.signature, out); - } - - /// Computes the length of the RLP-encoded [Transaction] struct in bytes. - /// - /// The computed length includes the lengths of the encoded transaction essence and - /// signature. If the transaction type (as per EIP-2718) is not zero, an - /// additional byte is added to the length. - #[inline] - fn length(&self) -> usize { - let tx_type = self.essence.tx_type(); - let payload_length = self.essence.payload_length() + self.signature.payload_length(); - - let length = payload_length + alloy_rlp::length_of_length(payload_length); - // add the EIP-2718 transaction type for non-legacy transactions - if tx_type != 0 { - length + 1 - } else { - length - } - } -} - -impl Transaction { - /// Calculates the Keccak hash of the RLP-encoded transaction. - /// - /// This hash uniquely identifies the transaction on the Ethereum network. - #[inline] - pub fn hash(&self) -> TxHash { - keccak(alloy_rlp::encode(self)).into() - } - - /// Recovers the Ethereum address of the sender from the transaction's signature. - /// - /// This method uses the ECDSA recovery mechanism to derive the sender's public key - /// and subsequently their Ethereum address. If the recovery is unsuccessful, an - /// error is returned. - #[inline] - pub fn recover_from(&self) -> anyhow::Result
{ - self.essence.recover_from(&self.signature) - } -} - -/// Joins two RLP-encoded lists into a single RLP-encoded list. -/// -/// This function takes two RLP-encoded lists, decodes their headers to ensure they are -/// valid lists, and then combines their payloads into a single RLP-encoded list. The -/// resulting list is written to the provided `out` buffer. -/// -/// # Panics -/// -/// This function will panic if either `a` or `b` are not valid RLP-encoded lists. -fn rlp_join_lists(a: impl Encodable, b: impl Encodable, out: &mut dyn alloy_rlp::BufMut) { - let a_buf = alloy_rlp::encode(a); - let header = alloy_rlp::Header::decode(&mut &a_buf[..]).unwrap(); - if !header.list { - panic!("`a` not a list"); - } - let a_head_length = header.length(); - let a_payload_length = a_buf.len() - a_head_length; - - let b_buf = alloy_rlp::encode(b); - let header = alloy_rlp::Header::decode(&mut &b_buf[..]).unwrap(); - if !header.list { - panic!("`b` not a list"); - } - let b_head_length = header.length(); - let b_payload_length = b_buf.len() - b_head_length; - - alloy_rlp::Header { - list: true, - payload_length: a_payload_length + b_payload_length, - } - .encode(out); - out.put_slice(&a_buf[a_head_length..]); // skip the header - out.put_slice(&b_buf[b_head_length..]); // skip the header -} - -#[cfg(test)] -mod tests { - use serde_json::json; - - use super::*; - use crate::transactions::EthereumTransaction; - - #[test] - fn rlp_length() { - let tx = json!({ - "essence": { - "Legacy": { - "nonce": 537760, - "gas_price": "0x03c49bfa04", - "gas_limit": "0x019a28", - "to": { "Call": "0xf0ee707731d1be239f9f482e1b2ea5384c0c426f" }, - "value": "0x06df842eaa9fb800", - "data": "0x", - "chain_id": 1 - } - }, - "signature": { - "v": 38, - "r": "0xcadd790a37b78e5613c8cf44dc3002e3d7f06a5325d045963c708efe3f9fdf7a", - "s": "0x1f63adb9a2d5e020c6aa0ff64695e25d7d9a780ed8471abe716d2dc0bf7d4259" - } - }); - let transaction: EthereumTransaction = serde_json::from_value(tx).unwrap(); - - let encoded = alloy_rlp::encode(&transaction.essence); - assert_eq!(encoded.len(), transaction.essence.length()); - - let encoded = alloy_rlp::encode(&transaction.signature); - assert_eq!(encoded.len(), transaction.signature.length()); - - let encoded = alloy_rlp::encode(&transaction); - assert_eq!(encoded.len(), transaction.length()); - } -} diff --git a/raiko-guests/risc0/guest/src/main.rs b/raiko-guests/risc0/guest/src/main.rs index b08802ef..4776da56 100644 --- a/raiko-guests/risc0/guest/src/main.rs +++ b/raiko-guests/risc0/guest/src/main.rs @@ -5,14 +5,13 @@ risc0_zkvm::guest::entry!(main); use zeth_lib::{ builder::{BlockBuilderStrategy, TaikoStrategy}, input::{GuestInput, GuestOutput}, - EthereumTxEssence }; use zeth_lib::protocol_instance::assemble_protocol_instance; use zeth_lib::protocol_instance::EvidenceType; fn main(){ - let input: GuestInput = env::read(); + let input: GuestInput = env::read(); let build_result = TaikoStrategy::build_from(&input); // TODO: cherry-pick risc0 latest output diff --git a/raiko-guests/sgx/src/one_shot.rs b/raiko-guests/sgx/src/one_shot.rs index bbcda08b..c2009cec 100644 --- a/raiko-guests/sgx/src/one_shot.rs +++ b/raiko-guests/sgx/src/one_shot.rs @@ -19,7 +19,6 @@ use zeth_lib::{ protocol_instance::{assemble_protocol_instance, EvidenceType}, TaikoGuestInput, }, - EthereumTxEssence, }; use zeth_primitives::{Address, B256}; base64_serde_type!(Base64Standard, base64::engine::general_purpose::STANDARD); diff --git a/raiko-guests/succinct/src/main.rs b/raiko-guests/succinct/src/main.rs index e0b78816..75fc05f9 100644 --- a/raiko-guests/succinct/src/main.rs +++ b/raiko-guests/succinct/src/main.rs @@ -6,14 +6,13 @@ sp1_zkvm::entrypoint!(main); use zeth_lib::{ builder::{BlockBuilderStrategy, TaikoStrategy}, input::{GuestInput, GuestOutput}, - EthereumTxEssence }; use zeth_lib::protocol_instance::assemble_protocol_instance; use zeth_lib::protocol_instance::EvidenceType; pub fn main() { - let input = sp1_zkvm::io::read::>(); + let input = sp1_zkvm::io::read::(); let build_result = TaikoStrategy::build_from(&input); let output = match &build_result { diff --git a/raiko-host/Cargo.toml b/raiko-host/Cargo.toml index 503231d0..5bb6d32f 100644 --- a/raiko-host/Cargo.toml +++ b/raiko-host/Cargo.toml @@ -5,6 +5,8 @@ edition = "2021" [dependencies] anyhow = "1.0" +alloy-rlp = { version = "0.3", default-features = false } +alloy-rlp-derive = { version = "0.3", default-features = false } alloy-sol-types = { version = "0.6" } alloy-primitives = { version = "0.6", default-features = false } alloy-rpc-types = { git = "https://github.com/brechtpd/alloy", branch = "header-serialize" } diff --git a/raiko-host/src/host/host.rs b/raiko-host/src/host/host.rs index 1acd7554..9ef5a34f 100644 --- a/raiko-host/src/host/host.rs +++ b/raiko-host/src/host/host.rs @@ -1,36 +1,51 @@ use std::{path::PathBuf, sync::Arc}; -use alloy_sol_types::SolCall; -use alloy_rpc_types::{Block as AlloyBlock, BlockTransactions}; +use alloy_sol_types::{SolCall, SolEvent}; +use alloy_rpc_types::{Block as AlloyBlock, BlockTransactions, Filter, Transaction as AlloyRpcTransaction}; use alloy_providers::tmp::{HttpProvider, TempProvider}; use alloy_transport_http::Http; use c_kzg::{Blob, KzgCommitment}; use url::Url; -use anyhow::{anyhow, ensure, Context, Result}; -use ethers_core::types::{Transaction as EthersTransaction, U256}; +use anyhow::{anyhow, bail, Result}; use hashbrown::HashSet; use log::info; use reth_primitives::{constants::eip4844::MAINNET_KZG_TRUSTED_SETUP, eip4844::kzg_to_versioned_hash}; -use rlp::Rlp; use serde::{Deserialize, Serialize}; use zeth_lib::{ builder::{prepare::TaikoHeaderPrepStrategy, BlockBuilder, TkoTxExecStrategy}, input::{ - decode_propose_block_call_params, proposeBlockCall, BlockMetadata, GuestInput, - TaikoGuestInput, TaikoProverData, + decode_anchor, decode_propose_block_call_params, proposeBlockCall, protocol_testnet::BlockProposed as TestnetBlockProposed, BlockProposed, GuestInput, TaikoGuestInput, TaikoProverData }, - taiko_utils::{generate_transactions, generate_transactions_alloy, to_header}, -}; -use zeth_primitives::{ - ethers::{from_ethers_h160, from_ethers_h256, from_ethers_u256}, - mpt::proofs_to_tries, - transactions::ethereum::EthereumTxEssence, - Bytes, + taiko_utils::{generate_transactions_alloy, get_contracts, to_header}, }; +use zeth_primitives::mpt::proofs_to_tries; + +use super::provider::GetBlobsResponse; +use crate::host::{provider::GetBlobData, provider_db::ProviderDb}; + +pub use alloy_primitives::*; +pub use alloy_rlp as rlp; + +pub trait RlpBytes { + /// Returns the RLP-encoding. + fn to_rlp(&self) -> Vec; +} + +impl RlpBytes for T +where + T: rlp::Encodable, +{ + #[inline] + fn to_rlp(&self) -> Vec { + let rlp_length = self.length(); + let mut out = Vec::with_capacity(rlp_length); + self.encode(&mut out); + debug_assert_eq!(out.len(), rlp_length); + out + } +} -use super::provider::BlockQuery; -use crate::host::{provider::GetBlobData, provider_db::ProviderDb, taiko_provider::TaikoProvider}; #[derive(Debug, Clone, Serialize, Deserialize)] pub struct HostArgs { @@ -60,6 +75,77 @@ pub fn get_block_alloy(rpc_url: String, block_number: u64, full: bool) -> Result } } +pub fn get_log_alloy(rpc_url: String, chain_name: &str, block_hash: B256, l2_block_no: u64) -> Result<(AlloyRpcTransaction, BlockProposed)> { + let http = Http::new(Url::parse(&rpc_url).expect("invalid rpc url")); + let provider: HttpProvider = HttpProvider::new(http); + + + let l1_address = get_contracts(chain_name).unwrap().0; + + //info!("Querying RPC for full block: {query:?}"); + + let tokio_handle = tokio::runtime::Handle::current(); + + let event_signature = if chain_name == "testnet" { + TestnetBlockProposed::SIGNATURE_HASH + } else { + BlockProposed::SIGNATURE_HASH + }; + + let filter = Filter::new() + .address(l1_address) + .at_block_hash(block_hash) + .event_signature(event_signature); + + let logs = tokio_handle.block_on(async { + provider + .get_logs(filter) + .await + })?; + + for log in logs { + if chain_name == "testnet" { + let event = TestnetBlockProposed::decode_log(&Log::new(log.address, log.topics, log.data).unwrap(), false).unwrap(); + if event.blockId == zeth_primitives::U256::from(l2_block_no) { + let tx = tokio_handle.block_on(async { + provider + .get_transaction_by_hash(log.transaction_hash.unwrap()) + .await + }).expect("could not find the propose tx"); + return Ok((tx, event.data.into())); + } + } else { + let event = BlockProposed::decode_log(&Log::new(log.address, log.topics, log.data).unwrap(), false).unwrap(); + if event.blockId == zeth_primitives::U256::from(l2_block_no) { + let tx = tokio_handle.block_on(async { + provider + .get_transaction_by_hash(log.transaction_hash.unwrap()) + .await + }).expect("could not find the propose tx"); + return Ok((tx, event.data)); + } + } + } + bail!("No BlockProposed event found for block {l2_block_no}"); +} + +fn get_blob_data(beacon_rpc_url: &str, block_id: u64) -> Result { + let tokio_handle = tokio::runtime::Handle::current(); + tokio_handle.block_on(async { + let url = format!("{}/eth/v1/beacon/blob_sidecars/{}", beacon_rpc_url, block_id); + let response = reqwest::get(url.clone()).await?; + if response.status().is_success() { + let blob_response: GetBlobsResponse = response.json().await?; + Ok(blob_response) + } else { + Err(anyhow::anyhow!( + "Request failed with status code: {}", + response.status() + )) + } + }) +} + pub fn taiko_run_preflight( l1_rpc_url: Option, l2_rpc_url: Option, @@ -67,79 +153,50 @@ pub fn taiko_run_preflight( chain_spec_name: &str, prover_data: TaikoProverData, beacon_rpc_url: Option, -) -> Result> { - let mut tp = TaikoProvider::new( - None, - l1_rpc_url.clone(), - None, - l2_rpc_url.clone(), - beacon_rpc_url, - )?; - - // Fetch the parent block - /*let parent_block = tp.l2_provider.get_partial_block(&BlockQuery { - block_no: l2_block_no - 1, - })?; - - println!("parent_block: {:?}", parent_block); - - info!( - "Initial block: {:?} ({:?})", - parent_block.number.unwrap(), - parent_block.hash.unwrap() - ); - let parent_header: Header = parent_block.try_into().context("invalid parent block")?;*/ +) -> Result { + let http_l2 = Http::new(Url::parse(&l2_rpc_url.clone().unwrap()).expect("invalid rpc url")); + let provider_l2: HttpProvider = HttpProvider::new(http_l2); let parent_block = get_block_alloy(l2_rpc_url.clone().unwrap(), l2_block_no - 1, false).unwrap(); - println!("*** alloy parent block ***:{:?}", parent_block); + //println!("*** alloy parent block ***:{:?}", parent_block); let block_alloy = get_block_alloy(l2_rpc_url.clone().unwrap(), l2_block_no, true).unwrap(); - println!("*** alloy block ***:{:?}", block_alloy); + //println!("*** alloy block ***:{:?}", block_alloy); // Fetch the target block - let mut block_ethers = tp.l2_provider.get_full_block(&BlockQuery { - block_no: l2_block_no, - })?; - let (anchor_tx_ethers, anchor_call_ethers) = tp.get_anchor(&block_ethers)?; - let (anchor_tx_alloy, anchor_call_alloy) = tp.get_anchor_alloy(&block_alloy)?; + let anchor_tx_alloy = match &block_alloy.transactions { + BlockTransactions::Full(txs) => txs[0].to_owned(), + _ => unreachable!(), + }; + let anchor_call_alloy = decode_anchor(anchor_tx_alloy.input.as_ref())?; + println!("block.hash: {:?}", block_alloy.header.hash.unwrap()); println!("block.parent_hash: {:?}", block_alloy.header.parent_hash); - println!("block: {:?}", block_ethers); - println!("anchor L1 block id: {:?}", anchor_call_ethers.l1Height); - println!("anchor L1 state root: {:?}", anchor_call_ethers.l1SignalRoot); + println!("anchor L1 block id: {:?}", anchor_call_alloy.l1Height); + println!("anchor L1 state root: {:?}", anchor_call_alloy.l1SignalRoot); - let l1_state_block_no = anchor_call_ethers.l1Height; + let l1_state_block_no = anchor_call_alloy.l1Height; let l1_inclusion_block_no = l1_state_block_no + 1; println!("l1_state_block_no: {:?}", l1_state_block_no); let l1_state_root_block_alloy = get_block_alloy(l1_rpc_url.clone().unwrap(), l1_state_block_no, false).unwrap(); - println!("*** alloy block ***:{:?}", l1_state_root_block_alloy); + + let l1_inclusion_block_alloy = get_block_alloy(l1_rpc_url.clone().unwrap(), l1_inclusion_block_no, false).unwrap(); // Get the L1 state block header so that we can prove the L1 state root - // Fetch the parent block - /*let l1_state_root_block = tp.l1_provider.get_partial_block(&BlockQuery { - block_no: l1_state_block_no, - })?;*/ - // println!("l1_state_root_block: {:?}", l1_state_root_block); println!( "l1_state_root_block hash: {:?}", l1_state_root_block_alloy.header.hash.unwrap() ); - // let l1_propose_block = tp.l1_provider.get_partial_block(&BlockQuery { - // block_no: l1_inclusion_block_no, - // })?; - // println!("l1_propose_block: {:?}", l1_propose_block); - - // Get the block proposal data - let (proposal_tx, proposal_event) = - tp.get_proposal(l1_inclusion_block_no, l2_block_no, chain_spec_name)?; + let (proposal_tx_alloy, proposal_event_alloy) = + get_log_alloy(l1_rpc_url.clone().unwrap(), chain_spec_name, l1_inclusion_block_alloy.header.hash.unwrap(), l2_block_no)?; - println!("proposal: {:?}", proposal_event); + println!("proposal alloy: {:?}", proposal_event_alloy); - let proposal_call = proposeBlockCall::abi_decode(&proposal_tx.input, false).unwrap(); + let proposal_call = proposeBlockCall::abi_decode(&proposal_tx_alloy.input, false).unwrap(); // .with_context(|| "failed to decode propose block call")?; // blobUsed == (txList.length == 0) according to TaikoL1 @@ -150,20 +207,20 @@ pub fn taiko_run_preflight( .expect("valid propose_block_call_params"); println!("metadata: {:?}", metadata); - let blob_hashs = proposal_tx.blob_versioned_hashes.unwrap(); + let blob_hashs = proposal_tx_alloy.blob_versioned_hashes; // TODO: multiple blob hash support assert!(blob_hashs.len() == 1); let blob_hash = blob_hashs[0]; // TODO: check _proposed_blob_hash with blob_hash if _proposed_blob_hash is not None - let blobs = tp.l1_provider.get_blob_data(l1_inclusion_block_no)?; + let blobs = get_blob_data(&beacon_rpc_url.clone().unwrap(), l1_inclusion_block_no)?; assert!(blobs.data.len() > 0, "blob data not available anymore"); let tx_blobs: Vec = blobs .data .iter() .filter(|blob: &&GetBlobData| { // calculate from plain blob - blob_hash.as_fixed_bytes() == &calc_blob_versioned_hash(&blob.blob) + blob_hash == &calc_blob_versioned_hash(&blob.blob) }) .cloned() .collect::>(); @@ -172,18 +229,16 @@ pub fn taiko_run_preflight( let size = metadata.txListByteSize as usize; ( blob_data.as_slice()[offset..(offset + size)].to_vec(), - Some(from_ethers_h256(blob_hash)), + Some(blob_hash), ) } else { (proposal_call.txList.clone(), None) }; - println!("tx_list: {:?}", tx_list); + //println!("tx_list: {:?}", tx_list); // Create the transactions for the proposed tx list - let transactions_ethers: Vec = generate_transactions(&tx_list, anchor_tx_ethers.clone()); let transactions_alloy = generate_transactions_alloy(&tx_list, anchor_tx_alloy.clone()); - assert!(transactions_ethers.len() == transactions_alloy.len()); println!("Block valid transactions: {:?}", block_alloy.transactions.len()); assert!( @@ -191,9 +246,6 @@ pub fn taiko_run_preflight( "unexpected number of transactions" ); - // Set the original transactions on the block - //block_alloy.transactions = BlockTransactions::default(); - info!( "Final block number: {:?} ({:?})", block_alloy.header.number.unwrap(), @@ -205,25 +257,12 @@ pub fn taiko_run_preflight( chain_spec_name: chain_spec_name.to_string(), l1_header: to_header(&l1_state_root_block_alloy.header), tx_list, - anchor_tx: Some(anchor_tx_ethers.try_into().unwrap()), anchor_tx_alloy: serde_json::to_string(&anchor_tx_alloy).unwrap(), tx_blob_hash, - block_proposed: proposal_event, + block_proposed: proposal_event_alloy.into(), prover_data, }; - // convert each withdrawal - let withdrawals = block_ethers - .withdrawals - .unwrap_or_default() - .into_iter() - .enumerate() - .map(|(i, tx)| { - tx.try_into() - .with_context(|| format!("withdrawal {i} invalid")) - }) - .collect::, _>>()?; - // Create the input struct without the block data set let input = GuestInput { block_hash: block_alloy.header.hash.unwrap().0.try_into().unwrap(), @@ -232,8 +271,7 @@ pub fn taiko_run_preflight( timestamp: block_alloy.header.timestamp.try_into().unwrap(), extra_data: block_alloy.header.extra_data.0.into(), mix_hash: block_alloy.header.mix_hash.unwrap(), - transactions: Vec::new(), - withdrawals, + withdrawals: block_alloy.withdrawals.unwrap_or_default(), parent_state_trie: Default::default(), parent_storage: Default::default(), contracts: Default::default(), @@ -244,7 +282,7 @@ pub fn taiko_run_preflight( }; // Create the provider DB - let provider_db = ProviderDb::new(tp.l2_provider, parent_block.header.number.unwrap().try_into().unwrap()); + let provider_db = ProviderDb::new(provider_l2, parent_block.header.number.unwrap().try_into().unwrap()); println!("execute block"); @@ -277,11 +315,6 @@ pub fn taiko_run_preflight( } } - info!("Saving provider cache ..."); - - // Save the provider cache - // tp.save()?; - info!("Provider-backed execution is Done!"); Ok(GuestInput { @@ -300,8 +333,8 @@ const BLOB_DATA_LEN: usize = BLOB_FIELD_ELEMENT_NUM * BLOB_FIELD_ELEMENT_BYTES; fn decode_blob_data(blob: &str) -> Vec { let origin_blob = hex::decode(blob.to_lowercase().trim_start_matches("0x")).unwrap(); - let header: U256 = U256::from_big_endian(&origin_blob[0..BLOB_FIELD_ELEMENT_BYTES]); // first element is the length - let expected_len = header.as_usize(); + let header: U256 = U256::from_be_bytes::(origin_blob[0..BLOB_FIELD_ELEMENT_BYTES].try_into().unwrap()); // first element is the length + let expected_len = header.as_limbs()[0] as usize; assert!(origin_blob.len() == BLOB_DATA_LEN); // the first 32 bytes is the length of the blob diff --git a/raiko-host/src/host/mod.rs b/raiko-host/src/host/mod.rs index 6a80018d..e2faf174 100644 --- a/raiko-host/src/host/mod.rs +++ b/raiko-host/src/host/mod.rs @@ -15,5 +15,4 @@ extern crate std; pub mod host; pub mod provider; -pub mod provider_db; -pub mod taiko_provider; +pub mod provider_db; \ No newline at end of file diff --git a/raiko-host/src/host/provider/mod.rs b/raiko-host/src/host/provider/mod.rs index 03d9caeb..25a1eeea 100644 --- a/raiko-host/src/host/provider/mod.rs +++ b/raiko-host/src/host/provider/mod.rs @@ -165,80 +165,3 @@ pub fn new_provider( (None, None) => Err(anyhow!("No cache_path or rpc_url given")), } } - -impl dyn Provider { - pub fn filter_event_log( - &mut self, - l1_contract: Address, - l1_block_no: u64, - _l2_block_no: u64, - ) -> Result> { - use alloy_sol_types::TopicList; - use zeth_primitives::ethers::from_ethers_h256; - - let logs = self.get_logs(&LogsQuery { - address: l1_contract.into_array().into(), - from_block: l1_block_no, - to_block: l1_block_no, - })?; - let res = logs - .iter() - .filter(|log| log.topics.len() == <::TopicList as TopicList>::COUNT) - .filter(|log| from_ethers_h256(log.topics[0]) == E::SIGNATURE_HASH) - .map(|log| { - let topics = log.topics.iter().map(|topic| from_ethers_h256(*topic)); - let event = E::decode_raw_log(topics, &log.data, false) - .unwrap_or_else(|_| panic!("Decode log failed for l1_block_no {l1_block_no}")); - (log.clone(), event) - }) - .collect::>(); - - Ok(res) - } - - #[allow(dead_code)] - fn filter_block_proposal( - &mut self, - l1_contract: H160, - l1_block_no: u64, - l2_block_no: u64, - ) -> Result<(Transaction, BlockProposed)> { - use alloy_sol_types::TopicList; - use zeth_primitives::ethers::from_ethers_h256; - - let logs = self.get_logs(&LogsQuery { - address: l1_contract, - from_block: l1_block_no, - to_block: l1_block_no, - })?; - let mut res = logs - .iter() - .filter(|log| { - log.topics.len() == <::TopicList as TopicList>::COUNT - }) - .filter(|log| from_ethers_h256(log.topics[0]) == BlockProposed::SIGNATURE_HASH) - .map(|log| { - let topics = log.topics.iter().map(|topic| from_ethers_h256(*topic)); - let block_proposed = BlockProposed::decode_raw_log(topics, &log.data, false) - .unwrap_or_else(|_| panic!("Decode log failed for l1_block_no {l1_block_no}")); - (log.block_number, log.transaction_hash, block_proposed) - }) - .filter(|(_block_no, _tx_hash, event)| { - event.blockId == revm::primitives::U256::from(l2_block_no) - }) - .collect::>(); - - let (block_no, tx_hash, event) = res - .pop() - .with_context(|| anyhow!("Cannot find BlockProposed event for {l2_block_no}"))?; - - let tx = self - .get_transaction(&TxQuery { - tx_hash: tx_hash.unwrap(), - block_no: block_no.map(|b| b.as_u64()), - }) - .with_context(|| anyhow!("Cannot find BlockProposed Tx {tx_hash:?}"))?; - - Ok((tx, event)) - } -} diff --git a/raiko-host/src/host/provider_db.rs b/raiko-host/src/host/provider_db.rs index 4f46da12..d3a5819d 100644 --- a/raiko-host/src/host/provider_db.rs +++ b/raiko-host/src/host/provider_db.rs @@ -11,93 +11,77 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. -use std::collections::BTreeSet; - -use alloy_rpc_types::EIP1186AccountProofResponse; -use ethers_core::types::{H160, H256}; +use alloy_rpc_types::{BlockId, EIP1186AccountProofResponse}; use hashbrown::HashMap; use revm::{ primitives::{Account, AccountInfo, Bytecode}, Database, DatabaseCommit, }; +use tokio::runtime::Handle; use zeth_lib::{taiko_utils::to_header, mem_db::{DbError, MemDb}}; use zeth_primitives::{ - ethers::{from_ethers_bytes, from_ethers_u256}, Address, B256, U256, }; -use alloy_rpc_types::Header as AlloyHeader; use alloy_consensus::Header as AlloyConsensusHeader; use crate::host::host::get_block_alloy; - -use super::provider::{AccountQuery, BlockQuery, ProofQuery, Provider, StorageQuery}; +use alloy_providers::tmp::{HttpProvider, TempProvider}; pub struct ProviderDb { - pub provider: Box, - pub block_no: u64, + pub provider: HttpProvider, + pub block_number: u64, pub initial_db: MemDb, - pub latest_db: MemDb, + pub current_db: MemDb, + async_executor: Handle, } impl ProviderDb { - pub fn new(provider: Box, block_no: u64) -> Self { + pub fn new(provider: HttpProvider, block_number: u64) -> Self { ProviderDb { provider, - block_no, + block_number, initial_db: MemDb::default(), - latest_db: MemDb::default(), + current_db: MemDb::default(), + async_executor: tokio::runtime::Handle::current(), } } - pub fn get_provider(&self) -> &dyn Provider { - self.provider.as_ref() - } - pub fn get_initial_db(&self) -> &MemDb { &self.initial_db } pub fn get_latest_db(&self) -> &MemDb { - &self.latest_db + &self.current_db } fn get_proofs( &mut self, - block_no: u64, + block_number: u64, storage_keys: HashMap>, ) -> Result, anyhow::Error> { - let mut out = HashMap::new(); - - for (address, indices) in storage_keys { - let proof = { - let address: H160 = address.into_array().into(); - let indices: BTreeSet = indices - .into_iter() - .map(|x| x.to_be_bytes().into()) - .collect(); - self.provider.get_proof(&ProofQuery { - block_no, - address, - indices, - })? - }; - out.insert(address, proof); + let mut storage_proofs = HashMap::new(); + for (address, keys) in storage_keys { + let indices = keys.into_iter().map(|x| x.to_be_bytes().into()).collect(); + let proof = self.async_executor.block_on(async { + self.provider + .get_proof(address, indices, Some(BlockId::from(block_number))) + .await + })?; + storage_proofs.insert(address, proof); } - - Ok(out) + Ok(storage_proofs) } pub fn get_initial_proofs( &mut self, ) -> Result, anyhow::Error> { - self.get_proofs(self.block_no, self.initial_db.storage_keys()) + self.get_proofs(self.block_number, self.initial_db.storage_keys()) } pub fn get_latest_proofs( &mut self, ) -> Result, anyhow::Error> { let mut storage_keys = self.initial_db.storage_keys(); - - for (address, mut indices) in self.latest_db.storage_keys() { + for (address, mut indices) in self.current_db.storage_keys() { match storage_keys.get_mut(&address) { Some(initial_indices) => initial_indices.append(&mut indices), None => { @@ -105,8 +89,7 @@ impl ProviderDb { } } } - - self.get_proofs(self.block_no + 1, storage_keys) + self.get_proofs(self.block_number + 1, storage_keys) } pub fn get_ancestor_headers(&mut self, rpc_url: String) -> Result, anyhow::Error> { @@ -115,8 +98,8 @@ impl ProviderDb { .block_hashes .keys() .min() - .unwrap_or(&self.block_no); - let headers = (*earliest_block..self.block_no) + .unwrap_or(&self.block_number); + let headers = (*earliest_block..self.block_number) .rev() .map(|block_no| { to_header(&get_block_alloy(rpc_url.clone(), block_no, false).unwrap().header) @@ -130,100 +113,100 @@ impl Database for ProviderDb { type Error = anyhow::Error; fn basic(&mut self, address: Address) -> Result, Self::Error> { - match self.latest_db.basic(address) { - Ok(db_result) => return Ok(db_result), - Err(DbError::AccountNotFound(_)) => {} - Err(err) => return Err(err.into()), + // Check if the account is in the current database. + if let Ok(db_result) = self.current_db.basic(address) { + return Ok(db_result); } - match self.initial_db.basic(address) { - Ok(db_result) => return Ok(db_result), - Err(DbError::AccountNotFound(_)) => {} - Err(err) => return Err(err.into()), + if let Ok(db_result) = self.initial_db.basic(address) { + return Ok(db_result); } - let account_info = { - let query = AccountQuery { - block_no: self.block_no, - address: address.into_array().into(), - }; - let nonce = self.provider.get_transaction_count(&query)?; - let balance = self.provider.get_balance(&query)?; - let code = self.provider.get_code(&query)?; - let bytecode = Bytecode::new_raw(from_ethers_bytes(code)); - - AccountInfo::new( - from_ethers_u256(balance), - nonce.as_u64(), - bytecode.hash_slow(), - bytecode, - ) - }; - + // Get the nonce, balance, and code to reconstruct the account. + let nonce = self.async_executor.block_on(async { + self.provider + .get_transaction_count(address, Some(BlockId::from(self.block_number))) + .await + })?; + let balance = self.async_executor.block_on(async { + self.provider + .get_balance(address, Some(BlockId::from(self.block_number))) + .await + })?; + let code = self.async_executor.block_on(async { + self.provider + .get_code_at(address, Some(BlockId::from(self.block_number))) + .await + })?; + + // Insert the account into the initial database. + let account_info = AccountInfo::new( + balance, + nonce.try_into().unwrap(), + Bytecode::new_raw(code.clone()).hash_slow(), + Bytecode::new_raw(code), + ); self.initial_db .insert_account_info(address, account_info.clone()); Ok(Some(account_info)) } - fn code_by_hash(&mut self, _code_hash: B256) -> Result { - // not needed because we already load code with basic info - unreachable!() - } - fn storage(&mut self, address: Address, index: U256) -> Result { - match self.latest_db.storage(address, index) { - Ok(db_result) => return Ok(db_result), - Err(DbError::AccountNotFound(_)) | Err(DbError::SlotNotFound(_, _)) => {} - Err(err) => return Err(err.into()), + // Check if the storage slot is in the current database. + if let Ok(db_result) = self.current_db.storage(address, index) { + return Ok(db_result); } - match self.initial_db.storage(address, index) { - Ok(db_result) => return Ok(db_result), - Err(DbError::AccountNotFound(_)) | Err(DbError::SlotNotFound(_, _)) => {} - Err(err) => return Err(err.into()), + if let Ok(db_result) = self.initial_db.storage(address, index) { + return Ok(db_result); } - // ensure that the corresponding account is loaded + // Get the storage slot from the provider. self.initial_db.basic(address)?; - - let storage = { - let bytes = index.to_be_bytes(); - let index = H256::from(bytes); - - let storage = self.provider.get_storage(&StorageQuery { - block_no: self.block_no, - address: address.into_array().into(), - index, - })?; - U256::from_be_bytes(storage.to_fixed_bytes()) - }; - + let storage = self.async_executor.block_on(async { + self.provider + .get_storage_at( + address.into_array().into(), + index, + Some(BlockId::from(self.block_number)), + ) + .await + })?; self.initial_db .insert_account_storage(&address, index, storage); Ok(storage) } fn block_hash(&mut self, number: U256) -> Result { - match self.initial_db.block_hash(number) { - Ok(block_hash) => return Ok(block_hash), - Err(DbError::BlockNotFound(_)) => {} - Err(err) => return Err(err.into()), + // Check if the block hash is in the current database. + if let Ok(block_hash) = self.initial_db.block_hash(number) { + return Ok(block_hash); } - let block_no = u64::try_from(number).unwrap(); - let block_hash = self - .provider - .get_partial_block(&BlockQuery { block_no })? - .hash - .unwrap() - .0 - .into(); - - self.initial_db.insert_block_hash(block_no, block_hash); + // Get the block hash from the provider. + let block_number = u64::try_from(number).unwrap(); + let block_hash = self.async_executor.block_on(async { + self.provider + .get_block_by_number(block_number.into(), false) + .await + .unwrap() + .unwrap() + .header + .hash + .unwrap() + .0 + .into() + }); + self.initial_db + .insert_block_hash(block_number, block_hash); Ok(block_hash) } + + fn code_by_hash(&mut self, _code_hash: B256) -> Result { + unreachable!() + } } impl DatabaseCommit for ProviderDb { fn commit(&mut self, changes: HashMap) { - self.latest_db.commit(changes) + self.current_db.commit(changes) } } diff --git a/raiko-host/src/host/taiko_provider.rs b/raiko-host/src/host/taiko_provider.rs deleted file mode 100644 index 21d64a99..00000000 --- a/raiko-host/src/host/taiko_provider.rs +++ /dev/null @@ -1,109 +0,0 @@ -use std::path::PathBuf; - -use alloy_rpc_types::{Block as AlloyBlock, BlockTransactions, Transaction as AlloyTransaction}; -use anyhow::{anyhow, bail, Context, Result}; -use ethers_core::types::{Block, Transaction}; -use zeth_lib::{ - input::{ - anchorCall, decode_anchor, protocol_testnet::BlockProposed as TestnetBlockProposed, - BlockProposed, - }, - taiko_utils::get_contracts, -}; - -use crate::host::provider::{new_provider, BlockQuery, Provider, TxQuery}; - -pub struct TaikoProvider { - pub l1_provider: Box, - pub l2_provider: Box, -} - -impl TaikoProvider { - pub fn new( - l1_cache: Option, - l1_rpc: Option, - l2_cache: Option, - l2_rpc: Option, - beacon_rpc_url: Option, - ) -> Result { - Ok(Self { - l1_provider: new_provider(None, l1_rpc, beacon_rpc_url.clone())?, - l2_provider: new_provider(None, l2_rpc, beacon_rpc_url)?, - }) - } - - pub fn save(&mut self) -> Result<()> { - self.l1_provider.save()?; - self.l2_provider.save()?; - Ok(()) - } - - pub fn get_l1_full_block(&mut self, l1_block_no: u64) -> Result> { - self.l1_provider.get_full_block(&BlockQuery { - block_no: l1_block_no, - }) - } - - pub fn get_l2_full_block(&mut self, l2_block_no: u64) -> Result> { - self.l2_provider.get_full_block(&BlockQuery { - block_no: l2_block_no, - }) - } - - pub fn get_anchor(&self, l2_block: &Block) -> Result<(Transaction, anchorCall)> { - let tx = l2_block.transactions[0].clone(); - let call = decode_anchor(tx.input.as_ref())?; - Ok((tx, call)) - } - - pub fn get_anchor_alloy(&self, block: &AlloyBlock) -> Result<(AlloyTransaction, anchorCall)> { - let anchor_tx = match &block.transactions { - BlockTransactions::Full(txs) => txs[0].to_owned(), - _ => unreachable!(), - }; - let call = decode_anchor(anchor_tx.input.as_ref())?; - Ok((anchor_tx, call)) - } - - pub fn get_proposal( - &mut self, - l1_block_no: u64, - l2_block_no: u64, - chain_name: &str, - ) -> Result<(Transaction, BlockProposed)> { - let l1_address = get_contracts(chain_name).unwrap().0; - - let logs = if chain_name == "testnet" { - self.l1_provider - .filter_event_log::(l1_address, l1_block_no, l2_block_no)? - .iter() - .map(|(log, event)| (log.clone(), event.clone().into())) - .collect() - } else { - self.l1_provider.filter_event_log::( - l1_address, - l1_block_no, - l2_block_no, - )? - }; - - for (log, event) in logs { - if event.blockId == zeth_primitives::U256::from(l2_block_no) { - let tx = self - .l1_provider - .get_transaction(&TxQuery { - tx_hash: log.transaction_hash.unwrap(), - block_no: log.block_number.map(|b| b.as_u64()), - }) - .with_context(|| { - anyhow!( - "Cannot find BlockProposed Tx {:?}", - log.transaction_hash.unwrap() - ) - })?; - return Ok((tx, event)); - } - } - bail!("No BlockProposed event found for block {l2_block_no}"); - } -} diff --git a/raiko-host/src/prover/execution.rs b/raiko-host/src/prover/execution.rs index fcaa918d..a689fc54 100644 --- a/raiko-host/src/prover/execution.rs +++ b/raiko-host/src/prover/execution.rs @@ -5,7 +5,6 @@ use zeth_lib::{ builder::{BlockBuilderStrategy, TaikoStrategy}, input::{GuestInput, GuestOutput, TaikoProverData}, protocol_instance::{assemble_protocol_instance, EvidenceType}, - EthereumTxEssence, taiko_utils::HeaderHasher, }; use zeth_primitives::Address; @@ -139,7 +138,7 @@ pub async fn execute( pub async fn prepare_input( ctx: &mut Context, req: ProofRequest, -) -> Result> { +) -> Result { // Todo(Cecilia): should contract address as args, curently hardcode let l1_cache = ctx.l1_cache_file.clone(); let l2_cache = ctx.l2_cache_file.clone(); @@ -155,7 +154,7 @@ pub async fn prepare_input( }, Some(req.beacon_rpc), ) - .expect("Init taiko failed") + .expect("Failed to fetch required data for block") }) .await .map_err(Into::::into) diff --git a/raiko-host/src/prover/proof/mod.rs b/raiko-host/src/prover/proof/mod.rs index 99fd9c25..6446eccb 100644 --- a/raiko-host/src/prover/proof/mod.rs +++ b/raiko-host/src/prover/proof/mod.rs @@ -1,7 +1,6 @@ //! Generate different proofs for the taiko protocol. use zeth_lib::{ input::{GuestInput, GuestOutput}, - EthereumTxEssence, }; use crate::prover::{ @@ -51,7 +50,7 @@ pub mod succinct { use super::*; use crate::prover::request::SP1Response; pub async fn execute_sp1( - input: GuestInput, + input: GuestInput, output: GuestOutput, ctx: &mut Context, req: &ProofRequest, @@ -67,7 +66,7 @@ pub mod risc0 { use super::*; use crate::prover::request::{Risc0ProofParams, Risc0Response}; pub async fn execute_risc0( - input: GuestInput, + input: GuestInput, output: GuestOutput, ctx: &Context, req: &Risc0ProofParams, diff --git a/raiko-host/src/prover/proof/risc0/mod.rs b/raiko-host/src/prover/proof/risc0/mod.rs index 2ebd6b5d..1e224bb7 100644 --- a/raiko-host/src/prover/proof/risc0/mod.rs +++ b/raiko-host/src/prover/proof/risc0/mod.rs @@ -9,7 +9,6 @@ use serde::{Deserialize, Serialize}; use tracing::info as traicing_info; use zeth_lib::{ input::{GuestInput, GuestOutput}, - EthereumTxEssence, }; use crate::prover::{ @@ -24,14 +23,14 @@ use crate::prover::{ // const RISC0_GUEST_ID: [u32; 8] = [1,2,3,4,5,6,7,8]; pub async fn execute_risc0( - input: GuestInput, + input: GuestInput, output: GuestOutput, ctx: &Context, req: &Risc0ProofParams, ) -> Result { println!("elf code length: {}", RISC0_METHODS_ELF.len()); - let result = maybe_prove::, GuestOutput>( + let result = maybe_prove::( req, &input, RISC0_METHODS_ELF, diff --git a/raiko-host/src/prover/proof/succinct.rs b/raiko-host/src/prover/proof/succinct.rs index 4e2ba52c..8f01139d 100644 --- a/raiko-host/src/prover/proof/succinct.rs +++ b/raiko-host/src/prover/proof/succinct.rs @@ -5,7 +5,6 @@ use serde::{Deserialize, Serialize}; use sp1_core::{utils, SP1Prover, SP1Stdin, SP1Verifier}; use zeth_lib::{ input::{GuestInput, GuestOutput}, - EthereumTxEssence, }; use crate::prover::{ @@ -19,7 +18,7 @@ const ELF: &[u8] = include_bytes!("../../../../raiko-guests/succinct/elf/riscv32im-succinct-zkvm-elf"); pub async fn execute_sp1( - input: GuestInput, + input: GuestInput, output: GuestOutput, ctx: &mut Context, req: &ProofRequest, From 14173bc7fe6f041994c3b5ec3775e65646c36775 Mon Sep 17 00:00:00 2001 From: brechtpd Date: Mon, 18 Mar 2024 00:08:46 +0000 Subject: [PATCH 04/10] some more code cleanup and removing --- lib/src/builder/execute/taiko.rs | 138 ++++------------------- lib/src/input.rs | 2 +- lib/src/taiko_utils.rs | 5 +- primitives/src/lib.rs | 3 +- primitives/src/signature.rs | 90 +++++++++++++++ primitives/src/transactions/mod.rs | 15 --- primitives/src/transactions/signature.rs | 46 -------- primitives/src/withdrawal.rs | 40 ------- raiko-host/src/host/host.rs | 131 ++++++++------------- raiko-host/src/host/provider_db.rs | 6 +- raiko-host/src/prover/execution.rs | 4 +- 11 files changed, 170 insertions(+), 310 deletions(-) create mode 100644 primitives/src/signature.rs delete mode 100644 primitives/src/transactions/mod.rs delete mode 100644 primitives/src/transactions/signature.rs delete mode 100644 primitives/src/withdrawal.rs diff --git a/lib/src/builder/execute/taiko.rs b/lib/src/builder/execute/taiko.rs index 0b17bb2d..99b6b6fd 100644 --- a/lib/src/builder/execute/taiko.rs +++ b/lib/src/builder/execute/taiko.rs @@ -36,7 +36,7 @@ use zeth_primitives::{ }; use super::TxExecStrategy; -use crate::taiko_utils::generate_transactions_alloy; +use crate::taiko_utils::generate_transactions; use crate::{ builder::BlockBuilder, consts::{self, ChainSpec, GWEI_TO_WEI}, @@ -69,29 +69,11 @@ impl TxExecStrategy for TkoTxExecStrategy { let chain_id = block_builder.chain_spec.chain_id(); // generate the transactions from the tx list - let mut transactions = generate_transactions_alloy( + let mut transactions = generate_transactions( &block_builder.input.taiko.tx_list, - serde_json::from_str(&block_builder.input.taiko.anchor_tx_alloy.clone()).unwrap(), + serde_json::from_str(&block_builder.input.taiko.anchor_tx.clone()).unwrap(), ); - #[cfg(feature = "std")] - { - use chrono::{TimeZone, Utc}; - use log::info; - let dt = Utc - .timestamp_opt(block_builder.input.timestamp.try_into().unwrap(), 0) - .unwrap(); - - info!("Block no. {}", header.number); - info!(" EVM spec ID: {spec_id:?}"); - info!(" Timestamp: {dt}"); - info!(" Transactions: {}", transactions.len()); - info!(" Fee Recipient: {:?}", block_builder.input.beneficiary); - info!(" Gas limit: {}", block_builder.input.gas_limit); - info!(" Base fee per gas: {}", header.base_fee_per_gas.unwrap()); - info!(" Extra data: {:?}", block_builder.input.extra_data); - } - let mut evm = Evm::builder() .spec_id(spec_id) .modify_cfg_env(|cfg_env| { @@ -124,48 +106,28 @@ impl TxExecStrategy for TkoTxExecStrategy { // track the actual tx number to use in the tx/receipt trees as the key let mut actual_tx_no = 0usize; for (tx_no, tx) in take(&mut transactions).into_iter().enumerate() { - // anchor transaction must be executed successfully + // anchor transaction always the first transaction let is_anchor = tx_no == 0; - let (tx_gas_limit, tx_hash) = match &tx { - TxEnvelope::Legacy(tx) => { - (tx.gas_limit, tx.hash()) - } - TxEnvelope::TaggedLegacy(tx) => { - (tx.gas_limit, tx.hash()) - } - TxEnvelope::Eip2930(tx) => { - (tx.gas_limit, tx.hash()) - } - TxEnvelope::Eip1559(tx) => { - (tx.gas_limit, tx.hash()) - } - TxEnvelope::Eip4844(tx) => { - (tx.tx().tx().gas_limit, tx.hash()) - } - }; - println!("**** hash: {:?}", tx_hash); - - let from = match &tx { + // TODO(Brecht): use optimized recover + let (tx_gas_limit, from) = match &tx { TxEnvelope::Legacy(tx) => { - tx.recover_signer() + (tx.gas_limit, tx.recover_signer()) } TxEnvelope::TaggedLegacy(tx) => { - tx.recover_signer() + (tx.gas_limit, tx.recover_signer()) } TxEnvelope::Eip2930(tx) => { - tx.recover_signer() + (tx.gas_limit, tx.recover_signer()) } TxEnvelope::Eip1559(tx) => { - tx.recover_signer() + (tx.gas_limit, tx.recover_signer()) } TxEnvelope::Eip4844(tx) => { - tx.recover_signer() + (tx.tx().tx().gas_limit, tx.recover_signer()) } }; - println!("**** from: {:?}", from); - let tx_type = match tx.tx_type() { alloy_consensus::TxType::Legacy => 0, alloy_consensus::TxType::Eip2930 => 1, @@ -173,8 +135,6 @@ impl TxExecStrategy for TkoTxExecStrategy { alloy_consensus::TxType::Eip4844 => 3, }; - //println!("**** tx_type: {:?}", tx_type); - // verify the transaction signature let tx_from = match from { Ok(tx_from) => tx_from, @@ -193,7 +153,6 @@ impl TxExecStrategy for TkoTxExecStrategy { }; // verify the anchor tx - // TODO(Brecht): reenable with alloy tx if is_anchor { check_anchor_tx( &block_builder.input, @@ -204,19 +163,15 @@ impl TxExecStrategy for TkoTxExecStrategy { .expect("invalid anchor tx"); } - #[cfg(feature = "std")] - { - //let tx_hash = tx.hash(); - debug!("Tx no. {tx_no} (hash: {tx_hash})"); - debug!(" Type: {}", tx_type); - debug!(" Fr: {tx_from:?}"); - //debug!(" To: {:?}", tx.to().unwrap_or_default()); - } - // verify transaction gas let block_available_gas = block_builder.input.gas_limit - cumulative_gas_used; if block_available_gas < tx_gas_limit.try_into().unwrap() { - bail!("Error at transaction {tx_no}: gas exceeds block limit"); + if is_anchor { + bail!("Error at transaction {}: gas exceeds block limit", tx_no); + } + #[cfg(not(target_os = "zkvm"))] + debug!("Error at transaction {}: gas exceeds block limit", tx_no); + continue; } // setup the transaction @@ -274,34 +229,6 @@ impl TxExecStrategy for TkoTxExecStrategy { result.logs().into_iter().map(|log| log.into()).collect(), ); - // update account states - #[cfg(feature = "std")] - for (address, account) in &state { - if account.is_touched() { - // log account - debug!( - " State {address:?} (is_selfdestructed={}, is_loaded_as_not_existing={}, is_created={})", - account.is_selfdestructed(), - account.is_loaded_as_not_existing(), - account.is_created() - ); - // log balance changes - debug!( - " After balance: {} (Nonce: {})", - account.info.balance, account.info.nonce - ); - - // log state changes - for (addr, slot) in &account.storage { - if slot.is_changed() { - debug!(" Storage address: {addr:?}"); - debug!(" Before: {:?}", slot.original_value()); - debug!(" After: {:?}", slot.present_value()); - } - } - } - } - // update the state evm.context.evm.db.commit(state); @@ -310,26 +237,15 @@ impl TxExecStrategy for TkoTxExecStrategy { // Add receipt and tx to tries let trie_key = actual_tx_no.to_rlp(); - - //tx_trie.insert_rlp(&trie_key, tx)?; - - //if is_anchor { + // This will encode the tx inside an rlp value wrapper let tx_rlp = tx.to_rlp(); - tx_trie.insert_rlp_encoded(&trie_key, tx_rlp[tx_rlp.len() - tx.inner_length() - 1..].to_vec())?; - //} else { - // tx_trie.insert_rlp(&trie_key, tx)?; - //}; - - //println!("ethers: {:?}", transactions_ether[tx_no].to_rlp()); - //println!("alloy: {:?}", tx.to_rlp()); - //let mut buf = vec![]; - //tx.encode(&mut buf); - //println!("alloy: {:?}", buf); - //println!("alloy inner length: {:?}", tx.inner_length()); - //println!("alloy length: {:?}", tx.length()); - //println!("fixed: {:?}", tx_rlp[tx_rlp.len() - tx.inner_length() - 1..].to_vec()); - + // Extract the actual tx rlp encoding + let tx_rlp = tx_rlp[tx_rlp.len() - tx.inner_length() - 1..].to_vec(); + tx_trie.insert_rlp_encoded(&trie_key, tx_rlp)?; + // Add to receipt trie receipt_trie.insert_rlp(&trie_key, receipt)?; + + // If we got here it means the tx is not invalid actual_tx_no += 1; } @@ -346,12 +262,6 @@ impl TxExecStrategy for TkoTxExecStrategy { .checked_mul(withdrawal.amount.try_into().unwrap()) .unwrap(); - #[cfg(not(target_os = "zkvm"))] - { - debug!("Withdrawal no. {}", withdrawal.index); - debug!(" Recipient: {:?}", withdrawal.address); - debug!(" Value: {}", amount_wei); - } // Credit withdrawal amount increase_account_balance(&mut db, withdrawal.address, amount_wei)?; // Add withdrawal to trie diff --git a/lib/src/input.rs b/lib/src/input.rs index 3912ceb3..3c1a9b5f 100644 --- a/lib/src/input.rs +++ b/lib/src/input.rs @@ -70,7 +70,7 @@ pub struct TaikoGuestInput { pub chain_spec_name: String, pub l1_header: AlloyConsensusHeader, pub tx_list: Vec, - pub anchor_tx_alloy: String, + pub anchor_tx: String, pub block_proposed: BlockProposed, pub prover_data: TaikoProverData, pub tx_blob_hash: Option, diff --git a/lib/src/taiko_utils.rs b/lib/src/taiko_utils.rs index d7d07f40..843ef368 100644 --- a/lib/src/taiko_utils.rs +++ b/lib/src/taiko_utils.rs @@ -74,7 +74,7 @@ pub mod internal_devnet_b { }); } -pub fn generate_transactions_alloy( +pub fn generate_transactions( tx_list: &[u8], anchor_tx: AlloyTransaction, ) -> Vec { @@ -198,9 +198,6 @@ pub fn check_anchor_tx( // Okay now let's decode the anchor tx to verify the inputs let anchor_call = decode_anchor(&tx.input)?; - - println!("anchor: {:?}", anchor_call.l1Hash); - println!("expected: {:?}", input.taiko.l1_header.hash()); // The L1 blockhash needs to match the expected value ensure!( anchor_call.l1Hash == input.taiko.l1_header.hash(), diff --git a/primitives/src/lib.rs b/primitives/src/lib.rs index 1b0ad4cf..c280f0c5 100644 --- a/primitives/src/lib.rs +++ b/primitives/src/lib.rs @@ -21,8 +21,7 @@ pub use alloc::{vec, vec::Vec}; pub mod keccak; pub mod mpt; pub mod receipt; -pub mod transactions; -pub mod withdrawal; +pub mod signature; #[cfg(feature = "revm")] pub mod revm; diff --git a/primitives/src/signature.rs b/primitives/src/signature.rs new file mode 100644 index 00000000..1de4be1d --- /dev/null +++ b/primitives/src/signature.rs @@ -0,0 +1,90 @@ +use std::error::Error; + +use k256::{ecdsa::RecoveryId, elliptic_curve::PublicKey}; +use revm_primitives::{Address, B256, U256}; + +use crate::keccak::keccak; + +/// The order of the secp256k1 curve, divided by two. Signatures that should be checked according +/// to EIP-2 should have an S value less than or equal to this. +/// +/// `57896044618658097711785492504343953926418782139537452191302581570759080747168` +const SECP256K1N_HALF: U256 = U256::from_be_bytes([ + 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0x5D, 0x57, 0x6E, 0x73, 0x57, 0xA4, 0x50, 0x1D, 0xDF, 0xE9, 0x2F, 0x46, 0x68, 0x1B, 0x20, 0xA0, +]); + +/* + +/// Recovers the address of the sender using secp256k1 pubkey recovery. +/// +/// Converts the public key into an ethereum address by hashing the public key with keccak256. +/// +/// This does not ensure that the `s` value in the signature is low, and _just_ wraps the +/// underlying secp256k1 library. +pub fn recover_signer_unchecked_crypto(sig: &[u8; 65], msg: &[u8; 32]) -> Result { + #[cfg(target_os = "zkvm")] + { + let pubkey = sp1_precompiles::secp256k1::ecrecover(sig, msg).unwrap(); + return Ok(public_key_bytes_to_address(&pubkey)); + } + { + let recid = RecoveryId::from_byte(sig[64]).expect("recovery ID is valid"); + let sig = K256Signature::from_slice(&sig.as_slice()[..64])?; + let recovered_key = VerifyingKey::recover_from_prehash(&msg[..], &sig, recid)?; + let pubkey = PublicKey::from(&recovered_key); + Ok(public_key_to_address(pubkey)) + } +} + +/// Recover signer from message hash, _without ensuring that the signature has a low `s` +/// value_. +/// +/// Using this for signature validation will succeed, even if the signature is malleable or not +/// compliant with EIP-2. This is provided for compatibility with old signatures which have +/// large `s` values. +pub fn recover_signer_unchecked(&self, hash: B256) -> Option
{ + let mut sig: [u8; 65] = [0; 65]; + + sig[0..32].copy_from_slice(&self.r.to_be_bytes::<32>()); + sig[32..64].copy_from_slice(&self.s.to_be_bytes::<32>()); + sig[64] = self.odd_y_parity as u8; + + // NOTE: we are removing error from underlying crypto library as it will restrain primitive + // errors and we care only if recovery is passing or not. + recover_signer_unchecked_crypto(&sig, &hash.0).ok() +} + +/// Recover signer address from message hash. This ensures that the signature S value is +/// greater than `secp256k1n / 2`, as specified in +/// [EIP-2](https://eips.ethereum.org/EIPS/eip-2). +/// +/// If the S value is too large, then this will return `None` +pub fn recover_signer(&self, hash: B256) -> Option
{ + if self.s > SECP256K1N_HALF { + return None + } + + self.recover_signer_unchecked(hash) +} + + +/// Converts a public key into an ethereum address by hashing the encoded public key with +/// keccak256. +pub fn public_key_to_address(public: PublicKey) -> Address { + let pubkey_bytes = + public.to_encoded_point(false).as_bytes().try_into().expect("The slice has 65 bytes"); + public_key_bytes_to_address(&pubkey_bytes) + // strip out the first byte because that should be the SECP256K1_TAG_PUBKEY_UNCOMPRESSED + // tag returned by libsecp's uncompressed pubkey serialization + // let hash = keccak256(&public.serialize_uncompressed()[1..]); + // Address::from_slice(&hash[12..]) +} + +fn public_key_bytes_to_address(public: &[u8; 65]) -> Address { + // Strip out first byte of sec1 encoded pubkey + let hash = keccak(&public[1..]); + Address::from_slice(&hash[12..]) +} + +*/ \ No newline at end of file diff --git a/primitives/src/transactions/mod.rs b/primitives/src/transactions/mod.rs deleted file mode 100644 index e953d967..00000000 --- a/primitives/src/transactions/mod.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2023 RISC Zero, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -pub mod signature; diff --git a/primitives/src/transactions/signature.rs b/primitives/src/transactions/signature.rs deleted file mode 100644 index 6b110c1a..00000000 --- a/primitives/src/transactions/signature.rs +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright 2023 RISC Zero, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -use alloy_primitives::U256; -use alloy_rlp_derive::{RlpEncodable, RlpMaxEncodedLen}; -use serde::{Deserialize, Serialize}; - -/// Represents a cryptographic signature associated with a transaction. -/// -/// The `TxSignature` struct encapsulates the components of an ECDSA signature: `v`, `r`, -/// and `s`. This signature can be used to recover the public key of the signer, ensuring -/// the authenticity of the transaction. -#[derive( - Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize, RlpEncodable, RlpMaxEncodedLen, -)] -pub struct TxSignature { - pub v: u64, - pub r: U256, - pub s: U256, -} - -impl TxSignature { - /// Computes the length of the RLP-encoded signature payload in bytes. - pub fn payload_length(&self) -> usize { - self._alloy_rlp_payload_length() - } - - pub fn to_bytes(&self) -> [u8; 65] { - let mut sig = [0u8; 65]; - sig[..32].copy_from_slice(&self.r.to_be_bytes::<32>()); - sig[32..64].copy_from_slice(&self.s.to_be_bytes::<32>()); - sig[64] = (self.v + 27) as u8; - sig - } -} diff --git a/primitives/src/withdrawal.rs b/primitives/src/withdrawal.rs deleted file mode 100644 index 56421fc4..00000000 --- a/primitives/src/withdrawal.rs +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright 2023 RISC Zero, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -use alloy_primitives::Address; -use alloy_rlp_derive::{RlpEncodable, RlpMaxEncodedLen}; -use serde::{Deserialize, Serialize}; - -/// Represents a validator's withdrawal from the Ethereum consensus layer. -/// -/// The `Withdrawal` struct provides a model for the process a validator undergoes when -/// withdrawing funds from the Ethereum consensus mechanism. This process is outlined in -/// detail in [EIP-4895](https://eips.ethereum.org/EIPS/eip-4895). Each `Withdrawal` instance carries -/// specific identifiers and target details to ensure the accurate and secure transfer of -/// ether. -#[derive( - Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize, RlpEncodable, RlpMaxEncodedLen, -)] -pub struct Withdrawal { - /// A unique, monotonically increasing identifier assigned by the consensus layer to - /// distinctly represent this withdrawal. - pub index: u64, - /// The distinct index of the validator initiating this withdrawal. - pub validator_index: u64, - /// The Ethereum address, encapsulated as a `Address` type, where the withdrawn ether - /// will be sent. - pub address: Address, - /// The total withdrawal amount, denominated in gwei. - pub amount: u64, -} diff --git a/raiko-host/src/host/host.rs b/raiko-host/src/host/host.rs index 9ef5a34f..aa3f83e7 100644 --- a/raiko-host/src/host/host.rs +++ b/raiko-host/src/host/host.rs @@ -17,7 +17,7 @@ use zeth_lib::{ input::{ decode_anchor, decode_propose_block_call_params, proposeBlockCall, protocol_testnet::BlockProposed as TestnetBlockProposed, BlockProposed, GuestInput, TaikoGuestInput, TaikoProverData }, - taiko_utils::{generate_transactions_alloy, get_contracts, to_header}, + taiko_utils::{generate_transactions, get_contracts, to_header}, }; use zeth_primitives::mpt::proofs_to_tries; @@ -55,27 +55,20 @@ pub struct HostArgs { pub l2_rpc: Option, } -pub fn get_block_alloy(rpc_url: String, block_number: u64, full: bool) -> Result { - let http = Http::new(Url::parse(&rpc_url).expect("invalid rpc url")); - let provider: HttpProvider = HttpProvider::new(http); - - //info!("Querying RPC for full block: {query:?}"); - +pub fn get_block(provider: &HttpProvider, block_number: u64, full: bool) -> Result { let tokio_handle = tokio::runtime::Handle::current(); - let response = tokio_handle.block_on(async { provider .get_block_by_number((block_number).into(), full) .await })?; - match response { Some(out) => Ok(out), None => Err(anyhow!("No data for {block_number:?}")), } } -pub fn get_log_alloy(rpc_url: String, chain_name: &str, block_hash: B256, l2_block_no: u64) -> Result<(AlloyRpcTransaction, BlockProposed)> { +pub fn get_log(rpc_url: String, chain_name: &str, block_hash: B256, l2_block_no: u64) -> Result<(AlloyRpcTransaction, BlockProposed)> { let http = Http::new(Url::parse(&rpc_url).expect("invalid rpc url")); let provider: HttpProvider = HttpProvider::new(http); @@ -146,7 +139,7 @@ fn get_blob_data(beacon_rpc_url: &str, block_id: u64) -> Result, l2_rpc_url: Option, l2_block_no: u64, @@ -157,59 +150,49 @@ pub fn taiko_run_preflight( let http_l2 = Http::new(Url::parse(&l2_rpc_url.clone().unwrap()).expect("invalid rpc url")); let provider_l2: HttpProvider = HttpProvider::new(http_l2); - let parent_block = get_block_alloy(l2_rpc_url.clone().unwrap(), l2_block_no - 1, false).unwrap(); - //println!("*** alloy parent block ***:{:?}", parent_block); + let http_l1 = Http::new(Url::parse(&l1_rpc_url.clone().unwrap()).expect("invalid rpc url")); + let provider_l1: HttpProvider = HttpProvider::new(http_l1); - let block_alloy = get_block_alloy(l2_rpc_url.clone().unwrap(), l2_block_no, true).unwrap(); - //println!("*** alloy block ***:{:?}", block_alloy); + let parent_block = get_block(&provider_l2, l2_block_no - 1, false).unwrap(); + let block = get_block(&provider_l2, l2_block_no, true).unwrap(); - // Fetch the target block - let anchor_tx_alloy = match &block_alloy.transactions { + // Decode the anchor tx to find out which L1 blocks we need to fetch + let anchor_tx = match &block.transactions { BlockTransactions::Full(txs) => txs[0].to_owned(), _ => unreachable!(), }; - let anchor_call_alloy = decode_anchor(anchor_tx_alloy.input.as_ref())?; - - println!("block.hash: {:?}", block_alloy.header.hash.unwrap()); - println!("block.parent_hash: {:?}", block_alloy.header.parent_hash); - - println!("anchor L1 block id: {:?}", anchor_call_alloy.l1Height); - println!("anchor L1 state root: {:?}", anchor_call_alloy.l1SignalRoot); - - let l1_state_block_no = anchor_call_alloy.l1Height; + let anchor_call = decode_anchor(anchor_tx.input.as_ref())?; + // The L1 blocks we need + let l1_state_block_no = anchor_call.l1Height; let l1_inclusion_block_no = l1_state_block_no + 1; - println!("l1_state_block_no: {:?}", l1_state_block_no); - - let l1_state_root_block_alloy = get_block_alloy(l1_rpc_url.clone().unwrap(), l1_state_block_no, false).unwrap(); - - let l1_inclusion_block_alloy = get_block_alloy(l1_rpc_url.clone().unwrap(), l1_inclusion_block_no, false).unwrap(); + println!("block.hash: {:?}", block.header.hash.unwrap()); + println!("block.parent_hash: {:?}", block.header.parent_hash); + println!("anchor L1 block id: {:?}", anchor_call.l1Height); + println!("anchor L1 state root: {:?}", anchor_call.l1SignalRoot); // Get the L1 state block header so that we can prove the L1 state root + let l1_state_block = get_block(&provider_l1, l1_state_block_no, false).unwrap(); + let l1_inclusion_block = get_block(&provider_l1, l1_inclusion_block_no, false).unwrap(); println!( "l1_state_root_block hash: {:?}", - l1_state_root_block_alloy.header.hash.unwrap() + l1_state_block.header.hash.unwrap() ); - let (proposal_tx_alloy, proposal_event_alloy) = - get_log_alloy(l1_rpc_url.clone().unwrap(), chain_spec_name, l1_inclusion_block_alloy.header.hash.unwrap(), l2_block_no)?; + // Get the block proposal data + let (proposal_tx, proposal_event) = + get_log(l1_rpc_url.clone().unwrap(), chain_spec_name, l1_inclusion_block.header.hash.unwrap(), l2_block_no)?; + let proposal_call = proposeBlockCall::abi_decode(&proposal_tx.input, false).unwrap(); - println!("proposal alloy: {:?}", proposal_event_alloy); - - let proposal_call = proposeBlockCall::abi_decode(&proposal_tx_alloy.input, false).unwrap(); - // .with_context(|| "failed to decode propose block call")?; - - // blobUsed == (txList.length == 0) according to TaikoL1 - let blob_used = proposal_call.txList.is_empty(); - let (tx_list, tx_blob_hash) = if blob_used { + // Fetch the tx list + let (tx_list, tx_blob_hash) = if proposal_event.meta.blobUsed { println!("blob active"); let metadata = decode_propose_block_call_params(&proposal_call.params) .expect("valid propose_block_call_params"); println!("metadata: {:?}", metadata); - let blob_hashs = proposal_tx_alloy.blob_versioned_hashes; - // TODO: multiple blob hash support - assert!(blob_hashs.len() == 1); + let blob_hashs = proposal_tx.blob_versioned_hashes; + assert!(blob_hashs.len() >= 1); let blob_hash = blob_hashs[0]; // TODO: check _proposed_blob_hash with blob_hash if _proposed_blob_hash is not None @@ -235,66 +218,50 @@ pub fn taiko_run_preflight( (proposal_call.txList.clone(), None) }; - //println!("tx_list: {:?}", tx_list); - - // Create the transactions for the proposed tx list - let transactions_alloy = generate_transactions_alloy(&tx_list, anchor_tx_alloy.clone()); - - println!("Block valid transactions: {:?}", block_alloy.transactions.len()); + // Create the transactions from the proposed tx list + let transactions = generate_transactions(&tx_list, anchor_tx.clone()); + // Do a sanity check using the transactions returned by the node + println!("Block transactions: {:?}", block.transactions.len()); assert!( - transactions_alloy.len() >= block_alloy.transactions.len(), + transactions.len() >= block.transactions.len(), "unexpected number of transactions" ); - info!( - "Final block number: {:?} ({:?})", - block_alloy.header.number.unwrap(), - block_alloy.header.hash.unwrap() - ); - println!("Transaction count: {:?}", block_alloy.transactions.len()); - + // Create the input struct without the block data set let taiko_guest_input = TaikoGuestInput { chain_spec_name: chain_spec_name.to_string(), - l1_header: to_header(&l1_state_root_block_alloy.header), + l1_header: to_header(&l1_state_block.header), tx_list, - anchor_tx_alloy: serde_json::to_string(&anchor_tx_alloy).unwrap(), + anchor_tx: serde_json::to_string(&anchor_tx).unwrap(), tx_blob_hash, - block_proposed: proposal_event_alloy.into(), + block_proposed: proposal_event, prover_data, }; - - // Create the input struct without the block data set let input = GuestInput { - block_hash: block_alloy.header.hash.unwrap().0.try_into().unwrap(), - beneficiary: block_alloy.header.miner, - gas_limit: block_alloy.header.gas_limit.try_into().unwrap(), - timestamp: block_alloy.header.timestamp.try_into().unwrap(), - extra_data: block_alloy.header.extra_data.0.into(), - mix_hash: block_alloy.header.mix_hash.unwrap(), - withdrawals: block_alloy.withdrawals.unwrap_or_default(), + block_hash: block.header.hash.unwrap().0.try_into().unwrap(), + beneficiary: block.header.miner, + gas_limit: block.header.gas_limit.try_into().unwrap(), + timestamp: block.header.timestamp.try_into().unwrap(), + extra_data: block.header.extra_data.0.into(), + mix_hash: block.header.mix_hash.unwrap(), + withdrawals: block.withdrawals.unwrap_or_default(), parent_state_trie: Default::default(), parent_storage: Default::default(), contracts: Default::default(), parent_header: to_header(&parent_block.header), ancestor_headers: Default::default(), - base_fee_per_gas: block_alloy.header.base_fee_per_gas.unwrap().try_into().unwrap(), + base_fee_per_gas: block.header.base_fee_per_gas.unwrap().try_into().unwrap(), taiko: taiko_guest_input, }; - // Create the provider DB - let provider_db = ProviderDb::new(provider_l2, parent_block.header.number.unwrap().try_into().unwrap()); - - println!("execute block"); - // Create the block builder, run the transactions and extract the DB + let provider_db = ProviderDb::new(provider_l2, parent_block.header.number.unwrap().try_into().unwrap()); let mut builder = BlockBuilder::new(&input) .with_db(provider_db) .prepare_header::()? .execute_transactions::()?; let provider_db: &mut ProviderDb = builder.mut_db().unwrap(); - info!("Gathering inclusion proofs ..."); - // Construct the state trie and storage from the storage proofs. // Gather inclusion proofs for the initial and final state let parent_proofs = provider_db.get_initial_proofs()?; @@ -303,7 +270,7 @@ pub fn taiko_run_preflight( proofs_to_tries(input.parent_header.state_root, parent_proofs, proofs)?; // Gather proofs for block history - let ancestor_headers = provider_db.get_ancestor_headers(l2_rpc_url.unwrap())?; + let ancestor_headers = provider_db.get_ancestor_headers()?; // Get the contracts from the initial db. let mut contracts = HashSet::new(); @@ -315,8 +282,7 @@ pub fn taiko_run_preflight( } } - info!("Provider-backed execution is Done!"); - + // Add the collected data to the input Ok(GuestInput { parent_state_trie: state_trie, parent_storage: storage, @@ -326,7 +292,6 @@ pub fn taiko_run_preflight( }) } - const BLOB_FIELD_ELEMENT_NUM: usize = 4096; const BLOB_FIELD_ELEMENT_BYTES: usize = 32; const BLOB_DATA_LEN: usize = BLOB_FIELD_ELEMENT_NUM * BLOB_FIELD_ELEMENT_BYTES; diff --git a/raiko-host/src/host/provider_db.rs b/raiko-host/src/host/provider_db.rs index d3a5819d..0d2dff49 100644 --- a/raiko-host/src/host/provider_db.rs +++ b/raiko-host/src/host/provider_db.rs @@ -23,7 +23,7 @@ use zeth_primitives::{ Address, B256, U256, }; use alloy_consensus::Header as AlloyConsensusHeader; -use crate::host::host::get_block_alloy; +use crate::host::host::get_block; use alloy_providers::tmp::{HttpProvider, TempProvider}; pub struct ProviderDb { @@ -92,7 +92,7 @@ impl ProviderDb { self.get_proofs(self.block_number + 1, storage_keys) } - pub fn get_ancestor_headers(&mut self, rpc_url: String) -> Result, anyhow::Error> { + pub fn get_ancestor_headers(&mut self) -> Result, anyhow::Error> { let earliest_block = self .initial_db .block_hashes @@ -102,7 +102,7 @@ impl ProviderDb { let headers = (*earliest_block..self.block_number) .rev() .map(|block_no| { - to_header(&get_block_alloy(rpc_url.clone(), block_no, false).unwrap().header) + to_header(&get_block(&self.provider, block_no, false).unwrap().header) }) .collect(); Ok(headers) diff --git a/raiko-host/src/prover/execution.rs b/raiko-host/src/prover/execution.rs index a689fc54..ad49864b 100644 --- a/raiko-host/src/prover/execution.rs +++ b/raiko-host/src/prover/execution.rs @@ -19,7 +19,7 @@ use super::{ request::{ProofRequest, ProofResponse, ProofType}, }; use crate::{ - host::host::taiko_run_preflight, + host::host::preflight, metrics::{inc_sgx_success, observe_input, observe_sgx_gen}, }; @@ -143,7 +143,7 @@ pub async fn prepare_input( let l1_cache = ctx.l1_cache_file.clone(); let l2_cache = ctx.l2_cache_file.clone(); tokio::task::spawn_blocking(move || { - taiko_run_preflight( + preflight( Some(req.l1_rpc), Some(req.l2_rpc), req.block_number, From be949fbd89664b15dfc15b4f48287532d7663ab2 Mon Sep 17 00:00:00 2001 From: brechtpd Date: Mon, 18 Mar 2024 18:26:35 +0000 Subject: [PATCH 05/10] more code cleanup and unused code removal --- .../builder/{execute/taiko.rs => execute.rs} | 56 +--- lib/src/builder/execute/mod.rs | 29 -- lib/src/builder/finalize.rs | 6 +- lib/src/builder/initialize.rs | 7 +- lib/src/builder/mod.rs | 17 +- lib/src/builder/prepare.rs | 6 +- lib/src/input.rs | 22 +- lib/src/protocol_instance.rs | 9 +- lib/src/taiko_utils.rs | 79 +++-- primitives/src/signature.rs | 150 +++++----- raiko-guests/sgx/src/one_shot.rs | 1 - raiko-host/src/host/host.rs | 281 ++++++++++-------- raiko-host/src/host/mod.rs | 3 +- .../src/host/provider/cached_rpc_provider.rs | 195 ------------ raiko-host/src/host/provider/file_provider.rs | 267 ----------------- raiko-host/src/host/provider/mod.rs | 167 ----------- raiko-host/src/host/provider/rpc_provider.rs | 215 -------------- raiko-host/src/host/provider_db.rs | 18 +- raiko-host/src/prover/execution.rs | 5 +- raiko-host/src/prover/proof/mod.rs | 4 +- raiko-host/src/prover/proof/risc0/mod.rs | 4 +- raiko-host/src/prover/proof/succinct.rs | 4 +- raiko-host/src/prover/server.rs | 1 - 23 files changed, 331 insertions(+), 1215 deletions(-) rename lib/src/builder/{execute/taiko.rs => execute.rs} (91%) delete mode 100644 lib/src/builder/execute/mod.rs delete mode 100644 raiko-host/src/host/provider/cached_rpc_provider.rs delete mode 100644 raiko-host/src/host/provider/file_provider.rs delete mode 100644 raiko-host/src/host/provider/mod.rs delete mode 100644 raiko-host/src/host/provider/rpc_provider.rs diff --git a/lib/src/builder/execute/taiko.rs b/lib/src/builder/execute.rs similarity index 91% rename from lib/src/builder/execute/taiko.rs rename to lib/src/builder/execute.rs index 99b6b6fd..636a4481 100644 --- a/lib/src/builder/execute/taiko.rs +++ b/lib/src/builder/execute.rs @@ -15,33 +15,23 @@ use core::{fmt::Debug, mem::take, str::from_utf8}; use alloy_consensus::{TxEnvelope, TxKind}; -use alloy_consensus::TxEip4844Variant::TxEip4844; -use alloy_consensus::TxEip4844Variant; -use alloy_rlp::Encodable; use anyhow::{anyhow, bail, Context, Result}; #[cfg(feature = "std")] use log::debug; use revm::{ interpreter::Host, - primitives::{ - Account, Address, EVMError, InvalidTransaction, ResultAndState, SpecId, TransactTo, TxEnv, - }, + primitives::{Account, Address, EVMError, ResultAndState, SpecId, TransactTo, TxEnv}, taiko, Database, DatabaseCommit, Evm, }; use ruint::aliases::U256; -use zeth_primitives::{ - mpt::MptNode, - receipt::Receipt, - Bloom, RlpBytes, -}; +use zeth_primitives::{mpt::MptNode, receipt::Receipt, Bloom, RlpBytes}; use super::TxExecStrategy; -use crate::taiko_utils::generate_transactions; use crate::{ builder::BlockBuilder, - consts::{self, ChainSpec, GWEI_TO_WEI}, + consts::GWEI_TO_WEI, guest_mem_forget, - taiko_utils::{check_anchor_tx, get_contracts}, + taiko_utils::{check_anchor_tx, generate_transactions, get_contracts}, }; /// Minimum supported protocol version: Bedrock (Block no. 105235063). @@ -50,9 +40,7 @@ const MIN_SPEC_ID: SpecId = SpecId::SHANGHAI /*change*/; pub struct TkoTxExecStrategy {} impl TxExecStrategy for TkoTxExecStrategy { - fn execute_transactions( - mut block_builder: BlockBuilder, - ) -> Result> + fn execute_transactions(mut block_builder: BlockBuilder) -> Result> where D: Database + DatabaseCommit, ::Error: Debug, @@ -111,24 +99,14 @@ impl TxExecStrategy for TkoTxExecStrategy { // TODO(Brecht): use optimized recover let (tx_gas_limit, from) = match &tx { - TxEnvelope::Legacy(tx) => { - (tx.gas_limit, tx.recover_signer()) - } - TxEnvelope::TaggedLegacy(tx) => { - (tx.gas_limit, tx.recover_signer()) - } - TxEnvelope::Eip2930(tx) => { - (tx.gas_limit, tx.recover_signer()) - } - TxEnvelope::Eip1559(tx) => { - (tx.gas_limit, tx.recover_signer()) - } - TxEnvelope::Eip4844(tx) => { - (tx.tx().tx().gas_limit, tx.recover_signer()) - } + TxEnvelope::Legacy(tx) => (tx.gas_limit, tx.recover_signer()), + TxEnvelope::TaggedLegacy(tx) => (tx.gas_limit, tx.recover_signer()), + TxEnvelope::Eip2930(tx) => (tx.gas_limit, tx.recover_signer()), + TxEnvelope::Eip1559(tx) => (tx.gas_limit, tx.recover_signer()), + TxEnvelope::Eip4844(tx) => (tx.tx().tx().gas_limit, tx.recover_signer()), }; - - let tx_type = match tx.tx_type() { + // Get the tx type as a number + let tx_type = match tx.tx_type() { alloy_consensus::TxType::Legacy => 0, alloy_consensus::TxType::Eip2930 => 1, alloy_consensus::TxType::Eip1559 => 2, @@ -182,7 +160,6 @@ impl TxExecStrategy for TkoTxExecStrategy { tx_from, is_anchor, ); - //println!("**** transact: {:?}", evm.env().tx); // process the transaction let ResultAndState { result, state } = match evm.transact() { Ok(result) => result, @@ -206,6 +183,8 @@ impl TxExecStrategy for TkoTxExecStrategy { } } }; + #[cfg(feature = "std")] + debug!(" Ok: {result:?}"); // anchor tx needs to succeed if is_anchor && !result.is_success() { @@ -215,12 +194,10 @@ impl TxExecStrategy for TkoTxExecStrategy { ); } + // keep track of all the gas used in the block let gas_used = result.gas_used().try_into().unwrap(); cumulative_gas_used = cumulative_gas_used.checked_add(gas_used).unwrap(); - #[cfg(feature = "std")] - debug!(" Ok: {result:?}"); - // create the receipt from the EVM result let receipt = Receipt::new( tx_type, @@ -274,7 +251,7 @@ impl TxExecStrategy for TkoTxExecStrategy { header.transactions_root = tx_trie.hash(); header.receipts_root = receipt_trie.hash(); header.logs_bloom = logs_bloom; - header.gas_used = cumulative_gas_used.try_into().unwrap() ; + header.gas_used = cumulative_gas_used.try_into().unwrap(); header.withdrawals_root = if spec_id < SpecId::SHANGHAI { None } else { @@ -382,7 +359,6 @@ pub fn fill_eth_tx_env_alloy( }; } - pub fn increase_account_balance( db: &mut D, address: Address, diff --git a/lib/src/builder/execute/mod.rs b/lib/src/builder/execute/mod.rs deleted file mode 100644 index 25105c41..00000000 --- a/lib/src/builder/execute/mod.rs +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2023 RISC Zero, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -use core::fmt::Debug; - -use anyhow::Result; -use revm::{Database, DatabaseCommit}; - -use super::BlockBuilder; - -pub(super) mod taiko; - -pub trait TxExecStrategy { - fn execute_transactions(block_builder: BlockBuilder) -> Result> - where - D: Database + DatabaseCommit, - ::Error: Debug; -} diff --git a/lib/src/builder/finalize.rs b/lib/src/builder/finalize.rs index b555c82b..1738cfd5 100644 --- a/lib/src/builder/finalize.rs +++ b/lib/src/builder/finalize.rs @@ -14,13 +14,13 @@ use core::mem; +use alloy_consensus::Header as AlloyConsensusHeader; use anyhow::Result; use revm::{Database, DatabaseCommit}; use zeth_primitives::{ keccak::keccak, mpt::{MptNode, StateAccount}, }; -use alloy_consensus::Header as AlloyConsensusHeader; use crate::{ builder::BlockBuilder, @@ -39,9 +39,7 @@ where pub struct MemDbBlockFinalizeStrategy {} impl BlockFinalizeStrategy for MemDbBlockFinalizeStrategy { - fn finalize( - mut block_builder: BlockBuilder, - ) -> Result<(AlloyConsensusHeader, MptNode)> { + fn finalize(mut block_builder: BlockBuilder) -> Result<(AlloyConsensusHeader, MptNode)> { let db: MemDb = block_builder.db.take().expect("DB not initialized"); // apply state updates diff --git a/lib/src/builder/initialize.rs b/lib/src/builder/initialize.rs index 647478a3..4c95870e 100644 --- a/lib/src/builder/initialize.rs +++ b/lib/src/builder/initialize.rs @@ -30,7 +30,8 @@ use crate::{ builder::BlockBuilder, consts::MAX_BLOCK_HASH_AGE, guest_mem_forget, - mem_db::{AccountState, DbAccount, MemDb}, taiko_utils::HeaderHasher, + mem_db::{AccountState, DbAccount, MemDb}, + taiko_utils::HeaderHasher, }; pub trait DbInitStrategy @@ -44,9 +45,7 @@ where pub struct MemDbInitStrategy {} impl DbInitStrategy for MemDbInitStrategy { - fn initialize_database( - mut block_builder: BlockBuilder, - ) -> Result> { + fn initialize_database(mut block_builder: BlockBuilder) -> Result> { // Verify state trie root if block_builder.input.parent_state_trie.hash() != block_builder.input.parent_header.state_root diff --git a/lib/src/builder/mod.rs b/lib/src/builder/mod.rs index 7e4bb6a2..55f736fe 100644 --- a/lib/src/builder/mod.rs +++ b/lib/src/builder/mod.rs @@ -12,16 +12,14 @@ // See the License for the specific language governing permissions and // limitations under the License. +use alloy_consensus::Header as AlloyConsensusHeader; use anyhow::Result; use revm::{Database, DatabaseCommit}; -use zeth_primitives::{ - mpt::MptNode, -}; +use zeth_primitives::mpt::MptNode; -pub use self::execute::taiko::TkoTxExecStrategy; +pub use self::execute::TkoTxExecStrategy; use crate::{ builder::{ - execute::TxExecStrategy, finalize::{BlockFinalizeStrategy, MemDbBlockFinalizeStrategy}, initialize::{DbInitStrategy, MemDbInitStrategy}, prepare::{HeaderPrepStrategy, TaikoHeaderPrepStrategy}, @@ -30,9 +28,8 @@ use crate::{ input::GuestInput, mem_db::MemDb, }; -use alloy_consensus::Header as AlloyConsensusHeader; -mod execute; +pub mod execute; mod finalize; mod initialize; pub mod prepare; @@ -123,3 +120,9 @@ impl BlockBuilderStrategy for TaikoStrategy { type TxExecStrategy = TkoTxExecStrategy; type BlockFinalizeStrategy = MemDbBlockFinalizeStrategy; } +pub trait TxExecStrategy { + fn execute_transactions(block_builder: BlockBuilder) -> Result> + where + D: Database + DatabaseCommit, + ::Error: core::fmt::Debug; +} diff --git a/lib/src/builder/prepare.rs b/lib/src/builder/prepare.rs index 079e7823..7e3d632c 100644 --- a/lib/src/builder/prepare.rs +++ b/lib/src/builder/prepare.rs @@ -14,9 +14,9 @@ use core::fmt::Debug; +use alloy_consensus::Header as AlloyConsensusHeader; use anyhow::{bail, Context, Result}; use revm::{Database, DatabaseCommit}; -use alloy_consensus::Header as AlloyConsensusHeader; use crate::{builder::BlockBuilder, consts::MAX_EXTRA_DATA_BYTES, taiko_utils::HeaderHasher}; @@ -58,7 +58,9 @@ impl HeaderPrepStrategy for TaikoHeaderPrepStrategy { block_builder.header = Some(AlloyConsensusHeader { // Initialize fields that we can compute from the parent parent_hash: block_builder.input.parent_header.hash(), - number: number.checked_add(1).with_context(|| "Invalid block number: too large")?, + number: number + .checked_add(1) + .with_context(|| "Invalid block number: too large")?, base_fee_per_gas: Some(block_builder.input.base_fee_per_gas), // Initialize metadata from input beneficiary: block_builder.input.beneficiary, diff --git a/lib/src/input.rs b/lib/src/input.rs index 3c1a9b5f..29ea11dd 100644 --- a/lib/src/input.rs +++ b/lib/src/input.rs @@ -13,17 +13,14 @@ // limitations under the License. use core::fmt::Debug; -use alloy_sol_types::{sol, SolCall, SolType}; use alloy_consensus::Header as AlloyConsensusHeader; +use alloy_rpc_types::Withdrawal as AlloyWithdrawal; +use alloy_sol_types::{sol, SolCall}; use anyhow::{anyhow, Result}; use ethers_core::types::H256; use hashbrown::HashMap; use serde::{Deserialize, Serialize}; -use zeth_primitives::{ - mpt::MptNode, - Address, Bytes, FixedBytes, B256, U256, -}; -use alloy_rpc_types::Withdrawal as AlloyWithdrawal; +use zeth_primitives::{mpt::MptNode, Address, Bytes, FixedBytes, B256, U256}; /// Represents the state of an account's storage. /// The storage trie together with the used storage slots allow us to reconstruct all the @@ -48,7 +45,7 @@ pub struct GuestInput { /// Hash previously used for the PoW now containing the RANDAO value. pub mix_hash: B256, /// List of transactions for execution - //pub transactions: Vec>, + // pub transactions: Vec>, /// List of stake withdrawals for execution pub withdrawals: Vec, /// State trie of the parent block. @@ -273,12 +270,6 @@ pub mod protocol_testnet { } } -pub fn decode_propose_block_call_params(data: &[u8]) -> Result { - let propose_block_params = BlockParams::abi_decode(data, false) - .map_err(|e| anyhow!("failed to decode propose block call: {e}"))?; - Ok(propose_block_params) -} - impl From for EthDeposit { fn from(item: protocol_testnet::EthDeposit) -> Self { EthDeposit { @@ -338,7 +329,7 @@ mod tests { timestamp: Default::default(), extra_data: Default::default(), mix_hash: Default::default(), - //transactions: vec![], + // transactions: vec![], withdrawals: vec![], parent_state_trie: Default::default(), parent_storage: Default::default(), @@ -347,7 +338,6 @@ mod tests { base_fee_per_gas: Default::default(), taiko: Default::default(), }; - let _: GuestInput = - bincode::deserialize(&bincode::serialize(&input).unwrap()).unwrap(); + let _: GuestInput = bincode::deserialize(&bincode::serialize(&input).unwrap()).unwrap(); } } diff --git a/lib/src/protocol_instance.rs b/lib/src/protocol_instance.rs index a2f41888..0c11aba6 100644 --- a/lib/src/protocol_instance.rs +++ b/lib/src/protocol_instance.rs @@ -1,11 +1,14 @@ +use alloy_consensus::Header as AlloyConsensusHeader; use alloy_primitives::{Address, TxHash, B256}; use alloy_sol_types::SolValue; use anyhow::{ensure, Result}; -use zeth_primitives::{keccak::keccak}; -use alloy_consensus::Header as AlloyConsensusHeader; +use zeth_primitives::keccak::keccak; use super::taiko_utils::ANCHOR_GAS_LIMIT; -use crate::{input::{BlockMetadata, EthDeposit, GuestInput, Transition}, taiko_utils::HeaderHasher}; +use crate::{ + input::{BlockMetadata, EthDeposit, GuestInput, Transition}, + taiko_utils::HeaderHasher, +}; #[derive(Debug)] pub struct ProtocolInstance { diff --git a/lib/src/taiko_utils.rs b/lib/src/taiko_utils.rs index 843ef368..7458cd5a 100644 --- a/lib/src/taiko_utils.rs +++ b/lib/src/taiko_utils.rs @@ -1,14 +1,13 @@ use core::str::FromStr; -use alloy_primitives::{uint, Address, U256, Signature}; +use alloy_consensus::{Header as AlloyConsensusHeader, TxEip1559, TxEnvelope, TxKind}; +use alloy_network::Signed; +use alloy_primitives::{uint, Address, Signature, U256}; +use alloy_rlp::*; +use alloy_rpc_types::{Header as AlloyHeader, Transaction as AlloyTransaction}; use anyhow::{anyhow, bail, ensure, Context, Result}; use once_cell::unsync::Lazy; use zeth_primitives::{keccak256, B256}; -use alloy_rlp::*; -use alloy_rpc_types::Header as AlloyHeader; -use alloy_consensus::{Header as AlloyConsensusHeader, TxEip1559, TxEnvelope, TxKind}; -use alloy_rpc_types::Transaction as AlloyTransaction; -use alloy_network::Signed; use crate::input::{decode_anchor, GuestInput}; @@ -74,44 +73,36 @@ pub mod internal_devnet_b { }); } -pub fn generate_transactions( - tx_list: &[u8], - anchor_tx: AlloyTransaction, -) -> Vec { - // Decode all the transactions in the tx list - //let transactions: Vec = Vec::::decode_list(tx_list); - - //println!("decoding... {:?} {}", tx_list, tx_list.len()); - - let eip1559_tx: TxEip1559 = TxEip1559 { - chain_id: anchor_tx.chain_id.unwrap().try_into().unwrap(), - nonce: anchor_tx.nonce.try_into().unwrap(), - gas_limit: anchor_tx.gas.try_into().unwrap(), - max_fee_per_gas: anchor_tx.max_fee_per_gas.unwrap().try_into().unwrap(), - max_priority_fee_per_gas: anchor_tx.max_priority_fee_per_gas.unwrap().try_into().unwrap(), - to: TxKind::Call(anchor_tx.to.unwrap()), - value: anchor_tx.value.try_into().unwrap(), - access_list: Default::default(), - input: anchor_tx.input, - }; - - let parity = anchor_tx.signature.unwrap().y_parity.unwrap(); - //println!("parity: {:?}", parity); - +pub fn generate_transactions(tx_list: &[u8], anchor_tx: AlloyTransaction) -> Vec { + // Decode the transactions from the tx list + let mut transactions: Vec = + alloy_rlp::Decodable::decode(&mut &tx_list.to_owned()[..]).unwrap_or_default(); + // Create a tx from the anchor tx that has the same type as the transactions encoded from + // the tx list let signed_eip1559_tx = Signed::::new_unchecked( - eip1559_tx, - Signature::from_rs_and_parity(anchor_tx.signature.unwrap().r, anchor_tx.signature.unwrap().s, parity.0).unwrap(), + TxEip1559 { + chain_id: anchor_tx.chain_id.unwrap().try_into().unwrap(), + nonce: anchor_tx.nonce.try_into().unwrap(), + gas_limit: anchor_tx.gas.try_into().unwrap(), + max_fee_per_gas: anchor_tx.max_fee_per_gas.unwrap().try_into().unwrap(), + max_priority_fee_per_gas: anchor_tx + .max_priority_fee_per_gas + .unwrap() + .try_into() + .unwrap(), + to: TxKind::Call(anchor_tx.to.unwrap()), + value: anchor_tx.value.try_into().unwrap(), + access_list: Default::default(), + input: anchor_tx.input, + }, + Signature::from_rs_and_parity( + anchor_tx.signature.unwrap().r, + anchor_tx.signature.unwrap().s, + anchor_tx.signature.unwrap().y_parity.unwrap().0, + ) + .unwrap(), anchor_tx.hash, ); - - let b = &mut &tx_list.to_owned()[..]; - let mut transactions: Vec = alloy_rlp::Decodable::decode(b).unwrap_or_default(); - //let transactions: Vec = decode_tx_list(&tx_list).unwrap_or_default(); - - //println!("alloy decoded transactions: {:?}", transactions); - - println!("num decoded: {:?}", transactions.len()); - // Insert the anchor transactions generated by the node (which needs to be verified!) transactions.insert(0, TxEnvelope::from(signed_eip1559_tx)); transactions @@ -223,7 +214,7 @@ pub fn check_anchor_tx( panic!("invalid anchor tx type"); } } - + Ok(()) } @@ -234,11 +225,11 @@ pub fn hash_header(header: &AlloyConsensusHeader) -> B256 { } pub trait HeaderHasher { - fn hash(&self)-> B256; + fn hash(&self) -> B256; } impl HeaderHasher for AlloyConsensusHeader { - fn hash(&self)-> B256 { + fn hash(&self) -> B256 { hash_header(self) } } diff --git a/primitives/src/signature.rs b/primitives/src/signature.rs index 1de4be1d..c398cfaa 100644 --- a/primitives/src/signature.rs +++ b/primitives/src/signature.rs @@ -5,8 +5,8 @@ use revm_primitives::{Address, B256, U256}; use crate::keccak::keccak; -/// The order of the secp256k1 curve, divided by two. Signatures that should be checked according -/// to EIP-2 should have an S value less than or equal to this. +/// The order of the secp256k1 curve, divided by two. Signatures that should be checked +/// according to EIP-2 should have an S value less than or equal to this. /// /// `57896044618658097711785492504343953926418782139537452191302581570759080747168` const SECP256K1N_HALF: U256 = U256::from_be_bytes([ @@ -14,77 +14,75 @@ const SECP256K1N_HALF: U256 = U256::from_be_bytes([ 0x5D, 0x57, 0x6E, 0x73, 0x57, 0xA4, 0x50, 0x1D, 0xDF, 0xE9, 0x2F, 0x46, 0x68, 0x1B, 0x20, 0xA0, ]); -/* - -/// Recovers the address of the sender using secp256k1 pubkey recovery. -/// -/// Converts the public key into an ethereum address by hashing the public key with keccak256. -/// -/// This does not ensure that the `s` value in the signature is low, and _just_ wraps the -/// underlying secp256k1 library. -pub fn recover_signer_unchecked_crypto(sig: &[u8; 65], msg: &[u8; 32]) -> Result { - #[cfg(target_os = "zkvm")] - { - let pubkey = sp1_precompiles::secp256k1::ecrecover(sig, msg).unwrap(); - return Ok(public_key_bytes_to_address(&pubkey)); - } - { - let recid = RecoveryId::from_byte(sig[64]).expect("recovery ID is valid"); - let sig = K256Signature::from_slice(&sig.as_slice()[..64])?; - let recovered_key = VerifyingKey::recover_from_prehash(&msg[..], &sig, recid)?; - let pubkey = PublicKey::from(&recovered_key); - Ok(public_key_to_address(pubkey)) - } -} - -/// Recover signer from message hash, _without ensuring that the signature has a low `s` -/// value_. -/// -/// Using this for signature validation will succeed, even if the signature is malleable or not -/// compliant with EIP-2. This is provided for compatibility with old signatures which have -/// large `s` values. -pub fn recover_signer_unchecked(&self, hash: B256) -> Option
{ - let mut sig: [u8; 65] = [0; 65]; - - sig[0..32].copy_from_slice(&self.r.to_be_bytes::<32>()); - sig[32..64].copy_from_slice(&self.s.to_be_bytes::<32>()); - sig[64] = self.odd_y_parity as u8; - - // NOTE: we are removing error from underlying crypto library as it will restrain primitive - // errors and we care only if recovery is passing or not. - recover_signer_unchecked_crypto(&sig, &hash.0).ok() -} - -/// Recover signer address from message hash. This ensures that the signature S value is -/// greater than `secp256k1n / 2`, as specified in -/// [EIP-2](https://eips.ethereum.org/EIPS/eip-2). -/// -/// If the S value is too large, then this will return `None` -pub fn recover_signer(&self, hash: B256) -> Option
{ - if self.s > SECP256K1N_HALF { - return None - } - - self.recover_signer_unchecked(hash) -} - - -/// Converts a public key into an ethereum address by hashing the encoded public key with -/// keccak256. -pub fn public_key_to_address(public: PublicKey) -> Address { - let pubkey_bytes = - public.to_encoded_point(false).as_bytes().try_into().expect("The slice has 65 bytes"); - public_key_bytes_to_address(&pubkey_bytes) - // strip out the first byte because that should be the SECP256K1_TAG_PUBKEY_UNCOMPRESSED - // tag returned by libsecp's uncompressed pubkey serialization - // let hash = keccak256(&public.serialize_uncompressed()[1..]); - // Address::from_slice(&hash[12..]) -} - -fn public_key_bytes_to_address(public: &[u8; 65]) -> Address { - // Strip out first byte of sec1 encoded pubkey - let hash = keccak(&public[1..]); - Address::from_slice(&hash[12..]) -} - -*/ \ No newline at end of file +// Recovers the address of the sender using secp256k1 pubkey recovery. +// +// Converts the public key into an ethereum address by hashing the public key with +// keccak256. +// +// This does not ensure that the `s` value in the signature is low, and _just_ wraps the +// underlying secp256k1 library. +// pub fn recover_signer_unchecked_crypto(sig: &[u8; 65], msg: &[u8; 32]) -> +// Result { #[cfg(target_os = "zkvm")] +// { +// let pubkey = sp1_precompiles::secp256k1::ecrecover(sig, msg).unwrap(); +// return Ok(public_key_bytes_to_address(&pubkey)); +// } +// { +// let recid = RecoveryId::from_byte(sig[64]).expect("recovery ID is valid"); +// let sig = K256Signature::from_slice(&sig.as_slice()[..64])?; +// let recovered_key = VerifyingKey::recover_from_prehash(&msg[..], &sig, recid)?; +// let pubkey = PublicKey::from(&recovered_key); +// Ok(public_key_to_address(pubkey)) +// } +// } +// +// Recover signer from message hash, _without ensuring that the signature has a low `s` +// value_. +// +// Using this for signature validation will succeed, even if the signature is malleable or +// not compliant with EIP-2. This is provided for compatibility with old signatures which +// have large `s` values. +// pub fn recover_signer_unchecked(&self, hash: B256) -> Option
{ +// let mut sig: [u8; 65] = [0; 65]; +// +// sig[0..32].copy_from_slice(&self.r.to_be_bytes::<32>()); +// sig[32..64].copy_from_slice(&self.s.to_be_bytes::<32>()); +// sig[64] = self.odd_y_parity as u8; +// +// NOTE: we are removing error from underlying crypto library as it will restrain +// primitive errors and we care only if recovery is passing or not. +// recover_signer_unchecked_crypto(&sig, &hash.0).ok() +// } +// +// Recover signer address from message hash. This ensures that the signature S value is +// greater than `secp256k1n / 2`, as specified in +// [EIP-2](https://eips.ethereum.org/EIPS/eip-2). +// +// If the S value is too large, then this will return `None` +// pub fn recover_signer(&self, hash: B256) -> Option
{ +// if self.s > SECP256K1N_HALF { +// return None +// } +// +// self.recover_signer_unchecked(hash) +// } +// +// +// Converts a public key into an ethereum address by hashing the encoded public key with +// keccak256. +// pub fn public_key_to_address(public: PublicKey) -> Address { +// let pubkey_bytes = +// public.to_encoded_point(false).as_bytes().try_into().expect("The slice has 65 bytes"); +// public_key_bytes_to_address(&pubkey_bytes) +// strip out the first byte because that should be the SECP256K1_TAG_PUBKEY_UNCOMPRESSED +// tag returned by libsecp's uncompressed pubkey serialization +// let hash = keccak256(&public.serialize_uncompressed()[1..]); +// Address::from_slice(&hash[12..]) +// } +// +// fn public_key_bytes_to_address(public: &[u8; 65]) -> Address { +// Strip out first byte of sec1 encoded pubkey +// let hash = keccak(&public[1..]); +// Address::from_slice(&hash[12..]) +// } +// diff --git a/raiko-guests/sgx/src/one_shot.rs b/raiko-guests/sgx/src/one_shot.rs index c2009cec..c247c434 100644 --- a/raiko-guests/sgx/src/one_shot.rs +++ b/raiko-guests/sgx/src/one_shot.rs @@ -15,7 +15,6 @@ use zeth_lib::{ consts::TKO_MAINNET_CHAIN_SPEC, input::Input, taiko::{ - host::{HostArgs}, protocol_instance::{assemble_protocol_instance, EvidenceType}, TaikoGuestInput, }, diff --git a/raiko-host/src/host/host.rs b/raiko-host/src/host/host.rs index aa3f83e7..5354ef46 100644 --- a/raiko-host/src/host/host.rs +++ b/raiko-host/src/host/host.rs @@ -1,31 +1,32 @@ -use std::{path::PathBuf, sync::Arc}; +use std::sync::Arc; -use alloy_sol_types::{SolCall, SolEvent}; -use alloy_rpc_types::{Block as AlloyBlock, BlockTransactions, Filter, Transaction as AlloyRpcTransaction}; +pub use alloy_primitives::*; use alloy_providers::tmp::{HttpProvider, TempProvider}; +pub use alloy_rlp as rlp; +use alloy_rpc_types::{ + Block as AlloyBlock, BlockTransactions, Filter, Transaction as AlloyRpcTransaction, +}; +use alloy_sol_types::{SolCall, SolEvent}; use alloy_transport_http::Http; -use c_kzg::{Blob, KzgCommitment}; -use url::Url; - use anyhow::{anyhow, bail, Result}; +use c_kzg::{Blob, KzgCommitment}; use hashbrown::HashSet; -use log::info; -use reth_primitives::{constants::eip4844::MAINNET_KZG_TRUSTED_SETUP, eip4844::kzg_to_versioned_hash}; +use reth_primitives::{ + constants::eip4844::MAINNET_KZG_TRUSTED_SETUP, eip4844::kzg_to_versioned_hash, +}; use serde::{Deserialize, Serialize}; +use url::Url; use zeth_lib::{ builder::{prepare::TaikoHeaderPrepStrategy, BlockBuilder, TkoTxExecStrategy}, input::{ - decode_anchor, decode_propose_block_call_params, proposeBlockCall, protocol_testnet::BlockProposed as TestnetBlockProposed, BlockProposed, GuestInput, TaikoGuestInput, TaikoProverData + decode_anchor, proposeBlockCall, protocol_testnet::BlockProposed as TestnetBlockProposed, + BlockProposed, GuestInput, TaikoGuestInput, TaikoProverData, }, taiko_utils::{generate_transactions, get_contracts, to_header}, }; use zeth_primitives::mpt::proofs_to_tries; -use super::provider::GetBlobsResponse; -use crate::host::{provider::GetBlobData, provider_db::ProviderDb}; - -pub use alloy_primitives::*; -pub use alloy_rlp as rlp; +use crate::host::provider_db::ProviderDb; pub trait RlpBytes { /// Returns the RLP-encoding. @@ -46,99 +47,6 @@ where } } - -#[derive(Debug, Clone, Serialize, Deserialize)] -pub struct HostArgs { - pub l1_cache: Option, - pub l1_rpc: Option, - pub l2_cache: Option, - pub l2_rpc: Option, -} - -pub fn get_block(provider: &HttpProvider, block_number: u64, full: bool) -> Result { - let tokio_handle = tokio::runtime::Handle::current(); - let response = tokio_handle.block_on(async { - provider - .get_block_by_number((block_number).into(), full) - .await - })?; - match response { - Some(out) => Ok(out), - None => Err(anyhow!("No data for {block_number:?}")), - } -} - -pub fn get_log(rpc_url: String, chain_name: &str, block_hash: B256, l2_block_no: u64) -> Result<(AlloyRpcTransaction, BlockProposed)> { - let http = Http::new(Url::parse(&rpc_url).expect("invalid rpc url")); - let provider: HttpProvider = HttpProvider::new(http); - - - let l1_address = get_contracts(chain_name).unwrap().0; - - //info!("Querying RPC for full block: {query:?}"); - - let tokio_handle = tokio::runtime::Handle::current(); - - let event_signature = if chain_name == "testnet" { - TestnetBlockProposed::SIGNATURE_HASH - } else { - BlockProposed::SIGNATURE_HASH - }; - - let filter = Filter::new() - .address(l1_address) - .at_block_hash(block_hash) - .event_signature(event_signature); - - let logs = tokio_handle.block_on(async { - provider - .get_logs(filter) - .await - })?; - - for log in logs { - if chain_name == "testnet" { - let event = TestnetBlockProposed::decode_log(&Log::new(log.address, log.topics, log.data).unwrap(), false).unwrap(); - if event.blockId == zeth_primitives::U256::from(l2_block_no) { - let tx = tokio_handle.block_on(async { - provider - .get_transaction_by_hash(log.transaction_hash.unwrap()) - .await - }).expect("could not find the propose tx"); - return Ok((tx, event.data.into())); - } - } else { - let event = BlockProposed::decode_log(&Log::new(log.address, log.topics, log.data).unwrap(), false).unwrap(); - if event.blockId == zeth_primitives::U256::from(l2_block_no) { - let tx = tokio_handle.block_on(async { - provider - .get_transaction_by_hash(log.transaction_hash.unwrap()) - .await - }).expect("could not find the propose tx"); - return Ok((tx, event.data)); - } - } - } - bail!("No BlockProposed event found for block {l2_block_no}"); -} - -fn get_blob_data(beacon_rpc_url: &str, block_id: u64) -> Result { - let tokio_handle = tokio::runtime::Handle::current(); - tokio_handle.block_on(async { - let url = format!("{}/eth/v1/beacon/blob_sidecars/{}", beacon_rpc_url, block_id); - let response = reqwest::get(url.clone()).await?; - if response.status().is_success() { - let blob_response: GetBlobsResponse = response.json().await?; - Ok(blob_response) - } else { - Err(anyhow::anyhow!( - "Request failed with status code: {}", - response.status() - )) - } - }) -} - pub fn preflight( l1_rpc_url: Option, l2_rpc_url: Option, @@ -153,8 +61,8 @@ pub fn preflight( let http_l1 = Http::new(Url::parse(&l1_rpc_url.clone().unwrap()).expect("invalid rpc url")); let provider_l1: HttpProvider = HttpProvider::new(http_l1); - let parent_block = get_block(&provider_l2, l2_block_no - 1, false).unwrap(); let block = get_block(&provider_l2, l2_block_no, true).unwrap(); + let parent_block = get_block(&provider_l2, l2_block_no - 1, false).unwrap(); // Decode the anchor tx to find out which L1 blocks we need to fetch let anchor_tx = match &block.transactions { @@ -172,32 +80,37 @@ pub fn preflight( println!("anchor L1 state root: {:?}", anchor_call.l1SignalRoot); // Get the L1 state block header so that we can prove the L1 state root - let l1_state_block = get_block(&provider_l1, l1_state_block_no, false).unwrap(); let l1_inclusion_block = get_block(&provider_l1, l1_inclusion_block_no, false).unwrap(); + let l1_state_block = get_block(&provider_l1, l1_state_block_no, false).unwrap(); println!( "l1_state_root_block hash: {:?}", l1_state_block.header.hash.unwrap() ); // Get the block proposal data - let (proposal_tx, proposal_event) = - get_log(l1_rpc_url.clone().unwrap(), chain_spec_name, l1_inclusion_block.header.hash.unwrap(), l2_block_no)?; - let proposal_call = proposeBlockCall::abi_decode(&proposal_tx.input, false).unwrap(); + let (proposal_tx, proposal_event) = get_log( + l1_rpc_url.clone().unwrap(), + chain_spec_name, + l1_inclusion_block.header.hash.unwrap(), + l2_block_no, + )?; // Fetch the tx list let (tx_list, tx_blob_hash) = if proposal_event.meta.blobUsed { println!("blob active"); - let metadata = decode_propose_block_call_params(&proposal_call.params) - .expect("valid propose_block_call_params"); - println!("metadata: {:?}", metadata); + let metadata = &proposal_event.meta; + // Get the blob hashes attached to the propose tx let blob_hashs = proposal_tx.blob_versioned_hashes; assert!(blob_hashs.len() >= 1); + // Currently the protocol enforces the first blob hash to be used let blob_hash = blob_hashs[0]; // TODO: check _proposed_blob_hash with blob_hash if _proposed_blob_hash is not None + // Get the blob data for this block let blobs = get_blob_data(&beacon_rpc_url.clone().unwrap(), l1_inclusion_block_no)?; assert!(blobs.data.len() > 0, "blob data not available anymore"); + // Get the blob data for the blob storing the tx list let tx_blobs: Vec = blobs .data .iter() @@ -208,6 +121,7 @@ pub fn preflight( .cloned() .collect::>(); let blob_data = decode_blob_data(&tx_blobs[0].blob); + // Extract the specified range at which the tx list is stored let offset = metadata.txListByteOffset as usize; let size = metadata.txListByteSize as usize; ( @@ -215,6 +129,8 @@ pub fn preflight( Some(blob_hash), ) } else { + // Get the tx list data directly from the propose transaction data + let proposal_call = proposeBlockCall::abi_decode(&proposal_tx.input, false).unwrap(); (proposal_call.txList.clone(), None) }; @@ -255,7 +171,10 @@ pub fn preflight( }; // Create the block builder, run the transactions and extract the DB - let provider_db = ProviderDb::new(provider_l2, parent_block.header.number.unwrap().try_into().unwrap()); + let provider_db = ProviderDb::new( + provider_l2, + parent_block.header.number.unwrap().try_into().unwrap(), + ); let mut builder = BlockBuilder::new(&input) .with_db(provider_db) .prepare_header::()? @@ -298,7 +217,9 @@ const BLOB_DATA_LEN: usize = BLOB_FIELD_ELEMENT_NUM * BLOB_FIELD_ELEMENT_BYTES; fn decode_blob_data(blob: &str) -> Vec { let origin_blob = hex::decode(blob.to_lowercase().trim_start_matches("0x")).unwrap(); - let header: U256 = U256::from_be_bytes::(origin_blob[0..BLOB_FIELD_ELEMENT_BYTES].try_into().unwrap()); // first element is the length + let header: U256 = U256::from_be_bytes::( + origin_blob[0..BLOB_FIELD_ELEMENT_BYTES].try_into().unwrap(), + ); // first element is the length let expected_len = header.as_limbs()[0] as usize; assert!(origin_blob.len() == BLOB_DATA_LEN); @@ -330,4 +251,128 @@ fn calc_blob_versioned_hash(blob_str: &str) -> [u8; 32] { let kzg_commit = KzgCommitment::blob_to_kzg_commitment(&blob, &kzg_settings).unwrap(); let version_hash: [u8; 32] = kzg_to_versioned_hash(kzg_commit).0; version_hash -} \ No newline at end of file +} + +fn get_blob_data(beacon_rpc_url: &str, block_id: u64) -> Result { + let tokio_handle = tokio::runtime::Handle::current(); + tokio_handle.block_on(async { + let url = format!( + "{}/eth/v1/beacon/blob_sidecars/{}", + beacon_rpc_url, block_id + ); + let response = reqwest::get(url.clone()).await?; + if response.status().is_success() { + let blob_response: GetBlobsResponse = response.json().await?; + Ok(blob_response) + } else { + Err(anyhow::anyhow!( + "Request failed with status code: {}", + response.status() + )) + } + }) +} + +// Blob data from the beacon chain +// type Sidecar struct { +// Index string `json:"index"` +// Blob string `json:"blob"` +// SignedBeaconBlockHeader *SignedBeaconBlockHeader `json:"signed_block_header"` +// KzgCommitment string `json:"kzg_commitment"` +// KzgProof string `json:"kzg_proof"` +// CommitmentInclusionProof []string +// `json:"kzg_commitment_inclusion_proof"` } +#[derive(Clone, Debug, Deserialize, Serialize)] +pub struct GetBlobData { + pub index: String, + pub blob: String, + // pub signed_block_header: SignedBeaconBlockHeader, // ignore for now + pub kzg_commitment: String, + pub kzg_proof: String, + pub kzg_commitment_inclusion_proof: Vec, +} + +#[derive(Clone, Debug, Deserialize, Serialize)] +pub struct GetBlobsResponse { + pub data: Vec, +} + +pub fn get_block(provider: &HttpProvider, block_number: u64, full: bool) -> Result { + let tokio_handle = tokio::runtime::Handle::current(); + let response = tokio_handle.block_on(async { + provider + .get_block_by_number((block_number).into(), full) + .await + })?; + match response { + Some(out) => Ok(out), + None => Err(anyhow!("No data for {block_number:?}")), + } +} + +pub fn get_log( + rpc_url: String, + chain_name: &str, + block_hash: B256, + l2_block_no: u64, +) -> Result<(AlloyRpcTransaction, BlockProposed)> { + let http = Http::new(Url::parse(&rpc_url).expect("invalid rpc url")); + let provider: HttpProvider = HttpProvider::new(http); + let tokio_handle = tokio::runtime::Handle::current(); + + // Get the address that emited the event + let l1_address = get_contracts(chain_name).unwrap().0; + + // Get the event signature (value can differ between chains) + let event_signature = if chain_name == "testnet" { + TestnetBlockProposed::SIGNATURE_HASH + } else { + BlockProposed::SIGNATURE_HASH + }; + // Setup the filter to get the relevant events + let filter = Filter::new() + .address(l1_address) + .at_block_hash(block_hash) + .event_signature(event_signature); + // Now fetch the events + let logs = tokio_handle.block_on(async { provider.get_logs(filter).await })?; + + // Run over the logs returned to find the matching event for the specified L2 block number + // (there can be multiple blocks proposed in the same block and even same tx) + for log in logs { + if chain_name == "testnet" { + let event = TestnetBlockProposed::decode_log( + &Log::new(log.address, log.topics, log.data).unwrap(), + false, + ) + .unwrap(); + if event.blockId == zeth_primitives::U256::from(l2_block_no) { + let tx = tokio_handle + .block_on(async { + provider + .get_transaction_by_hash(log.transaction_hash.unwrap()) + .await + }) + .expect("could not find the propose tx"); + return Ok((tx, event.data.into())); + } + } else { + let event = BlockProposed::decode_log( + &Log::new(log.address, log.topics, log.data).unwrap(), + false, + ) + .unwrap(); + if event.blockId == zeth_primitives::U256::from(l2_block_no) { + let tx = tokio_handle + .block_on(async { + provider + .get_transaction_by_hash(log.transaction_hash.unwrap()) + .await + }) + .expect("could not find the propose tx"); + return Ok((tx, event.data)); + } + } + } + bail!("No BlockProposed event found for block {l2_block_no}"); +} diff --git a/raiko-host/src/host/mod.rs b/raiko-host/src/host/mod.rs index e2faf174..fa5b386b 100644 --- a/raiko-host/src/host/mod.rs +++ b/raiko-host/src/host/mod.rs @@ -14,5 +14,4 @@ extern crate std; pub mod host; -pub mod provider; -pub mod provider_db; \ No newline at end of file +pub mod provider_db; diff --git a/raiko-host/src/host/provider/cached_rpc_provider.rs b/raiko-host/src/host/provider/cached_rpc_provider.rs deleted file mode 100644 index 20bbe071..00000000 --- a/raiko-host/src/host/provider/cached_rpc_provider.rs +++ /dev/null @@ -1,195 +0,0 @@ -// Copyright 2023 RISC Zero, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -use std::path::PathBuf; - -use alloy_rpc_types::EIP1186AccountProofResponse; -use anyhow::Result; -use ethers_core::types::{Block, Bytes, Log, Transaction, TransactionReceipt, H256, U256}; - -use super::{ - file_provider::FileProvider, rpc_provider::RpcProvider, AccountQuery, BlockQuery, - GetBlobsResponse, MutProvider, ProofQuery, Provider, StorageQuery, -}; -use crate::host::provider::LogsQuery; - -pub struct CachedRpcProvider { - cache: FileProvider, - rpc: RpcProvider, -} - -impl CachedRpcProvider { - pub fn new( - cache_path: PathBuf, - rpc_url: String, - beacon_rpc_url: Option, - ) -> Result { - let cache = match FileProvider::from_file(&cache_path) { - Ok(provider) => provider, - Err(_) => FileProvider::empty(cache_path), - }; - let rpc = RpcProvider::new(rpc_url, beacon_rpc_url)?; - - Ok(CachedRpcProvider { cache, rpc }) - } -} - -impl Provider for CachedRpcProvider { - fn save(&self) -> Result<()> { - self.cache.save() - } - - fn get_full_block(&mut self, query: &BlockQuery) -> Result> { - let cache_out = self.cache.get_full_block(query); - if cache_out.is_ok() { - return cache_out; - } - - let out = self.rpc.get_full_block(query)?; - self.cache.insert_full_block(query.clone(), out.clone()); - - Ok(out) - } - - fn get_partial_block(&mut self, query: &BlockQuery) -> Result> { - let cache_out = self.cache.get_partial_block(query); - if cache_out.is_ok() { - return cache_out; - } - - let out = self.rpc.get_partial_block(query)?; - self.cache.insert_partial_block(query.clone(), out.clone()); - - Ok(out) - } - - fn get_block_receipts(&mut self, query: &BlockQuery) -> Result> { - let cache_out = self.cache.get_block_receipts(query); - if cache_out.is_ok() { - return cache_out; - } - - let out = self.rpc.get_block_receipts(query)?; - self.cache.insert_block_receipts(query.clone(), out.clone()); - - Ok(out) - } - - fn get_proof(&mut self, query: &ProofQuery) -> Result { - let cache_out = self.cache.get_proof(query); - if cache_out.is_ok() { - return cache_out; - } - - let out = self.rpc.get_proof(query)?; - self.cache.insert_proof(query.clone(), out.clone()); - - Ok(out) - } - - fn get_transaction_count(&mut self, query: &AccountQuery) -> Result { - let cache_out = self.cache.get_transaction_count(query); - if cache_out.is_ok() { - return cache_out; - } - - let out = self.rpc.get_transaction_count(query)?; - self.cache.insert_transaction_count(query.clone(), out); - - Ok(out) - } - - fn get_balance(&mut self, query: &AccountQuery) -> Result { - let cache_out = self.cache.get_balance(query); - if cache_out.is_ok() { - return cache_out; - } - - let out = self.rpc.get_balance(query)?; - self.cache.insert_balance(query.clone(), out); - - Ok(out) - } - - fn get_code(&mut self, query: &AccountQuery) -> Result { - let cache_out = self.cache.get_code(query); - if cache_out.is_ok() { - return cache_out; - } - - let out = self.rpc.get_code(query)?; - self.cache.insert_code(query.clone(), out.clone()); - - Ok(out) - } - - fn get_storage(&mut self, query: &StorageQuery) -> Result { - let cache_out = self.cache.get_storage(query); - if cache_out.is_ok() { - return cache_out; - } - - let out = self.rpc.get_storage(query)?; - self.cache.insert_storage(query.clone(), out); - - Ok(out) - } - - fn get_logs(&mut self, query: &LogsQuery) -> Result> { - let cache_out = self.cache.get_logs(query); - if cache_out.is_ok() { - return cache_out; - } - - let out = self.rpc.get_logs(query)?; - self.cache.insert_logs(query.clone(), out.clone()); - - Ok(out) - } - - fn get_transaction(&mut self, query: &super::TxQuery) -> Result { - let cache_out = self.cache.get_transaction(query); - if cache_out.is_ok() { - return cache_out; - } - - // Search cached block for target Tx - if let Some(block_no) = query.block_no { - if let Ok(block) = self.cache.get_full_block(&BlockQuery { block_no }) { - for tx in block.transactions { - if tx.hash == query.tx_hash { - return Ok(tx.clone()); - } - } - } - } - - let out = self.rpc.get_transaction(query)?; - self.cache.insert_transaction(query.clone(), out.clone()); - - Ok(out) - } - - fn get_blob_data(&mut self, block_id: u64) -> Result { - let cache_out = self.cache.get_blob_data(block_id); - if cache_out.is_ok() { - return cache_out; - } - - let out = self.rpc.get_blob_data(block_id)?; - self.cache.insert_blob(block_id, out.clone()); - - Ok(out) - } -} diff --git a/raiko-host/src/host/provider/file_provider.rs b/raiko-host/src/host/provider/file_provider.rs deleted file mode 100644 index 6f9b5a1d..00000000 --- a/raiko-host/src/host/provider/file_provider.rs +++ /dev/null @@ -1,267 +0,0 @@ -// Copyright 2023 RISC Zero, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -use std::{ - collections::HashMap, - fs::File, - io::{Read, Write}, - path::{Path, PathBuf}, -}; - -use alloy_rpc_types::EIP1186AccountProofResponse; -use anyhow::{anyhow, Result}; -use ethers_core::types::{Block, Bytes, Log, Transaction, TransactionReceipt, H256, U256}; -use serde::{Deserialize, Serialize}; -use serde_with::serde_as; -use zeth_lib::input::BlockProposed; - -use super::{ - AccountQuery, BlockQuery, GetBlobsResponse, LogsQuery, MutProvider, ProofQuery, Provider, - StorageQuery, TxQuery, -}; - -#[serde_as] -#[derive(Default, Deserialize, Serialize)] -pub struct FileProvider { - #[serde(skip)] - file_path: PathBuf, - #[serde(skip)] - dirty: bool, - #[serde_as(as = "Vec<(_, _)>")] - full_blocks: HashMap>, - #[serde_as(as = "Vec<(_, _)>")] - partial_blocks: HashMap>, - #[serde(default)] - #[serde_as(as = "Vec<(_, _)>")] - receipts: HashMap>, - #[serde_as(as = "Vec<(_, _)>")] - proofs: HashMap, - #[serde_as(as = "Vec<(_, _)>")] - transaction_count: HashMap, - #[serde_as(as = "Vec<(_, _)>")] - balance: HashMap, - #[serde_as(as = "Vec<(_, _)>")] - code: HashMap, - #[serde_as(as = "Vec<(_, _)>")] - storage: HashMap, - - #[serde_as(as = "Vec<(_, _)>")] - logs: HashMap>, - #[serde_as(as = "Vec<(_, _)>")] - transactions: HashMap, - propose: Option<(Transaction, BlockProposed)>, - blobs: HashMap, -} - -impl FileProvider { - pub fn empty(file_path: PathBuf) -> Self { - FileProvider { - file_path, - dirty: false, - full_blocks: HashMap::new(), - partial_blocks: HashMap::new(), - receipts: HashMap::new(), - proofs: HashMap::new(), - transaction_count: HashMap::new(), - balance: HashMap::new(), - code: HashMap::new(), - storage: HashMap::new(), - logs: Default::default(), - transactions: Default::default(), - propose: Default::default(), - blobs: Default::default(), - } - } - - pub fn from_file(file_path: &PathBuf) -> Result { - let mut buf = vec![]; - let mut decoder = flate2::read::GzDecoder::new(File::open(file_path)?); - decoder.read_to_end(&mut buf)?; - - let mut out: Self = serde_json::from_slice(&buf[..])?; - - out.file_path = file_path.clone(); - out.dirty = false; - Ok(out) - } - - pub fn save_to_file(&self, file_path: &Path) -> Result<()> { - if self.dirty { - let mut encoder = flate2::write::GzEncoder::new( - File::create(file_path)?, - flate2::Compression::best(), - ); - encoder.write_all(&serde_json::to_vec(self)?)?; - encoder.finish()?; - } - - Ok(()) - } -} - -impl Provider for FileProvider { - fn save(&self) -> Result<()> { - self.save_to_file(&self.file_path) - } - - fn get_full_block(&mut self, query: &BlockQuery) -> Result> { - match self.full_blocks.get(query) { - Some(val) => Ok(val.clone()), - None => Err(anyhow!("No data for {query:?}")), - } - } - - fn get_partial_block(&mut self, query: &BlockQuery) -> Result> { - match self.partial_blocks.get(query) { - Some(val) => Ok(val.clone()), - None => Err(anyhow!("No data for {query:?}")), - } - } - - fn get_block_receipts(&mut self, query: &BlockQuery) -> Result> { - match self.receipts.get(query) { - Some(val) => Ok(val.clone()), - None => Err(anyhow!("No data for {query:?}")), - } - } - - fn get_proof(&mut self, query: &ProofQuery) -> Result { - match self.proofs.get(query) { - Some(val) => Ok(val.clone()), - None => Err(anyhow!("No data for {query:?}")), - } - } - - fn get_transaction_count(&mut self, query: &AccountQuery) -> Result { - match self.transaction_count.get(query) { - Some(val) => Ok(*val), - None => Err(anyhow!("No data for {query:?}")), - } - } - - fn get_balance(&mut self, query: &AccountQuery) -> Result { - match self.balance.get(query) { - Some(val) => Ok(*val), - None => Err(anyhow!("No data for {query:?}")), - } - } - - fn get_code(&mut self, query: &AccountQuery) -> Result { - match self.code.get(query) { - Some(val) => Ok(val.clone()), - None => Err(anyhow!("No data for {query:?}")), - } - } - - fn get_storage(&mut self, query: &StorageQuery) -> Result { - match self.storage.get(query) { - Some(val) => Ok(*val), - None => Err(anyhow!("No data for {query:?}")), - } - } - - fn get_logs(&mut self, query: &LogsQuery) -> Result> { - match self.logs.get(query) { - Some(val) => Ok(val.clone()), - None => Err(anyhow!("No data for {query:?}")), - } - } - - fn get_transaction(&mut self, query: &TxQuery) -> Result { - match self.transactions.get(query) { - Some(val) => Ok(val.clone()), - None => Err(anyhow!("No data for {query:?}")), - } - } - - fn get_blob_data(&mut self, block_id: u64) -> Result { - match self.blobs.get(&block_id) { - Some(val) => Ok(val.clone()), - None => Err(anyhow!("No data for block id: {block_id:?}")), - } - } -} - -impl MutProvider for FileProvider { - fn insert_full_block(&mut self, query: BlockQuery, val: Block) { - self.full_blocks.insert(query, val); - self.dirty = true; - } - - fn insert_partial_block(&mut self, query: BlockQuery, val: Block) { - self.partial_blocks.insert(query, val); - self.dirty = true; - } - - fn insert_block_receipts(&mut self, query: BlockQuery, val: Vec) { - self.receipts.insert(query, val); - self.dirty = true; - } - - fn insert_proof(&mut self, query: ProofQuery, val: EIP1186AccountProofResponse) { - self.proofs.insert(query, val); - self.dirty = true; - } - - fn insert_transaction_count(&mut self, query: AccountQuery, val: U256) { - self.transaction_count.insert(query, val); - self.dirty = true; - } - - fn insert_balance(&mut self, query: AccountQuery, val: U256) { - self.balance.insert(query, val); - self.dirty = true; - } - - fn insert_code(&mut self, query: AccountQuery, val: Bytes) { - self.code.insert(query, val); - self.dirty = true; - } - - fn insert_storage(&mut self, query: StorageQuery, val: H256) { - self.storage.insert(query, val); - self.dirty = true; - } - - fn insert_logs(&mut self, query: LogsQuery, val: Vec) { - self.logs.insert(query, val); - self.dirty = true; - } - - fn insert_transaction(&mut self, query: TxQuery, val: Transaction) { - self.transactions.insert(query, val); - self.dirty = true; - } - - fn insert_blob(&mut self, block_id: u64, val: GetBlobsResponse) { - self.blobs.insert(block_id, val); - self.dirty = true; - } -} - -pub fn cache_file_path(cache_path: &Path, block_no: u64, is_l1: bool) -> PathBuf { - let prefix = if is_l1 { "l1" } else { "l2" }; - let file_name = format!("{block_no}.{prefix}.json.gz"); - cache_path.join(file_name) -} - -#[cfg(test)] -mod tests { - #[test] - fn test_file_prefix() { - let path = std::path::Path::new("/tmp/ethereum/1234.l1.json.gz"); - let prefix = path.file_prefix().unwrap(); - assert_eq!(prefix, "1234"); - } -} diff --git a/raiko-host/src/host/provider/mod.rs b/raiko-host/src/host/provider/mod.rs deleted file mode 100644 index 25a1eeea..00000000 --- a/raiko-host/src/host/provider/mod.rs +++ /dev/null @@ -1,167 +0,0 @@ -// Copyright 2023 RISC Zero, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -use std::{collections::BTreeSet, path::PathBuf}; - -use alloy_primitives::Address; -use alloy_rpc_types::EIP1186AccountProofResponse; -use alloy_sol_types::SolEvent; -use anyhow::{anyhow, Context, Result}; -use ethers_core::types::{Block, Bytes, Log, Transaction, TransactionReceipt, H160, H256, U256}; -use serde::{Deserialize, Serialize}; -use zeth_lib::input::BlockProposed; - -pub mod cached_rpc_provider; -pub mod file_provider; -pub mod rpc_provider; - -// Blob data from the beacon chain -// type Sidecar struct { -// Index string `json:"index"` -// Blob string `json:"blob"` -// SignedBeaconBlockHeader *SignedBeaconBlockHeader `json:"signed_block_header"` -// KzgCommitment string `json:"kzg_commitment"` -// KzgProof string `json:"kzg_proof"` -// CommitmentInclusionProof []string -// `json:"kzg_commitment_inclusion_proof"` } -#[derive(Clone, Debug, Deserialize, Serialize)] -pub struct GetBlobData { - pub index: String, - pub blob: String, - // pub signed_block_header: SignedBeaconBlockHeader, // ignore for now - pub kzg_commitment: String, - pub kzg_proof: String, - pub kzg_commitment_inclusion_proof: Vec, -} - -#[derive(Clone, Debug, Deserialize, Serialize)] -pub struct GetBlobsResponse { - pub data: Vec, -} - -#[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)] -pub struct AccountQuery { - pub block_no: u64, - pub address: H160, -} - -#[derive(Clone, Debug, Deserialize, PartialOrd, Ord, Eq, Hash, PartialEq, Serialize)] -pub struct BlockQuery { - pub block_no: u64, -} - -#[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)] -pub struct ProofQuery { - pub block_no: u64, - pub address: H160, - pub indices: BTreeSet, -} - -#[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)] -pub struct StorageQuery { - pub block_no: u64, - pub address: H160, - pub index: H256, -} - -#[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)] -pub struct LogsQuery { - pub address: H160, - pub from_block: u64, - pub to_block: u64, -} - -#[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)] -pub struct TxQuery { - pub tx_hash: H256, - pub block_no: Option, -} - -#[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)] -pub struct ProposeQuery { - pub l1_contract: H160, - pub l1_block_no: u64, - pub l2_block_no: u64, -} - -pub trait Provider: Send { - fn save(&self) -> Result<()>; - - fn get_full_block(&mut self, query: &BlockQuery) -> Result>; - fn get_partial_block(&mut self, query: &BlockQuery) -> Result>; - fn get_block_receipts(&mut self, query: &BlockQuery) -> Result>; - fn get_proof(&mut self, query: &ProofQuery) -> Result; - fn get_transaction_count(&mut self, query: &AccountQuery) -> Result; - fn get_balance(&mut self, query: &AccountQuery) -> Result; - fn get_code(&mut self, query: &AccountQuery) -> Result; - fn get_storage(&mut self, query: &StorageQuery) -> Result; - fn get_logs(&mut self, query: &LogsQuery) -> Result>; - fn get_transaction(&mut self, query: &TxQuery) -> Result; - fn get_blob_data(&mut self, block_id: u64) -> Result; -} - -pub trait MutProvider: Provider { - fn insert_full_block(&mut self, query: BlockQuery, val: Block); - fn insert_partial_block(&mut self, query: BlockQuery, val: Block); - fn insert_block_receipts(&mut self, query: BlockQuery, val: Vec); - fn insert_proof(&mut self, query: ProofQuery, val: EIP1186AccountProofResponse); - fn insert_transaction_count(&mut self, query: AccountQuery, val: U256); - fn insert_balance(&mut self, query: AccountQuery, val: U256); - fn insert_code(&mut self, query: AccountQuery, val: Bytes); - fn insert_storage(&mut self, query: StorageQuery, val: H256); - fn insert_logs(&mut self, query: LogsQuery, val: Vec); - fn insert_transaction(&mut self, query: TxQuery, val: Transaction); - fn insert_blob(&mut self, block_id: u64, val: GetBlobsResponse); -} - -pub fn new_file_provider(file_path: PathBuf) -> Result> { - let provider = file_provider::FileProvider::from_file(&file_path) - .with_context(|| anyhow!("invalid cache file: {}", file_path.display()))?; - - Ok(Box::new(provider)) -} - -pub fn new_rpc_provider( - rpc_url: String, - beacon_rpc_url: Option, -) -> Result> { - let provider = rpc_provider::RpcProvider::new(rpc_url, beacon_rpc_url)?; - - Ok(Box::new(provider)) -} - -pub fn new_cached_rpc_provider( - cache_path: PathBuf, - rpc_url: String, - beacon_rpc_url: Option, -) -> Result> { - let provider = - cached_rpc_provider::CachedRpcProvider::new(cache_path, rpc_url, beacon_rpc_url)?; - - Ok(Box::new(provider)) -} - -pub fn new_provider( - cache_path: Option, - rpc_url: Option, - beacon_rpc_url: Option, -) -> Result> { - match (cache_path, rpc_url) { - (Some(cache_path), Some(rpc_url)) => { - new_cached_rpc_provider(cache_path, rpc_url, beacon_rpc_url) - } - (Some(cache_path), None) => new_file_provider(cache_path), - (None, Some(rpc_url)) => new_rpc_provider(rpc_url, beacon_rpc_url), - (None, None) => Err(anyhow!("No cache_path or rpc_url given")), - } -} diff --git a/raiko-host/src/host/provider/rpc_provider.rs b/raiko-host/src/host/provider/rpc_provider.rs deleted file mode 100644 index 42a1113c..00000000 --- a/raiko-host/src/host/provider/rpc_provider.rs +++ /dev/null @@ -1,215 +0,0 @@ -// Copyright 2023 RISC Zero, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -use alloy_providers::tmp::{HttpProvider, TempProvider}; -use alloy_rpc_types::{BlockId, EIP1186AccountProofResponse}; -use alloy_transport_http::Http; -use anyhow::{anyhow, Result}; -use ethers_core::types::{Block, Bytes, Filter, Log, Transaction, TransactionReceipt, H256, U256}; -use ethers_providers::{Http as ethers_Http, Middleware, RetryClient}; -use log::info; -use reqwest; -use url::Url; - -use super::{AccountQuery, BlockQuery, GetBlobsResponse, ProofQuery, Provider, StorageQuery}; -use crate::host::provider::LogsQuery; - -pub struct RpcProvider { - ethers_provider: ethers_providers::Provider>, - alloy_provider: HttpProvider, - beacon_rpc_url: Option, - tokio_handle: tokio::runtime::Handle, -} - -impl RpcProvider { - pub fn new(rpc_url: String, beacon_rpc_url: Option) -> Result { - // TODO(Brecht): switch to alloy provider for everything - let ethers_provider = - ethers_providers::Provider::>::new_client(&rpc_url, 3, 500)?; - - let alloy_http = Http::new(Url::parse(&rpc_url).expect("invalid rpc url")); - let alloy_provider: HttpProvider = HttpProvider::new(alloy_http); - - let tokio_handle = tokio::runtime::Handle::current(); - - Ok(RpcProvider { - ethers_provider, - alloy_provider, - beacon_rpc_url, - tokio_handle, - }) - } -} - -impl Provider for RpcProvider { - fn save(&self) -> Result<()> { - Ok(()) - } - - fn get_full_block(&mut self, query: &BlockQuery) -> Result> { - info!("Querying RPC for full block: {query:?}"); - - let response = self.tokio_handle.block_on(async { - self.ethers_provider - .get_block_with_txs(query.block_no) - .await - })?; - - match response { - Some(out) => Ok(out), - None => Err(anyhow!("No data for {query:?}")), - } - } - - fn get_partial_block(&mut self, query: &BlockQuery) -> Result> { - info!("Querying RPC for partial block: {query:?}"); - - let response = self - .tokio_handle - .block_on(async { self.ethers_provider.get_block(query.block_no).await })?; - - match response { - Some(out) => Ok(out), - None => Err(anyhow!("No data for {query:?}")), - } - } - - fn get_block_receipts(&mut self, query: &BlockQuery) -> Result> { - info!("Querying RPC for block receipts: {query:?}"); - - let response = self.tokio_handle.block_on(async { - self.ethers_provider - .get_block_receipts(query.block_no) - .await - })?; - - Ok(response) - } - - fn get_proof(&mut self, query: &ProofQuery) -> Result { - info!("Querying RPC for inclusion proof: {query:?}"); - - let out: EIP1186AccountProofResponse = self.tokio_handle.block_on(async { - self.alloy_provider - .get_proof( - zeth_primitives::Address::from_slice(&query.address.as_bytes()), - query - .indices - .iter() - .cloned() - .map(|v| alloy_primitives::FixedBytes(*v.as_fixed_bytes())) - .collect(), - Some(BlockId::from(query.block_no)), - ) - .await - })?; - - Ok(out) - } - - fn get_transaction_count(&mut self, query: &AccountQuery) -> Result { - info!("Querying RPC for transaction count: {query:?}"); - - let out = self.tokio_handle.block_on(async { - self.ethers_provider - .get_transaction_count(query.address, Some(query.block_no.into())) - .await - })?; - - Ok(out) - } - - fn get_balance(&mut self, query: &AccountQuery) -> Result { - info!("Querying RPC for balance: {query:?}"); - - let out = self.tokio_handle.block_on(async { - self.ethers_provider - .get_balance(query.address, Some(query.block_no.into())) - .await - })?; - - Ok(out) - } - - fn get_code(&mut self, query: &AccountQuery) -> Result { - info!("Querying RPC for code: {query:?}"); - - let out = self.tokio_handle.block_on(async { - self.ethers_provider - .get_code(query.address, Some(query.block_no.into())) - .await - })?; - - Ok(out) - } - - fn get_storage(&mut self, query: &StorageQuery) -> Result { - info!("Querying RPC for storage: {query:?}"); - - let out = self.tokio_handle.block_on(async { - self.ethers_provider - .get_storage_at(query.address, query.index, Some(query.block_no.into())) - .await - })?; - - Ok(out) - } - - fn get_logs(&mut self, query: &LogsQuery) -> Result> { - info!("Querying RPC for logs: {query:?}"); - - let out = self.tokio_handle.block_on(async { - self.ethers_provider - .get_logs( - &Filter::new() - .address(query.address) - .from_block(query.from_block) - .to_block(query.to_block), - ) - .await - })?; - - Ok(out) - } - - fn get_transaction(&mut self, query: &super::TxQuery) -> Result { - info!("Querying RPC for tx: {query:?}"); - let out = self - .tokio_handle - .block_on(async { self.ethers_provider.get_transaction(query.tx_hash).await })?; - match out { - Some(out) => Ok(out), - None => Err(anyhow!("No data for {query:?}")), - } - } - - fn get_blob_data(&mut self, block_id: u64) -> Result { - match self.beacon_rpc_url { - Some(ref url) => self.tokio_handle.block_on(async { - let url = format!("{}/eth/v1/beacon/blob_sidecars/{}", url, block_id); - let response = reqwest::get(url.clone()).await?; - if response.status().is_success() { - let blob_response: GetBlobsResponse = response.json().await?; - Ok(blob_response) - } else { - Err(anyhow::anyhow!( - "Request failed with status code: {}", - response.status() - )) - } - }), - None => Err(anyhow!("No beacon_rpc_url given")), - } - } -} diff --git a/raiko-host/src/host/provider_db.rs b/raiko-host/src/host/provider_db.rs index 0d2dff49..1bd8c809 100644 --- a/raiko-host/src/host/provider_db.rs +++ b/raiko-host/src/host/provider_db.rs @@ -11,6 +11,8 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. +use alloy_consensus::Header as AlloyConsensusHeader; +use alloy_providers::tmp::{HttpProvider, TempProvider}; use alloy_rpc_types::{BlockId, EIP1186AccountProofResponse}; use hashbrown::HashMap; use revm::{ @@ -18,13 +20,10 @@ use revm::{ Database, DatabaseCommit, }; use tokio::runtime::Handle; -use zeth_lib::{taiko_utils::to_header, mem_db::{DbError, MemDb}}; -use zeth_primitives::{ - Address, B256, U256, -}; -use alloy_consensus::Header as AlloyConsensusHeader; +use zeth_lib::{mem_db::MemDb, taiko_utils::to_header}; +use zeth_primitives::{Address, B256, U256}; + use crate::host::host::get_block; -use alloy_providers::tmp::{HttpProvider, TempProvider}; pub struct ProviderDb { pub provider: HttpProvider, @@ -101,9 +100,7 @@ impl ProviderDb { .unwrap_or(&self.block_number); let headers = (*earliest_block..self.block_number) .rev() - .map(|block_no| { - to_header(&get_block(&self.provider, block_no, false).unwrap().header) - }) + .map(|block_no| to_header(&get_block(&self.provider, block_no, false).unwrap().header)) .collect(); Ok(headers) } @@ -195,8 +192,7 @@ impl Database for ProviderDb { .0 .into() }); - self.initial_db - .insert_block_hash(block_number, block_hash); + self.initial_db.insert_block_hash(block_number, block_hash); Ok(block_hash) } diff --git a/raiko-host/src/prover/execution.rs b/raiko-host/src/prover/execution.rs index ad49864b..06a7409c 100644 --- a/raiko-host/src/prover/execution.rs +++ b/raiko-host/src/prover/execution.rs @@ -135,10 +135,7 @@ pub async fn execute( } /// prepare input data for guests -pub async fn prepare_input( - ctx: &mut Context, - req: ProofRequest, -) -> Result { +pub async fn prepare_input(ctx: &mut Context, req: ProofRequest) -> Result { // Todo(Cecilia): should contract address as args, curently hardcode let l1_cache = ctx.l1_cache_file.clone(); let l2_cache = ctx.l2_cache_file.clone(); diff --git a/raiko-host/src/prover/proof/mod.rs b/raiko-host/src/prover/proof/mod.rs index 6446eccb..a010b93b 100644 --- a/raiko-host/src/prover/proof/mod.rs +++ b/raiko-host/src/prover/proof/mod.rs @@ -1,7 +1,5 @@ //! Generate different proofs for the taiko protocol. -use zeth_lib::{ - input::{GuestInput, GuestOutput}, -}; +use zeth_lib::input::{GuestInput, GuestOutput}; use crate::prover::{ context::Context, diff --git a/raiko-host/src/prover/proof/risc0/mod.rs b/raiko-host/src/prover/proof/risc0/mod.rs index 1e224bb7..b07ec695 100644 --- a/raiko-host/src/prover/proof/risc0/mod.rs +++ b/raiko-host/src/prover/proof/risc0/mod.rs @@ -7,9 +7,7 @@ use hex::ToHex; use risc0_guest::{RISC0_METHODS_ELF, RISC0_METHODS_ID}; use serde::{Deserialize, Serialize}; use tracing::info as traicing_info; -use zeth_lib::{ - input::{GuestInput, GuestOutput}, -}; +use zeth_lib::input::{GuestInput, GuestOutput}; use crate::prover::{ consts::*, diff --git a/raiko-host/src/prover/proof/succinct.rs b/raiko-host/src/prover/proof/succinct.rs index 8f01139d..b5bfafc4 100644 --- a/raiko-host/src/prover/proof/succinct.rs +++ b/raiko-host/src/prover/proof/succinct.rs @@ -3,9 +3,7 @@ use std::{env, path::PathBuf}; use alloy_primitives::FixedBytes; use serde::{Deserialize, Serialize}; use sp1_core::{utils, SP1Prover, SP1Stdin, SP1Verifier}; -use zeth_lib::{ - input::{GuestInput, GuestOutput}, -}; +use zeth_lib::input::{GuestInput, GuestOutput}; use crate::prover::{ consts::*, diff --git a/raiko-host/src/prover/server.rs b/raiko-host/src/prover/server.rs index e5e946d1..2377e221 100644 --- a/raiko-host/src/prover/server.rs +++ b/raiko-host/src/prover/server.rs @@ -224,7 +224,6 @@ impl Handler { match method { // enqueues a task for computating proof for any given block "proof" => { - println!("prodfasdfkasj;dkflja;sldk"); let options = params.first().ok_or("expected struct ProofRequest")?; let req: ProofRequest = serde_json::from_value(options.to_owned()).map_err(|e| e.to_string())?; From b71c3f74bdc41ae3259318b84237e8e2bf0cc484 Mon Sep 17 00:00:00 2001 From: brechtpd Date: Tue, 19 Mar 2024 18:18:34 +0000 Subject: [PATCH 06/10] Fix some misc issues --- Cargo.lock | 32 +-- lib/Cargo.toml | 2 - lib/src/builder/execute.rs | 14 +- lib/src/input.rs | 5 +- primitives/Cargo.toml | 1 - raiko-guests/risc0/guest/Cargo.lock | 270 +-------------------- raiko-guests/sgx/Cargo.toml | 1 - raiko-guests/succinct/Cargo.lock | 290 +---------------------- raiko-host/Cargo.toml | 1 + raiko-host/src/prover/execution.rs | 4 +- raiko-host/src/prover/proof/risc0/mod.rs | 11 +- rust-toolchain | 2 +- testing/ef-tests/Cargo.toml | 5 - 13 files changed, 30 insertions(+), 608 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 04264a47..217ffae7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3236,7 +3236,7 @@ version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "681030a937600a36906c185595136d26abfebb4aa9c65701cefcaf8578bb982b" dependencies = [ - "proc-macro-crate 3.1.0", + "proc-macro-crate 1.3.1", "proc-macro2", "quote", "syn 2.0.52", @@ -3869,15 +3869,6 @@ dependencies = [ "toml_edit 0.20.7", ] -[[package]] -name = "proc-macro-crate" -version = "3.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d37c51ca738a55da99dc0c4a34860fd675453b8b36209178c2249bb13651284" -dependencies = [ - "toml_edit 0.21.1", -] - [[package]] name = "proc-macro-error" version = "1.0.4" @@ -5010,9 +5001,9 @@ dependencies = [ [[package]] name = "scale-info" -version = "2.10.0" +version = "2.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f7d66a1128282b7ef025a8ead62a4a9fcf017382ec53b8ffbf4d7bf77bd3c60" +checksum = "2ef2175c2907e7c8bc0a9c3f86aeb5ec1f3b275300ad58a44d0c3ae379a5e52e" dependencies = [ "cfg-if", "derive_more", @@ -5022,9 +5013,9 @@ dependencies = [ [[package]] name = "scale-info-derive" -version = "2.10.0" +version = "2.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abf2c68b89cafb3b8d918dd07b42be0da66ff202cf1155c5739a4e0c1ea0dc19" +checksum = "634d9b8eb8fd61c5cdd3390d9b2132300a7e7618955b98b8416f118c1b4e144f" dependencies = [ "proc-macro-crate 1.3.1", "proc-macro2", @@ -6021,17 +6012,6 @@ dependencies = [ "winnow 0.5.40", ] -[[package]] -name = "toml_edit" -version = "0.21.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a8534fd7f78b5405e860340ad6575217ce99f38d4d5c8f2442cb5ecb50090e1" -dependencies = [ - "indexmap 2.2.5", - "toml_datetime", - "winnow 0.5.40", -] - [[package]] name = "tower" version = "0.4.13" @@ -6801,7 +6781,6 @@ dependencies = [ "bincode", "bytes", "chrono", - "ethers-core", "flate2", "hashbrown 0.14.3", "hex", @@ -6834,7 +6813,6 @@ dependencies = [ "anyhow", "bincode", "bytes", - "ethers-core", "hashbrown 0.14.3", "hex", "hex-literal", diff --git a/lib/Cargo.toml b/lib/Cargo.toml index 16650a97..90044f8c 100644 --- a/lib/Cargo.toml +++ b/lib/Cargo.toml @@ -29,8 +29,6 @@ thiserror-no-std = "2.0.2" zeth-primitives = { path = "../primitives", features = ["revm"] } hex = { version = "0.4.3", default-features = false, optional = true } url = "2.5.0" -ethers-core = { git = "https://github.com/smtmfft/ethers-rs", branch = "ethers-core-2.0.10" } -#reth-primitives = { git = "https://github.com/paradigmxyz/reth.git" } # [target.'cfg(feature = "std")'.dependencies] thiserror = {version = "1.0", optional = true} diff --git a/lib/src/builder/execute.rs b/lib/src/builder/execute.rs index 636a4481..4d3e3a66 100644 --- a/lib/src/builder/execute.rs +++ b/lib/src/builder/execute.rs @@ -15,7 +15,7 @@ use core::{fmt::Debug, mem::take, str::from_utf8}; use alloy_consensus::{TxEnvelope, TxKind}; -use anyhow::{anyhow, bail, Context, Result}; +use anyhow::{anyhow, bail, Context, Result, Error}; #[cfg(feature = "std")] use log::debug; use revm::{ @@ -153,13 +153,13 @@ impl TxExecStrategy for TkoTxExecStrategy { } // setup the transaction - fill_eth_tx_env_alloy( + fill_eth_tx_env( &block_builder.input.taiko.chain_spec_name, &mut evm.env().tx, &tx, tx_from, is_anchor, - ); + )?; // process the transaction let ResultAndState { result, state } = match evm.transact() { Ok(result) => result, @@ -265,13 +265,13 @@ impl TxExecStrategy for TkoTxExecStrategy { } } -pub fn fill_eth_tx_env_alloy( +pub fn fill_eth_tx_env( chain_name: &str, tx_env: &mut TxEnv, tx: &TxEnvelope, caller: Address, is_anchor: bool, -) { +) -> Result<(), Error> { // claim the anchor tx_env.taiko.is_anchor = is_anchor; // set the treasury address @@ -355,8 +355,12 @@ pub fn fill_eth_tx_env_alloy( tx_env.chain_id = Some(tx.chain_id); tx_env.nonce = Some(tx.nonce); tx_env.access_list = tx.access_list.clone().into_flattened(); + + // Data blobs are not allowed on L2 + bail!(tx.blob_versioned_hashes.len() == 0); } }; + Ok(()) } pub fn increase_account_balance( diff --git a/lib/src/input.rs b/lib/src/input.rs index 29ea11dd..ae8e482c 100644 --- a/lib/src/input.rs +++ b/lib/src/input.rs @@ -17,7 +17,6 @@ use alloy_consensus::Header as AlloyConsensusHeader; use alloy_rpc_types::Withdrawal as AlloyWithdrawal; use alloy_sol_types::{sol, SolCall}; use anyhow::{anyhow, Result}; -use ethers_core::types::H256; use hashbrown::HashMap; use serde::{Deserialize, Serialize}; use zeth_primitives::{mpt::MptNode, Address, Bytes, FixedBytes, B256, U256}; @@ -31,7 +30,7 @@ pub type StorageEntry = (MptNode, Vec); #[derive(Debug, Clone, Deserialize, Serialize)] pub struct GuestInput { /// Block hash - for reference! - pub block_hash: H256, + pub block_hash: B256, /// Previous block header pub parent_header: AlloyConsensusHeader, /// Address to which all priority fees in this block are transferred. @@ -62,7 +61,7 @@ pub struct GuestInput { pub taiko: TaikoGuestInput, } -#[derive(Clone, Debug, Serialize, Deserialize)] +#[derive(Clone, Debug, Default, Serialize, Deserialize)] pub struct TaikoGuestInput { pub chain_spec_name: String, pub l1_header: AlloyConsensusHeader, diff --git a/primitives/Cargo.toml b/primitives/Cargo.toml index 77a72292..bb5d9b3b 100644 --- a/primitives/Cargo.toml +++ b/primitives/Cargo.toml @@ -15,7 +15,6 @@ alloy-rlp-derive = { version = "0.3", default-features = false } alloy-rpc-types = { git = "https://github.com/brechtpd/alloy", branch = "header-serialize" } anyhow = { version = "1.0", default-features = false } bytes = { version = "1.5", default-features = false } -ethers-core = { git = "https://github.com/smtmfft/ethers-rs", branch = "ethers-core-2.0.10" } k256 = { version = "^0.13.3", features = ["ecdsa"], default_features = false } hashbrown = { workspace = true } diff --git a/raiko-guests/risc0/guest/Cargo.lock b/raiko-guests/risc0/guest/Cargo.lock index ecc25e16..fbb1a1df 100644 --- a/raiko-guests/risc0/guest/Cargo.lock +++ b/raiko-guests/risc0/guest/Cargo.lock @@ -20,15 +20,6 @@ dependencies = [ "zerocopy", ] -[[package]] -name = "aho-corasick" -version = "1.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0" -dependencies = [ - "memchr", -] - [[package]] name = "allocator-api2" version = "0.2.16" @@ -897,80 +888,6 @@ dependencies = [ "windows-sys", ] -[[package]] -name = "ethabi" -version = "18.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7413c5f74cc903ea37386a8965a936cbeb334bd270862fdece542c1b2dcbc898" -dependencies = [ - "ethereum-types", - "hex", - "once_cell", - "regex", - "serde", - "serde_json", - "sha3", - "thiserror", - "uint", -] - -[[package]] -name = "ethbloom" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c22d4b5885b6aa2fe5e8b9329fb8d232bf739e434e6b87347c63bdd00c120f60" -dependencies = [ - "crunchy", - "fixed-hash", - "impl-codec", - "impl-rlp", - "impl-serde", - "scale-info", - "tiny-keccak", -] - -[[package]] -name = "ethereum-types" -version = "0.14.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02d215cbf040552efcbe99a38372fe80ab9d00268e20012b79fcd0f073edd8ee" -dependencies = [ - "ethbloom", - "fixed-hash", - "impl-codec", - "impl-rlp", - "impl-serde", - "primitive-types", - "scale-info", - "uint", -] - -[[package]] -name = "ethers-core" -version = "2.0.10" -source = "git+https://github.com/smtmfft/ethers-rs?branch=ethers-core-2.0.10#37493be6cd912dfe64a9036932dd6da8e13679ce" -dependencies = [ - "arrayvec", - "bytes", - "chrono", - "const-hex", - "elliptic-curve", - "ethabi", - "generic-array", - "k256", - "num_enum", - "open-fastrlp", - "rand", - "rlp", - "serde", - "serde_json", - "strum", - "tempfile", - "thiserror", - "tiny-keccak", - "unicode-xid", -] - [[package]] name = "fastrand" version = "2.0.1" @@ -1191,24 +1108,6 @@ dependencies = [ "parity-scale-codec", ] -[[package]] -name = "impl-rlp" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f28220f89297a075ddc7245cd538076ee98b01f2a9c23a53a4f1105d5a322808" -dependencies = [ - "rlp", -] - -[[package]] -name = "impl-serde" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ebc88fc67028ae3db0c853baa36269d398d5f45b6982f95549ff5def78c935cd" -dependencies = [ - "serde", -] - [[package]] name = "impl-trait-for-tuples" version = "0.2.2" @@ -1458,58 +1357,12 @@ dependencies = [ "libc", ] -[[package]] -name = "num_enum" -version = "0.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02339744ee7253741199f897151b38e72257d13802d4ee837285cc2990a90845" -dependencies = [ - "num_enum_derive", -] - -[[package]] -name = "num_enum_derive" -version = "0.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "681030a937600a36906c185595136d26abfebb4aa9c65701cefcaf8578bb982b" -dependencies = [ - "proc-macro-crate 2.0.0", - "proc-macro2", - "quote", - "syn 2.0.52", -] - [[package]] name = "once_cell" version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" -[[package]] -name = "open-fastrlp" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "786393f80485445794f6043fd3138854dd109cc6c4bd1a6383db304c9ce9b9ce" -dependencies = [ - "arrayvec", - "auto_impl", - "bytes", - "ethereum-types", - "open-fastrlp-derive", -] - -[[package]] -name = "open-fastrlp-derive" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "003b2be5c6c53c1cfeb0a238b8a1c3915cd410feb684457a36c10038f764bb1c" -dependencies = [ - "bytes", - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "parity-scale-codec" version = "3.6.9" @@ -1530,7 +1383,7 @@ version = "3.6.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "be30eaf4b0a9fba5336683b38de57bb86d179a35862ba6bfcf57625d006bde5b" dependencies = [ - "proc-macro-crate 2.0.0", + "proc-macro-crate", "proc-macro2", "quote", "syn 1.0.109", @@ -1595,29 +1448,16 @@ checksum = "0b34d9fd68ae0b74a41b21c03c2f62847aa0ffea044eee893b4c140b37e244e2" dependencies = [ "fixed-hash", "impl-codec", - "impl-rlp", - "impl-serde", - "scale-info", "uint", ] -[[package]] -name = "proc-macro-crate" -version = "1.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919" -dependencies = [ - "once_cell", - "toml_edit 0.19.15", -] - [[package]] name = "proc-macro-crate" version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7e8366a6159044a37876a2b9817124296703c586a5c92e2c53751fa06d8d43e8" dependencies = [ - "toml_edit 0.20.7", + "toml_edit", ] [[package]] @@ -1733,29 +1573,6 @@ dependencies = [ "rand_core", ] -[[package]] -name = "regex" -version = "1.10.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b62dbe01f0b06f9d8dc7d49e05a0785f153b00b2c227856282f671e0318c9b15" -dependencies = [ - "aho-corasick", - "memchr", - "regex-automata", - "regex-syntax", -] - -[[package]] -name = "regex-automata" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86b83b8b9847f9bf95ef68afb0b8e6cdb80f498442f5179a29fad448fcc1eaea" -dependencies = [ - "aho-corasick", - "memchr", - "regex-syntax", -] - [[package]] name = "regex-syntax" version = "0.8.2" @@ -1964,21 +1781,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bb919243f34364b6bd2fc10ef797edbfa75f33c252e7998527479c6d6b47e1ec" dependencies = [ "bytes", - "rlp-derive", "rustc-hex", ] -[[package]] -name = "rlp-derive" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e33d7b2abe0c340d8797fe2907d3f20d3b5ea5908683618bfe80df7f621f672a" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "rrs-lib" version = "0.1.0" @@ -2056,12 +1861,6 @@ dependencies = [ "windows-sys", ] -[[package]] -name = "rustversion" -version = "1.0.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ffc183a10b4478d04cbbbfc96d0873219d962dd5accaff2ffbd4ceb7df837f4" - [[package]] name = "rusty-fork" version = "0.3.0" @@ -2080,30 +1879,6 @@ version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e86697c916019a8588c99b5fac3cead74ec0b4b819707a682fd4d23fa0ce1ba1" -[[package]] -name = "scale-info" -version = "2.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f7d66a1128282b7ef025a8ead62a4a9fcf017382ec53b8ffbf4d7bf77bd3c60" -dependencies = [ - "cfg-if", - "derive_more", - "parity-scale-codec", - "scale-info-derive", -] - -[[package]] -name = "scale-info-derive" -version = "2.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abf2c68b89cafb3b8d918dd07b42be0da66ff202cf1155c5739a4e0c1ea0dc19" -dependencies = [ - "proc-macro-crate 1.3.1", - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "sec1" version = "0.7.3" @@ -2305,28 +2080,6 @@ version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" -[[package]] -name = "strum" -version = "0.25.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "290d54ea6f91c969195bdbcd7442c8c2a2ba87da8bf60a7ee86a235d4bc1e125" -dependencies = [ - "strum_macros", -] - -[[package]] -name = "strum_macros" -version = "0.25.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23dc1fa9ac9c169a78ba62f0b841814b7abae11bdd047b9c58f893439e309ea0" -dependencies = [ - "heck", - "proc-macro2", - "quote", - "rustversion", - "syn 2.0.52", -] - [[package]] name = "substrate-bn" version = "0.6.0" @@ -2508,17 +2261,6 @@ version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3550f4e9685620ac18a50ed434eb3aec30db8ba93b0287467bca5826ea25baf1" -[[package]] -name = "toml_edit" -version = "0.19.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" -dependencies = [ - "indexmap 2.2.5", - "toml_datetime", - "winnow", -] - [[package]] name = "toml_edit" version = "0.20.7" @@ -2623,12 +2365,6 @@ dependencies = [ "tinyvec", ] -[[package]] -name = "unicode-xid" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" - [[package]] name = "url" version = "2.5.0" @@ -2868,7 +2604,6 @@ dependencies = [ "anyhow", "bytes", "chrono", - "ethers-core", "flate2", "hashbrown 0.14.3", "hex", @@ -2896,7 +2631,6 @@ dependencies = [ "alloy-rpc-types", "anyhow", "bytes", - "ethers-core", "hashbrown 0.14.3", "hex", "k256", diff --git a/raiko-guests/sgx/Cargo.toml b/raiko-guests/sgx/Cargo.toml index faebd78f..3a13a932 100644 --- a/raiko-guests/sgx/Cargo.toml +++ b/raiko-guests/sgx/Cargo.toml @@ -6,7 +6,6 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -risc0-zkvm = { version = "0.18", default-features = false, features = ["std"] } zeth-lib = { path = "../../lib", default-features = false, features = ["taiko"] } zeth-primitives = { path = "../../primitives", features = ["taiko"] } raiko-host = { path = "../../raiko-host"} diff --git a/raiko-guests/succinct/Cargo.lock b/raiko-guests/succinct/Cargo.lock index 0f8db9f3..c8687f22 100644 --- a/raiko-guests/succinct/Cargo.lock +++ b/raiko-guests/succinct/Cargo.lock @@ -20,15 +20,6 @@ dependencies = [ "zerocopy", ] -[[package]] -name = "aho-corasick" -version = "1.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0" -dependencies = [ - "memchr", -] - [[package]] name = "allocator-api2" version = "0.2.16" @@ -746,80 +737,6 @@ dependencies = [ "windows-sys", ] -[[package]] -name = "ethabi" -version = "18.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7413c5f74cc903ea37386a8965a936cbeb334bd270862fdece542c1b2dcbc898" -dependencies = [ - "ethereum-types", - "hex", - "once_cell", - "regex", - "serde", - "serde_json", - "sha3", - "thiserror", - "uint", -] - -[[package]] -name = "ethbloom" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c22d4b5885b6aa2fe5e8b9329fb8d232bf739e434e6b87347c63bdd00c120f60" -dependencies = [ - "crunchy", - "fixed-hash", - "impl-codec", - "impl-rlp", - "impl-serde", - "scale-info", - "tiny-keccak", -] - -[[package]] -name = "ethereum-types" -version = "0.14.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02d215cbf040552efcbe99a38372fe80ab9d00268e20012b79fcd0f073edd8ee" -dependencies = [ - "ethbloom", - "fixed-hash", - "impl-codec", - "impl-rlp", - "impl-serde", - "primitive-types", - "scale-info", - "uint", -] - -[[package]] -name = "ethers-core" -version = "2.0.10" -source = "git+https://github.com/smtmfft/ethers-rs?branch=ethers-core-2.0.10#37493be6cd912dfe64a9036932dd6da8e13679ce" -dependencies = [ - "arrayvec", - "bytes", - "chrono", - "const-hex", - "elliptic-curve", - "ethabi", - "generic-array", - "k256", - "num_enum", - "open-fastrlp", - "rand", - "rlp", - "serde", - "serde_json", - "strum", - "tempfile", - "thiserror", - "tiny-keccak", - "unicode-xid", -] - [[package]] name = "fastrand" version = "2.0.1" @@ -1031,24 +948,6 @@ dependencies = [ "parity-scale-codec", ] -[[package]] -name = "impl-rlp" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f28220f89297a075ddc7245cd538076ee98b01f2a9c23a53a4f1105d5a322808" -dependencies = [ - "rlp", -] - -[[package]] -name = "impl-serde" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ebc88fc67028ae3db0c853baa36269d398d5f45b6982f95549ff5def78c935cd" -dependencies = [ - "serde", -] - [[package]] name = "impl-trait-for-tuples" version = "0.2.2" @@ -1288,58 +1187,12 @@ dependencies = [ "libc", ] -[[package]] -name = "num_enum" -version = "0.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02339744ee7253741199f897151b38e72257d13802d4ee837285cc2990a90845" -dependencies = [ - "num_enum_derive", -] - -[[package]] -name = "num_enum_derive" -version = "0.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "681030a937600a36906c185595136d26abfebb4aa9c65701cefcaf8578bb982b" -dependencies = [ - "proc-macro-crate 3.1.0", - "proc-macro2", - "quote", - "syn 2.0.52", -] - [[package]] name = "once_cell" version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" -[[package]] -name = "open-fastrlp" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "786393f80485445794f6043fd3138854dd109cc6c4bd1a6383db304c9ce9b9ce" -dependencies = [ - "arrayvec", - "auto_impl", - "bytes", - "ethereum-types", - "open-fastrlp-derive", -] - -[[package]] -name = "open-fastrlp-derive" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "003b2be5c6c53c1cfeb0a238b8a1c3915cd410feb684457a36c10038f764bb1c" -dependencies = [ - "bytes", - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "parity-scale-codec" version = "3.6.9" @@ -1360,7 +1213,7 @@ version = "3.6.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "be30eaf4b0a9fba5336683b38de57bb86d179a35862ba6bfcf57625d006bde5b" dependencies = [ - "proc-macro-crate 2.0.0", + "proc-macro-crate", "proc-macro2", "quote", "syn 1.0.109", @@ -1419,38 +1272,16 @@ checksum = "0b34d9fd68ae0b74a41b21c03c2f62847aa0ffea044eee893b4c140b37e244e2" dependencies = [ "fixed-hash", "impl-codec", - "impl-rlp", - "impl-serde", - "scale-info", "uint", ] -[[package]] -name = "proc-macro-crate" -version = "1.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919" -dependencies = [ - "once_cell", - "toml_edit 0.19.15", -] - [[package]] name = "proc-macro-crate" version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7e8366a6159044a37876a2b9817124296703c586a5c92e2c53751fa06d8d43e8" dependencies = [ - "toml_edit 0.20.7", -] - -[[package]] -name = "proc-macro-crate" -version = "3.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d37c51ca738a55da99dc0c4a34860fd675453b8b36209178c2249bb13651284" -dependencies = [ - "toml_edit 0.21.1", + "toml_edit", ] [[package]] @@ -1576,29 +1407,6 @@ dependencies = [ "rand_core", ] -[[package]] -name = "regex" -version = "1.10.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b62dbe01f0b06f9d8dc7d49e05a0785f153b00b2c227856282f671e0318c9b15" -dependencies = [ - "aho-corasick", - "memchr", - "regex-automata", - "regex-syntax", -] - -[[package]] -name = "regex-automata" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86b83b8b9847f9bf95ef68afb0b8e6cdb80f498442f5179a29fad448fcc1eaea" -dependencies = [ - "aho-corasick", - "memchr", - "regex-syntax", -] - [[package]] name = "regex-syntax" version = "0.8.2" @@ -1686,21 +1494,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bb919243f34364b6bd2fc10ef797edbfa75f33c252e7998527479c6d6b47e1ec" dependencies = [ "bytes", - "rlp-derive", "rustc-hex", ] -[[package]] -name = "rlp-derive" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e33d7b2abe0c340d8797fe2907d3f20d3b5ea5908683618bfe80df7f621f672a" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "ruint" version = "1.12.0" @@ -1768,12 +1564,6 @@ dependencies = [ "windows-sys", ] -[[package]] -name = "rustversion" -version = "1.0.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ffc183a10b4478d04cbbbfc96d0873219d962dd5accaff2ffbd4ceb7df837f4" - [[package]] name = "rusty-fork" version = "0.3.0" @@ -1792,30 +1582,6 @@ version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e86697c916019a8588c99b5fac3cead74ec0b4b819707a682fd4d23fa0ce1ba1" -[[package]] -name = "scale-info" -version = "2.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f7d66a1128282b7ef025a8ead62a4a9fcf017382ec53b8ffbf4d7bf77bd3c60" -dependencies = [ - "cfg-if", - "derive_more", - "parity-scale-codec", - "scale-info-derive", -] - -[[package]] -name = "scale-info-derive" -version = "2.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abf2c68b89cafb3b8d918dd07b42be0da66ff202cf1155c5739a4e0c1ea0dc19" -dependencies = [ - "proc-macro-crate 1.3.1", - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "sec1" version = "0.7.3" @@ -2031,28 +1797,6 @@ version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" -[[package]] -name = "strum" -version = "0.25.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "290d54ea6f91c969195bdbcd7442c8c2a2ba87da8bf60a7ee86a235d4bc1e125" -dependencies = [ - "strum_macros", -] - -[[package]] -name = "strum_macros" -version = "0.25.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23dc1fa9ac9c169a78ba62f0b841814b7abae11bdd047b9c58f893439e309ea0" -dependencies = [ - "heck", - "proc-macro2", - "quote", - "rustversion", - "syn 2.0.52", -] - [[package]] name = "substrate-bn" version = "0.6.0" @@ -2234,17 +1978,6 @@ version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3550f4e9685620ac18a50ed434eb3aec30db8ba93b0287467bca5826ea25baf1" -[[package]] -name = "toml_edit" -version = "0.19.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" -dependencies = [ - "indexmap 2.2.5", - "toml_datetime", - "winnow", -] - [[package]] name = "toml_edit" version = "0.20.7" @@ -2256,17 +1989,6 @@ dependencies = [ "winnow", ] -[[package]] -name = "toml_edit" -version = "0.21.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a8534fd7f78b5405e860340ad6575217ce99f38d4d5c8f2442cb5ecb50090e1" -dependencies = [ - "indexmap 2.2.5", - "toml_datetime", - "winnow", -] - [[package]] name = "typenum" version = "1.17.0" @@ -2318,12 +2040,6 @@ dependencies = [ "tinyvec", ] -[[package]] -name = "unicode-xid" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" - [[package]] name = "url" version = "2.5.0" @@ -2563,7 +2279,6 @@ dependencies = [ "anyhow", "bytes", "chrono", - "ethers-core", "flate2", "hashbrown 0.14.3", "hex", @@ -2591,7 +2306,6 @@ dependencies = [ "alloy-rpc-types", "anyhow", "bytes", - "ethers-core", "hashbrown 0.14.3", "hex", "k256", diff --git a/raiko-host/Cargo.toml b/raiko-host/Cargo.toml index aab1f006..bafe4568 100644 --- a/raiko-host/Cargo.toml +++ b/raiko-host/Cargo.toml @@ -18,6 +18,7 @@ bytemuck = "1.13" clap = { version = "4.0", features = ["derive"] } structopt = "0.3.26" structopt-toml = "0.5.1" +# TODO(Brecht): remove ethers ethers-contract = { git = "https://github.com/smtmfft/ethers-rs", branch = "ethers-core-2.0.10" } ethers-core = { git = "https://github.com/smtmfft/ethers-rs", branch = "ethers-core-2.0.10" } ethers-providers = { git = "https://github.com/smtmfft/ethers-rs", branch = "ethers-core-2.0.10" } diff --git a/raiko-host/src/prover/execution.rs b/raiko-host/src/prover/execution.rs index 81130c5a..b515527f 100644 --- a/raiko-host/src/prover/execution.rs +++ b/raiko-host/src/prover/execution.rs @@ -57,7 +57,7 @@ pub async fn execute( // Make sure the blockhash from the node matches the one from the builder assert_eq!( header.hash().0, - input.block_hash.to_fixed_bytes(), + input.block_hash, "block hash unexpected" ); GuestOutput::Success((header.clone(), pi)) @@ -109,7 +109,7 @@ pub async fn execute( // Make sure the blockhash from the node matches the one from the builder assert_eq!( header.hash().0, - input.block_hash.to_fixed_bytes(), + input.block_hash, "block hash unexpected" ); ProofResponse::Native(output) diff --git a/raiko-host/src/prover/proof/risc0/mod.rs b/raiko-host/src/prover/proof/risc0/mod.rs index 018cee2d..2439b7ed 100644 --- a/raiko-host/src/prover/proof/risc0/mod.rs +++ b/raiko-host/src/prover/proof/risc0/mod.rs @@ -376,8 +376,11 @@ pub fn prove_locally( let env = env_builder.build().unwrap(); let mut exec = ExecutorImpl::from_elf(env, elf).unwrap(); - // let segment_dir = tempdir().unwrap(); - let segment_dir = env::current_dir().expect("dir error"); + let segment_dir = PathBuf::from("/tmp/risc0-cache"); + if segment_dir.exists() { + fs::remove_dir_all(segment_dir.clone()).unwrap(); + } + fs::create_dir(segment_dir.clone()).unwrap(); exec.run_with_callback(|segment| { let path = segment_dir @@ -492,9 +495,7 @@ pub fn save_receipt(receipt_label: &String, receipt_data: & } fn zkp_cache_path(receipt_label: &String) -> String { - // Path::new("cache_zkp") - env::current_dir() - .expect("dir error") + Path::new("cache_zkp") .as_path() .join(format!("{}.zkp", receipt_label)) .to_str() diff --git a/rust-toolchain b/rust-toolchain index 924c78bd..44a45ef4 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1,5 +1,5 @@ [toolchain] -channel = "nightly-2024-02-25" +channel = "nightly-2024-01-25" components = ["clippy", "rustfmt", "rust-src"] profile = "minimal" diff --git a/testing/ef-tests/Cargo.toml b/testing/ef-tests/Cargo.toml index e691c96a..f2c24616 100644 --- a/testing/ef-tests/Cargo.toml +++ b/testing/ef-tests/Cargo.toml @@ -8,7 +8,6 @@ ef-tests = [] [dependencies] anyhow = "1.0" -ethers-core = { git = "https://github.com/smtmfft/ethers-rs", branch = "ethers-core-2.0.10" } hashbrown = { workspace = true } revm = { workspace = true } serde = "1.0" @@ -21,12 +20,8 @@ zeth-primitives = { path = "../../primitives" } diff = "0.1" env_logger = "0.10" log = "0.4" -risc0-zkvm = { workspace = true, features = ["prove"] } rstest = "0.18" tempfile = "3.6" -[build-dependencies] -risc0-build = { version = "0.20.1" } - [package.metadata.risc0] methods = ["testguest"] From c1fdce86dda3d8818211cf19630ad7472eaab77c Mon Sep 17 00:00:00 2001 From: brechtpd Date: Tue, 19 Mar 2024 18:27:04 +0000 Subject: [PATCH 07/10] remove unused tests + fmt --- lib/src/builder/execute.rs | 2 +- raiko-host/src/prover/execution.rs | 12 +- testing/ef-tests/Cargo.toml | 27 - testing/ef-tests/build.rs | 17 - testing/ef-tests/src/ethers.rs | 218 -- testing/ef-tests/src/ethtests.rs | 61 - testing/ef-tests/src/lib.rs | 376 --- testing/ef-tests/testdata | 1 - testing/ef-tests/testguest/Cargo.lock | 3711 ------------------------ testing/ef-tests/testguest/Cargo.toml | 16 - testing/ef-tests/testguest/src/main.rs | 37 - testing/ef-tests/tests/evm.rs | 96 - testing/ef-tests/tests/executor.rs | 96 - tests/geth/Cargo.toml | 17 - tests/geth/build.rs | 51 - tests/geth/gethutil/mpt.go | 118 - tests/geth/go.mod | 62 - tests/geth/go.sum | 476 --- tests/geth/lib/lib.go | 36 - tests/geth/src/lib.rs | 97 - 20 files changed, 3 insertions(+), 5524 deletions(-) delete mode 100644 testing/ef-tests/Cargo.toml delete mode 100644 testing/ef-tests/build.rs delete mode 100644 testing/ef-tests/src/ethers.rs delete mode 100644 testing/ef-tests/src/ethtests.rs delete mode 100644 testing/ef-tests/src/lib.rs delete mode 160000 testing/ef-tests/testdata delete mode 100644 testing/ef-tests/testguest/Cargo.lock delete mode 100644 testing/ef-tests/testguest/Cargo.toml delete mode 100644 testing/ef-tests/testguest/src/main.rs delete mode 100644 testing/ef-tests/tests/evm.rs delete mode 100644 testing/ef-tests/tests/executor.rs delete mode 100644 tests/geth/Cargo.toml delete mode 100644 tests/geth/build.rs delete mode 100644 tests/geth/gethutil/mpt.go delete mode 100644 tests/geth/go.mod delete mode 100644 tests/geth/go.sum delete mode 100644 tests/geth/lib/lib.go delete mode 100644 tests/geth/src/lib.rs diff --git a/lib/src/builder/execute.rs b/lib/src/builder/execute.rs index 4d3e3a66..073f0944 100644 --- a/lib/src/builder/execute.rs +++ b/lib/src/builder/execute.rs @@ -15,7 +15,7 @@ use core::{fmt::Debug, mem::take, str::from_utf8}; use alloy_consensus::{TxEnvelope, TxKind}; -use anyhow::{anyhow, bail, Context, Result, Error}; +use anyhow::{anyhow, bail, Context, Error, Result}; #[cfg(feature = "std")] use log::debug; use revm::{ diff --git a/raiko-host/src/prover/execution.rs b/raiko-host/src/prover/execution.rs index b515527f..319b1512 100644 --- a/raiko-host/src/prover/execution.rs +++ b/raiko-host/src/prover/execution.rs @@ -55,11 +55,7 @@ pub async fn execute( .instance_hash(req.proof_type.clone().into()); // Make sure the blockhash from the node matches the one from the builder - assert_eq!( - header.hash().0, - input.block_hash, - "block hash unexpected" - ); + assert_eq!(header.hash().0, input.block_hash, "block hash unexpected"); GuestOutput::Success((header.clone(), pi)) } Err(_) => { @@ -107,11 +103,7 @@ pub async fn execute( match &build_result { Ok((header, mpt_node)) => { // Make sure the blockhash from the node matches the one from the builder - assert_eq!( - header.hash().0, - input.block_hash, - "block hash unexpected" - ); + assert_eq!(header.hash().0, input.block_hash, "block hash unexpected"); ProofResponse::Native(output) } Err(_) => { diff --git a/testing/ef-tests/Cargo.toml b/testing/ef-tests/Cargo.toml deleted file mode 100644 index f2c24616..00000000 --- a/testing/ef-tests/Cargo.toml +++ /dev/null @@ -1,27 +0,0 @@ -[package] -name = "zeth-testeth" -version = "0.1.0" -edition = "2021" - -[features] -ef-tests = [] - -[dependencies] -anyhow = "1.0" -hashbrown = { workspace = true } -revm = { workspace = true } -serde = "1.0" -serde_json = "1.0" -serde_with = "3.1" -zeth-lib = { path = "../../lib" } -zeth-primitives = { path = "../../primitives" } - -[dev-dependencies] -diff = "0.1" -env_logger = "0.10" -log = "0.4" -rstest = "0.18" -tempfile = "3.6" - -[package.metadata.risc0] -methods = ["testguest"] diff --git a/testing/ef-tests/build.rs b/testing/ef-tests/build.rs deleted file mode 100644 index 42c6db8e..00000000 --- a/testing/ef-tests/build.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2023 RISC Zero, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -fn main() { - risc0_build::embed_methods(); -} diff --git a/testing/ef-tests/src/ethers.rs b/testing/ef-tests/src/ethers.rs deleted file mode 100644 index bffdb68f..00000000 --- a/testing/ef-tests/src/ethers.rs +++ /dev/null @@ -1,218 +0,0 @@ -// Copyright 2023 RISC Zero, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -use std::collections::BTreeSet; - -use ethers_core::types::{ - Block, Bloom, Bytes, EIP1186ProofResponse, StorageProof, Transaction, TransactionReceipt, H256, - U256, -}; -use zeth_primitives::U256 as LibU256; - -use super::*; - -/// Provider that always returns the default if not contained in the state. -pub struct TestProvider { - pub state: TestState, - pub header: Header, - pub post: TestState, -} - -impl Provider for TestProvider { - fn save(&self) -> Result<(), anyhow::Error> { - unimplemented!() - } - - fn get_full_block(&mut self, _: &BlockQuery) -> Result, anyhow::Error> { - unimplemented!() - } - - fn get_partial_block(&mut self, query: &BlockQuery) -> Result, anyhow::Error> { - if query.block_no != self.header.number { - bail!("block {} not found", query.block_no); - } - - Ok(Block:: { - parent_hash: self.header.parent_hash.0.into(), - uncles_hash: self.header.ommers_hash.0.into(), - author: Some(self.header.beneficiary.into_array().into()), - state_root: self.header.state_root.0.into(), - transactions_root: self.header.transactions_root.0.into(), - receipts_root: self.header.receipts_root.0.into(), - logs_bloom: Some(Bloom::from_slice(self.header.logs_bloom.as_slice())), - difficulty: self.header.difficulty.to_be_bytes().into(), - number: Some(self.header.number.into()), - gas_limit: self.header.gas_limit.to_be_bytes().into(), - gas_used: self.header.gas_used.to_be_bytes().into(), - timestamp: self.header.timestamp.to_be_bytes().into(), - extra_data: self.header.extra_data.0.clone().into(), - mix_hash: Some(self.header.mix_hash.0.into()), - nonce: Some(self.header.nonce.0.into()), - base_fee_per_gas: Some(self.header.base_fee_per_gas.to_be_bytes().into()), - withdrawals_root: self.header.withdrawals_root.map(|r| r.0.into()), - hash: Some(self.header.hash().0.into()), - ..Default::default() - }) - } - - fn get_block_receipts( - &mut self, - _query: &BlockQuery, - ) -> anyhow::Result> { - unimplemented!() - } - - fn get_proof(&mut self, query: &ProofQuery) -> Result { - let indices = query - .indices - .iter() - .map(|idx| LibU256::from_be_bytes(idx.0)); - - match query.block_no { - n if n == self.header.number => { - get_proof(from_ethers_h160(query.address), indices, &self.state) - } - n if n == self.header.number + 1 => { - get_proof(from_ethers_h160(query.address), indices, &self.post) - } - _ => panic!("invalid block number: {}", query.block_no), - } - } - - fn get_transaction_count(&mut self, query: &AccountQuery) -> Result { - assert_eq!(query.block_no, self.header.number); - - let nonce: u64 = self - .state - .0 - .get(&from_ethers_h160(query.address)) - .map(|account| account.nonce.try_into().unwrap()) - .unwrap_or_default(); - Ok(U256::from(nonce)) - } - - fn get_balance(&mut self, query: &AccountQuery) -> Result { - assert_eq!(query.block_no, self.header.number); - - let balance = self - .state - .0 - .get(&from_ethers_h160(query.address)) - .map(|account| account.balance) - .unwrap_or_default(); - Ok(balance.to_be_bytes().into()) - } - - fn get_code(&mut self, query: &AccountQuery) -> Result { - assert_eq!(query.block_no, self.header.number); - - let code = self - .state - .0 - .get(&from_ethers_h160(query.address)) - .map(|account| account.code.clone()) - .unwrap_or_default(); - Ok(code.0.into()) - } - - fn get_storage(&mut self, query: &StorageQuery) -> Result { - assert_eq!(query.block_no, self.header.number); - - match self.state.0.get(&from_ethers_h160(query.address)) { - Some(account) => { - let value = account - .storage - .get(&LibU256::from_be_bytes(query.index.0)) - .cloned() - .unwrap_or_default(); - Ok(value.to_be_bytes().into()) - } - None => Ok(H256::zero()), - } - } -} - -/// Builds the state trie and storage tries from the test state. -pub fn build_tries(state: &TestState) -> (MptNode, HashMap) { - let mut state_trie = MptNode::default(); - let mut storage_tries = HashMap::new(); - for (address, account) in &state.0 { - let mut storage_trie = MptNode::default(); - for (slot, value) in &account.storage { - if *value != LibU256::ZERO { - storage_trie - .insert_rlp(&keccak(slot.to_be_bytes::<32>()), *value) - .unwrap(); - } - } - - state_trie - .insert_rlp( - &keccak(address), - StateAccount { - nonce: account.nonce.try_into().unwrap(), - balance: account.balance, - storage_root: storage_trie.hash(), - code_hash: keccak(account.code.clone()).into(), - }, - ) - .unwrap(); - storage_tries.insert(*address, storage_trie); - } - - (state_trie, storage_tries) -} - -fn get_proof( - address: Address, - indices: impl IntoIterator, - state: &TestState, -) -> Result { - let account = state.0.get(&address).cloned().unwrap_or_default(); - let (state_trie, mut storage_tries) = build_tries(state); - let storage_trie = storage_tries.remove(&address).unwrap_or_default(); - - let account_proof = mpt_proof(&state_trie, keccak(address))? - .into_iter() - .map(|p| p.into()) - .collect(); - let index_set = indices.into_iter().collect::>(); - let storage_proof = index_set - .into_iter() - .map(|index| StorageProof { - key: index.to_be_bytes().into(), - proof: mpt_proof(&storage_trie, keccak(index.to_be_bytes::<32>()))? - .into_iter() - .map(|p| p.into()) - .collect(), - value: account - .storage - .get(&index) - .cloned() - .unwrap_or_default() - .to_be_bytes() - .into(), - }) - .collect::>(); - - Ok(EIP1186ProofResponse { - address: address.into_array().into(), - balance: account.balance.to_be_bytes().into(), - code_hash: keccak(account.code).into(), - nonce: account.nonce.to_be_bytes().into(), - storage_hash: storage_trie.hash().0.into(), - account_proof, - storage_proof, - }) -} diff --git a/testing/ef-tests/src/ethtests.rs b/testing/ef-tests/src/ethtests.rs deleted file mode 100644 index 6ea7f2a0..00000000 --- a/testing/ef-tests/src/ethtests.rs +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright 2023 RISC Zero, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -use std::{fs::File, io::BufReader, path::PathBuf}; - -use revm::primitives::SpecId; -use serde_json::Value; -use zeth_lib::consts::ChainSpec; -use zeth_primitives::block::Header; - -use crate::TestJson; - -pub struct EthTestCase { - pub json: TestJson, - pub genesis: Header, - pub chain_spec: ChainSpec, -} - -pub fn read_eth_test(path: PathBuf) -> Vec { - println!("Using file: {}", path.display()); - let f = File::open(path).unwrap(); - let mut root: Value = serde_json::from_reader(BufReader::new(f)).unwrap(); - - root.as_object_mut() - .unwrap() - .into_iter() - .map(|(name, test)| { - println!("test '{}'", name); - let json: TestJson = serde_json::from_value(test.take()).unwrap(); - - let spec: SpecId = json.network.as_str().into(); - // skip tests with an unsupported network version - if spec < SpecId::MERGE || spec > SpecId::SHANGHAI { - println!("skipping ({})", json.network); - return None; - } - let chain_spec = ChainSpec::new_single(1, spec, Default::default()); - - let genesis: Header = json.genesis.clone().into(); - assert_eq!(genesis.hash(), json.genesis.hash); - - Some(EthTestCase { - json, - genesis, - chain_spec, - }) - }) - .flatten() - .collect() -} diff --git a/testing/ef-tests/src/lib.rs b/testing/ef-tests/src/lib.rs deleted file mode 100644 index 421ae3df..00000000 --- a/testing/ef-tests/src/lib.rs +++ /dev/null @@ -1,376 +0,0 @@ -// Copyright 2023 RISC Zero, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#![cfg(feature = "ef-tests")] - -use anyhow::bail; -use hashbrown::HashMap; -use serde::{Deserialize, Serialize}; -use serde_with::{serde_as, NoneAsEmptyString}; -use zeth_lib::{ - builder::{BlockBuilder, BlockBuilderStrategy, EthereumStrategy}, - consts::ChainSpec, - host::{ - preflight::Data, - provider::{AccountQuery, BlockQuery, ProofQuery, Provider, StorageQuery}, - provider_db::ProviderDb, - }, - input::Input, - mem_db::{AccountState, DbAccount, MemDb}, -}; -use zeth_primitives::{ - access_list::{AccessList, AccessListItem}, - block::Header, - ethers::from_ethers_h160, - keccak::keccak, - transactions::{ - ethereum::{ - EthereumTxEssence, TransactionKind, TxEssenceEip1559, TxEssenceEip2930, TxEssenceLegacy, - }, - signature::TxSignature, - EthereumTransaction, - }, - trie::{self, MptNode, MptNodeData, StateAccount}, - withdrawal::Withdrawal, - Address, Bloom, Bytes, RlpBytes, StorageKey, B256, B64, U256, U64, -}; - -use crate::ethers::TestProvider; - -pub mod ethers; -pub mod ethtests; - -pub mod guests { - include!(concat!(env!("OUT_DIR"), "/methods.rs")); -} - -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(rename_all = "camelCase")] -pub struct TestJson { - pub blocks: Vec, - #[serde(rename = "genesisBlockHeader")] - pub genesis: TestHeader, - #[serde(rename = "genesisRLP")] - pub genesis_rlp: Bytes, - pub network: String, - pub pre: TestState, - #[serde(rename = "postState")] - pub post: Option, -} - -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(rename_all = "camelCase")] -pub struct TestBlock { - pub block_header: Option, - pub expect_exception: Option, - pub rlp: Bytes, - #[serde(default)] - pub transactions: Vec, - #[serde(default)] - pub uncle_headers: Vec, - pub withdrawals: Option>, -} - -#[derive(Debug, Clone, Default, Serialize, Deserialize, PartialEq, Eq)] -#[serde(rename_all = "camelCase")] -pub struct TestAccount { - pub balance: U256, - pub nonce: U64, - pub code: Bytes, - pub storage: HashMap, -} - -impl From for TestAccount { - fn from(account: DbAccount) -> Self { - TestAccount { - balance: account.info.balance, - nonce: U64::from(account.info.nonce), - code: account.info.code.unwrap().bytecode.into(), - storage: account.storage.into_iter().map(|(k, v)| (k, v)).collect(), - } - } -} - -#[derive(Debug, Clone, Default, Serialize, Deserialize, PartialEq, Eq)] -#[serde(rename_all = "camelCase")] -pub struct TestState(pub HashMap); - -impl From<&MemDb> for TestState { - fn from(db: &MemDb) -> Self { - TestState( - db.accounts - .iter() - .filter_map(|(addr, account)| { - (account.state != AccountState::Deleted) - .then_some((*addr, account.clone().into())) - }) - .collect(), - ) - } -} - -impl From<&ProviderDb> for TestState { - fn from(db: &ProviderDb) -> Self { - (&db.latest_db).into() - } -} - -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(rename_all = "camelCase")] -pub struct TestHeader { - pub base_fee_per_gas: Option, - pub bloom: Bloom, - pub coinbase: Address, - pub extra_data: Bytes, - pub difficulty: U256, - pub gas_limit: U256, - pub gas_used: U256, - pub hash: B256, - pub mix_hash: B256, - pub nonce: B64, - pub number: U64, - pub parent_hash: B256, - pub receipt_trie: B256, - pub state_root: B256, - pub timestamp: U256, - pub transactions_trie: B256, - pub uncle_hash: B256, - pub withdrawals_root: Option, -} - -impl From for Header { - fn from(header: TestHeader) -> Self { - Header { - parent_hash: header.parent_hash, - ommers_hash: header.uncle_hash, - beneficiary: header.coinbase, - state_root: header.state_root, - transactions_root: header.transactions_trie, - receipts_root: header.receipt_trie, - logs_bloom: header.bloom, - difficulty: header.difficulty, - number: header.number.try_into().unwrap(), - gas_limit: header.gas_limit, - gas_used: header.gas_used, - timestamp: header.timestamp, - extra_data: header.extra_data, - mix_hash: header.mix_hash, - nonce: header.nonce, - base_fee_per_gas: header.base_fee_per_gas.unwrap(), - withdrawals_root: header.withdrawals_root, - } - } -} - -#[serde_as] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(rename_all = "camelCase")] -pub struct TestTransaction { - pub data: Bytes, - pub access_list: Option, - pub gas_limit: U256, - pub gas_price: Option, - pub max_fee_per_gas: Option, - pub max_priority_fee_per_gas: Option, - pub value: U256, - #[serde_as(as = "NoneAsEmptyString")] - pub to: Option
, - pub nonce: U64, - pub v: U64, - pub r: U256, - pub s: U256, -} - -impl From for EthereumTransaction { - fn from(tx: TestTransaction) -> Self { - let signature = TxSignature { - v: tx.v.try_into().unwrap(), - r: tx.r, - s: tx.s, - }; - let essence = if tx.access_list.is_none() { - EthereumTxEssence::Legacy(TxEssenceLegacy { - chain_id: None, - nonce: tx.nonce.try_into().unwrap(), - gas_price: tx.gas_price.unwrap(), - gas_limit: tx.gas_limit, - to: match tx.to { - Some(addr) => TransactionKind::Call(addr), - None => TransactionKind::Create, - }, - value: tx.value, - data: tx.data, - }) - } else if tx.max_fee_per_gas.is_none() { - EthereumTxEssence::Eip2930(TxEssenceEip2930 { - chain_id: 1, - nonce: tx.nonce.try_into().unwrap(), - gas_price: tx.gas_price.unwrap(), - gas_limit: tx.gas_limit, - to: match tx.to { - Some(addr) => TransactionKind::Call(addr), - None => TransactionKind::Create, - }, - value: tx.value, - data: tx.data, - access_list: tx.access_list.unwrap().into(), - }) - } else { - EthereumTxEssence::Eip1559(TxEssenceEip1559 { - chain_id: 1, - nonce: tx.nonce.try_into().unwrap(), - max_priority_fee_per_gas: tx.max_priority_fee_per_gas.unwrap(), - max_fee_per_gas: tx.max_fee_per_gas.unwrap(), - gas_limit: tx.gas_limit, - to: match tx.to { - Some(addr) => TransactionKind::Call(addr), - None => TransactionKind::Create, - }, - value: tx.value, - data: tx.data, - access_list: tx.access_list.unwrap().into(), - }) - }; - EthereumTransaction { essence, signature } - } -} - -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(rename_all = "camelCase")] -pub struct TestAccessList(pub Vec); - -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(rename_all = "camelCase")] -pub struct TestAccessListItem { - pub address: Address, - pub storage_keys: Vec, -} - -impl From for AccessList { - fn from(list: TestAccessList) -> Self { - AccessList( - list.0 - .into_iter() - .map(|item| AccessListItem { - address: item.address, - storage_keys: item.storage_keys, - }) - .collect(), - ) - } -} - -/// Computes the Merkle proof for the given key in the trie. -pub fn mpt_proof(root: &MptNode, key: impl AsRef<[u8]>) -> Result>, anyhow::Error> { - let mut path = proof_internal(root, &trie::to_nibs(key.as_ref()))?; - path.reverse(); - Ok(path) -} - -fn proof_internal(node: &MptNode, key_nibs: &[u8]) -> Result>, anyhow::Error> { - if key_nibs.is_empty() { - return Ok(vec![node.to_rlp()]); - } - - let mut path: Vec> = match node.as_data() { - MptNodeData::Null | MptNodeData::Leaf(_, _) => vec![], - MptNodeData::Branch(children) => { - let (i, tail) = key_nibs.split_first().unwrap(); - match &children[*i as usize] { - Some(child) => proof_internal(child, tail)?, - None => vec![], - } - } - MptNodeData::Extension(_, child) => { - if let Some(tail) = key_nibs.strip_prefix(node.nibs().as_slice()) { - proof_internal(child, tail)? - } else { - vec![] - } - } - MptNodeData::Digest(_) => bail!("Cannot descend pointer!"), - }; - path.push(node.to_rlp()); - - Ok(path) -} - -/// The size of the stack to use for the EVM. -pub const BIG_STACK_SIZE: usize = 8 * 1024 * 1024; - -pub fn create_input( - chain_spec: &ChainSpec, - parent_header: Header, - parent_state: TestState, - header: Header, - transactions: Vec, - withdrawals: Vec, - state: TestState, -) -> Input { - // create the provider DB - let provider_db = ProviderDb::new( - Box::new(TestProvider { - state: parent_state, - header: parent_header.clone(), - post: state, - }), - parent_header.number, - ); - - let transactions: Vec = transactions - .into_iter() - .map(EthereumTransaction::from) - .collect(); - let input = Input { - beneficiary: header.beneficiary, - gas_limit: header.gas_limit, - timestamp: header.timestamp, - extra_data: header.extra_data.clone(), - mix_hash: header.mix_hash, - transactions: transactions.clone(), - withdrawals: withdrawals.clone(), - parent_state_trie: Default::default(), - parent_storage: Default::default(), - contracts: vec![], - parent_header: parent_header.clone(), - - ancestor_headers: vec![], - }; - - // create and run the block builder once to create the initial DB - let mut builder = BlockBuilder::new(&chain_spec, input) - .with_db(provider_db) - .prepare_header::<::HeaderPrepStrategy>() - .unwrap() - .execute_transactions::<::TxExecStrategy>() - .unwrap(); - let provider_db = builder.mut_db().unwrap(); - - let parent_proofs = provider_db.get_initial_proofs().unwrap(); - let proofs = provider_db.get_latest_proofs().unwrap(); - let ancestor_headers = provider_db.get_ancestor_headers().unwrap(); - - let preflight_data = Data { - db: provider_db.get_initial_db().clone(), - parent_header, - parent_proofs, - header, - transactions, - withdrawals, - proofs, - ancestor_headers, - }; - - preflight_data.try_into().unwrap() -} diff --git a/testing/ef-tests/testdata b/testing/ef-tests/testdata deleted file mode 160000 index 66135631..00000000 --- a/testing/ef-tests/testdata +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 661356317ac6df52208d54187e692472a25a01f8 diff --git a/testing/ef-tests/testguest/Cargo.lock b/testing/ef-tests/testguest/Cargo.lock deleted file mode 100644 index fa658e5e..00000000 --- a/testing/ef-tests/testguest/Cargo.lock +++ /dev/null @@ -1,3711 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -version = 3 - -[[package]] -name = "addr2line" -version = "0.21.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb" -dependencies = [ - "gimli", -] - -[[package]] -name = "adler" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" - -[[package]] -name = "adler32" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aae1277d39aeec15cb388266ecc24b11c80469deae6067e17a1a7aa9e5c1f234" - -[[package]] -name = "ahash" -version = "0.8.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42cd52102d3df161c77a887b608d7a4897d7cc112886a9537b738a887a03aaff" -dependencies = [ - "cfg-if", - "once_cell", - "version_check", - "zerocopy", -] - -[[package]] -name = "aho-corasick" -version = "1.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0" -dependencies = [ - "memchr", -] - -[[package]] -name = "allocator-api2" -version = "0.2.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5" - -[[package]] -name = "alloy-primitives" -version = "0.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4b6fb2b432ff223d513db7f908937f63c252bee0af9b82bfd25b0a5dd1eb0d8" -dependencies = [ - "alloy-rlp", - "bytes", - "cfg-if", - "const-hex", - "derive_more", - "hex-literal", - "itoa", - "k256", - "keccak-asm", - "proptest", - "rand", - "ruint", - "serde", - "tiny-keccak", -] - -[[package]] -name = "alloy-rlp" -version = "0.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d58d9f5da7b40e9bfff0b7e7816700be4019db97d4b6359fe7f94a9e22e42ac" -dependencies = [ - "arrayvec", - "bytes", -] - -[[package]] -name = "alloy-rlp-derive" -version = "0.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a047897373be4bbb0224c1afdabca92648dc57a9c9ef6e7b0be3aff7a859c83" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.48", -] - -[[package]] -name = "android-tzdata" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0" - -[[package]] -name = "android_system_properties" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" -dependencies = [ - "libc", -] - -[[package]] -name = "anyhow" -version = "1.0.79" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "080e9890a082662b09c1ad45f567faeeb47f22b5fb23895fbe1e651e718e25ca" - -[[package]] -name = "ark-ff" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b3235cc41ee7a12aaaf2c575a2ad7b46713a8a50bda2fc3b003a04845c05dd6" -dependencies = [ - "ark-ff-asm 0.3.0", - "ark-ff-macros 0.3.0", - "ark-serialize 0.3.0", - "ark-std 0.3.0", - "derivative", - "num-bigint", - "num-traits", - "paste", - "rustc_version 0.3.3", - "zeroize", -] - -[[package]] -name = "ark-ff" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec847af850f44ad29048935519032c33da8aa03340876d351dfab5660d2966ba" -dependencies = [ - "ark-ff-asm 0.4.2", - "ark-ff-macros 0.4.2", - "ark-serialize 0.4.2", - "ark-std 0.4.0", - "derivative", - "digest 0.10.7", - "itertools", - "num-bigint", - "num-traits", - "paste", - "rustc_version 0.4.0", - "zeroize", -] - -[[package]] -name = "ark-ff-asm" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db02d390bf6643fb404d3d22d31aee1c4bc4459600aef9113833d17e786c6e44" -dependencies = [ - "quote", - "syn 1.0.109", -] - -[[package]] -name = "ark-ff-asm" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ed4aa4fe255d0bc6d79373f7e31d2ea147bcf486cba1be5ba7ea85abdb92348" -dependencies = [ - "quote", - "syn 1.0.109", -] - -[[package]] -name = "ark-ff-macros" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db2fd794a08ccb318058009eefdf15bcaaaaf6f8161eb3345f907222bac38b20" -dependencies = [ - "num-bigint", - "num-traits", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "ark-ff-macros" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7abe79b0e4288889c4574159ab790824d0033b9fdcb2a112a3182fac2e514565" -dependencies = [ - "num-bigint", - "num-traits", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "ark-serialize" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d6c2b318ee6e10f8c2853e73a83adc0ccb88995aa978d8a3408d492ab2ee671" -dependencies = [ - "ark-std 0.3.0", - "digest 0.9.0", -] - -[[package]] -name = "ark-serialize" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "adb7b85a02b83d2f22f89bd5cac66c9c89474240cb6207cb1efc16d098e822a5" -dependencies = [ - "ark-std 0.4.0", - "digest 0.10.7", - "num-bigint", -] - -[[package]] -name = "ark-std" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1df2c09229cbc5a028b1d70e00fdb2acee28b1055dfb5ca73eea49c5a25c4e7c" -dependencies = [ - "num-traits", - "rand", -] - -[[package]] -name = "ark-std" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94893f1e0c6eeab764ade8dc4c0db24caf4fe7cbbaafc0eba0a9030f447b5185" -dependencies = [ - "num-traits", - "rand", -] - -[[package]] -name = "arrayvec" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" - -[[package]] -name = "async-trait" -version = "0.1.77" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c980ee35e870bd1a4d2c8294d4c04d0499e67bca1e4b5cefcc693c2fa00caea9" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.48", -] - -[[package]] -name = "async_io_stream" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6d7b9decdf35d8908a7e3ef02f64c5e9b1695e230154c0e8de3969142d9b94c" -dependencies = [ - "futures", - "pharos", - "rustc_version 0.4.0", -] - -[[package]] -name = "aurora-engine-modexp" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfacad86e9e138fca0670949eb8ed4ffdf73a55bded8887efe0863cd1a3a6f70" -dependencies = [ - "hex", - "num", -] - -[[package]] -name = "auto_impl" -version = "1.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "823b8bb275161044e2ac7a25879cb3e2480cb403e3943022c7c769c599b756aa" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.48", -] - -[[package]] -name = "autocfg" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" - -[[package]] -name = "backtrace" -version = "0.3.69" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2089b7e3f35b9dd2d0ed921ead4f6d318c27680d4a5bd167b3ee120edb105837" -dependencies = [ - "addr2line", - "cc", - "cfg-if", - "libc", - "miniz_oxide", - "object", - "rustc-demangle", -] - -[[package]] -name = "base16ct" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf" - -[[package]] -name = "base64" -version = "0.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" - -[[package]] -name = "base64" -version = "0.21.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" - -[[package]] -name = "base64ct" -version = "1.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" - -[[package]] -name = "bit-set" -version = "0.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0700ddab506f33b20a03b13996eccd309a48e5ff77d0d95926aa0210fb4e95f1" -dependencies = [ - "bit-vec", -] - -[[package]] -name = "bit-vec" -version = "0.6.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "349f9b6a179ed607305526ca489b34ad0a41aed5f7980fa90eb03160b69598fb" - -[[package]] -name = "bitflags" -version = "1.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" - -[[package]] -name = "bitflags" -version = "2.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed570934406eb16438a4e976b1b4500774099c13b8cb96eec99f620f05090ddf" -dependencies = [ - "serde", -] - -[[package]] -name = "bitvec" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" -dependencies = [ - "funty", - "radium", - "serde", - "tap", - "wyz", -] - -[[package]] -name = "blake2" -version = "0.10.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46502ad458c9a52b69d4d4d32775c788b7a1b85e8bc9d482d92250fc0e3f8efe" -dependencies = [ - "digest 0.10.7", -] - -[[package]] -name = "block-buffer" -version = "0.10.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" -dependencies = [ - "generic-array", -] - -[[package]] -name = "blst" -version = "0.3.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c94087b935a822949d3291a9989ad2b2051ea141eda0fd4e478a75f6aa3e604b" -dependencies = [ - "cc", - "glob", - "threadpool", - "zeroize", -] - -[[package]] -name = "bumpalo" -version = "3.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f30e7476521f6f8af1a1c4c0b8cc94f0bee37d91763d0ca2665f299b6cd8aec" - -[[package]] -name = "byte-slice-cast" -version = "1.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3ac9f8b63eca6fd385229b3675f6cc0dc5c8a5c8a54a59d4f52ffd670d87b0c" - -[[package]] -name = "bytemuck" -version = "1.14.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2ef034f05691a48569bd920a96c81b9d91bbad1ab5ac7c4616c1f6ef36cb79f" -dependencies = [ - "bytemuck_derive", -] - -[[package]] -name = "bytemuck_derive" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "965ab7eb5f8f97d2a083c799f3a1b994fc397b2fe2da5d1da1626ce15a39f2b1" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.48", -] - -[[package]] -name = "byteorder" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" - -[[package]] -name = "bytes" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2bd12c1caf447e69cd4528f47f94d203fd2582878ecb9e9465484c4148a8223" -dependencies = [ - "serde", -] - -[[package]] -name = "c-kzg" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9d8c306be83ec04bf5f73710badd8edf56dea23f2f0d8b7f9fe4644d371c758" -dependencies = [ - "blst", - "cc", - "glob", - "hex", - "libc", - "serde", -] - -[[package]] -name = "cc" -version = "1.0.83" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0" -dependencies = [ - "libc", -] - -[[package]] -name = "cfg-if" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" - -[[package]] -name = "chrono" -version = "0.4.34" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5bc015644b92d5890fab7489e49d21f879d5c990186827d42ec511919404f38b" -dependencies = [ - "android-tzdata", - "iana-time-zone", - "num-traits", - "serde", - "windows-targets 0.52.0", -] - -[[package]] -name = "const-hex" -version = "1.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18d59688ad0945eaf6b84cb44fedbe93484c81b48970e98f09db8a22832d7961" -dependencies = [ - "cfg-if", - "cpufeatures", - "hex", - "proptest", - "serde", -] - -[[package]] -name = "const-oid" -version = "0.9.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" - -[[package]] -name = "convert_case" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" - -[[package]] -name = "core-foundation" -version = "0.9.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91e195e091a93c46f7102ec7818a2aa394e1e1771c3ab4825963fa03e45afb8f" -dependencies = [ - "core-foundation-sys", - "libc", -] - -[[package]] -name = "core-foundation-sys" -version = "0.8.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f" - -[[package]] -name = "core2" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b49ba7ef1ad6107f8824dbe97de947cbaac53c44e7f9756a1fba0d37c1eec505" -dependencies = [ - "memchr", -] - -[[package]] -name = "cpufeatures" -version = "0.2.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53fe5e26ff1b7aef8bca9c6080520cfb8d9333c7568e1829cef191a9723e5504" -dependencies = [ - "libc", -] - -[[package]] -name = "crc32fast" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3855a8a784b474f333699ef2bbca9db2c4a1f6d9088a90a2d25b1eb53111eaa" -dependencies = [ - "cfg-if", -] - -[[package]] -name = "crunchy" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" - -[[package]] -name = "crypto-bigint" -version = "0.5.2" -source = "git+https://github.com/risc0/RustCrypto-crypto-bigint?tag=v0.5.2-risczero.0#8b30304277cfe553b51a78a0e693f48bbb059eb3" -dependencies = [ - "generic-array", - "getrandom", - "rand_core", - "subtle", - "zeroize", -] - -[[package]] -name = "crypto-common" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" -dependencies = [ - "generic-array", - "typenum", -] - -[[package]] -name = "darling" -version = "0.20.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc5d6b04b3fd0ba9926f945895de7d806260a2d7431ba82e7edaecb043c4c6b8" -dependencies = [ - "darling_core", - "darling_macro", -] - -[[package]] -name = "darling_core" -version = "0.20.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04e48a959bcd5c761246f5d090ebc2fbf7b9cd527a492b07a67510c108f1e7e3" -dependencies = [ - "fnv", - "ident_case", - "proc-macro2", - "quote", - "strsim", - "syn 2.0.48", -] - -[[package]] -name = "darling_macro" -version = "0.20.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d1545d67a2149e1d93b7e5c7752dce5a7426eb5d1357ddcfd89336b94444f77" -dependencies = [ - "darling_core", - "quote", - "syn 2.0.48", -] - -[[package]] -name = "dary_heap" -version = "0.3.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7762d17f1241643615821a8455a0b2c3e803784b058693d990b11f2dce25a0ca" - -[[package]] -name = "data-encoding" -version = "2.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e962a19be5cfc3f3bf6dd8f61eb50107f356ad6270fbb3ed41476571db78be5" - -[[package]] -name = "der" -version = "0.7.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fffa369a668c8af7dbf8b5e56c9f744fbd399949ed171606040001947de40b1c" -dependencies = [ - "const-oid", - "zeroize", -] - -[[package]] -name = "deranged" -version = "0.3.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b42b6fa04a440b495c8b04d0e71b707c585f83cb9cb28cf8cd0d976c315e31b4" -dependencies = [ - "powerfmt", - "serde", -] - -[[package]] -name = "derivative" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "derive_more" -version = "0.99.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" -dependencies = [ - "convert_case", - "proc-macro2", - "quote", - "rustc_version 0.4.0", - "syn 1.0.109", -] - -[[package]] -name = "digest" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" -dependencies = [ - "generic-array", -] - -[[package]] -name = "digest" -version = "0.10.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" -dependencies = [ - "block-buffer", - "const-oid", - "crypto-common", - "subtle", -] - -[[package]] -name = "downcast-rs" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ea835d29036a4087793836fa931b08837ad5e957da9e23886b29586fb9b6650" - -[[package]] -name = "ecdsa" -version = "0.16.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee27f32b5c5292967d2d4a9d7f1e0b0aed2c15daded5a60300e4abb9d8020bca" -dependencies = [ - "der", - "digest 0.10.7", - "elliptic-curve", - "rfc6979", - "signature", - "spki", -] - -[[package]] -name = "either" -version = "1.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11157ac094ffbdde99aa67b23417ebdd801842852b500e395a45a9c0aac03e4a" - -[[package]] -name = "elf" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4445909572dbd556c457c849c4ca58623d84b27c8fff1e74b0b4227d8b90d17b" - -[[package]] -name = "elliptic-curve" -version = "0.13.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5e6043086bf7973472e0c7dff2142ea0b680d30e18d9cc40f267efbf222bd47" -dependencies = [ - "base16ct", - "crypto-bigint", - "digest 0.10.7", - "ff", - "generic-array", - "group", - "pkcs8", - "rand_core", - "sec1", - "subtle", - "zeroize", -] - -[[package]] -name = "encoding_rs" -version = "0.8.33" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7268b386296a025e474d5140678f75d6de9493ae55a5d709eeb9dd08149945e1" -dependencies = [ - "cfg-if", -] - -[[package]] -name = "enr" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe81b5c06ecfdbc71dd845216f225f53b62a10cb8a16c946836a3467f701d05b" -dependencies = [ - "base64 0.21.7", - "bytes", - "hex", - "k256", - "log", - "rand", - "rlp", - "serde", - "sha3", - "zeroize", -] - -[[package]] -name = "enumn" -version = "0.1.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6fd000fd6988e73bbe993ea3db9b1aa64906ab88766d654973924340c8cddb42" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.48", -] - -[[package]] -name = "equivalent" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" - -[[package]] -name = "errno" -version = "0.3.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a258e46cdc063eb8519c00b9fc845fc47bcfca4130e2f08e88665ceda8474245" -dependencies = [ - "libc", - "windows-sys 0.52.0", -] - -[[package]] -name = "ethabi" -version = "18.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7413c5f74cc903ea37386a8965a936cbeb334bd270862fdece542c1b2dcbc898" -dependencies = [ - "ethereum-types", - "hex", - "once_cell", - "regex", - "serde", - "serde_json", - "sha3", - "thiserror", - "uint", -] - -[[package]] -name = "ethbloom" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c22d4b5885b6aa2fe5e8b9329fb8d232bf739e434e6b87347c63bdd00c120f60" -dependencies = [ - "crunchy", - "fixed-hash", - "impl-codec", - "impl-rlp", - "impl-serde", - "scale-info", - "tiny-keccak", -] - -[[package]] -name = "ethereum-types" -version = "0.14.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02d215cbf040552efcbe99a38372fe80ab9d00268e20012b79fcd0f073edd8ee" -dependencies = [ - "ethbloom", - "fixed-hash", - "impl-codec", - "impl-rlp", - "impl-serde", - "primitive-types", - "scale-info", - "uint", -] - -[[package]] -name = "ethers-core" -version = "2.0.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aab3cef6cc1c9fd7f787043c81ad3052eff2b96a3878ef1526aa446311bdbfc9" -dependencies = [ - "arrayvec", - "bytes", - "chrono", - "const-hex", - "elliptic-curve", - "ethabi", - "generic-array", - "k256", - "num_enum", - "open-fastrlp", - "rand", - "rlp", - "serde", - "serde_json", - "strum", - "tempfile", - "thiserror", - "tiny-keccak", - "unicode-xid", -] - -[[package]] -name = "ethers-providers" -version = "2.0.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb6b15393996e3b8a78ef1332d6483c11d839042c17be58decc92fa8b1c3508a" -dependencies = [ - "async-trait", - "auto_impl", - "base64 0.21.7", - "bytes", - "const-hex", - "enr", - "ethers-core", - "futures-channel", - "futures-core", - "futures-timer", - "futures-util", - "hashers", - "http", - "instant", - "jsonwebtoken", - "once_cell", - "pin-project", - "reqwest", - "serde", - "serde_json", - "thiserror", - "tokio", - "tokio-tungstenite", - "tracing", - "tracing-futures", - "url", - "wasm-bindgen", - "wasm-bindgen-futures", - "web-sys", - "ws_stream_wasm", -] - -[[package]] -name = "fastrand" -version = "2.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25cbce373ec4653f1a01a31e8a5e5ec0c622dc27ff9c4e6606eefef5cbbed4a5" - -[[package]] -name = "fastrlp" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "139834ddba373bbdd213dffe02c8d110508dcf1726c2be27e8d1f7d7e1856418" -dependencies = [ - "arrayvec", - "auto_impl", - "bytes", -] - -[[package]] -name = "ff" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ded41244b729663b1e574f1b4fb731469f69f79c17667b5d776b16cda0479449" -dependencies = [ - "rand_core", - "subtle", -] - -[[package]] -name = "fixed-hash" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "835c052cb0c08c1acf6ffd71c022172e18723949c8282f2b9f27efbc51e64534" -dependencies = [ - "byteorder", - "rand", - "rustc-hex", - "static_assertions", -] - -[[package]] -name = "flate2" -version = "1.0.28" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46303f565772937ffe1d394a4fac6f411c6013172fadde9dcdb1e147a086940e" -dependencies = [ - "crc32fast", - "miniz_oxide", -] - -[[package]] -name = "fnv" -version = "1.0.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" - -[[package]] -name = "form_urlencoded" -version = "1.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456" -dependencies = [ - "percent-encoding", -] - -[[package]] -name = "funty" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" - -[[package]] -name = "futures" -version = "0.3.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "645c6916888f6cb6350d2550b80fb63e734897a8498abe35cfb732b6487804b0" -dependencies = [ - "futures-channel", - "futures-core", - "futures-executor", - "futures-io", - "futures-sink", - "futures-task", - "futures-util", -] - -[[package]] -name = "futures-channel" -version = "0.3.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78" -dependencies = [ - "futures-core", - "futures-sink", -] - -[[package]] -name = "futures-core" -version = "0.3.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d" - -[[package]] -name = "futures-executor" -version = "0.3.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a576fc72ae164fca6b9db127eaa9a9dda0d61316034f33a0a0d4eda41f02b01d" -dependencies = [ - "futures-core", - "futures-task", - "futures-util", -] - -[[package]] -name = "futures-io" -version = "0.3.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1" - -[[package]] -name = "futures-macro" -version = "0.3.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.48", -] - -[[package]] -name = "futures-sink" -version = "0.3.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9fb8e00e87438d937621c1c6269e53f536c14d3fbd6a042bb24879e57d474fb5" - -[[package]] -name = "futures-task" -version = "0.3.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004" - -[[package]] -name = "futures-timer" -version = "3.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e64b03909df88034c26dc1547e8970b91f98bdb65165d6a4e9110d94263dbb2c" -dependencies = [ - "gloo-timers", - "send_wrapper 0.4.0", -] - -[[package]] -name = "futures-util" -version = "0.3.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48" -dependencies = [ - "futures-channel", - "futures-core", - "futures-io", - "futures-macro", - "futures-sink", - "futures-task", - "memchr", - "pin-project-lite", - "pin-utils", - "slab", -] - -[[package]] -name = "fxhash" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c31b6d751ae2c7f11320402d34e41349dd1016f8d5d45e48c4312bc8625af50c" -dependencies = [ - "byteorder", -] - -[[package]] -name = "generic-array" -version = "0.14.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" -dependencies = [ - "typenum", - "version_check", - "zeroize", -] - -[[package]] -name = "getrandom" -version = "0.2.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "190092ea657667030ac6a35e305e62fc4dd69fd98ac98631e5d3a2b1575a12b5" -dependencies = [ - "cfg-if", - "libc", - "wasi", -] - -[[package]] -name = "gimli" -version = "0.28.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" - -[[package]] -name = "glob" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" - -[[package]] -name = "gloo-timers" -version = "0.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b995a66bb87bebce9a0f4a95aed01daca4872c050bfcb21653361c03bc35e5c" -dependencies = [ - "futures-channel", - "futures-core", - "js-sys", - "wasm-bindgen", -] - -[[package]] -name = "group" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63" -dependencies = [ - "ff", - "rand_core", - "subtle", -] - -[[package]] -name = "h2" -version = "0.3.24" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb2c4422095b67ee78da96fbb51a4cc413b3b25883c7717ff7ca1ab31022c9c9" -dependencies = [ - "bytes", - "fnv", - "futures-core", - "futures-sink", - "futures-util", - "http", - "indexmap 2.2.3", - "slab", - "tokio", - "tokio-util", - "tracing", -] - -[[package]] -name = "hashbrown" -version = "0.12.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" - -[[package]] -name = "hashbrown" -version = "0.13.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e" -dependencies = [ - "ahash", -] - -[[package]] -name = "hashbrown" -version = "0.14.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" -dependencies = [ - "ahash", - "allocator-api2", - "serde", -] - -[[package]] -name = "hashers" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2bca93b15ea5a746f220e56587f71e73c6165eab783df9e26590069953e3c30" -dependencies = [ - "fxhash", -] - -[[package]] -name = "heck" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" - -[[package]] -name = "hermit-abi" -version = "0.3.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd5256b483761cd23699d0da46cc6fd2ee3be420bbe6d020ae4a091e70b7e9fd" - -[[package]] -name = "hex" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" -dependencies = [ - "serde", -] - -[[package]] -name = "hex-literal" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6fe2267d4ed49bc07b63801559be28c718ea06c4738b7a03c94df7386d2cde46" - -[[package]] -name = "hmac" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" -dependencies = [ - "digest 0.10.7", -] - -[[package]] -name = "http" -version = "0.2.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8947b1a6fad4393052c7ba1f4cd97bed3e953a95c79c92ad9b051a04611d9fbb" -dependencies = [ - "bytes", - "fnv", - "itoa", -] - -[[package]] -name = "http-body" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ceab25649e9960c0311ea418d17bee82c0dcec1bd053b5f9a66e265a693bed2" -dependencies = [ - "bytes", - "http", - "pin-project-lite", -] - -[[package]] -name = "httparse" -version = "1.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904" - -[[package]] -name = "httpdate" -version = "1.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" - -[[package]] -name = "hyper" -version = "0.14.28" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf96e135eb83a2a8ddf766e426a841d8ddd7449d5f00d34ea02b41d2f19eef80" -dependencies = [ - "bytes", - "futures-channel", - "futures-core", - "futures-util", - "h2", - "http", - "http-body", - "httparse", - "httpdate", - "itoa", - "pin-project-lite", - "socket2", - "tokio", - "tower-service", - "tracing", - "want", -] - -[[package]] -name = "hyper-rustls" -version = "0.24.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec3efd23720e2049821a693cbc7e65ea87c72f1c58ff2f9522ff332b1491e590" -dependencies = [ - "futures-util", - "http", - "hyper", - "rustls", - "tokio", - "tokio-rustls", -] - -[[package]] -name = "iana-time-zone" -version = "0.1.60" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7ffbb5a1b541ea2561f8c41c087286cc091e21e556a4f09a8f6cbf17b69b141" -dependencies = [ - "android_system_properties", - "core-foundation-sys", - "iana-time-zone-haiku", - "js-sys", - "wasm-bindgen", - "windows-core", -] - -[[package]] -name = "iana-time-zone-haiku" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" -dependencies = [ - "cc", -] - -[[package]] -name = "ident_case" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" - -[[package]] -name = "idna" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6" -dependencies = [ - "unicode-bidi", - "unicode-normalization", -] - -[[package]] -name = "impl-codec" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba6a270039626615617f3f36d15fc827041df3b78c439da2cadfa47455a77f2f" -dependencies = [ - "parity-scale-codec", -] - -[[package]] -name = "impl-rlp" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f28220f89297a075ddc7245cd538076ee98b01f2a9c23a53a4f1105d5a322808" -dependencies = [ - "rlp", -] - -[[package]] -name = "impl-serde" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ebc88fc67028ae3db0c853baa36269d398d5f45b6982f95549ff5def78c935cd" -dependencies = [ - "serde", -] - -[[package]] -name = "impl-trait-for-tuples" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11d7a9f6330b71fea57921c9b61c47ee6e84f72d394754eff6163ae67e7395eb" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "indexmap" -version = "1.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" -dependencies = [ - "autocfg", - "hashbrown 0.12.3", - "serde", -] - -[[package]] -name = "indexmap" -version = "2.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "233cf39063f058ea2caae4091bf4a3ef70a653afbc026f5c4a4135d114e3c177" -dependencies = [ - "equivalent", - "hashbrown 0.14.3", - "serde", -] - -[[package]] -name = "instant" -version = "0.1.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" -dependencies = [ - "cfg-if", -] - -[[package]] -name = "ipnet" -version = "2.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f518f335dce6725a761382244631d86cf0ccb2863413590b31338feb467f9c3" - -[[package]] -name = "itertools" -version = "0.10.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" -dependencies = [ - "either", -] - -[[package]] -name = "itoa" -version = "1.0.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c" - -[[package]] -name = "js-sys" -version = "0.3.68" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "406cda4b368d531c842222cf9d2600a9a4acce8d29423695379c6868a143a9ee" -dependencies = [ - "wasm-bindgen", -] - -[[package]] -name = "jsonwebtoken" -version = "8.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6971da4d9c3aa03c3d8f3ff0f4155b534aad021292003895a469716b2a230378" -dependencies = [ - "base64 0.21.7", - "pem", - "ring 0.16.20", - "serde", - "serde_json", - "simple_asn1", -] - -[[package]] -name = "k256" -version = "0.13.3" -source = "git+https://github.com/risc0/RustCrypto-elliptic-curves?tag=k256/v0.13.3-risczero.0#d4f457a04410397cbb652a67c168b6cd6e9757c4" -dependencies = [ - "cfg-if", - "ecdsa", - "elliptic-curve", - "once_cell", - "sha2", - "signature", -] - -[[package]] -name = "keccak" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ecc2af9a1119c51f12a14607e783cb977bde58bc069ff0c3da1095e635d70654" -dependencies = [ - "cpufeatures", -] - -[[package]] -name = "keccak-asm" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb8515fff80ed850aea4a1595f2e519c003e2a00a82fe168ebf5269196caf444" -dependencies = [ - "digest 0.10.7", - "sha3-asm", -] - -[[package]] -name = "lazy_static" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" -dependencies = [ - "spin 0.5.2", -] - -[[package]] -name = "libc" -version = "0.2.153" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" - -[[package]] -name = "libflate" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f7d5654ae1795afc7ff76f4365c2c8791b0feb18e8996a96adad8ffd7c3b2bf" -dependencies = [ - "adler32", - "core2", - "crc32fast", - "dary_heap", - "libflate_lz77", -] - -[[package]] -name = "libflate_lz77" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be5f52fb8c451576ec6b79d3f4deb327398bc05bbdbd99021a6e77a4c855d524" -dependencies = [ - "core2", - "hashbrown 0.13.2", - "rle-decode-fast", -] - -[[package]] -name = "libm" -version = "0.2.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" - -[[package]] -name = "linux-raw-sys" -version = "0.4.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01cda141df6706de531b6c46c3a33ecca755538219bd484262fa09410c13539c" - -[[package]] -name = "lock_api" -version = "0.4.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c168f8615b12bc01f9c17e2eb0cc07dcae1940121185446edc3744920e8ef45" -dependencies = [ - "autocfg", - "scopeguard", -] - -[[package]] -name = "log" -version = "0.4.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" - -[[package]] -name = "memchr" -version = "2.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149" - -[[package]] -name = "mime" -version = "0.3.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" - -[[package]] -name = "miniz_oxide" -version = "0.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d811f3e15f28568be3407c8e7fdb6514c1cda3cb30683f15b6a1a1dc4ea14a7" -dependencies = [ - "adler", -] - -[[package]] -name = "mio" -version = "0.8.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f3d0b296e374a4e6f3c7b0a1f5a51d748a0d34c85e7dc48fc3fa9a87657fe09" -dependencies = [ - "libc", - "wasi", - "windows-sys 0.48.0", -] - -[[package]] -name = "num" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b05180d69e3da0e530ba2a1dae5110317e49e3b7f3d41be227dc5f92e49ee7af" -dependencies = [ - "num-bigint", - "num-complex", - "num-integer", - "num-iter", - "num-rational", - "num-traits", -] - -[[package]] -name = "num-bigint" -version = "0.4.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "608e7659b5c3d7cba262d894801b9ec9d00de989e8a82bd4bef91d08da45cdc0" -dependencies = [ - "autocfg", - "num-integer", - "num-traits", -] - -[[package]] -name = "num-complex" -version = "0.4.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23c6602fda94a57c990fe0df199a035d83576b496aa29f4e634a8ac6004e68a6" -dependencies = [ - "num-traits", -] - -[[package]] -name = "num-conv" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9" - -[[package]] -name = "num-derive" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed3955f1a9c7c0c15e092f9c887db08b1fc683305fdf6eb6684f22555355e202" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.48", -] - -[[package]] -name = "num-integer" -version = "0.1.46" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" -dependencies = [ - "num-traits", -] - -[[package]] -name = "num-iter" -version = "0.1.44" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d869c01cc0c455284163fd0092f1f93835385ccab5a98a0dcc497b2f8bf055a9" -dependencies = [ - "autocfg", - "num-integer", - "num-traits", -] - -[[package]] -name = "num-rational" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0638a1c9d0a3c0914158145bc76cff373a75a627e6ecbfb71cbe6f453a5a19b0" -dependencies = [ - "autocfg", - "num-bigint", - "num-integer", - "num-traits", -] - -[[package]] -name = "num-traits" -version = "0.2.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da0df0e5185db44f69b44f26786fe401b6c293d1907744beaa7fa62b2e5a517a" -dependencies = [ - "autocfg", - "libm", -] - -[[package]] -name = "num_cpus" -version = "1.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" -dependencies = [ - "hermit-abi", - "libc", -] - -[[package]] -name = "num_enum" -version = "0.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02339744ee7253741199f897151b38e72257d13802d4ee837285cc2990a90845" -dependencies = [ - "num_enum_derive", -] - -[[package]] -name = "num_enum_derive" -version = "0.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "681030a937600a36906c185595136d26abfebb4aa9c65701cefcaf8578bb982b" -dependencies = [ - "proc-macro-crate 3.1.0", - "proc-macro2", - "quote", - "syn 2.0.48", -] - -[[package]] -name = "object" -version = "0.32.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a6a622008b6e321afc04970976f62ee297fdbaa6f95318ca343e3eebb9648441" -dependencies = [ - "memchr", -] - -[[package]] -name = "once_cell" -version = "1.19.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" - -[[package]] -name = "open-fastrlp" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "786393f80485445794f6043fd3138854dd109cc6c4bd1a6383db304c9ce9b9ce" -dependencies = [ - "arrayvec", - "auto_impl", - "bytes", - "ethereum-types", - "open-fastrlp-derive", -] - -[[package]] -name = "open-fastrlp-derive" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "003b2be5c6c53c1cfeb0a238b8a1c3915cd410feb684457a36c10038f764bb1c" -dependencies = [ - "bytes", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "parity-scale-codec" -version = "3.6.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "881331e34fa842a2fb61cc2db9643a8fedc615e47cfcc52597d1af0db9a7e8fe" -dependencies = [ - "arrayvec", - "bitvec", - "byte-slice-cast", - "impl-trait-for-tuples", - "parity-scale-codec-derive", - "serde", -] - -[[package]] -name = "parity-scale-codec-derive" -version = "3.6.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be30eaf4b0a9fba5336683b38de57bb86d179a35862ba6bfcf57625d006bde5b" -dependencies = [ - "proc-macro-crate 2.0.0", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "parking_lot" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" -dependencies = [ - "lock_api", - "parking_lot_core", -] - -[[package]] -name = "parking_lot_core" -version = "0.9.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c42a9226546d68acdd9c0a280d17ce19bfe27a46bf68784e4066115788d008e" -dependencies = [ - "cfg-if", - "libc", - "redox_syscall", - "smallvec", - "windows-targets 0.48.5", -] - -[[package]] -name = "paste" -version = "1.0.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c" - -[[package]] -name = "pem" -version = "1.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8835c273a76a90455d7344889b0964598e3316e2a79ede8e36f16bdcf2228b8" -dependencies = [ - "base64 0.13.1", -] - -[[package]] -name = "percent-encoding" -version = "2.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" - -[[package]] -name = "pest" -version = "2.7.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "219c0dcc30b6a27553f9cc242972b67f75b60eb0db71f0b5462f38b058c41546" -dependencies = [ - "memchr", - "thiserror", - "ucd-trie", -] - -[[package]] -name = "pharos" -version = "0.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9567389417feee6ce15dd6527a8a1ecac205ef62c2932bcf3d9f6fc5b78b414" -dependencies = [ - "futures", - "rustc_version 0.4.0", -] - -[[package]] -name = "pin-project" -version = "1.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0302c4a0442c456bd56f841aee5c3bfd17967563f6fadc9ceb9f9c23cf3807e0" -dependencies = [ - "pin-project-internal", -] - -[[package]] -name = "pin-project-internal" -version = "1.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "266c042b60c9c76b8d53061e52b2e0d1116abc57cefc8c5cd671619a56ac3690" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.48", -] - -[[package]] -name = "pin-project-lite" -version = "0.2.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" - -[[package]] -name = "pin-utils" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" - -[[package]] -name = "pkcs8" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" -dependencies = [ - "der", - "spki", -] - -[[package]] -name = "powerfmt" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" - -[[package]] -name = "ppv-lite86" -version = "0.2.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" - -[[package]] -name = "primitive-types" -version = "0.12.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b34d9fd68ae0b74a41b21c03c2f62847aa0ffea044eee893b4c140b37e244e2" -dependencies = [ - "fixed-hash", - "impl-codec", - "impl-rlp", - "impl-serde", - "scale-info", - "uint", -] - -[[package]] -name = "proc-macro-crate" -version = "1.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919" -dependencies = [ - "once_cell", - "toml_edit 0.19.15", -] - -[[package]] -name = "proc-macro-crate" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e8366a6159044a37876a2b9817124296703c586a5c92e2c53751fa06d8d43e8" -dependencies = [ - "toml_edit 0.20.7", -] - -[[package]] -name = "proc-macro-crate" -version = "3.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d37c51ca738a55da99dc0c4a34860fd675453b8b36209178c2249bb13651284" -dependencies = [ - "toml_edit 0.21.1", -] - -[[package]] -name = "proc-macro2" -version = "1.0.78" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2422ad645d89c99f8f3e6b88a9fdeca7fabeac836b1002371c4367c8f984aae" -dependencies = [ - "unicode-ident", -] - -[[package]] -name = "proptest" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31b476131c3c86cb68032fdc5cb6d5a1045e3e42d96b69fa599fd77701e1f5bf" -dependencies = [ - "bit-set", - "bit-vec", - "bitflags 2.4.2", - "lazy_static", - "num-traits", - "rand", - "rand_chacha", - "rand_xorshift", - "regex-syntax", - "rusty-fork", - "tempfile", - "unarray", -] - -[[package]] -name = "quick-error" -version = "1.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" - -[[package]] -name = "quote" -version = "1.0.35" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" -dependencies = [ - "proc-macro2", -] - -[[package]] -name = "radium" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" - -[[package]] -name = "rand" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" -dependencies = [ - "libc", - "rand_chacha", - "rand_core", -] - -[[package]] -name = "rand_chacha" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" -dependencies = [ - "ppv-lite86", - "rand_core", -] - -[[package]] -name = "rand_core" -version = "0.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" -dependencies = [ - "getrandom", -] - -[[package]] -name = "rand_xorshift" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d25bf25ec5ae4a3f1b92f929810509a2f53d7dca2f50b794ff57e3face536c8f" -dependencies = [ - "rand_core", -] - -[[package]] -name = "redox_syscall" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa" -dependencies = [ - "bitflags 1.3.2", -] - -[[package]] -name = "regex" -version = "1.10.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b62dbe01f0b06f9d8dc7d49e05a0785f153b00b2c227856282f671e0318c9b15" -dependencies = [ - "aho-corasick", - "memchr", - "regex-automata", - "regex-syntax", -] - -[[package]] -name = "regex-automata" -version = "0.4.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5bb987efffd3c6d0d8f5f89510bb458559eab11e4f869acb20bf845e016259cd" -dependencies = [ - "aho-corasick", - "memchr", - "regex-syntax", -] - -[[package]] -name = "regex-syntax" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" - -[[package]] -name = "reqwest" -version = "0.11.24" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6920094eb85afde5e4a138be3f2de8bbdf28000f0029e72c45025a56b042251" -dependencies = [ - "base64 0.21.7", - "bytes", - "encoding_rs", - "futures-core", - "futures-util", - "h2", - "http", - "http-body", - "hyper", - "hyper-rustls", - "ipnet", - "js-sys", - "log", - "mime", - "once_cell", - "percent-encoding", - "pin-project-lite", - "rustls", - "rustls-pemfile", - "serde", - "serde_json", - "serde_urlencoded", - "sync_wrapper", - "system-configuration", - "tokio", - "tokio-rustls", - "tower-service", - "url", - "wasm-bindgen", - "wasm-bindgen-futures", - "web-sys", - "webpki-roots", - "winreg", -] - -[[package]] -name = "revm" -version = "3.5.0" -source = "git+https://github.com/ceciliaz030/revm.git?branch=sync-taiko-v3.5#09531f2d92b80989c79fb9508ef20f8e9cbdd079" -dependencies = [ - "auto_impl", - "revm-interpreter", - "revm-precompile", - "serde", - "serde_json", -] - -[[package]] -name = "revm-interpreter" -version = "1.3.0" -source = "git+https://github.com/ceciliaz030/revm.git?branch=sync-taiko-v3.5#09531f2d92b80989c79fb9508ef20f8e9cbdd079" -dependencies = [ - "revm-primitives", - "serde", -] - -[[package]] -name = "revm-precompile" -version = "2.2.0" -source = "git+https://github.com/ceciliaz030/revm.git?branch=sync-taiko-v3.5#09531f2d92b80989c79fb9508ef20f8e9cbdd079" -dependencies = [ - "aurora-engine-modexp", - "c-kzg", - "k256", - "once_cell", - "revm-primitives", - "ripemd", - "secp256k1", - "sha2", - "substrate-bn", -] - -[[package]] -name = "revm-primitives" -version = "1.3.0" -source = "git+https://github.com/ceciliaz030/revm.git?branch=sync-taiko-v3.5#09531f2d92b80989c79fb9508ef20f8e9cbdd079" -dependencies = [ - "alloy-primitives", - "auto_impl", - "bitflags 2.4.2", - "bitvec", - "c-kzg", - "enumn", - "hashbrown 0.14.3", - "hex", - "serde", -] - -[[package]] -name = "rfc6979" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8dd2a808d456c4a54e300a23e9f5a67e122c3024119acbfd73e3bf664491cb2" -dependencies = [ - "hmac", - "subtle", -] - -[[package]] -name = "ring" -version = "0.16.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3053cf52e236a3ed746dfc745aa9cacf1b791d846bdaf412f60a8d7d6e17c8fc" -dependencies = [ - "cc", - "libc", - "once_cell", - "spin 0.5.2", - "untrusted 0.7.1", - "web-sys", - "winapi", -] - -[[package]] -name = "ring" -version = "0.17.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "688c63d65483050968b2a8937f7995f443e27041a0f7700aa59b0822aedebb74" -dependencies = [ - "cc", - "getrandom", - "libc", - "spin 0.9.8", - "untrusted 0.9.0", - "windows-sys 0.48.0", -] - -[[package]] -name = "ripemd" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd124222d17ad93a644ed9d011a40f4fb64aa54275c08cc216524a9ea82fb09f" -dependencies = [ - "digest 0.10.7", -] - -[[package]] -name = "risc0-binfmt" -version = "0.19.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "923c85a23cb9a9475b8cd4479ad3a06252604a361626e9ae7dc0dc635af22c22" -dependencies = [ - "anyhow", - "elf", - "log", - "risc0-zkp", - "risc0-zkvm-platform", - "serde", -] - -[[package]] -name = "risc0-circuit-recursion" -version = "0.19.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97547e10e9fdaaab8b64ffb45dc158b31f023b1a68015c6ce9f12fe3e403012a" -dependencies = [ - "anyhow", - "bytemuck", - "log", - "risc0-core", - "risc0-zkp", - "tracing", -] - -[[package]] -name = "risc0-circuit-rv32im" -version = "0.19.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a269d01b18cba24ee1a08f68726fc3623e8705ed79d158377d12e9129dcde2e" -dependencies = [ - "anyhow", - "log", - "risc0-core", - "risc0-zkp", - "risc0-zkvm-platform", - "tracing", -] - -[[package]] -name = "risc0-core" -version = "0.19.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "477e0bb8d2ec0b7955088b521eb596901e652d0faa2ea73bda0b77e05af5c07d" -dependencies = [ - "bytemuck", - "rand_core", -] - -[[package]] -name = "risc0-zkp" -version = "0.19.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5abb1a0cf847d3f9aed1e563b76c358107e7ba66dbfab28f7144252c990bd82" -dependencies = [ - "anyhow", - "blake2", - "bytemuck", - "digest 0.10.7", - "hex", - "log", - "paste", - "rand_core", - "risc0-core", - "risc0-zkvm-platform", - "serde", - "sha2", - "tracing", -] - -[[package]] -name = "risc0-zkvm" -version = "0.19.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3cf80df202c038efc2199be34fda8114b38bfc5b2b51c60cbbdf1f425b07b384" -dependencies = [ - "anyhow", - "bytemuck", - "cfg-if", - "getrandom", - "hex", - "log", - "num-derive", - "num-traits", - "risc0-binfmt", - "risc0-circuit-recursion", - "risc0-circuit-rv32im", - "risc0-core", - "risc0-zkp", - "risc0-zkvm-platform", - "rrs-lib", - "semver 1.0.21", - "serde", - "tracing", -] - -[[package]] -name = "risc0-zkvm-platform" -version = "0.19.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2dcd6b66f7a4972001db0acf3f06d99b7851c8d9f0de1f7e0fb4496c66c5cd02" -dependencies = [ - "bytemuck", - "getrandom", - "libm", -] - -[[package]] -name = "rle-decode-fast" -version = "1.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3582f63211428f83597b51b2ddb88e2a91a9d52d12831f9d08f5e624e8977422" - -[[package]] -name = "rlp" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb919243f34364b6bd2fc10ef797edbfa75f33c252e7998527479c6d6b47e1ec" -dependencies = [ - "bytes", - "rlp-derive", - "rustc-hex", -] - -[[package]] -name = "rlp-derive" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e33d7b2abe0c340d8797fe2907d3f20d3b5ea5908683618bfe80df7f621f672a" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "rrs-lib" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4382d3af3a4ebdae7f64ba6edd9114fff92c89808004c4943b393377a25d001" -dependencies = [ - "downcast-rs", - "paste", -] - -[[package]] -name = "ruint" -version = "1.11.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "608a5726529f2f0ef81b8fde9873c4bb829d6b5b5ca6be4d97345ddf0749c825" -dependencies = [ - "alloy-rlp", - "ark-ff 0.3.0", - "ark-ff 0.4.2", - "bytes", - "fastrlp", - "num-bigint", - "num-traits", - "parity-scale-codec", - "primitive-types", - "proptest", - "rand", - "rlp", - "ruint-macro", - "serde", - "valuable", - "zeroize", -] - -[[package]] -name = "ruint-macro" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e666a5496a0b2186dbcd0ff6106e29e093c15591bde62c20d3842007c6978a09" - -[[package]] -name = "rustc-demangle" -version = "0.1.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" - -[[package]] -name = "rustc-hex" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e75f6a532d0fd9f7f13144f392b6ad56a32696bfcd9c78f797f16bbb6f072d6" - -[[package]] -name = "rustc_version" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0dfe2087c51c460008730de8b57e6a320782fbfb312e1f4d520e6c6fae155ee" -dependencies = [ - "semver 0.11.0", -] - -[[package]] -name = "rustc_version" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" -dependencies = [ - "semver 1.0.21", -] - -[[package]] -name = "rustix" -version = "0.38.31" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ea3e1a662af26cd7a3ba09c0297a31af215563ecf42817c98df621387f4e949" -dependencies = [ - "bitflags 2.4.2", - "errno", - "libc", - "linux-raw-sys", - "windows-sys 0.52.0", -] - -[[package]] -name = "rustls" -version = "0.21.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9d5a6813c0759e4609cd494e8e725babae6a2ca7b62a5536a13daaec6fcb7ba" -dependencies = [ - "log", - "ring 0.17.7", - "rustls-webpki", - "sct", -] - -[[package]] -name = "rustls-pemfile" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c74cae0a4cf6ccbbf5f359f08efdf8ee7e1dc532573bf0db71968cb56b1448c" -dependencies = [ - "base64 0.21.7", -] - -[[package]] -name = "rustls-webpki" -version = "0.101.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b6275d1ee7a1cd780b64aca7726599a1dbc893b1e64144529e55c3c2f745765" -dependencies = [ - "ring 0.17.7", - "untrusted 0.9.0", -] - -[[package]] -name = "rustversion" -version = "1.0.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ffc183a10b4478d04cbbbfc96d0873219d962dd5accaff2ffbd4ceb7df837f4" - -[[package]] -name = "rusty-fork" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb3dcc6e454c328bb824492db107ab7c0ae8fcffe4ad210136ef014458c1bc4f" -dependencies = [ - "fnv", - "quick-error", - "tempfile", - "wait-timeout", -] - -[[package]] -name = "ryu" -version = "1.0.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f98d2aa92eebf49b69786be48e4477826b256916e84a57ff2a4f21923b48eb4c" - -[[package]] -name = "scale-info" -version = "2.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f7d66a1128282b7ef025a8ead62a4a9fcf017382ec53b8ffbf4d7bf77bd3c60" -dependencies = [ - "cfg-if", - "derive_more", - "parity-scale-codec", - "scale-info-derive", -] - -[[package]] -name = "scale-info-derive" -version = "2.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abf2c68b89cafb3b8d918dd07b42be0da66ff202cf1155c5739a4e0c1ea0dc19" -dependencies = [ - "proc-macro-crate 1.3.1", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "scopeguard" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" - -[[package]] -name = "sct" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da046153aa2352493d6cb7da4b6e5c0c057d8a1d0a9aa8560baffdd945acd414" -dependencies = [ - "ring 0.17.7", - "untrusted 0.9.0", -] - -[[package]] -name = "sec1" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3e97a565f76233a6003f9f5c54be1d9c5bdfa3eccfb189469f11ec4901c47dc" -dependencies = [ - "base16ct", - "der", - "generic-array", - "pkcs8", - "subtle", - "zeroize", -] - -[[package]] -name = "secp256k1" -version = "0.28.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d24b59d129cdadea20aea4fb2352fa053712e5d713eee47d700cd4b2bc002f10" -dependencies = [ - "secp256k1-sys", -] - -[[package]] -name = "secp256k1-sys" -version = "0.9.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5d1746aae42c19d583c3c1a8c646bfad910498e2051c551a7f2e3c0c9fbb7eb" -dependencies = [ - "cc", -] - -[[package]] -name = "semver" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f301af10236f6df4160f7c3f04eec6dbc70ace82d23326abad5edee88801c6b6" -dependencies = [ - "semver-parser", -] - -[[package]] -name = "semver" -version = "1.0.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b97ed7a9823b74f99c7742f5336af7be5ecd3eeafcb1507d1fa93347b1d589b0" - -[[package]] -name = "semver-parser" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00b0bef5b7f9e0df16536d3961cfb6e84331c065b4066afb39768d0e319411f7" -dependencies = [ - "pest", -] - -[[package]] -name = "send_wrapper" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f638d531eccd6e23b980caf34876660d38e265409d8e99b397ab71eb3612fad0" - -[[package]] -name = "send_wrapper" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd0b0ec5f1c1ca621c432a25813d8d60c88abe6d3e08a3eb9cf37d97a0fe3d73" - -[[package]] -name = "serde" -version = "1.0.196" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "870026e60fa08c69f064aa766c10f10b1d62db9ccd4d0abb206472bee0ce3b32" -dependencies = [ - "serde_derive", -] - -[[package]] -name = "serde_derive" -version = "1.0.196" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33c85360c95e7d137454dc81d9a4ed2b8efd8fbe19cee57357b32b9771fccb67" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.48", -] - -[[package]] -name = "serde_json" -version = "1.0.113" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69801b70b1c3dac963ecb03a364ba0ceda9cf60c71cfe475e99864759c8b8a79" -dependencies = [ - "indexmap 2.2.3", - "itoa", - "ryu", - "serde", -] - -[[package]] -name = "serde_urlencoded" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd" -dependencies = [ - "form_urlencoded", - "itoa", - "ryu", - "serde", -] - -[[package]] -name = "serde_with" -version = "3.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15d167997bd841ec232f5b2b8e0e26606df2e7caa4c31b95ea9ca52b200bd270" -dependencies = [ - "base64 0.21.7", - "chrono", - "hex", - "indexmap 1.9.3", - "indexmap 2.2.3", - "serde", - "serde_derive", - "serde_json", - "serde_with_macros", - "time", -] - -[[package]] -name = "serde_with_macros" -version = "3.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "865f9743393e638991566a8b7a479043c2c8da94a33e0a31f18214c9cae0a64d" -dependencies = [ - "darling", - "proc-macro2", - "quote", - "syn 2.0.48", -] - -[[package]] -name = "sha1" -version = "0.10.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6ba" -dependencies = [ - "cfg-if", - "cpufeatures", - "digest 0.10.7", -] - -[[package]] -name = "sha2" -version = "0.10.6" -source = "git+https://github.com/risc0/RustCrypto-hashes?tag=sha2-v0.10.6-risczero.0#7fd6900c4f637bd15ee2642dfa77110f8f1ad065" -dependencies = [ - "cfg-if", - "cpufeatures", - "digest 0.10.7", -] - -[[package]] -name = "sha3" -version = "0.10.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75872d278a8f37ef87fa0ddbda7802605cb18344497949862c0d4dcb291eba60" -dependencies = [ - "digest 0.10.7", - "keccak", -] - -[[package]] -name = "sha3-asm" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bac61da6b35ad76b195eb4771210f947734321a8d81d7738e1580d953bc7a15e" -dependencies = [ - "cc", - "cfg-if", -] - -[[package]] -name = "signal-hook-registry" -version = "1.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8229b473baa5980ac72ef434c4415e70c4b5e71b423043adb4ba059f89c99a1" -dependencies = [ - "libc", -] - -[[package]] -name = "signature" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" -dependencies = [ - "digest 0.10.7", - "rand_core", -] - -[[package]] -name = "simple_asn1" -version = "0.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "adc4e5204eb1910f40f9cfa375f6f05b68c3abac4b6fd879c8ff5e7ae8a0a085" -dependencies = [ - "num-bigint", - "num-traits", - "thiserror", - "time", -] - -[[package]] -name = "slab" -version = "0.4.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" -dependencies = [ - "autocfg", -] - -[[package]] -name = "smallvec" -version = "1.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6ecd384b10a64542d77071bd64bd7b231f4ed5940fba55e98c3de13824cf3d7" - -[[package]] -name = "socket2" -version = "0.5.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b5fac59a5cb5dd637972e5fca70daf0523c9067fcdc4842f053dae04a18f8e9" -dependencies = [ - "libc", - "windows-sys 0.48.0", -] - -[[package]] -name = "spin" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" - -[[package]] -name = "spin" -version = "0.9.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" - -[[package]] -name = "spki" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d91ed6c858b01f942cd56b37a94b3e0a1798290327d1236e4d9cf4eaca44d29d" -dependencies = [ - "base64ct", - "der", -] - -[[package]] -name = "static_assertions" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" - -[[package]] -name = "strsim" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" - -[[package]] -name = "strum" -version = "0.25.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "290d54ea6f91c969195bdbcd7442c8c2a2ba87da8bf60a7ee86a235d4bc1e125" -dependencies = [ - "strum_macros", -] - -[[package]] -name = "strum_macros" -version = "0.25.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23dc1fa9ac9c169a78ba62f0b841814b7abae11bdd047b9c58f893439e309ea0" -dependencies = [ - "heck", - "proc-macro2", - "quote", - "rustversion", - "syn 2.0.48", -] - -[[package]] -name = "substrate-bn" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b5bbfa79abbae15dd642ea8176a21a635ff3c00059961d1ea27ad04e5b441c" -dependencies = [ - "byteorder", - "crunchy", - "lazy_static", - "rand", - "rustc-hex", -] - -[[package]] -name = "subtle" -version = "2.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" - -[[package]] -name = "syn" -version = "1.0.109" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - -[[package]] -name = "syn" -version = "2.0.48" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f3531638e407dfc0814761abb7c00a5b54992b849452a0646b7f65c9f770f3f" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - -[[package]] -name = "sync_wrapper" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" - -[[package]] -name = "system-configuration" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba3a3adc5c275d719af8cb4272ea1c4a6d668a777f37e115f6d11ddbc1c8e0e7" -dependencies = [ - "bitflags 1.3.2", - "core-foundation", - "system-configuration-sys", -] - -[[package]] -name = "system-configuration-sys" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a75fb188eb626b924683e3b95e3a48e63551fcfb51949de2f06a9d91dbee93c9" -dependencies = [ - "core-foundation-sys", - "libc", -] - -[[package]] -name = "tap" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" - -[[package]] -name = "tempfile" -version = "3.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a365e8cd18e44762ef95d87f284f4b5cd04107fec2ff3052bd6a3e6069669e67" -dependencies = [ - "cfg-if", - "fastrand", - "rustix", - "windows-sys 0.52.0", -] - -[[package]] -name = "test-guest" -version = "0.1.0" -dependencies = [ - "risc0-zkvm", - "zeth-lib", -] - -[[package]] -name = "thiserror" -version = "1.0.57" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e45bcbe8ed29775f228095caf2cd67af7a4ccf756ebff23a306bf3e8b47b24b" -dependencies = [ - "thiserror-impl", -] - -[[package]] -name = "thiserror-impl" -version = "1.0.57" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a953cb265bef375dae3de6663da4d3804eee9682ea80d8e2542529b73c531c81" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.48", -] - -[[package]] -name = "thiserror-impl-no-std" -version = "2.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58e6318948b519ba6dc2b442a6d0b904ebfb8d411a3ad3e07843615a72249758" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "thiserror-no-std" -version = "2.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3ad459d94dd517257cc96add8a43190ee620011bb6e6cdc82dafd97dfafafea" -dependencies = [ - "thiserror-impl-no-std", -] - -[[package]] -name = "threadpool" -version = "1.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d050e60b33d41c19108b32cea32164033a9013fe3b46cbd4457559bfbf77afaa" -dependencies = [ - "num_cpus", -] - -[[package]] -name = "time" -version = "0.3.34" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8248b6521bb14bc45b4067159b9b6ad792e2d6d754d6c41fb50e29fefe38749" -dependencies = [ - "deranged", - "itoa", - "num-conv", - "powerfmt", - "serde", - "time-core", - "time-macros", -] - -[[package]] -name = "time-core" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" - -[[package]] -name = "time-macros" -version = "0.2.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ba3a3ef41e6672a2f0f001392bb5dcd3ff0a9992d618ca761a11c3121547774" -dependencies = [ - "num-conv", - "time-core", -] - -[[package]] -name = "tiny-keccak" -version = "2.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c9d3793400a45f954c52e73d068316d76b6f4e36977e3fcebb13a2721e80237" -dependencies = [ - "crunchy", -] - -[[package]] -name = "tinyvec" -version = "1.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" -dependencies = [ - "tinyvec_macros", -] - -[[package]] -name = "tinyvec_macros" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" - -[[package]] -name = "tokio" -version = "1.36.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61285f6515fa018fb2d1e46eb21223fff441ee8db5d0f1435e8ab4f5cdb80931" -dependencies = [ - "backtrace", - "bytes", - "libc", - "mio", - "num_cpus", - "parking_lot", - "pin-project-lite", - "signal-hook-registry", - "socket2", - "tokio-macros", - "windows-sys 0.48.0", -] - -[[package]] -name = "tokio-macros" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.48", -] - -[[package]] -name = "tokio-rustls" -version = "0.24.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c28327cf380ac148141087fbfb9de9d7bd4e84ab5d2c28fbc911d753de8a7081" -dependencies = [ - "rustls", - "tokio", -] - -[[package]] -name = "tokio-tungstenite" -version = "0.20.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "212d5dcb2a1ce06d81107c3d0ffa3121fe974b73f068c8282cb1c32328113b6c" -dependencies = [ - "futures-util", - "log", - "rustls", - "tokio", - "tokio-rustls", - "tungstenite", - "webpki-roots", -] - -[[package]] -name = "tokio-util" -version = "0.7.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5419f34732d9eb6ee4c3578b7989078579b7f039cbbb9ca2c4da015749371e15" -dependencies = [ - "bytes", - "futures-core", - "futures-sink", - "pin-project-lite", - "tokio", - "tracing", -] - -[[package]] -name = "toml_datetime" -version = "0.6.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3550f4e9685620ac18a50ed434eb3aec30db8ba93b0287467bca5826ea25baf1" - -[[package]] -name = "toml_edit" -version = "0.19.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" -dependencies = [ - "indexmap 2.2.3", - "toml_datetime", - "winnow", -] - -[[package]] -name = "toml_edit" -version = "0.20.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70f427fce4d84c72b5b732388bf4a9f4531b53f74e2887e3ecb2481f68f66d81" -dependencies = [ - "indexmap 2.2.3", - "toml_datetime", - "winnow", -] - -[[package]] -name = "toml_edit" -version = "0.21.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a8534fd7f78b5405e860340ad6575217ce99f38d4d5c8f2442cb5ecb50090e1" -dependencies = [ - "indexmap 2.2.3", - "toml_datetime", - "winnow", -] - -[[package]] -name = "tower-service" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" - -[[package]] -name = "tracing" -version = "0.1.40" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" -dependencies = [ - "pin-project-lite", - "tracing-attributes", - "tracing-core", -] - -[[package]] -name = "tracing-attributes" -version = "0.1.27" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.48", -] - -[[package]] -name = "tracing-core" -version = "0.1.32" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" -dependencies = [ - "once_cell", -] - -[[package]] -name = "tracing-futures" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97d095ae15e245a057c8e8451bab9b3ee1e1f68e9ba2b4fbc18d0ac5237835f2" -dependencies = [ - "pin-project", - "tracing", -] - -[[package]] -name = "try-lock" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" - -[[package]] -name = "tungstenite" -version = "0.20.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e3dac10fd62eaf6617d3a904ae222845979aec67c615d1c842b4002c7666fb9" -dependencies = [ - "byteorder", - "bytes", - "data-encoding", - "http", - "httparse", - "log", - "rand", - "rustls", - "sha1", - "thiserror", - "url", - "utf-8", -] - -[[package]] -name = "typenum" -version = "1.17.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" - -[[package]] -name = "ucd-trie" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed646292ffc8188ef8ea4d1e0e0150fb15a5c2e12ad9b8fc191ae7a8a7f3c4b9" - -[[package]] -name = "uint" -version = "0.9.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76f64bba2c53b04fcab63c01a7d7427eadc821e3bc48c34dc9ba29c501164b52" -dependencies = [ - "byteorder", - "crunchy", - "hex", - "static_assertions", -] - -[[package]] -name = "unarray" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eaea85b334db583fe3274d12b4cd1880032beab409c0d774be044d4480ab9a94" - -[[package]] -name = "unicode-bidi" -version = "0.3.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08f95100a766bf4f8f28f90d77e0a5461bbdb219042e7679bebe79004fed8d75" - -[[package]] -name = "unicode-ident" -version = "1.0.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" - -[[package]] -name = "unicode-normalization" -version = "0.1.22" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921" -dependencies = [ - "tinyvec", -] - -[[package]] -name = "unicode-xid" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" - -[[package]] -name = "untrusted" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" - -[[package]] -name = "untrusted" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" - -[[package]] -name = "url" -version = "2.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31e6302e3bb753d46e83516cae55ae196fc0c309407cf11ab35cc51a4c2a4633" -dependencies = [ - "form_urlencoded", - "idna", - "percent-encoding", -] - -[[package]] -name = "utf-8" -version = "0.7.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9" - -[[package]] -name = "valuable" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" - -[[package]] -name = "version_check" -version = "0.9.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" - -[[package]] -name = "wait-timeout" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f200f5b12eb75f8c1ed65abd4b2db8a6e1b138a20de009dacee265a2498f3f6" -dependencies = [ - "libc", -] - -[[package]] -name = "want" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfa7760aed19e106de2c7c0b581b509f2f25d3dacaf737cb82ac61bc6d760b0e" -dependencies = [ - "try-lock", -] - -[[package]] -name = "wasi" -version = "0.11.0+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" - -[[package]] -name = "wasm-bindgen" -version = "0.2.91" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1e124130aee3fb58c5bdd6b639a0509486b0338acaaae0c84a5124b0f588b7f" -dependencies = [ - "cfg-if", - "wasm-bindgen-macro", -] - -[[package]] -name = "wasm-bindgen-backend" -version = "0.2.91" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c9e7e1900c352b609c8488ad12639a311045f40a35491fb69ba8c12f758af70b" -dependencies = [ - "bumpalo", - "log", - "once_cell", - "proc-macro2", - "quote", - "syn 2.0.48", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-futures" -version = "0.4.41" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "877b9c3f61ceea0e56331985743b13f3d25c406a7098d45180fb5f09bc19ed97" -dependencies = [ - "cfg-if", - "js-sys", - "wasm-bindgen", - "web-sys", -] - -[[package]] -name = "wasm-bindgen-macro" -version = "0.2.91" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b30af9e2d358182b5c7449424f017eba305ed32a7010509ede96cdc4696c46ed" -dependencies = [ - "quote", - "wasm-bindgen-macro-support", -] - -[[package]] -name = "wasm-bindgen-macro-support" -version = "0.2.91" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "642f325be6301eb8107a83d12a8ac6c1e1c54345a7ef1a9261962dfefda09e66" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.48", - "wasm-bindgen-backend", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-shared" -version = "0.2.91" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f186bd2dcf04330886ce82d6f33dd75a7bfcf69ecf5763b89fcde53b6ac9838" - -[[package]] -name = "web-sys" -version = "0.3.68" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96565907687f7aceb35bc5fc03770a8a0471d82e479f25832f54a0e3f4b28446" -dependencies = [ - "js-sys", - "wasm-bindgen", -] - -[[package]] -name = "webpki-roots" -version = "0.25.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f20c57d8d7db6d3b86154206ae5d8fba62dd39573114de97c2cb0578251f8e1" - -[[package]] -name = "winapi" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" -dependencies = [ - "winapi-i686-pc-windows-gnu", - "winapi-x86_64-pc-windows-gnu", -] - -[[package]] -name = "winapi-i686-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" - -[[package]] -name = "winapi-x86_64-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" - -[[package]] -name = "windows-core" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" -dependencies = [ - "windows-targets 0.52.0", -] - -[[package]] -name = "windows-sys" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" -dependencies = [ - "windows-targets 0.48.5", -] - -[[package]] -name = "windows-sys" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" -dependencies = [ - "windows-targets 0.52.0", -] - -[[package]] -name = "windows-targets" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" -dependencies = [ - "windows_aarch64_gnullvm 0.48.5", - "windows_aarch64_msvc 0.48.5", - "windows_i686_gnu 0.48.5", - "windows_i686_msvc 0.48.5", - "windows_x86_64_gnu 0.48.5", - "windows_x86_64_gnullvm 0.48.5", - "windows_x86_64_msvc 0.48.5", -] - -[[package]] -name = "windows-targets" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a18201040b24831fbb9e4eb208f8892e1f50a37feb53cc7ff887feb8f50e7cd" -dependencies = [ - "windows_aarch64_gnullvm 0.52.0", - "windows_aarch64_msvc 0.52.0", - "windows_i686_gnu 0.52.0", - "windows_i686_msvc 0.52.0", - "windows_x86_64_gnu 0.52.0", - "windows_x86_64_gnullvm 0.52.0", - "windows_x86_64_msvc 0.52.0", -] - -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" - -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb7764e35d4db8a7921e09562a0304bf2f93e0a51bfccee0bd0bb0b666b015ea" - -[[package]] -name = "windows_aarch64_msvc" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" - -[[package]] -name = "windows_aarch64_msvc" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbaa0368d4f1d2aaefc55b6fcfee13f41544ddf36801e793edbbfd7d7df075ef" - -[[package]] -name = "windows_i686_gnu" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" - -[[package]] -name = "windows_i686_gnu" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a28637cb1fa3560a16915793afb20081aba2c92ee8af57b4d5f28e4b3e7df313" - -[[package]] -name = "windows_i686_msvc" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" - -[[package]] -name = "windows_i686_msvc" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffe5e8e31046ce6230cc7215707b816e339ff4d4d67c65dffa206fd0f7aa7b9a" - -[[package]] -name = "windows_x86_64_gnu" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" - -[[package]] -name = "windows_x86_64_gnu" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d6fa32db2bc4a2f5abeacf2b69f7992cd09dca97498da74a151a3132c26befd" - -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" - -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a657e1e9d3f514745a572a6846d3c7aa7dbe1658c056ed9c3344c4109a6949e" - -[[package]] -name = "windows_x86_64_msvc" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" - -[[package]] -name = "windows_x86_64_msvc" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" - -[[package]] -name = "winnow" -version = "0.5.40" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f593a95398737aeed53e489c785df13f3618e41dbcd6718c6addbf1395aa6876" -dependencies = [ - "memchr", -] - -[[package]] -name = "winreg" -version = "0.50.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "524e57b2c537c0f9b1e69f1965311ec12182b4122e45035b1508cd24d2adadb1" -dependencies = [ - "cfg-if", - "windows-sys 0.48.0", -] - -[[package]] -name = "ws_stream_wasm" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7999f5f4217fe3818726b66257a4475f71e74ffd190776ad053fa159e50737f5" -dependencies = [ - "async_io_stream", - "futures", - "js-sys", - "log", - "pharos", - "rustc_version 0.4.0", - "send_wrapper 0.6.0", - "thiserror", - "wasm-bindgen", - "wasm-bindgen-futures", - "web-sys", -] - -[[package]] -name = "wyz" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed" -dependencies = [ - "tap", -] - -[[package]] -name = "zerocopy" -version = "0.7.32" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74d4d3961e53fa4c9a25a8637fc2bfaf2595b3d3ae34875568a5cf64787716be" -dependencies = [ - "zerocopy-derive", -] - -[[package]] -name = "zerocopy-derive" -version = "0.7.32" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.48", -] - -[[package]] -name = "zeroize" -version = "1.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "525b4ec142c6b68a2d10f01f7bbf6755599ca3f81ea53b8431b7dd348f5fdb2d" -dependencies = [ - "zeroize_derive", -] - -[[package]] -name = "zeroize_derive" -version = "1.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.48", -] - -[[package]] -name = "zeth-lib" -version = "0.1.0" -dependencies = [ - "alloy-primitives", - "anyhow", - "bytes", - "chrono", - "ethers-core", - "ethers-providers", - "flate2", - "hashbrown 0.14.3", - "libflate", - "log", - "once_cell", - "revm", - "ruint", - "serde", - "serde_json", - "serde_with", - "thiserror", - "thiserror-no-std", - "tokio", - "zeth-primitives", -] - -[[package]] -name = "zeth-primitives" -version = "0.1.0" -dependencies = [ - "alloy-primitives", - "alloy-rlp", - "alloy-rlp-derive", - "anyhow", - "bytes", - "ethers-core", - "hex", - "k256", - "revm-primitives", - "rlp", - "ruint", - "serde", - "sha3", - "thiserror-no-std", -] diff --git a/testing/ef-tests/testguest/Cargo.toml b/testing/ef-tests/testguest/Cargo.toml deleted file mode 100644 index 05f42753..00000000 --- a/testing/ef-tests/testguest/Cargo.toml +++ /dev/null @@ -1,16 +0,0 @@ -[package] -name = "test-guest" -version = "0.1.0" -edition = "2021" - -[workspace] - -[dependencies] -risc0-zkvm = { version = "0.19", default-features = false, features = ['std'] } -zeth-lib = { path = "../../../lib", default-features = false } - -[patch.crates-io] -# use optimized risc0 circuit -crypto-bigint = { git = "https://github.com/risc0/RustCrypto-crypto-bigint", tag = "v0.5.2-risczero.0" } -k256 = { git = "https://github.com/risc0/RustCrypto-elliptic-curves", tag = "k256/v0.13.3-risczero.0" } -sha2 = { git = "https://github.com/risc0/RustCrypto-hashes", tag = "sha2-v0.10.6-risczero.0" } diff --git a/testing/ef-tests/testguest/src/main.rs b/testing/ef-tests/testguest/src/main.rs deleted file mode 100644 index 6abd32f6..00000000 --- a/testing/ef-tests/testguest/src/main.rs +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright 2023 RISC Zero, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#![no_main] - -use risc0_zkvm::guest::env; -use zeth_lib::{ - builder::{BlockBuilderStrategy, EthereumStrategy}, - consts::ChainSpec, -}; - -risc0_zkvm::guest::entry!(main); - -pub fn main() { - // Read the test block's chain specification - let chain_spec: ChainSpec = env::read(); - // Read the input previous block and transaction data - let input = env::read(); - // Build the resulting block - let (header, state) = EthereumStrategy::build_from(&chain_spec, input) - .expect("Failed to build the resulting block"); - // Output the resulting block's hash to the journal - env::commit(&header.hash()); - // Leak memory, save cycles - core::mem::forget((header, state)); -} diff --git a/testing/ef-tests/tests/evm.rs b/testing/ef-tests/tests/evm.rs deleted file mode 100644 index 7abc2a86..00000000 --- a/testing/ef-tests/tests/evm.rs +++ /dev/null @@ -1,96 +0,0 @@ -// Copyright 2023 RISC Zero, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#![cfg(feature = "ef-tests")] - -use std::path::PathBuf; - -use rstest::rstest; -use zeth_lib::builder::{BlockBuilderStrategy, EthereumStrategy}; -use zeth_primitives::{block::Header, trie::StateAccount}; -use zeth_testeth::{ - create_input, ethers, - ethtests::{read_eth_test, EthTestCase}, -}; - -#[rstest] -fn evm( - #[files("testdata/BlockchainTests/GeneralStateTests/**/*.json")] - #[exclude("RevertPrecompiledTouch_storage.json|RevertPrecompiledTouch.json")] // precompiles having storage is not possible - #[exclude("stTimeConsuming")] // exclude only the time consuming tests - path: PathBuf, -) { - let _ = env_logger::builder() - .filter_level(log::LevelFilter::Debug) - .is_test(true) - .try_init(); - - for EthTestCase { - mut json, - genesis, - chain_spec, - } in read_eth_test(path) - { - // only one block supported for now - assert_eq!(json.blocks.len(), 1); - let block = json.blocks.pop().unwrap(); - - // skip failing tests for now - if let Some(message) = block.expect_exception { - println!("skipping ({message})"); - break; - } - - let block_header = block.block_header.unwrap(); - let expected_header: Header = block_header.clone().into(); - assert_eq!(&expected_header.hash(), &block_header.hash); - - // using the empty/default state for the input prepares all accounts for deletion - // this leads to larger input, but can never fail - let post_state = json.post.clone().unwrap_or_default(); - - let input = create_input( - &chain_spec, - genesis, - json.pre, - expected_header.clone(), - block.transactions, - block.withdrawals.unwrap_or_default(), - post_state, - ); - - let (header, state) = EthereumStrategy::build_from(&chain_spec, input).unwrap(); - - if let Some(post) = json.post { - let (exp_state, _) = ethers::build_tries(&post); - - println!("diffing state trie:"); - for diff in diff::slice( - &state.debug_rlp::(), - &exp_state.debug_rlp::(), - ) { - match diff { - diff::Result::Left(l) => println!("✗{l}"), - diff::Result::Right(r) => println!("✓{r}"), - diff::Result::Both(l, _) => println!(" {l}"), - } - } - assert_eq!(state.hash(), exp_state.hash()); - } - - // the headers should match - assert_eq!(header, expected_header); - assert_eq!(header.hash(), expected_header.hash()); - } -} diff --git a/testing/ef-tests/tests/executor.rs b/testing/ef-tests/tests/executor.rs deleted file mode 100644 index f23b9fbe..00000000 --- a/testing/ef-tests/tests/executor.rs +++ /dev/null @@ -1,96 +0,0 @@ -// Copyright 2023 RISC Zero, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#![cfg(feature = "ef-tests")] - -use std::path::PathBuf; - -use risc0_zkvm::{ExecutorEnv, ExecutorImpl, FileSegmentRef}; -use rstest::rstest; -use tempfile::tempdir; -use zeth_primitives::{block::Header, BlockHash}; -use zeth_testeth::{ - create_input, - ethtests::{read_eth_test, EthTestCase}, - guests::TEST_GUEST_ELF, -}; - -const SEGMENT_LIMIT_PO2: u32 = 21; - -#[rstest] -fn executor( - // execute only the deep stack tests - #[files("testdata/BlockchainTests/GeneralStateTests/**/*Call1024BalanceTooLow.json")] - path: PathBuf, -) { - let _ = env_logger::builder() - .filter_level(log::LevelFilter::Debug) - .filter_module("risc0_zkvm", log::LevelFilter::Info) // reduce noise - .is_test(true) - .try_init(); - - for EthTestCase { - json, - genesis, - chain_spec, - } in read_eth_test(path) - { - // only one block - assert_eq!(json.blocks.len(), 1usize); - let block = json.blocks.first().unwrap().clone(); - - // skip failing tests for now - if let Some(message) = block.expect_exception { - println!("skipping ({message})"); - break; - } - - let block_header = block.block_header.unwrap(); - let expected_header: Header = block_header.clone().into(); - assert_eq!(&expected_header.hash(), &block_header.hash); - - let input = create_input( - &chain_spec, - genesis, - json.pre, - expected_header.clone(), - block.transactions, - block.withdrawals.unwrap_or_default(), - json.post.unwrap(), - ); - - let env = ExecutorEnv::builder() - .session_limit(None) - .segment_limit_po2(SEGMENT_LIMIT_PO2) - .write(&chain_spec) - .unwrap() - .write(&input) - .unwrap() - .build() - .unwrap(); - let mut exec = ExecutorImpl::from_elf(env, TEST_GUEST_ELF).unwrap(); - - let segment_dir = tempdir().unwrap(); - let session = exec - .run_with_callback(|segment| { - Ok(Box::new(FileSegmentRef::new(&segment, segment_dir.path())?)) - }) - .unwrap(); - println!("Generated {} segments", session.segments.len()); - - let found_hash: BlockHash = session.journal.decode().unwrap(); - println!("Block hash (from executor): {found_hash}"); - assert_eq!(found_hash, expected_header.hash()); - } -} diff --git a/tests/geth/Cargo.toml b/tests/geth/Cargo.toml deleted file mode 100644 index c64941ee..00000000 --- a/tests/geth/Cargo.toml +++ /dev/null @@ -1,17 +0,0 @@ -[package] -name = "tests" -version = "0.1.0" -edition = "2021" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] -zeth-primitives = { version = "0.1.0", path = "../../primitives" } -serde_json = "1.0" -serde = "*" -hex = "*" - -[build-dependencies] -gobuild = "0.1.0-alpha.1" -log = "0.4.14" -env_logger = "0.10.2" diff --git a/tests/geth/build.rs b/tests/geth/build.rs deleted file mode 100644 index c7b91c64..00000000 --- a/tests/geth/build.rs +++ /dev/null @@ -1,51 +0,0 @@ -use std::{ - env, - io::{self, Write}, -}; - -fn main() { - let lib_name = "go-geth-utils"; - let out_dir = env::var("OUT_DIR").unwrap(); - - // Build - if let Err(e) = gobuild::Build::new() - .file("./lib/lib.go") - .try_compile(lib_name) - { - // The error type is private so have to check the error string - if format!("{}", e).starts_with("Failed to find tool.") { - fail_with_code( - 0, - " Failed to find Go. Please install Go 1.16 or later \ - following the instructions at https://golang.org/doc/install. - On linux it is also likely available as a package." - .to_string(), - ); - } else { - fail(format!("{}", e)); - } - } - - // Files the lib depends on that should recompile the lib - let dep_files = vec!["./gethutil/mpt.go", "./go.mod"]; - for file in dep_files { - println!("cargo:rerun-if-changed={}", file); - } - - // Link - println!("cargo:rustc-link-search=native={}", out_dir); - println!("cargo:rustc-link-lib=static={}", lib_name); -} - -fn fail_with_code(code: i32, message: String) -> ! { - let _ = writeln!( - io::stderr(), - "\n\nError while building geth-utils: {}\n\n", - message - ); - std::process::exit(code); -} - -fn fail(message: String) { - fail_with_code(1, message) -} diff --git a/tests/geth/gethutil/mpt.go b/tests/geth/gethutil/mpt.go deleted file mode 100644 index bb66dc68..00000000 --- a/tests/geth/gethutil/mpt.go +++ /dev/null @@ -1,118 +0,0 @@ -package gethutil - -import ( - "bytes" - "encoding/hex" - "encoding/json" - "math/big" - - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/common/hexutil" - "github.com/ethereum/go-ethereum/core/types" - "github.com/ethereum/go-ethereum/trie" -) - -type Transaction struct { - Essence struct { - Eip1559 *EIP1559Transaction `json:"Eip1559"` - Legacy *LegacyTransaction `json:"Legacy"` - } `json:"essence"` - Signature struct { - R *hexutil.Big `json:"r"` - S *hexutil.Big `json:"s"` - V int64 `json:"v"` - } `json:"signature"` -} - -type EIP1559Transaction struct { - AccessList []common.Address `json:"access_list"` - ChainId int64 `json:"chain_id"` - Data hexutil.Bytes `json:"data"` - GasLimit hexutil.Uint64 `json:"gas_limit"` - MaxFeePerGas *hexutil.Big `json:"max_fee_per_gas"` - MaxPriorityFeePerGas *hexutil.Big `json:"max_priority_fee_per_gas"` - To To `json:"to"` - Nonce uint64 `json:"nonce"` - Value *hexutil.Big `json:"value"` -} - -type LegacyTransaction struct { - ChainId int64 `json:"chain_id"` - Data hexutil.Bytes `json:"data"` - GasLimit hexutil.Uint64 `json:"gas_limit"` - GasPrice *hexutil.Big `json:"gas_price"` - Nonce uint64 `json:"nonce"` - To To `json:"to"` - Value *hexutil.Big `json:"value"` -} - -type To struct { - Create bool `json:"create"` - Call *common.Address `json:"Call"` -} - -func (t *To) UnmarshalJSON(data []byte) error { - type to struct { - Call *common.Address `json:"Call"` - } - if string(data) == `"Create"` { - t.Create = true - return nil - } else { - to := &to{} - if err := json.Unmarshal(data, to); err != nil { - return err - } - t.Call = to.Call - return nil - } -} - -type Result struct { - Root common.Hash `json:"root"` - Rlps []string `json:"rlps"` -} - -func MptRoot(txs []Transaction) *Result { - var txs2 []*types.Transaction - result := &Result{} - for _, tx := range txs { - var tx2 *types.Transaction - if tx.Essence.Eip1559 != nil { - tx2 = types.NewTx(&types.DynamicFeeTx{ - ChainID: big.NewInt(tx.Essence.Eip1559.ChainId), - Nonce: tx.Essence.Eip1559.Nonce, - GasTipCap: tx.Essence.Eip1559.MaxPriorityFeePerGas.ToInt(), - GasFeeCap: tx.Essence.Eip1559.MaxFeePerGas.ToInt(), - Gas: uint64(tx.Essence.Eip1559.GasLimit), - Value: tx.Essence.Eip1559.Value.ToInt(), - Data: tx.Essence.Eip1559.Data, - To: tx.Essence.Eip1559.To.Call, - AccessList: []types.AccessTuple{}, - V: big.NewInt(tx.Signature.V), - R: tx.Signature.R.ToInt(), - S: tx.Signature.S.ToInt(), - }) - } else { - tx2 = types.NewTx(&types.LegacyTx{ - Nonce: tx.Essence.Legacy.Nonce, - GasPrice: tx.Essence.Legacy.GasPrice.ToInt(), - Gas: uint64(tx.Essence.Legacy.GasLimit), - Value: tx.Essence.Legacy.Value.ToInt(), - Data: tx.Essence.Legacy.Data, - To: tx.Essence.Legacy.To.Call, - V: big.NewInt(tx.Signature.V), - R: tx.Signature.R.ToInt(), - S: tx.Signature.S.ToInt(), - }) - } - - var buf bytes.Buffer - tx2.EncodeRLP(&buf) - result.Rlps = append(result.Rlps, hex.EncodeToString(buf.Bytes())) - txs2 = append(txs2, tx2) - } - root := types.DeriveSha(types.Transactions(txs2), trie.NewStackTrie(nil)) - result.Root = root - return result -} diff --git a/tests/geth/go.mod b/tests/geth/go.mod deleted file mode 100644 index 084031be..00000000 --- a/tests/geth/go.mod +++ /dev/null @@ -1,62 +0,0 @@ -module main - -go 1.21 - -require github.com/ethereum/go-ethereum v1.13.10 - -replace github.com/ethereum/go-ethereum v1.13.10 => github.com/taikoxyz/taiko-geth v0.0.0-20240118064628-88e3acd1f435 - -require ( - github.com/DataDog/zstd v1.5.2 // indirect - github.com/StackExchange/wmi v1.2.1 // indirect - github.com/VictoriaMetrics/fastcache v1.12.1 // indirect - github.com/beorn7/perks v1.0.1 // indirect - github.com/bits-and-blooms/bitset v1.10.0 // indirect - github.com/btcsuite/btcd/btcec/v2 v2.2.0 // indirect - github.com/cespare/xxhash/v2 v2.2.0 // indirect - github.com/cockroachdb/errors v1.9.1 // indirect - github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b // indirect - github.com/cockroachdb/pebble v0.0.0-20230928194634-aa077af62593 // indirect - github.com/cockroachdb/redact v1.1.3 // indirect - github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 // indirect - github.com/consensys/bavard v0.1.13 // indirect - github.com/consensys/gnark-crypto v0.12.1 // indirect - github.com/crate-crypto/go-ipa v0.0.0-20231025140028-3c0104f4b233 // indirect - github.com/crate-crypto/go-kzg-4844 v0.7.0 // indirect - github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 // indirect - github.com/ethereum/c-kzg-4844 v0.4.0 // indirect - github.com/gballet/go-verkle v0.1.1-0.20231031103413-a67434b50f46 // indirect - github.com/getsentry/sentry-go v0.18.0 // indirect - github.com/go-ole/go-ole v1.2.5 // indirect - github.com/gofrs/flock v0.8.1 // indirect - github.com/gogo/protobuf v1.3.2 // indirect - github.com/golang/protobuf v1.5.3 // indirect - github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb // indirect - github.com/holiman/uint256 v1.2.4 // indirect - github.com/klauspost/compress v1.15.15 // indirect - github.com/kr/pretty v0.3.1 // indirect - github.com/kr/text v0.2.0 // indirect - github.com/mattn/go-runewidth v0.0.13 // indirect - github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect - github.com/mmcloughlin/addchain v0.4.0 // indirect - github.com/olekukonko/tablewriter v0.0.5 // indirect - github.com/pkg/errors v0.9.1 // indirect - github.com/prometheus/client_golang v1.14.0 // indirect - github.com/prometheus/client_model v0.3.0 // indirect - github.com/prometheus/common v0.39.0 // indirect - github.com/prometheus/procfs v0.9.0 // indirect - github.com/rivo/uniseg v0.2.0 // indirect - github.com/rogpeppe/go-internal v1.9.0 // indirect - github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible // indirect - github.com/supranational/blst v0.3.11 // indirect - github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 // indirect - github.com/tklauser/go-sysconf v0.3.12 // indirect - github.com/tklauser/numcpus v0.6.1 // indirect - golang.org/x/crypto v0.17.0 // indirect - golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa // indirect - golang.org/x/sync v0.5.0 // indirect - golang.org/x/sys v0.15.0 // indirect - golang.org/x/text v0.14.0 // indirect - google.golang.org/protobuf v1.28.1 // indirect - rsc.io/tmplfunc v0.0.3 // indirect -) diff --git a/tests/geth/go.sum b/tests/geth/go.sum deleted file mode 100644 index 0d6d63d7..00000000 --- a/tests/geth/go.sum +++ /dev/null @@ -1,476 +0,0 @@ -cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= -github.com/AndreasBriese/bbloom v0.0.0-20190306092124-e2d15f34fcf9/go.mod h1:bOvUY6CB00SOBii9/FifXqc0awNKxLFCL/+pkDPuyl8= -github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= -github.com/CloudyKit/fastprinter v0.0.0-20200109182630-33d98a066a53/go.mod h1:+3IMCy2vIlbG1XG/0ggNQv0SvxCAIpPM5b1nCz56Xno= -github.com/CloudyKit/jet/v3 v3.0.0/go.mod h1:HKQPgSJmdK8hdoAbKUUWajkHyHo4RaU5rMdUywE7VMo= -github.com/DataDog/zstd v1.5.2 h1:vUG4lAyuPCXO0TLbXvPv7EB7cNK1QV/luu55UHLrrn8= -github.com/DataDog/zstd v1.5.2/go.mod h1:g4AWEaM3yOg3HYfnJ3YIawPnVdXJh9QME85blwSAmyw= -github.com/Joker/hpp v1.0.0/go.mod h1:8x5n+M1Hp5hC0g8okX3sR3vFQwynaX/UgSOM9MeBKzY= -github.com/Shopify/goreferrer v0.0.0-20181106222321-ec9c9a553398/go.mod h1:a1uqRtAwp2Xwc6WNPJEufxJ7fx3npB4UV/JOLmbu5I0= -github.com/StackExchange/wmi v1.2.1 h1:VIkavFPXSjcnS+O8yTq7NI32k0R5Aj+v39y29VYDOSA= -github.com/StackExchange/wmi v1.2.1/go.mod h1:rcmrprowKIVzvc+NUiLncP2uuArMWLCbu9SBzvHz7e8= -github.com/VictoriaMetrics/fastcache v1.12.1 h1:i0mICQuojGDL3KblA7wUNlY5lOK6a4bwt3uRKnkZU40= -github.com/VictoriaMetrics/fastcache v1.12.1/go.mod h1:tX04vaqcNoQeGLD+ra5pU5sWkuxnzWhEzLwhP9w653o= -github.com/ajg/form v1.5.1/go.mod h1:uL1WgH+h2mgNtvBq0339dVnzXdBETtL2LeUXaIv25UY= -github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156 h1:eMwmnE/GDgah4HI848JfFxHt+iPb26b4zyfspmqY0/8= -github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156/go.mod h1:Cb/ax3seSYIx7SuZdm2G2xzfwmv3TPSk2ucNfQESPXM= -github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= -github.com/aymerick/raymond v2.0.3-0.20180322193309-b565731e1464+incompatible/go.mod h1:osfaiScAUVup+UC9Nfq76eWqDhXlp+4UYaA8uhTBO6g= -github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= -github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= -github.com/bits-and-blooms/bitset v1.10.0 h1:ePXTeiPEazB5+opbv5fr8umg2R/1NlzgDsyepwsSr88= -github.com/bits-and-blooms/bitset v1.10.0/go.mod h1:7hO7Gc7Pp1vODcmWvKMRA9BNmbv6a/7QIWpPxHddWR8= -github.com/btcsuite/btcd/btcec/v2 v2.2.0 h1:fzn1qaOt32TuLjFlkzYSsBC35Q3KUjT1SwPxiMSCF5k= -github.com/btcsuite/btcd/btcec/v2 v2.2.0/go.mod h1:U7MHm051Al6XmscBQ0BoNydpOTsFAn707034b5nY8zU= -github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 h1:q0rUy8C/TYNBQS1+CGKw68tLOFYSNEs0TFnxxnS9+4U= -github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1/go.mod h1:7SFka0XMvUgj3hfZtydOrQY2mwhPclbT2snogU7SQQc= -github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= -github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= -github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= -github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= -github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= -github.com/cockroachdb/datadriven v1.0.2/go.mod h1:a9RdTaap04u637JoCzcUoIcDmvwSUtcUFtT/C3kJlTU= -github.com/cockroachdb/datadriven v1.0.3-0.20230413201302-be42291fc80f h1:otljaYPt5hWxV3MUfO5dFPFiOXg9CyG5/kCfayTqsJ4= -github.com/cockroachdb/datadriven v1.0.3-0.20230413201302-be42291fc80f/go.mod h1:a9RdTaap04u637JoCzcUoIcDmvwSUtcUFtT/C3kJlTU= -github.com/cockroachdb/errors v1.9.1 h1:yFVvsI0VxmRShfawbt/laCIDy/mtTqqnvoNgiy5bEV8= -github.com/cockroachdb/errors v1.9.1/go.mod h1:2sxOtL2WIc096WSZqZ5h8fa17rdDq9HZOZLBCor4mBk= -github.com/cockroachdb/logtags v0.0.0-20211118104740-dabe8e521a4f/go.mod h1:Vz9DsVWQQhf3vs21MhPMZpMGSht7O/2vFW2xusFUVOs= -github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b h1:r6VH0faHjZeQy818SGhaone5OnYfxFR/+AzdY3sf5aE= -github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b/go.mod h1:Vz9DsVWQQhf3vs21MhPMZpMGSht7O/2vFW2xusFUVOs= -github.com/cockroachdb/pebble v0.0.0-20230928194634-aa077af62593 h1:aPEJyR4rPBvDmeyi+l/FS/VtA00IWvjeFvjen1m1l1A= -github.com/cockroachdb/pebble v0.0.0-20230928194634-aa077af62593/go.mod h1:6hk1eMY/u5t+Cf18q5lFMUA1Rc+Sm5I6Ra1QuPyxXCo= -github.com/cockroachdb/redact v1.1.3 h1:AKZds10rFSIj7qADf0g46UixK8NNLwWTNdCIGS5wfSQ= -github.com/cockroachdb/redact v1.1.3/go.mod h1:BVNblN9mBWFyMyqK1k3AAiSxhvhfK2oOZZ2lK+dpvRg= -github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 h1:zuQyyAKVxetITBuuhv3BI9cMrmStnpT18zmgmTxunpo= -github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06/go.mod h1:7nc4anLGjupUW/PeY5qiNYsdNXj7zopG+eqsS7To5IQ= -github.com/codegangsta/inject v0.0.0-20150114235600-33e0aa1cb7c0/go.mod h1:4Zcjuz89kmFXt9morQgcfYZAYZ5n8WHjt81YYWIwtTM= -github.com/consensys/bavard v0.1.13 h1:oLhMLOFGTLdlda/kma4VOJazblc7IM5y5QPd2A/YjhQ= -github.com/consensys/bavard v0.1.13/go.mod h1:9ItSMtA/dXMAiL7BG6bqW2m3NdSEObYWoH223nGHukI= -github.com/consensys/gnark-crypto v0.12.1 h1:lHH39WuuFgVHONRl3J0LRBtuYdQTumFSDtJF7HpyG8M= -github.com/consensys/gnark-crypto v0.12.1/go.mod h1:v2Gy7L/4ZRosZ7Ivs+9SfUDr0f5UlG+EM5t7MPHiLuY= -github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= -github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk= -github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= -github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE= -github.com/crate-crypto/go-ipa v0.0.0-20231025140028-3c0104f4b233 h1:d28BXYi+wUpz1KBmiF9bWrjEMacUEREV6MBi2ODnrfQ= -github.com/crate-crypto/go-ipa v0.0.0-20231025140028-3c0104f4b233/go.mod h1:geZJZH3SzKCqnz5VT0q/DyIG/tvu/dZk+VIfXicupJs= -github.com/crate-crypto/go-kzg-4844 v0.7.0 h1:C0vgZRk4q4EZ/JgPfzuSoxdCq3C3mOZMBShovmncxvA= -github.com/crate-crypto/go-kzg-4844 v0.7.0/go.mod h1:1kMhvPgI0Ky3yIa+9lFySEBUBXkYxeOi8ZF1sYioxhc= -github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= -github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/decred/dcrd/crypto/blake256 v1.0.0 h1:/8DMNYp9SGi5f0w7uCm6d6M4OU2rGFK09Y2A4Xv7EE0= -github.com/decred/dcrd/crypto/blake256 v1.0.0/go.mod h1:sQl2p6Y26YV+ZOcSTP6thNdn47hh8kt6rqSlvmrXFAc= -github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 h1:YLtO71vCjJRCBcrPMtQ9nqBsqpA1m5sE92cU+pd5Mcc= -github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1/go.mod h1:hyedUtir6IdtD/7lIxGeCxkaw7y45JueMRL4DIyJDKs= -github.com/dgraph-io/badger v1.6.0/go.mod h1:zwt7syl517jmP8s94KqSxTlM6IMsdhYy6psNgSztDR4= -github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw= -github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= -github.com/eknkc/amber v0.0.0-20171010120322-cdade1c07385/go.mod h1:0vRUJqYpeSZifjYj7uP3BG/gKcuzL9xWVV/Y+cK33KM= -github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= -github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= -github.com/envoyproxy/go-control-plane v0.9.9-0.20210217033140-668b12f5399d/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= -github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= -github.com/etcd-io/bbolt v1.3.3/go.mod h1:ZF2nL25h33cCyBtcyWeZ2/I3HQOfTP+0PIEvHjkjCrw= -github.com/ethereum/c-kzg-4844 v0.4.0 h1:3MS1s4JtA868KpJxroZoepdV0ZKBp3u/O5HcZ7R3nlY= -github.com/ethereum/c-kzg-4844 v0.4.0/go.mod h1:VewdlzQmpT5QSrVhbBuGoCdFJkpaJlO1aQputP83wc0= -github.com/fasthttp-contrib/websocket v0.0.0-20160511215533-1f3b11f56072/go.mod h1:duJ4Jxv5lDcvg4QuQr0oowTf7dz4/CR8NtyCooz9HL8= -github.com/fatih/structs v1.1.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga6PJ7M= -github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= -github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= -github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY= -github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw= -github.com/gavv/httpexpect v2.0.0+incompatible/go.mod h1:x+9tiU1YnrOvnB725RkpoLv1M62hOWzwo5OXotisrKc= -github.com/gballet/go-verkle v0.1.1-0.20231031103413-a67434b50f46 h1:BAIP2GihuqhwdILrV+7GJel5lyPV3u1+PgzrWLc0TkE= -github.com/gballet/go-verkle v0.1.1-0.20231031103413-a67434b50f46/go.mod h1:QNpY22eby74jVhqH4WhDLDwxc/vqsern6pW+u2kbkpc= -github.com/getsentry/sentry-go v0.12.0/go.mod h1:NSap0JBYWzHND8oMbyi0+XZhUalc1TBdRL1M71JZW2c= -github.com/getsentry/sentry-go v0.18.0 h1:MtBW5H9QgdcJabtZcuJG80BMOwaBpkRDZkxRkNC1sN0= -github.com/getsentry/sentry-go v0.18.0/go.mod h1:Kgon4Mby+FJ7ZWHFUAZgVaIa8sxHtnRJRLTXZr51aKQ= -github.com/gin-contrib/sse v0.0.0-20190301062529-5545eab6dad3/go.mod h1:VJ0WA2NBN22VlZ2dKZQPAPnyWw5XTlK1KymzLKsr59s= -github.com/gin-gonic/gin v1.4.0/go.mod h1:OW2EZn3DO8Ln9oIKOvM++LBO+5UPHJJDH72/q/3rZdM= -github.com/go-check/check v0.0.0-20180628173108-788fd7840127/go.mod h1:9ES+weclKsC9YodN5RgxqK/VD9HM9JsCSh7rNhMZE98= -github.com/go-errors/errors v1.0.1/go.mod h1:f4zRHt4oKfwPJE5k8C9vpYG+aDHdBFUsgrm6/TyX73Q= -github.com/go-errors/errors v1.4.2 h1:J6MZopCL4uSllY1OfXM374weqZFFItUbrImctkmUxIA= -github.com/go-errors/errors v1.4.2/go.mod h1:sIVyrIiJhuEF+Pj9Ebtd6P/rEYROXFi3BopGUQ5a5Og= -github.com/go-martini/martini v0.0.0-20170121215854-22fa46961aab/go.mod h1:/P9AEU963A2AYjv4d1V5eVL1CQbEJq6aCNHDDjibzu8= -github.com/go-ole/go-ole v1.2.5 h1:t4MGB5xEDZvXI+0rMjjsfBsD7yAgp/s9ZDkL1JndXwY= -github.com/go-ole/go-ole v1.2.5/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0= -github.com/gobwas/httphead v0.0.0-20180130184737-2c6c146eadee/go.mod h1:L0fX3K22YWvt/FAX9NnzrNzcI4wNYi9Yku4O0LKYflo= -github.com/gobwas/pool v0.2.0/go.mod h1:q8bcK0KcYlCgd9e7WYLm9LpyS+YeLd8JVDW6WezmKEw= -github.com/gobwas/ws v1.0.2/go.mod h1:szmBTxLgaFppYjEmNtny/v3w89xOydFnnZMcgRRu/EM= -github.com/gofrs/flock v0.8.1 h1:+gYjHKf32LDeiEEFhQaotPbLuUXjY5ZqxKgXy7n59aw= -github.com/gofrs/flock v0.8.1/go.mod h1:F1TvTiK9OcQqauNUHlbJvyl9Qa1QvF/gOUDKA14jxHU= -github.com/gogo/googleapis v0.0.0-20180223154316-0cd9801be74a/go.mod h1:gf4bu3Q80BeJ6H1S1vYPm8/ELATdvryBaNFGgqEef3s= -github.com/gogo/googleapis v1.4.1/go.mod h1:2lpHqI5OcWCtVElxXnPt+s8oJvMpySlOyM6xDCrzib4= -github.com/gogo/protobuf v1.2.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= -github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= -github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= -github.com/gogo/status v1.1.0/go.mod h1:BFv9nrluPLmrS0EmGVvLaPNmRosr9KapBYd5/hpY1WM= -github.com/golang-jwt/jwt v3.2.2+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I= -github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= -github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= -github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.5/go.mod h1:6O5/vntMXwX2lRkT1hjjk0nAC1IDOTvTlVgjlRvqsdk= -github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= -github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= -github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= -github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= -github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= -github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= -github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= -github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= -github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= -github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= -github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= -github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= -github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb h1:PBC98N2aIaM3XXiurYmW7fx4GZkL8feAMVq7nEjURHk= -github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= -github.com/gomodule/redigo v1.7.1-0.20190724094224-574c33c3df38/go.mod h1:B4C85qUVwatsJoIUNIfCRsp7qO0iAmpGFZ4EELWSbC4= -github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= -github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= -github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= -github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= -github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck= -github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/google/subcommands v1.2.0/go.mod h1:ZjhPrFU+Olkh9WazFPsl27BQ4UPiG37m3yTrtFlrHVk= -github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= -github.com/gorilla/websocket v1.4.1/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= -github.com/hashicorp/go-version v1.2.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= -github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= -github.com/holiman/uint256 v1.2.4 h1:jUc4Nk8fm9jZabQuqr2JzednajVmBpC+oiTiXZJEApU= -github.com/holiman/uint256 v1.2.4/go.mod h1:EOMSn4q6Nyt9P6efbI3bueV4e1b3dGlUCXeiRV4ng7E= -github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= -github.com/hydrogen18/memlistener v0.0.0-20200120041712-dcc25e7acd91/go.mod h1:qEIFzExnS6016fRpRfxrExeVn2gbClQA99gQhnIcdhE= -github.com/imkira/go-interpol v1.1.0/go.mod h1:z0h2/2T3XF8kyEPpRgJ3kmNv+C43p+I/CoI+jC3w2iA= -github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= -github.com/iris-contrib/blackfriday v2.0.0+incompatible/go.mod h1:UzZ2bDEoaSGPbkg6SAB4att1aAwTmVIx/5gCVqeyUdI= -github.com/iris-contrib/go.uuid v2.0.0+incompatible/go.mod h1:iz2lgM/1UnEf1kP0L/+fafWORmlnuysV2EMP8MW+qe0= -github.com/iris-contrib/jade v1.1.3/go.mod h1:H/geBymxJhShH5kecoiOCSssPX7QWYH7UaeZTSWddIk= -github.com/iris-contrib/pongo2 v0.0.1/go.mod h1:Ssh+00+3GAZqSQb30AvBRNxBx7rf0GqwkjqxNd0u65g= -github.com/iris-contrib/schema v0.0.1/go.mod h1:urYA3uvUNG1TIIjOSCzHr9/LmbQo8LrOcOqfqxa4hXw= -github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= -github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= -github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= -github.com/k0kubun/colorstring v0.0.0-20150214042306-9440f1994b88/go.mod h1:3w7q1U84EfirKl04SVQ/s7nPm1ZPhiXd34z40TNz36k= -github.com/kataras/golog v0.0.10/go.mod h1:yJ8YKCmyL+nWjERB90Qwn+bdyBZsaQwU3bTVFgkFIp8= -github.com/kataras/iris/v12 v12.1.8/go.mod h1:LMYy4VlP67TQ3Zgriz8RE2h2kMZV2SgMYbq3UhfoFmE= -github.com/kataras/neffos v0.0.14/go.mod h1:8lqADm8PnbeFfL7CLXh1WHw53dG27MC3pgi2R1rmoTE= -github.com/kataras/pio v0.0.2/go.mod h1:hAoW0t9UmXi4R5Oyq5Z4irTbaTsOemSrDGUtaTl7Dro= -github.com/kataras/sitemap v0.0.5/go.mod h1:KY2eugMKiPwsJgx7+U103YZehfvNGOXURubcGyk0Bz8= -github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= -github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= -github.com/klauspost/compress v1.8.2/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A= -github.com/klauspost/compress v1.9.7/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A= -github.com/klauspost/compress v1.15.15 h1:EF27CXIuDsYJ6mmvtBRlEuB2UVOqHG1tAXgZ7yIO+lw= -github.com/klauspost/compress v1.15.15/go.mod h1:ZcK2JAFqKOpnBlxcLsJzYfrS9X1akm9fHZNnD9+Vo/4= -github.com/klauspost/cpuid v1.2.1/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek= -github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= -github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk= -github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= -github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= -github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= -github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= -github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= -github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= -github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= -github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= -github.com/labstack/echo/v4 v4.5.0/go.mod h1:czIriw4a0C1dFun+ObrXp7ok03xON0N1awStJ6ArI7Y= -github.com/labstack/gommon v0.3.0/go.mod h1:MULnywXg0yavhxWKc+lOruYdAhDwPK9wf0OL7NoOu+k= -github.com/leanovate/gopter v0.2.9 h1:fQjYxZaynp97ozCzfOyOuAGOU4aU/z37zf/tOujFk7c= -github.com/leanovate/gopter v0.2.9/go.mod h1:U2L/78B+KVFIx2VmW6onHJQzXtFb+p5y3y2Sh+Jxxv8= -github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= -github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= -github.com/mattn/go-colorable v0.1.8/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= -github.com/mattn/go-colorable v0.1.11/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4= -github.com/mattn/go-isatty v0.0.7/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= -github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= -github.com/mattn/go-isatty v0.0.9/go.mod h1:YNRxwqDuOph6SZLI9vUUz6OYw3QyUt7WiY2yME+cCiQ= -github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= -github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= -github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= -github.com/mattn/go-runewidth v0.0.13 h1:lTGmDsbAYt5DmK6OnoV7EuIF1wEIFAcxld6ypU4OSgU= -github.com/mattn/go-runewidth v0.0.13/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= -github.com/mattn/goveralls v0.0.2/go.mod h1:8d1ZMHsd7fW6IRPKQh46F2WRpyib5/X4FOpevwGNQEw= -github.com/matttproud/golang_protobuf_extensions v1.0.4 h1:mmDVorXM7PCGKw94cs5zkfA9PSy5pEvNWRP0ET0TIVo= -github.com/matttproud/golang_protobuf_extensions v1.0.4/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4= -github.com/mediocregopher/radix/v3 v3.4.2/go.mod h1:8FL3F6UQRXHXIBSPUs5h0RybMF8i4n7wVopoX3x7Bv8= -github.com/microcosm-cc/bluemonday v1.0.2/go.mod h1:iVP4YcDBq+n/5fb23BhYFvIMq/leAFZyRl6bYmGDlGc= -github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= -github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= -github.com/mmcloughlin/addchain v0.4.0 h1:SobOdjm2xLj1KkXN5/n0xTIWyZA2+s99UCY1iPfkHRY= -github.com/mmcloughlin/addchain v0.4.0/go.mod h1:A86O+tHqZLMNO4w6ZZ4FlVQEadcoqkyU72HC5wJ4RlU= -github.com/mmcloughlin/profile v0.1.1/go.mod h1:IhHD7q1ooxgwTgjxQYkACGA77oFTDdFVejUS1/tS/qU= -github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= -github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= -github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= -github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= -github.com/moul/http2curl v1.0.0/go.mod h1:8UbvGypXm98wA/IqH45anm5Y2Z6ep6O31QGOAZ3H0fQ= -github.com/nats-io/jwt v0.3.0/go.mod h1:fRYCDE99xlTsqUzISS1Bi75UBJ6ljOJQOAAu5VglpSg= -github.com/nats-io/nats.go v1.9.1/go.mod h1:ZjDU1L/7fJ09jvUSRVBR2e7+RnLiiIQyqyzEE/Zbp4w= -github.com/nats-io/nkeys v0.1.0/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxziKVo7w= -github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c= -github.com/nxadm/tail v1.4.4 h1:DQuhQpB1tVlglWS2hLQ5OV6B5r8aGxSrPc5Qo6uTN78= -github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= -github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= -github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= -github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= -github.com/onsi/ginkgo v1.10.3/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= -github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= -github.com/onsi/ginkgo v1.14.0 h1:2mOpI4JVVPBN+WQRa0WKH2eXR+Ey+uK4n7Zj0aYpIQA= -github.com/onsi/ginkgo v1.14.0/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9klQyY= -github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= -github.com/onsi/gomega v1.10.1 h1:o0+MgICZLuZ7xjH7Vx6zS/zcu93/BEp1VwkIW1mEXCE= -github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= -github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= -github.com/pingcap/errors v0.11.4 h1:lFuQV/oaUMGcD2tqt+01ROSmJs75VG1ToEOkZIZ4nE4= -github.com/pingcap/errors v0.11.4/go.mod h1:Oi8TUi2kEtXXLMJk9l1cGmz20kV3TaQ0usTwv5KuLY8= -github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= -github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= -github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/prometheus/client_golang v1.14.0 h1:nJdhIvne2eSX/XRAFV9PcvFFRbrjbcTUj0VP62TMhnw= -github.com/prometheus/client_golang v1.14.0/go.mod h1:8vpkKitgIVNcqrRBWh1C4TIUQgYNtG/XQE4E/Zae36Y= -github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/prometheus/client_model v0.3.0 h1:UBgGFHqYdG/TPFD1B1ogZywDqEkwp3fBMvqdiQ7Xew4= -github.com/prometheus/client_model v0.3.0/go.mod h1:LDGWKZIo7rky3hgvBe+caln+Dr3dPggB5dvjtD7w9+w= -github.com/prometheus/common v0.39.0 h1:oOyhkDq05hPZKItWVBkJ6g6AtGxi+fy7F4JvUV8uhsI= -github.com/prometheus/common v0.39.0/go.mod h1:6XBZ7lYdLCbkAVhwRsWTZn+IN5AB9F/NXd5w0BbEX0Y= -github.com/prometheus/procfs v0.9.0 h1:wzCHvIvM5SxWqYvwgVL7yJY8Lz3PKn49KQtpgMYJfhI= -github.com/prometheus/procfs v0.9.0/go.mod h1:+pB4zwohETzFnmlpe6yd2lSc+0/46IYZRB/chUwxUZY= -github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY= -github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= -github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= -github.com/rogpeppe/go-internal v1.8.1/go.mod h1:JeRgkft04UBgHMgCIwADu4Pn6Mtm5d4nPKWu0nJ5d+o= -github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8= -github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= -github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= -github.com/ryanuber/columnize v2.1.0+incompatible/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= -github.com/schollz/closestmatch v2.1.0+incompatible/go.mod h1:RtP1ddjLong6gTkbtmuhtR2uUrrJOpYzYRvbcPAid+g= -github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= -github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible h1:Bn1aCHHRnjv4Bl16T8rcaFjYSrGrIZvpiGO6P3Q4GpU= -github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= -github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= -github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= -github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= -github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ= -github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= -github.com/spf13/cobra v0.0.5/go.mod h1:3K3wKZymM7VvHMDS9+Akkh4K60UwM26emMESw8tLCHU= -github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo= -github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= -github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s= -github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= -github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= -github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= -github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= -github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= -github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= -github.com/supranational/blst v0.3.11 h1:LyU6FolezeWAhvQk0k6O/d49jqgO52MSDDfYgbeoEm4= -github.com/supranational/blst v0.3.11/go.mod h1:jZJtfjgudtNl4en1tzwPIV3KjUnQUvG3/j+w+fVonLw= -github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 h1:epCh84lMvA70Z7CTTCmYQn2CKbY8j86K7/FAIr141uY= -github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7/go.mod h1:q4W45IWZaF22tdD+VEXcAWRA037jwmWEB5VWYORlTpc= -github.com/taikoxyz/taiko-geth v0.0.0-20240118064628-88e3acd1f435 h1:XaAE25G77ghpc2LdID3iVdyi916cMa2ifTQN5Ck7eYE= -github.com/taikoxyz/taiko-geth v0.0.0-20240118064628-88e3acd1f435/go.mod h1:sc48XYQxCzH3fG9BcrXCOOgQk2JfZzNAmIKnceogzsA= -github.com/tklauser/go-sysconf v0.3.12 h1:0QaGUFOdQaIVdPgfITYzaTegZvdCjmYO52cSFAEVmqU= -github.com/tklauser/go-sysconf v0.3.12/go.mod h1:Ho14jnntGE1fpdOqQEEaiKRpvIavV0hSfmBq8nJbHYI= -github.com/tklauser/numcpus v0.6.1 h1:ng9scYS7az0Bk4OZLvrNXNSAO2Pxr1XXRAPyjhIx+Fk= -github.com/tklauser/numcpus v0.6.1/go.mod h1:1XfjsgE2zo8GVw7POkMbHENHzVg3GzmoZ9fESEdAacY= -github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc= -github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw= -github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0= -github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY= -github.com/urfave/negroni v1.0.0/go.mod h1:Meg73S6kFm/4PpbYdq35yYWoCZ9mS/YSx+lKnmiohz4= -github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= -github.com/valyala/fasthttp v1.6.0/go.mod h1:FstJa9V+Pj9vQ7OJie2qMHdwemEDaDiSdBnvPM1Su9w= -github.com/valyala/fasttemplate v1.0.1/go.mod h1:UQGH1tvbgY+Nz5t2n7tXsz52dQxojPUpymEIMZ47gx8= -github.com/valyala/fasttemplate v1.2.1/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ= -github.com/valyala/tcplisten v0.0.0-20161114210144-ceec8f93295a/go.mod h1:v3UYOV9WzVtRmSR+PDvWpU/qWl4Wa5LApYYX4ZtKbio= -github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU= -github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ= -github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y= -github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q= -github.com/yalp/jsonpath v0.0.0-20180802001716-5cc68e5049a0/go.mod h1:/LWChgwKmvncFJFHJ7Gvn9wZArjbV5/FppcK2fKk/tI= -github.com/yudai/gojsondiff v1.0.0/go.mod h1:AY32+k2cwILAkW1fbgxQ5mUmMiZFgLIV+FBNExI05xg= -github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82/go.mod h1:lgjkn3NuSvDfVJdfcVVdX+jpBxNmX4rDAzaS45IcYoM= -github.com/yudai/pp v2.0.1+incompatible/go.mod h1:PuxR/8QJ7cyCkFp/aUDS+JY727OFEZkTdatxwunjIkc= -github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= -golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20191227163750-53104e6ec876/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= -golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k= -golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= -golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= -golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa h1:FRnLl4eNAQl8hwxVVC17teOw8kdjVDVAiFMtgUdTSRQ= -golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa/go.mod h1:zk2irFbV9DP96SEBUUAy67IdHUaZuSnrz1n472HUCLE= -golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= -golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= -golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/lint v0.0.0-20210508222113-6edffad5e616/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= -golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= -golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190327091125-710a502c58a2/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20200813134508-3edf25e44fcc/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= -golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= -golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= -golang.org/x/net v0.0.0-20211008194852-3b03d305991f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.18.0 h1:mIYleuAkSbHh0tCv7RvjL3F6ZVbLjq4+R7zbOn3Kokg= -golang.org/x/net v0.18.0/go.mod h1:/czyP5RqHAH4odGYxBJ1qz0+CE5WZ+2j1YgoEo8F2jQ= -golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= -golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.5.0 h1:60k92dhOjHxJkrqnwsfl8KuaHbn/5dl0lUPUklKo3qE= -golang.org/x/sync v0.5.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= -golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190626221950-04f50cda93cb/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200519105757-fe76b779f299/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200814200057-3d37ad5750ed/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210403161142-5e06dd20ab57/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220209214540-3681064d5158/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc= -golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= -golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= -golang.org/x/time v0.0.0-20201208040808-7e3f01d25324/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20181221001348-537d06c36207/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= -golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190327201419-c70d86f8b7cf/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.1.3/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= -google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= -google.golang.org/genproto v0.0.0-20180518175338-11a468237815/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= -google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= -google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= -google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= -google.golang.org/genproto v0.0.0-20210624195500-8bfb893ecb84/go.mod h1:SzzZ/N+nwJDaO1kznhnlzqS8ocJICar6hYhVyhi++24= -google.golang.org/grpc v1.12.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw= -google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= -google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= -google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= -google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= -google.golang.org/grpc v1.38.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM= -google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= -google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= -google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= -google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= -google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= -google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= -google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= -google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= -google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= -google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= -google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w= -google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= -gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= -gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= -gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= -gopkg.in/go-playground/assert.v1 v1.2.1/go.mod h1:9RXL0bg/zibRAgZUYszZSwO/z8Y/a8bDuhia5mkpMnE= -gopkg.in/go-playground/validator.v8 v8.18.2/go.mod h1:RX2a/7Ha8BgOhfk7j780h4/u/RRjR0eouCJSH80/M2Y= -gopkg.in/ini.v1 v1.51.1/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= -gopkg.in/mgo.v2 v2.0.0-20180705113604-9856a29383ce/go.mod h1:yeKp02qBN3iKW1OzL3MGk2IdtZzaj7SFntXj72NppTA= -gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= -gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= -gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= -gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= -gopkg.in/yaml.v3 v3.0.0-20191120175047-4206685974f2/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= -gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -rsc.io/tmplfunc v0.0.3 h1:53XFQh69AfOa8Tw0Jm7t+GV7KZhOi6jzsCzTtKbMvzU= -rsc.io/tmplfunc v0.0.3/go.mod h1:AG3sTPzElb1Io3Yg4voV9AGZJuleGAwaVRxL9M49PhA= diff --git a/tests/geth/lib/lib.go b/tests/geth/lib/lib.go deleted file mode 100644 index b7195651..00000000 --- a/tests/geth/lib/lib.go +++ /dev/null @@ -1,36 +0,0 @@ -package main - -/* - #include -*/ -import "C" -import ( - "encoding/json" - "fmt" - "main/gethutil" - "unsafe" -) - -//export MptRoot -func MptRoot(configStr *C.char) *C.char { - var txs []gethutil.Transaction - err := json.Unmarshal([]byte(C.GoString(configStr)), &txs) - if err != nil { - return C.CString(fmt.Sprintf("Failed to unmarshal txs, err: %v", err)) - } - - executionResults := gethutil.MptRoot(txs) - bytes, err := json.MarshalIndent(executionResults, "", " ") - if err != nil { - return C.CString(fmt.Sprintf("Failed to marshal []ExecutionResult, err: %v", err)) - } - - return C.CString(string(bytes)) -} - -//export FreeString -func FreeString(str *C.char) { - C.free(unsafe.Pointer(str)) -} - -func main() {} diff --git a/tests/geth/src/lib.rs b/tests/geth/src/lib.rs deleted file mode 100644 index a2a9d122..00000000 --- a/tests/geth/src/lib.rs +++ /dev/null @@ -1,97 +0,0 @@ -use core::fmt::{Display, Formatter, Result as FmtResult}; -use std::{ - ffi::{CStr, CString}, - os::raw::c_char, -}; - -use serde::Deserialize; -extern "C" { - fn MptRoot(str: *const c_char) -> *const c_char; - fn FreeString(str: *const c_char); -} - -#[derive(Deserialize, Debug)] -pub struct MptResult { - pub root: B256, - pub rlps: Vec, -} - -pub fn go_mtp_root(txs: &str) -> Result { - // Create a string we can pass into Go - let c_txs = CString::new(txs).expect("invalid config"); - - // Generate the trace externally - let result = unsafe { MptRoot(c_txs.as_ptr()) }; - - // Convert the returned string to something we can use in Rust again. - // Also make sure the returned data is copied to rust managed memory. - let c_result = unsafe { CStr::from_ptr(result) }; - let result = c_result - .to_str() - .expect("Error translating EVM trace from library") - .to_string(); - - // We can now free the returned string (memory managed by Go) - unsafe { FreeString(c_result.as_ptr()) }; - - // Return the trace - let result = match result.is_empty() || result.starts_with("Failed") { - true => return Err(Error::MptRoot(result)), - false => result, - }; - let result: MptResult = from_str(&result).map_err(|e| Error::MptRoot(e.to_string()))?; - Ok(result) -} - -use serde_json::from_str; -use zeth_primitives::{mpt::MptNode, transactions::EthereumTransaction, RlpBytes, B256}; - -pub fn rust_mtp_root(txs: &str) -> Result { - let txs = from_str::>(txs).unwrap(); - let mut tx_trie = MptNode::default(); - let mut rlps = vec![]; - for (tx_no, tx) in txs.iter().enumerate() { - let tx_rlp = tx.to_rlp(); - let tx_hex = hex::encode(&tx_rlp); - rlps.push(tx_hex); - tx_trie.insert_rlp(&tx_no.to_rlp(), tx).unwrap(); - } - Ok(MptResult { - root: tx_trie.hash(), - rlps, - }) -} - -/// Error type for any geth-utils related failure. -#[derive(Debug, Clone)] -pub enum Error { - /// Error while tracing. - MptRoot(String), -} - -impl Display for Error { - fn fmt(&self, f: &mut Formatter<'_>) -> FmtResult { - write!(f, "{:?}", self) - } -} - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn test_mpt_root() { - let txs = r#" - [{"essence":{"Eip1559":{"chain_id":167008,"nonce":23206,"max_priority_fee_per_gas":"0x0","max_fee_per_gas":"0x1","gas_limit":"0x3d090","to":{"Call":"0x1670080000000000000000000000000000010001"},"value":"0x0","data":"0xda69d3db5e05b7df7c06a03d7b463a5374c9e8aeb9f3dc21c152f7309cac258958f6b15dd80f1a3f49e593ac3be25fa60632d332f386880624acbee8edd73679adfc49ec00000000000000000000000000000000000000000000000000000000000ba5a10000000000000000000000000000000000000000000000000000000000e076be","access_list":[]}},"signature":{"v":1,"r":"0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","s":"0x64053f595237fe5f29377f48c113c40576452a7373c385d676a849c804d02144"}},{"essence":{"Eip1559":{"chain_id":167008,"nonce":8,"max_priority_fee_per_gas":"0x59682f00","max_fee_per_gas":"0x59682f01","gas_limit":"0x2a351","to":{"Call":"0xf2f88e7ea95f2c93339484529dc7af9014657cfa"},"value":"0x0","data":"0xd37c353b0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000036697066733a2f2f516d547463666873625363536b47453366324c633167517274394241415661464d6958586b353646316a64676d692f000000000000000000000000000000000000000000000000000000000000000000000000000000000000","access_list":[]}},"signature":{"v":0,"r":"0xee56a183c013a6901e9a309a449186118cd7c5cdd7487d6fa74257a31c1ef534","s":"0x6a5adba439ad3423a8c2a24ff60eb4efa897284dba946ad8ac025dd12063843b"}},{"essence":{"Eip1559":{"chain_id":167008,"nonce":7,"max_priority_fee_per_gas":"0x59682f00","max_fee_per_gas":"0x59682f01","gas_limit":"0x1e4b0","to":"Create","value":"0x0","data":"0x608060405234801561000f575f80fd5b506101438061001d5f395ff3fe608060405234801561000f575f80fd5b5060043610610034575f3560e01c80632e64cec1146100385780636057361d14610056575b5f80fd5b610040610072565b60405161004d919061009b565b60405180910390f35b610070600480360381019061006b91906100e2565b61007a565b005b5f8054905090565b805f8190555050565b5f819050919050565b61009581610083565b82525050565b5f6020820190506100ae5f83018461008c565b92915050565b5f80fd5b6100c181610083565b81146100cb575f80fd5b50565b5f813590506100dc816100b8565b92915050565b5f602082840312156100f7576100f66100b4565b5b5f610104848285016100ce565b9150509291505056fea26469706673582212207ca8a77a375aff548bc76892f6b2093ea5bec72e34f6638bcd6bc43f620679bc64736f6c63430008160033","access_list":[]}},"signature":{"v":1,"r":"0x8f822b9f11612d0ad65c31c03168f13c3be44615b3d99edfa744e367241e65b0","s":"0x178c11d68167aace32216f8a2163e6087d996b73c73c606e3e682d80cf5b678f"}},{"essence":{"Eip1559":{"chain_id":167008,"nonce":3,"max_priority_fee_per_gas":"0x59682f00","max_fee_per_gas":"0x59682f01","gas_limit":"0x31752","to":{"Call":"0xd2c3cbb943fed0cfc8389b14a3f6df518fd46346"},"value":"0xb1a2bc2ec50000","data":"0x3593564c000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000065a970bc00000000000000000000000000000000000000000000000000000000000000020b000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000b1a2bc2ec500000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000b1a2bc2ec500000000000000000000000000000000000000000000000000000000000b00aa1f0400000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002b0011e559da84dde3f841e22dc33f3adbf184d84a0000642a99837850543e223c134687f0c2b7e059873047000000000000000000000000000000000000000000","access_list":[]}},"signature":{"v":1,"r":"0xa114a8306dc24ae55eabdb8693342bb96d38ec5e02bfcf49258d4fe1585142c1","s":"0x1431ab11ed548dd466edc5e759a3bec24f3ae07620f57d858fb77c9b246ce23a"}},{"essence":{"Eip1559":{"chain_id":167008,"nonce":49,"max_priority_fee_per_gas":"0x59682f00","max_fee_per_gas":"0x59682f01","gas_limit":"0x9f96c","to":{"Call":"0x5cbfccd27db8a3981fe9965b0de59d436b2bd8b9"},"value":"0x13c3777bf34ffb","data":"0xac9650d800000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000001e00000000000000000000000000000000000000000000000000000000000000164883164560000000000000000000000000011e559da84dde3f841e22dc33f3adbf184d84a0000000000000000000000002a99837850543e223c134687f0c2b7e05987304700000000000000000000000000000000000000000000000000000000000001f4fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdbb56fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdff620000000000000000000000000000000000000000000000000013c3777bf34ffb000000000000000000000000000000000000000000000000000000018e3ea11800000000000000000000000000000000000000000000000000139ae99228cb98000000000000000000000000000000000000000000000000000000018bb4e1fb000000000000000000000000a29b384a523729bc9e076013fa035ce9c2544cbc0000000000000000000000000000000000000000000000000000000065a970bc00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000412210e8a00000000000000000000000000000000000000000000000000000000","access_list":[]}},"signature":{"v":1,"r":"0x689068e5ae1aa38507a8d58a8a7a2c93435bf79de56285b7579f5be542c2d76","s":"0x31eda5de43d522209ac8a01bd73e6c3c1c2e4b7a71df1671e683c8e78aa6f5dd"}},{"essence":{"Eip1559":{"chain_id":167008,"nonce":10,"max_priority_fee_per_gas":"0x59682f00","max_fee_per_gas":"0x59682f01","gas_limit":"0x2a351","to":{"Call":"0x2fcc2e44ff836fbf5c3d7e9c2ebdf3b1509cf4f3"},"value":"0x0","data":"0xd37c353b0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000036697066733a2f2f516d62507a4d336645634561365270424c4765694d686e4467734d4c7347447531334263324a6b514d6e77564c482f000000000000000000000000000000000000000000000000000000000000000000000000000000000000","access_list":[]}},"signature":{"v":1,"r":"0x7f1f660b98f4600538e0c59b2eda352bce86a8229e4c32a7e5ff36373b44afb6","s":"0xd74d693dfd28bb0a611d34f5d38c1c5350aaa07a92890d065cf8705f90fd44f"}},{"essence":{"Eip1559":{"chain_id":167008,"nonce":3,"max_priority_fee_per_gas":"0x59682f00","max_fee_per_gas":"0x59682f01","gas_limit":"0x7e0c3","to":{"Call":"0x5cbfccd27db8a3981fe9965b0de59d436b2bd8b9"},"value":"0x66dea16dd4bad73","data":"0xac9650d800000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000001e00000000000000000000000000000000000000000000000000000000000000164883164560000000000000000000000000011e559da84dde3f841e22dc33f3adbf184d84a000000000000000000000000d69d3e64d71844bbdda51cd7f23ed3631e9fac490000000000000000000000000000000000000000000000000000000000002710fffffffffffffffffffffffffffffffffffffffffffffffffffffffffff2766000000000000000000000000000000000000000000000000000000000000d89a0000000000000000000000000000000000000000000000000066dea16dd4bad73000000000000000000000000000000000000000000000046791fc84e07cff5100000000000000000000000000000000000000000000000000669d0a34d4952160000000000000000000000000000000000000000000000464bf6fe6f905302050000000000000000000000003da1db2cfab5f12239ee5ed0c84112a3ac6ed14b0000000000000000000000000000000000000000000000000000000065a970bc00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000412210e8a00000000000000000000000000000000000000000000000000000000","access_list":[]}},"signature":{"v":0,"r":"0xeb181f0b30e077e595db6b4141e51e31fc77ad6050fee4b93c714e679db5ed40","s":"0x7e8dadd2fd476a3da2163f553402c97fbacbf621ac35680bca4cde75752f5cd2"}},{"essence":{"Eip1559":{"chain_id":167008,"nonce":7,"max_priority_fee_per_gas":"0x59682f00","max_fee_per_gas":"0x59682f01","gas_limit":"0x1e4b0","to":"Create","value":"0x0","data":"0x608060405234801561000f575f80fd5b506101438061001d5f395ff3fe608060405234801561000f575f80fd5b5060043610610034575f3560e01c80632e64cec1146100385780636057361d14610056575b5f80fd5b610040610072565b60405161004d919061009b565b60405180910390f35b610070600480360381019061006b91906100e2565b61007a565b005b5f8054905090565b805f8190555050565b5f819050919050565b61009581610083565b82525050565b5f6020820190506100ae5f83018461008c565b92915050565b5f80fd5b6100c181610083565b81146100cb575f80fd5b50565b5f813590506100dc816100b8565b92915050565b5f602082840312156100f7576100f66100b4565b5b5f610104848285016100ce565b9150509291505056fea2646970667358221220175b5ff5925b348b9f880264a1038aba4c999696f4387cf13a5ccdd35467fb6664736f6c63430008160033","access_list":[]}},"signature":{"v":0,"r":"0x92186532daaee1105b32dc5d9f6a08af177fa70a1c82b78f4f300f7883bc05da","s":"0x60446c625c010ec561f7e58ce5c9e5397552c43c47cb21360dda05084d38a44d"}},{"essence":{"Eip1559":{"chain_id":167008,"nonce":4,"max_priority_fee_per_gas":"0x59682f00","max_fee_per_gas":"0x59682f01","gas_limit":"0x1e4a4","to":"Create","value":"0x0","data":"0x608060405234801561000f575f80fd5b506101438061001d5f395ff3fe608060405234801561000f575f80fd5b5060043610610034575f3560e01c80632e64cec1146100385780636057361d14610056575b5f80fd5b610040610072565b60405161004d919061009b565b60405180910390f35b610070600480360381019061006b91906100e2565b61007a565b005b5f8054905090565b805f8190555050565b5f819050919050565b61009581610083565b82525050565b5f6020820190506100ae5f83018461008c565b92915050565b5f80fd5b6100c181610083565b81146100cb575f80fd5b50565b5f813590506100dc816100b8565b92915050565b5f602082840312156100f7576100f66100b4565b5b5f610104848285016100ce565b9150509291505056fea2646970667358221220af7008041a150a4ff43e9709ce67654cf19205ed004c4b1fe1500399ade56b9b64736f6c63430008170033","access_list":[]}},"signature":{"v":0,"r":"0x258ee024e15f77051480ac80950a73fa01a63ad3177d4ec7c95777799bf63f03","s":"0x40153d47a283de30db685aa6ae382f55415bd22733c115c6dc089fc8a5115bd7"}},{"essence":{"Eip1559":{"chain_id":167008,"nonce":5,"max_priority_fee_per_gas":"0x59682f00","max_fee_per_gas":"0x59682f01","gas_limit":"0xf34f","to":{"Call":"0xd69d3e64d71844bbdda51cd7f23ed3631e9fac49"},"value":"0x0","data":"0x095ea7b30000000000000000000000005cbfccd27db8a3981fe9965b0de59d436b2bd8b9ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff","access_list":[]}},"signature":{"v":1,"r":"0x6262be6fbbf8faabf3dade6f0ed9db7c0c640a5c4635e69f917858c9fbb83377","s":"0x4d18809f51c9f0ac05b6d11c7a9fad3cc188737a63e7c27dfc37c9dc2bf1fb33"}},{"essence":{"Eip1559":{"chain_id":167008,"nonce":34,"max_priority_fee_per_gas":"0x59682f00","max_fee_per_gas":"0x59682f01","gas_limit":"0x2cae4","to":{"Call":"0xd2c3cbb943fed0cfc8389b14a3f6df518fd46346"},"value":"0x11c37937e080000","data":"0x3593564c000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000065a970bc00000000000000000000000000000000000000000000000000000000000000020b000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000011c37937e08000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000011c37937e080000000000000000000000000000000000000000000000000000000000119a5a1d9e00000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002b0011e559da84dde3f841e22dc33f3adbf184d84a0000642a99837850543e223c134687f0c2b7e059873047000000000000000000000000000000000000000000","access_list":[]}},"signature":{"v":1,"r":"0x229795aac8a953809780d882cef11783aa775a348e13e13937990c15fbb0c4e","s":"0x1071aba3e0a1a1f91dd2d4aaacd4077c292cfbaf5dbb77e5290b226e9b06708a"}},{"essence":{"Eip1559":{"chain_id":167008,"nonce":0,"max_priority_fee_per_gas":"0x59682f00","max_fee_per_gas":"0x59682f01","gas_limit":"0x18e05","to":{"Call":"0x1670080000000000000000000000000000000001"},"value":"0x26c6036ae68a20","data":"0x33bcd0cc0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000085841072598236162b9a8fff9f254a9e20e9cc2d0000000000000000000000000000000000000000000000000000000000028c60000000000000000000000000000000000000000000000000000000000000426800000000000000000000000085841072598236162b9a8fff9f254a9e20e9cc2d00000000000000000000000085841072598236162b9a8fff9f254a9e20e9cc2d00000000000000000000000085841072598236162b9a8fff9f254a9e20e9cc2d000000000000000000000000000000000000000000000000002386f26fc1000000000000000000000000000000000000000000000000000000033f10fb258a2000000000000000000000000000000000000000000000000000000000000222e0000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000001a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","access_list":[]}},"signature":{"v":1,"r":"0x69c02aca8c3ebb8f3ab9c3ec247538acc3c600d4a80b155a1a97f76124c3e9be","s":"0x71fe7065af839d2e7722430d162b806bec0ff65f3a7d70e39a0b9e8deb163a47"}},{"essence":{"Eip1559":{"chain_id":167008,"nonce":9,"max_priority_fee_per_gas":"0x59682f00","max_fee_per_gas":"0x59682f01","gas_limit":"0x1c71f","to":{"Call":"0x5d04bc3ddd8bcbdf3ff71ab39e62287ca185ae3e"},"value":"0x38d7ea4c68000","data":"0x1249c58b","access_list":[]}},"signature":{"v":0,"r":"0xfb9511460ab049660f2481840ed862642528247687800f9f00fb2b7b73a2c8bf","s":"0x2c38d48b31721f3893228be8705e0b34b5774011a5fdb54f3d3a18560a3955c5"}},{"essence":{"Eip1559":{"chain_id":167008,"nonce":3,"max_priority_fee_per_gas":"0x59682f00","max_fee_per_gas":"0x59682f01","gas_limit":"0xf34f","to":{"Call":"0xd69d3e64d71844bbdda51cd7f23ed3631e9fac49"},"value":"0x0","data":"0x095ea7b30000000000000000000000005cbfccd27db8a3981fe9965b0de59d436b2bd8b9ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff","access_list":[]}},"signature":{"v":1,"r":"0x4c2a32a6a6747c871566ecf4415255fd94ee3c2f648f46b8ea15cb509ffafed8","s":"0x58c53a01ff12fd74f21f00fea903753dd632c0c6a5763ccf680f9e9c8ca242e9"}},{"essence":{"Eip1559":{"chain_id":167008,"nonce":18,"max_priority_fee_per_gas":"0x59682f00","max_fee_per_gas":"0x59682f01","gas_limit":"0xfc55","to":{"Call":"0x5535b9ff2aa1a63b87921599850cb942f813323b"},"value":"0x0","data":"0xa9059cbb000000000000000000000000eb15859af4dc37738f32e8bb468eb1ffde5bd7a700000000000000000000000000000000000000000000021e19e0c9bab2400000","access_list":[]}},"signature":{"v":1,"r":"0xac3db1534cf8dad72a8cb063c3fea0d1d0f48d27ab0c7f8eb16054e9324395f","s":"0x458c8ac58e9f6d94dc64d59747b56cbfeef3b2db7ba0db8ccadc049d84069337"}},{"essence":{"Eip1559":{"chain_id":167008,"nonce":13,"max_priority_fee_per_gas":"0x59682f00","max_fee_per_gas":"0x59682f01","gas_limit":"0xd105","to":{"Call":"0xae2c46ddb314b9ba743c6dee4878f151881333d9"},"value":"0x0","data":"0x095ea7b3000000000000000000000000fde807b7c79f69f22622acb73db5b59654e115b60000000000000000000000000000000000000000000000000000000000402a73","access_list":[]}},"signature":{"v":1,"r":"0x907171397fefd07536584acf07fa05e113b7887964aa802761b7c8b161fe1bcd","s":"0x3be9419669fc93e94f68f3cd67edb941b0d6257a63ef860e9bb44eb2311d105"}},{"essence":{"Eip1559":{"chain_id":167008,"nonce":2,"max_priority_fee_per_gas":"0x59682f00","max_fee_per_gas":"0x59682f01","gas_limit":"0x66a97","to":{"Call":"0x1670080000000000000000000000000000000001"},"value":"0x0","data":"0x0138240800000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000001d764000000000000000000000000d209f6fbdce2462f3063321be3b96b481b44858100000000000000000000000000000000000000000000000000000000000042680000000000000000000000000000000000000000000000000000000000028c60000000000000000000000000d209f6fbdce2462f3063321be3b96b481b448581000000000000000000000000d209f6fbdce2462f3063321be3b96b481b448581000000000000000000000000d209f6fbdce2462f3063321be3b96b481b4485810000000000000000000000000000000000000000000000000011c37937e080000000000000000000000000000000000000000000000000000004cbd15e801ba000000000000000000000000000000000000000000000000000000000000222e0000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000001a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000009800000000000000000000000000000000000000000000000000000000000000020000000000000000000000000167008000000000000000000000000000001000100000000000000000000000000000000000000000000000000000000000ba59a000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000009400000000000000000000000000000000000000000000000000000000000000896f90893b90214f90211a04d338534c32c08dad0c101fe1798d1203edb20b2549468d1a3bb35237f5b76d9a04f2a94632c3c16f5c0f122731eb2beb951b7acf3249414e7a7ccd04597d9c746a0685df84299cc6f9ac64b2f49e2568d02f0c77aad28ee5b664748192e11f007a4a0aee90207fdca1d5e1ea19b61c3ae4b24d7e1aa4b7d283e66029e191e709c864ba0f197a203c989c02cd7f150f0596333d98079e4db2975a53cff67892497c208fda06303c9fce964d57aefb2bc0933477768fd48159deae37fac7138c2a3b8d51cc4a0179b035da2f9fdbb8bcf0ecafefb8d192ad5461aa146c6a690d20f1aa2089cd2a03e7b4458cbef3a6450004d40e0405a5571d030aa726d3a3da927d2a0ad1ba2fca0a4fffc6f869f6fc1bd00e64717df0035bee73e053c8ffa2765fbe2b27e86b3cfa06a1c14b1afbc465cc1553022116dde190b75cb92f8934074d2d046819d96dc00a0ec5386f3963a273e86060b6331ffc6c80a0df3a62e80193e6b9e66fe3262a9a6a066b2ff83824da5d831dda93c61a86c1b7a47492e558812878fcac7eacc1fa2a3a0e956b036b9570e798ddd15d9addf05a9f4e6a59bb3fd390ee86af1ba59632399a07ba682d91356cbb366314dab761dc97f6b53408562220b6233d2d7548d8522c4a0d9193d56e31ed7c50961592f21100febfcad45483fdd936d90ea8d8a2373cd31a0c9c8646daffe4b5fd7034deb172d4395462b3d72496a694c932b2908d1b2fbf780b90214f90211a0696c733cbbb18499e545004214dcb110a35c6acd9ce77461f9ab4f2f30311203a002b91aaa1ce363e25b95e77273990878898c9b100f038b51eafbf1f96baeae89a0984508740e4512154619a4274f22b5cdee7eb6e4faae6ed5741d4b6027390152a06e3344335cd57cda7affb56155f126c60d2fe34b02e9ce8d2be7f1f88ab98a10a0b3254e9ef461f192c9044a65d0e60b304142649ad2057c684f1f26acdae63230a00a65ce7f2398a7a71eb158670acfc4f349e0152a5020d6dc279c4447ef8e9793a001049d0c5ebac806f9189934025ed3820c83fc7ccb4a67387a46fc53d0e9e3b8a0f4e9edeb76a7f2d1e1f70c315cfd2c642c48a4b2e53d6f9fdac1f26d1ad3f60aa03059144b248f828a560a3fec36da447b4f22cc81910db5690d5587844cbd7948a010a11769e51f30f523001bbdcd72370d8e2eea566889ccdd02cde1e3a7beb1ada010c9a764788bf1b6891589350c4f38847832992fe94351fb212d6b33baf0a283a0c4da0adc3b7b82324a20d15760487a79562cbb0f406bc8559e1deab5cee3f260a0e6a50d75e9499e7ba4bf0ed5b45ccee2935088aed62450406228c84c3c317b22a0c206a8a4627daf678da0710496c28dfb2a09e2ed9d10c4d78dcd992a733b8e4aa00e7a51b5c5a86483925750dc1eb0b6b2e597d59ca5e402a4bcd3010fcbb4b0bfa0f565212ee1fdbbc53a29832495f71ac368c06c1b2988d64fd6588dd69ddd020880b90214f90211a0094855f0e01800ab91e234bd4475b26cee6c4b8bafd93be4890bcbe6aa929819a0091bb2ef5ab4862381362ffb0378c9d30e05eae96211f8527e3e255747886d33a0faaf2e875df5fdd723e58919ed9caf447dc6c0248a25f8fd0cb148e04215872ba0db91cc17d08bd087d67a236984c2e12cc9ddea4862a1a21a13f478dc6c80d855a0733fddac882f5a7fce648478daf566988aeefc82a668e4fc1857d98199b01b66a0db33be24d2f3f3df19167f1a08dceb543d47e4530f334eb73bd10fad7e945cfaa0de73de062cab691c79044a024d499c53ef2306afb3955781bb4791d3f95460f0a0f9e7845a7fc516fb1fb3697045addcc638cf084e8ac5810ac70022a4c7c670c7a0a0c2f93c0c5718871c846ca47f449833f131610146ff59e1d943aed70eb79712a04ce6d5d782d3d61cb9c3160ceadcf377384c31a49ed0ac427e26cbf04691586ba0a49205927873adfa81c1dfc05ce22459e3e9ad7c7aa43111d3238412aa70de5fa095fcb28f0fa956ba3236f7cb2bf5f0240ce26671bd2805bd42f9739ccb027814a060d982e4f8d08a0ac23f2f05436d086fa2491a1927162bb2cc02059fcc421090a0612c90d3cd9d84e9baded563e523cef2fbe63fe7713fb666628e6123236e5313a02cbc5e9b1fee2358f2b3a12049778e5c7f8589d1dd8077a98fe549c2969fbdbda0d81256248ec40a800150815c2880135654a428b67665f7d1a2767736e371536f80b901d4f901d1a06e6a5be3912d1e57cd7e62c8cd26bac69f85d985238bdee92dc3d1e76217f021a074e4d0d470f4e14d7039a8bf622f28d71727b857815a26d9116b612e0ad6062580a0dd3b2dd3e45de43392021d9b6711ae51f0ddce380706cc873854eb79fa9702c1a0e6c2420f1bbca66b295de1b50c8098283df205e36b21cbd1fe28bb8f5d478a84a0e08af052acaad51a6ca56e8eab502daaaf1750992c8f75dce02e4064cd6e67c5a07da506423017a0796f02c910edc631dc0efb8a5bcc8f4b71b2a4c7d53ba5afb6a0ef5fdc8453a143c403bb1db38026bb78edfd4e86f4c4af1c0a7d2712c21c573ba05b392046508ce0894d57c3e44579eb71ff03a73d06b7e39894aa0dc39b9cba09a0dfcec8f3f4d10129f4d14843f3c957f2b16d1e262efd72b9babcf997d280527fa070ce02729dbe2f92a5f612e3602f020ed7f7b88c7f288e3112128d53505c6848a04f94d5e5a1a910d400f378e3dadf2cc07c0aa2e637d86b09922a0f8477f8bc5a80a012afb69e9d1de641d4d4f91fe240d7104e594c15a282f51097771908b92153b7a03ef659dcc44ebd4fd09a9d4f98ffe749a41d8b1a4bfead679dcfa6e92c25b2dda0af80c4e08ac9185959a41fe015532674a0b1b030735d6ba8991e59a7b617c53e80b853f851808080a00224e1fdf1ab331b3134156b057cb59d9bc1428229a324ccc7a1261676e7557c80808080808080a0e6e623c65732560b5e311649960f5ae5c9d9c93da90f3f41b98bc3f52a5c50798080808080a1e09e3bf3e72547899f614325047fbbd95aa7d3089f0a4fe8da9293a0b34e5ec901000000000000000000000000000000000000000000000000000000000000000000000000000000000000","access_list":[]}},"signature":{"v":0,"r":"0xf622a174fc4803fd9c5f3581671487e0e1ccbec5c7128f231252a81364ab772d","s":"0x71cadc95edcfd863e0192cebee1b867212b5662f75ddc3d11e8d2450bb1c5f4"}},{"essence":{"Eip1559":{"chain_id":167008,"nonce":2,"max_priority_fee_per_gas":"0x59682f00","max_fee_per_gas":"0x59682f01","gas_limit":"0xc989","to":{"Call":"0xd69d3e64d71844bbdda51cd7f23ed3631e9fac49"},"value":"0x0","data":"0x095ea7b3000000000000000000000000fde807b7c79f69f22622acb73db5b59654e115b6000000000000000000000000000000000000000000000000d02ab486cedc0000","access_list":[]}},"signature":{"v":0,"r":"0x374cacab8e656e89b5726c0a62b0184a9922e58b625abfe442333affef9cb5d2","s":"0x3fc455c2876bb3c5c6c33550459e6a5da56a444327577ffea74851bf5554e3da"}},{"essence":{"Eip1559":{"chain_id":167008,"nonce":6,"max_priority_fee_per_gas":"0x59682f00","max_fee_per_gas":"0x59682f01","gas_limit":"0x7e07b","to":{"Call":"0x5cbfccd27db8a3981fe9965b0de59d436b2bd8b9"},"value":"0x221b262dd8000","data":"0xac9650d800000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000001e00000000000000000000000000000000000000000000000000000000000000164883164560000000000000000000000000011e559da84dde3f841e22dc33f3adbf184d84a000000000000000000000000d69d3e64d71844bbdda51cd7f23ed3631e9fac490000000000000000000000000000000000000000000000000000000000002710fffffffffffffffffffffffffffffffffffffffffffffffffffffffffff2766000000000000000000000000000000000000000000000000000000000000d89a0000000000000000000000000000000000000000000000000000221b262dd8000000000000000000000000000000000000000000000000000175d77c37d3e32d00000000000000000000000000000000000000000000000000002205671c88644000000000000000000000000000000000000000000000000174e7ed3b949b396000000000000000000000000b56d486406d4c8e7af2da8b79eab680309f7b0030000000000000000000000000000000000000000000000000000000065a970bc00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000412210e8a00000000000000000000000000000000000000000000000000000000","access_list":[]}},"signature":{"v":1,"r":"0xe969a2e7c314fc6a369e72b2ce5bd99340f81072d5ef42cec35cc7510d4f1f06","s":"0x75b5f0a869c54fd473023cc362edb2dc1ae41868a11e4c29efde300fd9ae6eb"}},{"essence":{"Eip1559":{"chain_id":167008,"nonce":3,"max_priority_fee_per_gas":"0x59682f00","max_fee_per_gas":"0x59682f01","gas_limit":"0x1e4b0","to":"Create","value":"0x0","data":"0x608060405234801561000f575f80fd5b506101438061001d5f395ff3fe608060405234801561000f575f80fd5b5060043610610034575f3560e01c80632e64cec1146100385780636057361d14610056575b5f80fd5b610040610072565b60405161004d919061009b565b60405180910390f35b610070600480360381019061006b91906100e2565b61007a565b005b5f8054905090565b805f8190555050565b5f819050919050565b61009581610083565b82525050565b5f6020820190506100ae5f83018461008c565b92915050565b5f80fd5b6100c181610083565b81146100cb575f80fd5b50565b5f813590506100dc816100b8565b92915050565b5f602082840312156100f7576100f66100b4565b5b5f610104848285016100ce565b9150509291505056fea26469706673582212207ca8a77a375aff548bc76892f6b2093ea5bec72e34f6638bcd6bc43f620679bc64736f6c63430008160033","access_list":[]}},"signature":{"v":1,"r":"0x8faabd527d388ef1a925df7b6cda79a8db15fa4841c7b65cefb9feb79bc0c191","s":"0x6da937d631650c8f0583d449c5a7d963a0868dc24eb86f31895111bf6b77fcec"}},{"essence":{"Eip1559":{"chain_id":167008,"nonce":1,"max_priority_fee_per_gas":"0x59682f00","max_fee_per_gas":"0x59682f01","gas_limit":"0x47eb9","to":{"Call":"0xd2c3cbb943fed0cfc8389b14a3f6df518fd46346"},"value":"0xb1a2bc2ec500000","data":"0x3593564c000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000065a970bc00000000000000000000000000000000000000000000000000000000000000030b000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000001e0000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000b1a2bc2ec5000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000006a94d74f4300000000000000000000000000000000000000000000000000000000000000132060300000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002b0011e559da84dde3f841e22dc33f3adbf184d84a0001f4ae2c46ddb314b9ba743c6dee4878f151881333d9000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000470de4df82000000000000000000000000000000000000000000000000000000000000000cbd3eb00000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002b0011e559da84dde3f841e22dc33f3adbf184d84a000bb8ae2c46ddb314b9ba743c6dee4878f151881333d9000000000000000000000000000000000000000000","access_list":[]}},"signature":{"v":0,"r":"0x400e80dc05b0d0500951513bf209257e00c71b28d4e777b9f1dd4dae7f898489","s":"0x7a8fa0a5ebcc6d924a6c1875efdf7242786ac03e1a84101eeb833458608742d7"}},{"essence":{"Eip1559":{"chain_id":167008,"nonce":802,"max_priority_fee_per_gas":"0x186a0","max_fee_per_gas":"0x186a1","gas_limit":"0x55200","to":{"Call":"0xbfcfd6fb89c1fdd0d87c3d24dd8fc1d371203651"},"value":"0x0","data":"0x783cf332000000000000000000000000000000000000000000000000000000395bb93400","access_list":[]}},"signature":{"v":0,"r":"0xcbaea2f53ed121fa6d314add4cb619dd971e0578bec2b1c9d91912d54f7bac7a","s":"0x6c7819f144ff6caba3c31ed383fde2c6f8eed40a3dfbff5183f00fb2095ff208"}}] - "#; - let rust_root = rust_mtp_root(txs).unwrap(); - let go_root = go_mtp_root(txs).unwrap(); - - assert_eq!(rust_root.rlps.len(), go_root.rlps.len()); - println!("rust_root.rlps[0]: {}", rust_root.rlps[0]); - println!("go_root.rlps[0]: {}", go_root.rlps[0]); - println!("rust_root.root: {}", rust_root.root); - println!("go_root.root: {}", go_root.root); - assert_eq!(rust_root.root, go_root.root); - } -} From e12ade611ec29f44c5e69e694c7b14759a9021d4 Mon Sep 17 00:00:00 2001 From: brechtpd Date: Wed, 20 Mar 2024 01:16:05 +0000 Subject: [PATCH 08/10] misc small cleanup --- README.md | 4 ++-- lib/src/taiko_utils.rs | 10 +++------- raiko-host/src/prover/proof/risc0/mod.rs | 3 +-- 3 files changed, 6 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index fc0fc200..c84e22c7 100644 --- a/README.md +++ b/README.md @@ -72,11 +72,11 @@ cargo run --release --features risc0 #### GPU ``` -RISC0_DEV_MODE=1 cargo run -F cuda --release --features risc0 +cargo run -F cuda --release --features risc0 ``` OR ``` -RISC0_DEV_MODE=1 cargo run -F metal --release --features risc0 +cargo run -F metal --release --features risc0 ``` CUDA needs to be installed when using `cuda`: https://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html diff --git a/lib/src/taiko_utils.rs b/lib/src/taiko_utils.rs index 7458cd5a..f513b4d1 100644 --- a/lib/src/taiko_utils.rs +++ b/lib/src/taiko_utils.rs @@ -218,19 +218,15 @@ pub fn check_anchor_tx( Ok(()) } -pub fn hash_header(header: &AlloyConsensusHeader) -> B256 { - let mut out = Vec::::new(); - header.encode(&mut out); - keccak256(&out) -} - pub trait HeaderHasher { fn hash(&self) -> B256; } impl HeaderHasher for AlloyConsensusHeader { fn hash(&self) -> B256 { - hash_header(self) + let mut out = Vec::::new(); + self.encode(&mut out); + keccak256(&out) } } diff --git a/raiko-host/src/prover/proof/risc0/mod.rs b/raiko-host/src/prover/proof/risc0/mod.rs index 2439b7ed..51defd51 100644 --- a/raiko-host/src/prover/proof/risc0/mod.rs +++ b/raiko-host/src/prover/proof/risc0/mod.rs @@ -495,8 +495,7 @@ pub fn save_receipt(receipt_label: &String, receipt_data: & } fn zkp_cache_path(receipt_label: &String) -> String { - Path::new("cache_zkp") - .as_path() + Path::new("/tmp/risc0-cache") .join(format!("{}.zkp", receipt_label)) .to_str() .unwrap() From bda526cfd1b5f1a370bfd84056c592981ac7e35a Mon Sep 17 00:00:00 2001 From: brechtpd Date: Wed, 20 Mar 2024 13:09:06 +0000 Subject: [PATCH 09/10] Fix devnet support --- lib/src/input.rs | 24 +- lib/src/protocol_instance.rs | 2 - lib/src/taiko_utils.rs | 11 +- raiko-host/src/host/host.rs | 423 +++++++++++++++++++++++++++++++---- 4 files changed, 398 insertions(+), 62 deletions(-) diff --git a/lib/src/input.rs b/lib/src/input.rs index ae8e482c..a7f494af 100644 --- a/lib/src/input.rs +++ b/lib/src/input.rs @@ -113,21 +113,19 @@ sol! { #[derive(Debug, Default, Deserialize, Serialize)] struct BlockMetadata { - bytes32 l1Hash; // slot 1 - bytes32 difficulty; // slot 2 - bytes32 blobHash; //or txListHash (if Blob not yet supported), // slot 3 - bytes32 extraData; // slot 4 - bytes32 depositsHash; // slot 5 - address coinbase; // L2 coinbase, // slot 6 + bytes32 l1Hash; + bytes32 difficulty; + bytes32 blobHash; //or txListHash (if Blob not yet supported) + bytes32 extraData; + bytes32 depositsHash; + address coinbase; // L2 coinbase uint64 id; uint32 gasLimit; - uint64 timestamp; // slot 7 + uint64 timestamp; uint64 l1Height; - uint24 txListByteOffset; - uint24 txListByteSize; uint16 minTier; bool blobUsed; - bytes32 parentMetaHash; // slot 8 + bytes32 parentMetaHash; address sender; } @@ -136,10 +134,6 @@ sol! { address assignedProver; address coinbase; bytes32 extraData; - bytes32 blobHash; - uint24 txListByteOffset; - uint24 txListByteSize; - bool cacheBlobForReuse; bytes32 parentMetaHash; HookCall[] hookCalls; } @@ -296,8 +290,6 @@ impl From for BlockProposed { gasLimit: item.meta.gasLimit, timestamp: item.meta.timestamp, l1Height: item.meta.l1Height, - txListByteOffset: item.meta.txListByteOffset, - txListByteSize: item.meta.txListByteSize, minTier: item.meta.minTier, blobUsed: item.meta.blobUsed, parentMetaHash: item.meta.parentMetaHash, diff --git a/lib/src/protocol_instance.rs b/lib/src/protocol_instance.rs index 0c11aba6..77d6d857 100644 --- a/lib/src/protocol_instance.rs +++ b/lib/src/protocol_instance.rs @@ -110,8 +110,6 @@ pub fn assemble_protocol_instance( gasLimit: (gas_limit - ANCHOR_GAS_LIMIT) as u32, timestamp: header.timestamp.try_into().unwrap(), l1Height: input.taiko.l1_header.number.try_into().unwrap(), - txListByteOffset: 0u32, - txListByteSize: input.taiko.tx_list.len() as u32, minTier: input.taiko.block_proposed.meta.minTier, blobUsed: blob_used, parentMetaHash: input.taiko.block_proposed.meta.parentMetaHash, diff --git a/lib/src/taiko_utils.rs b/lib/src/taiko_utils.rs index f513b4d1..6f493c07 100644 --- a/lib/src/taiko_utils.rs +++ b/lib/src/taiko_utils.rs @@ -16,6 +16,10 @@ pub const GOLDEN_TOUCH_ACCOUNT: Lazy
= Lazy::new(|| { Address::from_str("0x0000777735367b36bC9B61C50022d9D0700dB4Ec") .expect("invalid golden touch account") }); +pub const SGX_VERIFIER_ADDRESS: Lazy
= Lazy::new(|| { + Address::from_str("0xA4702E22F8807Df82Fe5B6dDdd99eB3Fcb0237B0") + .expect("invalid sgx verifier contract address") +}); macro_rules! taiko_contracts { ($name:ident) => {{ @@ -73,10 +77,13 @@ pub mod internal_devnet_b { }); } +pub fn decode_transactions(tx_list: &[u8]) -> Vec { + alloy_rlp::Decodable::decode(&mut &tx_list.to_owned()[..]).unwrap_or_default() +} + pub fn generate_transactions(tx_list: &[u8], anchor_tx: AlloyTransaction) -> Vec { // Decode the transactions from the tx list - let mut transactions: Vec = - alloy_rlp::Decodable::decode(&mut &tx_list.to_owned()[..]).unwrap_or_default(); + let mut transactions = decode_transactions(tx_list); // Create a tx from the anchor tx that has the same type as the transactions encoded from // the tx list let signed_eip1559_tx = Signed::::new_unchecked( diff --git a/raiko-host/src/host/host.rs b/raiko-host/src/host/host.rs index 5354ef46..ac5e5774 100644 --- a/raiko-host/src/host/host.rs +++ b/raiko-host/src/host/host.rs @@ -98,15 +98,11 @@ pub fn preflight( // Fetch the tx list let (tx_list, tx_blob_hash) = if proposal_event.meta.blobUsed { println!("blob active"); - let metadata = &proposal_event.meta; - // Get the blob hashes attached to the propose tx let blob_hashs = proposal_tx.blob_versioned_hashes; assert!(blob_hashs.len() >= 1); // Currently the protocol enforces the first blob hash to be used let blob_hash = blob_hashs[0]; - // TODO: check _proposed_blob_hash with blob_hash if _proposed_blob_hash is not None - // Get the blob data for this block let blobs = get_blob_data(&beacon_rpc_url.clone().unwrap(), l1_inclusion_block_no)?; assert!(blobs.data.len() > 0, "blob data not available anymore"); @@ -120,14 +116,8 @@ pub fn preflight( }) .cloned() .collect::>(); - let blob_data = decode_blob_data(&tx_blobs[0].blob); - // Extract the specified range at which the tx list is stored - let offset = metadata.txListByteOffset as usize; - let size = metadata.txListByteSize as usize; - ( - blob_data.as_slice()[offset..(offset + size)].to_vec(), - Some(blob_hash), - ) + assert!(!tx_blobs.is_empty()); + (decode_blob_data(&tx_blobs[0].blob), Some(blob_hash)) } else { // Get the tx list data directly from the propose transaction data let proposal_call = proposeBlockCall::abi_decode(&proposal_tx.input, false).unwrap(); @@ -213,46 +203,121 @@ pub fn preflight( const BLOB_FIELD_ELEMENT_NUM: usize = 4096; const BLOB_FIELD_ELEMENT_BYTES: usize = 32; -const BLOB_DATA_LEN: usize = BLOB_FIELD_ELEMENT_NUM * BLOB_FIELD_ELEMENT_BYTES; - -fn decode_blob_data(blob: &str) -> Vec { - let origin_blob = hex::decode(blob.to_lowercase().trim_start_matches("0x")).unwrap(); - let header: U256 = U256::from_be_bytes::( - origin_blob[0..BLOB_FIELD_ELEMENT_BYTES].try_into().unwrap(), - ); // first element is the length - let expected_len = header.as_limbs()[0] as usize; - - assert!(origin_blob.len() == BLOB_DATA_LEN); - // the first 32 bytes is the length of the blob - // every first 1 byte is reserved. - assert!(expected_len <= (BLOB_FIELD_ELEMENT_NUM - 1) * (BLOB_FIELD_ELEMENT_BYTES - 1)); - let mut chunk: Vec> = Vec::new(); - let mut decoded_len = 0; - let mut i = 1; - while decoded_len < expected_len && i < BLOB_FIELD_ELEMENT_NUM { - let segment_len = if expected_len - decoded_len >= 31 { - 31 - } else { - expected_len - decoded_len - }; - let segment = &origin_blob - [i * BLOB_FIELD_ELEMENT_BYTES + 1..i * BLOB_FIELD_ELEMENT_BYTES + 1 + segment_len]; - i += 1; - decoded_len += segment_len; - chunk.push(segment.to_vec()); +const BLOB_DATA_CAPACITY: usize = BLOB_FIELD_ELEMENT_NUM * BLOB_FIELD_ELEMENT_BYTES; +const BLOB_VERSION_OFFSET: usize = 1; +const BLOB_ENCODING_VERSION: u8 = 0; +const MAX_BLOB_DATA_SIZE: usize = (4 * 31 + 3) * 1024 - 4; + +// decoding https://github.com/ethereum-optimism/optimism/blob/develop/op-service/eth/blob.go +fn decode_blob_data(blob_str: &str) -> Vec { + let blob_buf: Vec = match hex::decode(blob_str.to_lowercase().trim_start_matches("0x")) { + Ok(b) => b, + Err(_) => return Vec::new(), + }; + + // check the version + if blob_buf[BLOB_VERSION_OFFSET] != BLOB_ENCODING_VERSION { + return Vec::new(); + } + + // decode the 3-byte big-endian length value into a 4-byte integer + let output_len = + ((blob_buf[2] as u32) << 16 | (blob_buf[3] as u32) << 8 | (blob_buf[4] as u32)) as usize; + if output_len > MAX_BLOB_DATA_SIZE { + return Vec::new(); + } + + // round 0 is special cased to copy only the remaining 27 bytes of the first field element + // into the output due to version/length encoding already occupying its first 5 bytes. + let mut output = [0; MAX_BLOB_DATA_SIZE]; + output[0..27].copy_from_slice(&blob_buf[5..32]); + + // now process remaining 3 field elements to complete round 0 + let mut opos: usize = 28; // current position into output buffer + let mut ipos: usize = 32; // current position into the input blob + let mut encoded_byte: [u8; 4] = [0; 4]; // buffer for the 4 6-bit chunks + encoded_byte[0] = blob_buf[0]; + for encoded_byte_i in encoded_byte.iter_mut().skip(1) { + (*encoded_byte_i, opos, ipos) = + match decode_field_element(&blob_buf, opos, ipos, &mut output) { + Ok(res) => res, + Err(_) => return Vec::new(), + } } - chunk.iter().flatten().cloned().collect() + opos = reassemble_bytes(opos, &encoded_byte, &mut output); + + // in each remaining round we decode 4 field elements (128 bytes) of the input into 127 + // bytes of output + for _ in 1..1024 { + if opos < output_len { + for encoded_byte_j in &mut encoded_byte { + // save the first byte of each field element for later re-assembly + (*encoded_byte_j, opos, ipos) = + match decode_field_element(&blob_buf, opos, ipos, &mut output) { + Ok(res) => res, + Err(_) => return Vec::new(), + } + } + opos = reassemble_bytes(opos, &encoded_byte, &mut output) + } + } + for otailing in output.iter().skip(output_len) { + if *otailing != 0 { + return Vec::new(); + } + } + for itailing in blob_buf.iter().take(BLOB_DATA_CAPACITY).skip(ipos) { + if *itailing != 0 { + return Vec::new(); + } + } + output[0..output_len].to_vec() +} + +fn decode_field_element( + b: &[u8], + opos: usize, + ipos: usize, + output: &mut [u8], +) -> Result<(u8, usize, usize)> { + // two highest order bits of the first byte of each field element should always be 0 + if b[ipos] & 0b1100_0000 != 0 { + return Err(anyhow::anyhow!( + "ErrBlobInvalidFieldElement: field element: {}", + ipos + )); + } + // copy(output[opos:], b[ipos+1:ipos+32]) + output[opos..opos + 31].copy_from_slice(&b[ipos + 1..ipos + 32]); + Ok((b[ipos], opos + 32, ipos + 32)) +} + +fn reassemble_bytes( + opos: usize, + encoded_byte: &[u8; 4], + output: &mut [u8; MAX_BLOB_DATA_SIZE], +) -> usize { + // account for fact that we don't output a 128th byte + let opos = opos - 1; + let x = (encoded_byte[0] & 0b0011_1111) | ((encoded_byte[1] & 0b0011_0000) << 2); + let y = (encoded_byte[1] & 0b0000_1111) | ((encoded_byte[3] & 0b0000_1111) << 4); + let z = (encoded_byte[2] & 0b0011_1111) | ((encoded_byte[3] & 0b0011_0000) << 2); + // put the re-assembled bytes in their appropriate output locations + output[opos - 32] = z; + output[opos - (32 * 2)] = y; + output[opos - (32 * 3)] = x; + opos } fn calc_blob_versioned_hash(blob_str: &str) -> [u8; 32] { - let blob_bytes = hex::decode(blob_str.to_lowercase().trim_start_matches("0x")).unwrap(); + let blob_bytes: Vec = + hex::decode(blob_str.to_lowercase().trim_start_matches("0x")).unwrap(); let kzg_settings = Arc::clone(&*MAINNET_KZG_TRUSTED_SETUP); let blob = Blob::from_bytes(&blob_bytes).unwrap(); let kzg_commit = KzgCommitment::blob_to_kzg_commitment(&blob, &kzg_settings).unwrap(); let version_hash: [u8; 32] = kzg_to_versioned_hash(kzg_commit).0; version_hash } - fn get_blob_data(beacon_rpc_url: &str, block_id: u64) -> Result { let tokio_handle = tokio::runtime::Handle::current(); tokio_handle.block_on(async { @@ -376,3 +441,277 @@ pub fn get_log( } bail!("No BlockProposed event found for block {l2_block_no}"); } + +#[cfg(test)] +mod test { + use std::sync::Arc; + + use c_kzg::{Blob, KzgCommitment}; + use ethers_core::types::Transaction; + use reth_primitives::{ + constants::eip4844::MAINNET_KZG_TRUSTED_SETUP, + eip4844::kzg_to_versioned_hash, + revm_primitives::kzg::{parse_kzg_trusted_setup, KzgSettings}, + }; + use zeth_lib::taiko_utils::decode_transactions; + + use super::*; + + fn calc_commit_versioned_hash(commitment: &str) -> [u8; 32] { + let commit_bytes = hex::decode(commitment.to_lowercase().trim_start_matches("0x")).unwrap(); + let kzg_commit = c_kzg::KzgCommitment::from_bytes(&commit_bytes).unwrap(); + let version_hash: [u8; 32] = kzg_to_versioned_hash(kzg_commit).0; + version_hash + } + + #[test] + fn test_parse_kzg_trusted_setup() { + // check if file exists + let b_file_exists = std::path::Path::new("../kzg_parsed_trust_setup").exists(); + assert!(b_file_exists); + // open file as lines of strings + let kzg_trust_setup_str = std::fs::read_to_string("../kzg_parsed_trust_setup").unwrap(); + let (g1, g2) = parse_kzg_trusted_setup(&kzg_trust_setup_str) + .map_err(|e| { + println!("error: {:?}", e); + e + }) + .unwrap(); + println!("g1: {:?}", g1.0.len()); + println!("g2: {:?}", g2.0.len()); + } + + #[test] + fn test_blob_to_kzg_commitment() { + // check if file exists + let b_file_exists = std::path::Path::new("../kzg_parsed_trust_setup").exists(); + assert!(b_file_exists); + // open file as lines of strings + let kzg_trust_setup_str = std::fs::read_to_string("../kzg_parsed_trust_setup").unwrap(); + let (g1, g2) = parse_kzg_trusted_setup(&kzg_trust_setup_str) + .map_err(|e| { + println!("error: {:?}", e); + e + }) + .unwrap(); + let kzg_settings = KzgSettings::load_trusted_setup(&g1.0, &g2.0).unwrap(); + let blob = [0u8; 131072].into(); + let kzg_commit = KzgCommitment::blob_to_kzg_commitment(&blob, &kzg_settings).unwrap(); + assert_eq!( + kzg_to_versioned_hash(kzg_commit).to_string(), + "0x010657f37554c781402a22917dee2f75def7ab966d7b770905398eba3c444014" + ); + } + + #[ignore] + #[test] + fn test_new_blob_decode() { + let valid_blob_str = "\ + 01000004b0f904adb8b502f8b283028c59188459682f008459682f028286b394\ + 006700100000000000000000000000000001009980b844a9059cbb0000000000\ + 0000000000000001670010000000000000000000000000000100990000000000\ + 000000000000000000000000000000000000000000000000000001c080a0af40\ + 093afa19e4b7256a209c71a902d33985c5655e580d5fbf36815e290b623177a0\ + 19d4b4ccaa5497a47845016680c128b63e74e9d6a9756ebdeb2f78a65e0fa120\ + 0001f802f901f483028c592e8459682f008459682f02832625a0941670010000\ + 0b000000000000000000000000000280b90184fa233d0c000000000000000000\ + 0000000000000000000000000000000000000000000000200000000000000000\ + 000000000000000000000000000000000000000000007e7e0000000000000000\ + 0000000014dc79964da2c08b23698b3d3cc7ca32193d99550000000000000000\ + 0000000014dc79964da2c08b23698b3d3cc7ca32193d99550000000000000000\ + 0000000000016700100000000000000000000000000001009900000000000000\ + 0000000000000000000000000000000000000000000000000100000000000000\ + 000000000000000000000000000000000000000000002625a000000000000000\ + 0000000000000000000000000000000000000000000000000000000000000000\ + 000000000000976ea74026e726554db657fa54763abd0c3a0aa9000000000000\ + 0000000000000000000000000000000000000000000000000120000000000000\ + 220000000000000000000000000000000000000000000000001243726f6e4a6f\ + 102053656e64546f6b656e730000000000000000000000000000c080a0a99edd\ + 2b13d5436cb0fe71b2ea4e69c2292fdc682ae54fe702cc36d6634dd0ba85a057\ + 119f9297ca5ebd5402bd886405fe3aa8f8182438a9e56c1ef2a1ec0ae4a0acb9\ + 00f802f901f483028c592f8459682f008459682f02832625a094167001000000\ + 000000000000000000000000000280b90184fa233d0c00000000000000000000\ + 0000000000000000000000000000000000000000000020000000000000000000\ + 0000000000000000000000000000000000000000007e7e000000000000000000\ + 00000014dc79964da2c08b23698b3d3cc7ca32193d9955000000000000000000\ + 00000014dc79964da2c08b23698b3d3cc7ca32193d9955000000000000000000\ + 0000000001670010000000000000000000000000000100990000000000000000\ + 0000000000000000000000000000000000000000000000010000000000000000\ + 0000000000000000000000000000000000000000002625a00000000000000000\ + 0000000000000000000000000000000000000000000000000000000000000000\ + 0000000000976ea74026e726554db657fa54763abd0c3a0aa900000000000000\ + 0000000000000000000000000000000000000000000000012000000000000000\ + 2000000000000000000000000000000000000000000000001243726f6e4a6f62\ + 0053656e64546f6b656e730000000000000000000000000000c080a08f0a9757\ + 35d78526f1339c69c2ed02df7a6d7cded10c74fb57398c11c1420526c2a0047f\ + 003054d3d75d33120020872b6d5e0a4a05e47c50179bb9a8b866b7fb71b30000\ + 0000000000000000000000000000000000000000000000000000000000000000\ + 0000000000000000000000000000000000000000000000000000000000000000\ + 0000000000000000000000000000000000000000000000000000000000000000\ + 0000000000000000000000000000000000000000000000000000000000000000\ + 0000000000000000000000000000000000000000000000000000000000000000\ + 00000000000000000000000000000000"; + // println!("valid blob: {:?}", valid_blob_str); + let blob_str = format!("{:0<262144}", valid_blob_str); + let dec_blob = decode_blob_data(&blob_str); + println!("dec blob tx len: {:?}", dec_blob.len()); + let txs = decode_transactions(&dec_blob); + println!("dec blob tx: {:?}", txs); + // assert_eq!(hex::encode(dec_blob), expected_dec_blob); + } + + #[test] + fn test_c_kzg_lib_commitment() { + // check c-kzg mainnet trusted setup is ok + let kzg_settings = Arc::clone(&*MAINNET_KZG_TRUSTED_SETUP); + let blob = [0u8; 131072].into(); + let kzg_commit = KzgCommitment::blob_to_kzg_commitment(&blob, &kzg_settings).unwrap(); + assert_eq!( + kzg_to_versioned_hash(kzg_commit).to_string(), + "0x010657f37554c781402a22917dee2f75def7ab966d7b770905398eba3c444014" + ); + } + + // #[ignore] + // #[tokio::test] + // async fn test_propose_block() { + // tokio::task::spawn_blocking(|| { + // let l2_chain_spec = get_taiko_chain_spec("internal_devnet_a"); + // let mut l1_provider = new_provider( + // None, + // Some("https://localhost:8545".to_owned()), + // Some("https://localhost:3500/".to_owned()), + // ) + // .expect("bad provider"); + // let (propose_tx, block_metadata) = l1_provider + // .get_propose(&ProposeQuery { + // l1_contract: H160::from_slice(l2_chain_spec.l1_contract.unwrap().as_slice()), + // l1_block_no: 6093, + // l2_block_no: 1000, + // }) + // .expect("bad get_propose"); + // println!("propose_tx: {:?}", propose_tx); + // println!("block_metadata: {:?}", block_metadata); + // }) + // .await + // .unwrap(); + // } + // + // #[ignore] + // #[tokio::test] + // async fn test_fetch_blob_data_and_hash() { + // tokio::task::spawn_blocking(|| { + // let mut provider = new_provider( + // None, + // Some("https://l1rpc.internal.taiko.xyz/".to_owned()), + // Some("https://l1beacon.internal.taiko.xyz/".to_owned()), + // ) + // .expect("bad provider"); + // let blob_data = fetch_blob_data("http://localhost:3500".to_string(), 5).unwrap(); + // let blob_data = provider.get_blob_data(17138).unwrap(); + // println!("blob len: {:?}", blob_data.data[0].blob.len()); + // let dec_blob = decode_blob_data(&blob_data.data[0].blob); + // println!("dec blob tx: {:?}", dec_blob.len()); + // + // println!("blob commitment: {:?}", blob_data.data[0].kzg_commitment); + // let blob_hash = calc_commit_versioned_hash(&blob_data.data[0].kzg_commitment); + // println!("blob hash {:?}", hex::encode(blob_hash)); + // }) + // .await + // .unwrap(); + // } + // + // #[ignore] + // #[tokio::test] + // async fn test_fetch_and_verify_blob_data() { + // tokio::task::spawn_blocking(|| { + // let mut provider = new_provider( + // None, + // Some("https://l1rpc.internal.taiko.xyz".to_owned()), + // Some("https://l1beacon.internal.taiko.xyz".to_owned()), + // ) + // .expect("bad provider"); + // let blob_data = provider.get_blob_data(168).unwrap(); + // let blob_bytes: [u8; 4096 * 32] = hex::decode( + // blob_data.data[0] + // .blob + // .to_lowercase() + // .trim_start_matches("0x"), + // ) + // .unwrap() + // .try_into() + // .unwrap(); + // let blob: Blob = blob_bytes.into(); + // let kzg_settings = Arc::clone(&*MAINNET_KZG_TRUSTED_SETUP); + // let kzg_commit: KzgCommitment = + // KzgCommitment::blob_to_kzg_commitment(&blob, &kzg_settings).unwrap(); + // assert_eq!( + // "0x".to_owned() + &kzg_commit.as_hex_string(), + // blob_data.data[0].kzg_commitment + // ); + // println!("blob commitment: {:?}", blob_data.data[0].kzg_commitment); + // let calc_versioned_hash = + // calc_commit_versioned_hash(&blob_data.data[0].kzg_commitment); println!("blob hash + // {:?}", hex::encode(calc_versioned_hash)); }) + // .await + // .unwrap(); + // } + // + // #[ignore] + // #[tokio::test] + // async fn test_fetch_and_decode_blob_tx() { + // let block_num = std::env::var("TAIKO_L2_BLOCK_NO") + // .unwrap_or("94".to_owned()) + // .parse::() + // .unwrap(); + // tokio::task::spawn_blocking(move || { + // let mut provider = new_provider( + // None, + // Some("http://35.202.137.144:8545".to_owned()), + // Some("http://35.202.137.144:3500".to_owned()), + // ) + // .expect("bad provider"); + // let blob_data = provider.get_blob_data(block_num).unwrap(); + // println!("blob str len: {:?}", blob_data.data[0].blob.len()); + // let blob_bytes = decode_blob_data(&blob_data.data[0].blob); + // println!("blob byte len: {:?}", blob_bytes.len()); + // println!("blob bytes {:?}", blob_bytes); + // rlp decode blob tx + // let txs: Vec = rlp_decode_list(&blob_bytes).unwrap(); + // println!("blob tx: {:?}", txs); + // }) + // .await + // .unwrap(); + // } + + #[ignore] + #[test] + fn json_to_ethers_blob_tx() { + let response = "{ + \"blockHash\":\"0xa61eea0256aa361dfd436be11b0e276470413fbbc34b3642fbbf3b5d8d72f612\", + \"blockNumber\":\"0x4\", + \"from\":\"0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266\", + \"gas\":\"0xf4240\", + \"gasPrice\":\"0x5e92e74e\", + \"maxFeePerGas\":\"0x8b772ea6\", + \"maxPriorityFeePerGas\":\"0x3b9aca00\", + \"maxFeePerBlobGas\":\"0x2\", + \"hash\":\"0xdb3b11250a2332cc4944fa8022836bd32da43c34d4f2e9e1b246cfdbc5b4c60e\", + \"input\":\"0x11762da2\", + \"nonce\":\"0x1\", + \"to\":\"0x5fbdb2315678afecb367f032d93f642f64180aa3\", + \"transactionIndex\":\"0x0\", + \"value\":\"0x0\", + \"type\":\"0x3\", + \"accessList\":[], + \"chainId\":\"0x7e7e\", + \"blobVersionedHashes\":[\"0x012d46373b7d1f53793cd6872e40e801f9af6860ecbdbaa2e28df25937618c6f\",\"0x0126d296b606f85b775b12b8b4abeb3bdb88f5a50502754d598537ae9b7fb947\"], + \"v\":\"0x0\", + \"r\":\"0xaba289efba8ef610a5b3b70b72a42fe1916640f64d7112ec0b89087bbc8fff5f\", + \"s\":\"0x1de067d69b79d28d0a3bd179e332c85b93cedbd299d9e205398c073a59633dcf\", + \"yParity\":\"0x0\" + }"; + let tx: Transaction = serde_json::from_str(response).unwrap(); + println!("tx: {:?}", tx); + } +} From 3974e4775aefb1c4161c75be147437d7f4121f0f Mon Sep 17 00:00:00 2001 From: brechtpd Date: Thu, 21 Mar 2024 01:23:00 +0000 Subject: [PATCH 10/10] improve network spec code --- lib/src/builder/execute.rs | 12 ++--- lib/src/builder/mod.rs | 4 +- lib/src/consts.rs | 45 +++++++++++------- lib/src/input.rs | 29 ++++++------ lib/src/protocol_instance.rs | 2 +- lib/src/taiko_utils.rs | 73 +++++------------------------- primitives/src/signature.rs | 23 +++++----- prove_block.sh | 8 ++-- raiko-host/src/host/host.rs | 29 ++++++------ raiko-host/src/prover/execution.rs | 5 +- 10 files changed, 95 insertions(+), 135 deletions(-) diff --git a/lib/src/builder/execute.rs b/lib/src/builder/execute.rs index 073f0944..6b950a31 100644 --- a/lib/src/builder/execute.rs +++ b/lib/src/builder/execute.rs @@ -29,9 +29,9 @@ use zeth_primitives::{mpt::MptNode, receipt::Receipt, Bloom, RlpBytes}; use super::TxExecStrategy; use crate::{ builder::BlockBuilder, - consts::GWEI_TO_WEI, + consts::{get_network_spec, Network, GWEI_TO_WEI}, guest_mem_forget, - taiko_utils::{check_anchor_tx, generate_transactions, get_contracts}, + taiko_utils::{check_anchor_tx, generate_transactions}, }; /// Minimum supported protocol version: Bedrock (Block no. 105235063). @@ -136,7 +136,7 @@ impl TxExecStrategy for TkoTxExecStrategy { &block_builder.input, &tx, &tx_from, - &block_builder.input.taiko.chain_spec_name, + block_builder.input.network, ) .expect("invalid anchor tx"); } @@ -154,7 +154,7 @@ impl TxExecStrategy for TkoTxExecStrategy { // setup the transaction fill_eth_tx_env( - &block_builder.input.taiko.chain_spec_name, + block_builder.input.network, &mut evm.env().tx, &tx, tx_from, @@ -266,7 +266,7 @@ impl TxExecStrategy for TkoTxExecStrategy { } pub fn fill_eth_tx_env( - chain_name: &str, + network: Network, tx_env: &mut TxEnv, tx: &TxEnvelope, caller: Address, @@ -275,7 +275,7 @@ pub fn fill_eth_tx_env( // claim the anchor tx_env.taiko.is_anchor = is_anchor; // set the treasury address - tx_env.taiko.treasury = get_contracts(chain_name).unwrap().1; + tx_env.taiko.treasury = get_network_spec(network).l2_contract.unwrap(); tx_env.caller = caller; match tx { diff --git a/lib/src/builder/mod.rs b/lib/src/builder/mod.rs index 55f736fe..afb6b6b5 100644 --- a/lib/src/builder/mod.rs +++ b/lib/src/builder/mod.rs @@ -24,7 +24,7 @@ use crate::{ initialize::{DbInitStrategy, MemDbInitStrategy}, prepare::{HeaderPrepStrategy, TaikoHeaderPrepStrategy}, }, - consts::{get_chain_spec, ChainSpec}, + consts::{get_network_spec, ChainSpec}, input::GuestInput, mem_db::MemDb, }; @@ -51,7 +51,7 @@ where /// Creates a new block builder. pub fn new(input: &GuestInput) -> BlockBuilder { BlockBuilder { - chain_spec: get_chain_spec(&input.taiko.chain_spec_name), + chain_spec: get_network_spec(input.network), db: None, header: None, input: input.clone(), diff --git a/lib/src/consts.rs b/lib/src/consts.rs index f0c6edc5..9cfc1067 100644 --- a/lib/src/consts.rs +++ b/lib/src/consts.rs @@ -17,6 +17,7 @@ extern crate alloc; use alloc::{collections::BTreeMap, str::FromStr}; +use alloy_primitives::Address; use anyhow::bail; use once_cell::unsync::Lazy; use revm::primitives::SpecId; @@ -54,11 +55,13 @@ pub const ETH_MAINNET_CHAIN_SPEC: Lazy = Lazy::new(|| { base_fee_max_decrease_denominator: uint!(8_U256), elasticity_multiplier: uint!(2_U256), }, + l1_contract: None, + l2_contract: None, } }); -/// The Taiko testnet specification. -pub const TKO_TESTNET_CHAIN_SPEC: Lazy = Lazy::new(|| ChainSpec { +/// The Taiko A6 specification. +pub const TAIKO_A6_CHAIN_SPEC: Lazy = Lazy::new(|| ChainSpec { chain_id: 167008, hard_forks: BTreeMap::from([ (SpecId::SHANGHAI, ForkCondition::Block(0)), @@ -70,10 +73,12 @@ pub const TKO_TESTNET_CHAIN_SPEC: Lazy = Lazy::new(|| ChainSpec { base_fee_max_decrease_denominator: uint!(8_U256), elasticity_multiplier: uint!(2_U256), }, + l1_contract: Some(Address::from_str("0xB20BB9105e007Bd3E0F73d63D4D3dA2c8f736b77").unwrap()), + l2_contract: Some(Address::from_str("0x1670080000000000000000000000000000010001").unwrap()), }); -/// The Taiko testnet specification. -pub const TKO_DEVNETA_CHAIN_SPEC: Lazy = Lazy::new(|| ChainSpec { +/// The Taiko A7 specification. +pub const TAIKO_A7_CHAIN_SPEC: Lazy = Lazy::new(|| ChainSpec { chain_id: 167001, hard_forks: BTreeMap::from([ (SpecId::SHANGHAI, ForkCondition::Block(0)), @@ -85,18 +90,18 @@ pub const TKO_DEVNETA_CHAIN_SPEC: Lazy = Lazy::new(|| ChainSpec { base_fee_max_decrease_denominator: uint!(8_U256), elasticity_multiplier: uint!(2_U256), }, + l1_contract: Some(Address::from_str("0x78155FaC733356cbA069245A435Eb114e7fd815d").unwrap()), + l2_contract: Some(Address::from_str("0x1670010000000000000000000000000000010001").unwrap()), }); -pub fn get_chain_spec(name: &str) -> ChainSpec { - match name { - "testnet" => TKO_TESTNET_CHAIN_SPEC.clone(), - "internal_devnet_a" => TKO_DEVNETA_CHAIN_SPEC.clone(), - _ => unimplemented!("invalid chain name: {name}"), +pub fn get_network_spec(network: Network) -> ChainSpec { + match network { + Network::TaikoA6 => TAIKO_A6_CHAIN_SPEC.clone(), + Network::TaikoA7 => TAIKO_A7_CHAIN_SPEC.clone(), + _ => unimplemented!("invalid chain name: {:?}", network), } } -pub use crate::taiko_utils::testnet::*; - /// The condition at which a fork is activated. #[derive(Debug, Clone, Serialize, Deserialize)] pub enum ForkCondition { @@ -143,6 +148,8 @@ pub struct ChainSpec { pub chain_id: ChainId, pub hard_forks: BTreeMap, pub eip_1559_constants: Eip1559Constants, + pub l1_contract: Option
, + pub l2_contract: Option
, } impl ChainSpec { @@ -156,6 +163,8 @@ impl ChainSpec { chain_id, hard_forks: BTreeMap::from([(spec_id, ForkCondition::Block(0))]), eip_1559_constants, + l1_contract: None, + l2_contract: None, } } /// Returns the network chain ID. @@ -177,13 +186,15 @@ impl ChainSpec { } } -#[derive(Debug, Clone, Copy, Default, Serialize, Deserialize)] +#[derive(Debug, Clone, Copy, Default, Serialize, Deserialize, PartialEq, Eq)] pub enum Network { /// The Ethereum Mainnet #[default] Ethereum, - /// The Taiko Mainnet - Taiko, + /// Taiko A6 tesnet + TaikoA6, + /// Taiko A7 tesnet + TaikoA7, } impl FromStr for Network { @@ -192,7 +203,8 @@ impl FromStr for Network { fn from_str(s: &str) -> Result { match s.to_lowercase().as_str() { "ethereum" => Ok(Network::Ethereum), - "taiko" => Ok(Network::Taiko), + "taiko_a6" => Ok(Network::TaikoA6), + "taiko_a7" => Ok(Network::TaikoA7), #[allow(clippy::needless_return)] _ => bail!("Unknown network"), } @@ -203,7 +215,8 @@ impl ToString for Network { fn to_string(&self) -> String { match self { Network::Ethereum => String::from("ethereum"), - Network::Taiko => String::from("taiko"), + Network::TaikoA6 => String::from("taiko_a6"), + Network::TaikoA7 => String::from("taiko_a7"), } } } diff --git a/lib/src/input.rs b/lib/src/input.rs index a7f494af..b3dd3af2 100644 --- a/lib/src/input.rs +++ b/lib/src/input.rs @@ -21,6 +21,8 @@ use hashbrown::HashMap; use serde::{Deserialize, Serialize}; use zeth_primitives::{mpt::MptNode, Address, Bytes, FixedBytes, B256, U256}; +use crate::consts::Network; + /// Represents the state of an account's storage. /// The storage trie together with the used storage slots allow us to reconstruct all the /// required values. @@ -29,6 +31,8 @@ pub type StorageEntry = (MptNode, Vec); /// External block input. #[derive(Debug, Clone, Deserialize, Serialize)] pub struct GuestInput { + /// The network to generate the proof for + pub network: Network, /// Block hash - for reference! pub block_hash: B256, /// Previous block header @@ -43,8 +47,6 @@ pub struct GuestInput { pub extra_data: Bytes, /// Hash previously used for the PoW now containing the RANDAO value. pub mix_hash: B256, - /// List of transactions for execution - // pub transactions: Vec>, /// List of stake withdrawals for execution pub withdrawals: Vec, /// State trie of the parent block. @@ -63,7 +65,6 @@ pub struct GuestInput { #[derive(Clone, Debug, Default, Serialize, Deserialize)] pub struct TaikoGuestInput { - pub chain_spec_name: String, pub l1_header: AlloyConsensusHeader, pub tx_list: Vec, pub anchor_tx: String, @@ -87,10 +88,8 @@ pub enum GuestOutput { sol! { function anchor( bytes32 l1Hash, - //bytes32 l1StateRoot, - //uint64 l1BlockId, - bytes32 l1SignalRoot, - uint64 l1Height, + bytes32 l1StateRoot, + uint64 l1BlockId, uint32 parentGasUsed ) external @@ -148,8 +147,7 @@ sol! { struct Transition { bytes32 parentHash; bytes32 blockHash; - bytes32 signalRoot; - //bytes32 stateRoot; + bytes32 stateRoot; bytes32 graffiti; } @@ -178,7 +176,7 @@ sol! { function proveBlock(uint64 blockId, bytes calldata input) {} } -pub mod protocol_testnet { +pub mod taiko_a6 { use alloy_sol_types::sol; use serde::{Deserialize, Serialize}; @@ -233,7 +231,6 @@ pub mod protocol_testnet { bytes32 parentHash; bytes32 blockHash; bytes32 signalRoot; - //bytes32 stateRoot; bytes32 graffiti; } @@ -263,8 +260,8 @@ pub mod protocol_testnet { } } -impl From for EthDeposit { - fn from(item: protocol_testnet::EthDeposit) -> Self { +impl From for EthDeposit { + fn from(item: taiko_a6::EthDeposit) -> Self { EthDeposit { recipient: item.recipient, amount: item.amount, @@ -273,8 +270,8 @@ impl From for EthDeposit { } } -impl From for BlockProposed { - fn from(item: protocol_testnet::BlockProposed) -> Self { +impl From for BlockProposed { + fn from(item: taiko_a6::BlockProposed) -> Self { BlockProposed { blockId: item.blockId, assignedProver: item.assignedProver, @@ -313,6 +310,7 @@ mod tests { #[test] fn input_serde_roundtrip() { let input = GuestInput { + network: Default::default(), block_hash: Default::default(), parent_header: Default::default(), beneficiary: Default::default(), @@ -320,7 +318,6 @@ mod tests { timestamp: Default::default(), extra_data: Default::default(), mix_hash: Default::default(), - // transactions: vec![], withdrawals: vec![], parent_state_trie: Default::default(), parent_storage: Default::default(), diff --git a/lib/src/protocol_instance.rs b/lib/src/protocol_instance.rs index 77d6d857..b243d8c2 100644 --- a/lib/src/protocol_instance.rs +++ b/lib/src/protocol_instance.rs @@ -96,7 +96,7 @@ pub fn assemble_protocol_instance( transition: Transition { parentHash: header.parent_hash, blockHash: header.hash(), - signalRoot: input.taiko.l1_header.state_root, + stateRoot: input.taiko.l1_header.state_root, graffiti: input.taiko.prover_data.graffiti, }, block_metadata: BlockMetadata { diff --git a/lib/src/taiko_utils.rs b/lib/src/taiko_utils.rs index 6f493c07..0e48dc30 100644 --- a/lib/src/taiko_utils.rs +++ b/lib/src/taiko_utils.rs @@ -9,7 +9,10 @@ use anyhow::{anyhow, bail, ensure, Context, Result}; use once_cell::unsync::Lazy; use zeth_primitives::{keccak256, B256}; -use crate::input::{decode_anchor, GuestInput}; +use crate::{ + consts::{get_network_spec, Network}, + input::{decode_anchor, GuestInput}, +}; pub const ANCHOR_GAS_LIMIT: u64 = 250_000; pub const GOLDEN_TOUCH_ACCOUNT: Lazy
= Lazy::new(|| { @@ -21,62 +24,6 @@ pub const SGX_VERIFIER_ADDRESS: Lazy
= Lazy::new(|| { .expect("invalid sgx verifier contract address") }); -macro_rules! taiko_contracts { - ($name:ident) => {{ - use crate::taiko_utils::$name::*; - Ok((*L1_CONTRACT, *L2_CONTRACT)) - }}; -} - -pub fn get_contracts(name: &str) -> Result<(Address, Address)> { - match name { - "testnet" => taiko_contracts!(testnet), - "internal_devnet_a" => taiko_contracts!(internal_devnet_a), - "internal_devnet_b" => taiko_contracts!(internal_devnet_b), - #[allow(clippy::needless_return)] - _ => bail!("invalid chain name: {name}"), - } -} - -pub mod testnet { - use super::*; - pub const CHAIN_ID: u64 = 167008; - pub const L1_CONTRACT: Lazy
= Lazy::new(|| { - Address::from_str("0xB20BB9105e007Bd3E0F73d63D4D3dA2c8f736b77") - .expect("invalid l1 contract address") - }); - pub const L2_CONTRACT: Lazy
= Lazy::new(|| { - Address::from_str("0x1670080000000000000000000000000000010001") - .expect("invalid l2 contract address") - }); -} - -pub mod internal_devnet_a { - use super::*; - pub const CHAIN_ID: u64 = 167001; - pub const L1_CONTRACT: Lazy
= Lazy::new(|| { - Address::from_str("0x78155FaC733356cbA069245A435Eb114e7fd815d") - .expect("invalid l1 contract address") - }); - pub const L2_CONTRACT: Lazy
= Lazy::new(|| { - Address::from_str("0x1670010000000000000000000000000000010001") - .expect("invalid l2 contract address") - }); -} - -pub mod internal_devnet_b { - use super::*; - pub const CHAIN_ID: u64 = 167002; - pub const L1_CONTRACT: Lazy
= Lazy::new(|| { - Address::from_str("0x674313F932cc0cE272154a288cf3De474D44e14F") - .expect("invalid l1 contract address") - }); - pub const L2_CONTRACT: Lazy
= Lazy::new(|| { - Address::from_str("0x1670020000000000000000000000000000010001") - .expect("invalid l2 contract address") - }); -} - pub fn decode_transactions(tx_list: &[u8]) -> Vec { alloy_rlp::Decodable::decode(&mut &tx_list.to_owned()[..]).unwrap_or_default() } @@ -155,7 +102,7 @@ pub fn check_anchor_tx( input: &GuestInput, anchor: &TxEnvelope, from: &Address, - chain_name: &str, + network: Network, ) -> Result<()> { match anchor { TxEnvelope::Eip1559(tx) => { @@ -175,7 +122,7 @@ pub fn check_anchor_tx( ); // Check that the L2 contract is being called ensure!( - to == get_contracts(chain_name).unwrap().1, + to == get_network_spec(network).l2_contract.unwrap(), "anchor transaction to mismatch" ); // Tx can't have any ETH attached @@ -201,14 +148,14 @@ pub fn check_anchor_tx( anchor_call.l1Hash == input.taiko.l1_header.hash(), "L1 hash mismatch" ); - if chain_name != "testnet" { + if network == Network::TaikoA7 { ensure!( - anchor_call.l1SignalRoot == input.taiko.l1_header.state_root, + anchor_call.l1StateRoot == input.taiko.l1_header.state_root, "L1 state root mismatch" ); } ensure!( - anchor_call.l1Height == input.taiko.l1_header.number, + anchor_call.l1BlockId == input.taiko.l1_header.number, "L1 block number mismatch" ); // The parent gas used input needs to match the gas used value of the parent block @@ -237,6 +184,8 @@ impl HeaderHasher for AlloyConsensusHeader { } } +/// Convert from an Alloy RPC header to an ALloy Consensus Header +/// which can be serialized and can be used to generate the block hash. pub fn to_header(header: &AlloyHeader) -> AlloyConsensusHeader { AlloyConsensusHeader { parent_hash: header.parent_hash, diff --git a/primitives/src/signature.rs b/primitives/src/signature.rs index c398cfaa..ffc95310 100644 --- a/primitives/src/signature.rs +++ b/primitives/src/signature.rs @@ -71,18 +71,17 @@ const SECP256K1N_HALF: U256 = U256::from_be_bytes([ // Converts a public key into an ethereum address by hashing the encoded public key with // keccak256. // pub fn public_key_to_address(public: PublicKey) -> Address { -// let pubkey_bytes = -// public.to_encoded_point(false).as_bytes().try_into().expect("The slice has 65 bytes"); -// public_key_bytes_to_address(&pubkey_bytes) -// strip out the first byte because that should be the SECP256K1_TAG_PUBKEY_UNCOMPRESSED -// tag returned by libsecp's uncompressed pubkey serialization -// let hash = keccak256(&public.serialize_uncompressed()[1..]); -// Address::from_slice(&hash[12..]) +// let pubkey_bytes = +// public.to_encoded_point(false).as_bytes().try_into().expect("The slice has 65 +// bytes"); public_key_bytes_to_address(&pubkey_bytes); +// // strip out the first byte because that should be the +// SECP256K1_TAG_PUBKEY_UNCOMPRESSED // tag returned by libsecp's uncompressed pubkey +// serialization let hash = keccak(&public.serialize_uncompressed()[1..]); +// Address::from_slice(&hash[12..]) // } -// + // fn public_key_bytes_to_address(public: &[u8; 65]) -> Address { -// Strip out first byte of sec1 encoded pubkey -// let hash = keccak(&public[1..]); -// Address::from_slice(&hash[12..]) +// // Strip out first byte of sec1 encoded pubkey +// let hash = keccak(&public[1..]); +// Address::from_slice(&hash[12..]) // } -// diff --git a/prove_block.sh b/prove_block.sh index 8b40c652..5ffa189f 100755 --- a/prove_block.sh +++ b/prove_block.sh @@ -9,14 +9,14 @@ rangeStart="$3" rangeEnd="$4" # Check the caain name and set the corresponding RPC values -if [ "$chain" == "testnet" ]; then +if [ "$chain" == "taiko_a6" ]; then l2Rpc="https://rpc.katla.taiko.xyz" l1Rpc="https://l1rpc.katla.taiko.xyz" -elif [ "$chain" == "internal_devnet_a" ]; then +elif [ "$chain" == "taiko_a7" ]; then l2Rpc="https://rpc.internal.taiko.xyz" l1Rpc="https://l1rpc.internal.taiko.xyz" else - echo "Invalid chain name. Please use 'testnet' or 'internal_devnet_a'." + echo "Invalid chain name. Please use 'taiko_a6' or 'taiko_a7'." exit 1 fi @@ -43,7 +43,7 @@ elif [ "$proof" == "risc0-bonsai" ]; then } }' else - echo "Invalid proof name. Please use 'native' or 'risc0[-bonsai]'." + echo "Invalid proof name. Please use 'native', 'risc0[-bonsai]', or 'succinct'." exit 1 fi diff --git a/raiko-host/src/host/host.rs b/raiko-host/src/host/host.rs index ac5e5774..9644cc51 100644 --- a/raiko-host/src/host/host.rs +++ b/raiko-host/src/host/host.rs @@ -18,11 +18,12 @@ use serde::{Deserialize, Serialize}; use url::Url; use zeth_lib::{ builder::{prepare::TaikoHeaderPrepStrategy, BlockBuilder, TkoTxExecStrategy}, + consts::{get_network_spec, Network}, input::{ - decode_anchor, proposeBlockCall, protocol_testnet::BlockProposed as TestnetBlockProposed, + decode_anchor, proposeBlockCall, taiko_a6::BlockProposed as TestnetBlockProposed, BlockProposed, GuestInput, TaikoGuestInput, TaikoProverData, }, - taiko_utils::{generate_transactions, get_contracts, to_header}, + taiko_utils::{generate_transactions, to_header}, }; use zeth_primitives::mpt::proofs_to_tries; @@ -51,7 +52,7 @@ pub fn preflight( l1_rpc_url: Option, l2_rpc_url: Option, l2_block_no: u64, - chain_spec_name: &str, + network: Network, prover_data: TaikoProverData, beacon_rpc_url: Option, ) -> Result { @@ -71,13 +72,13 @@ pub fn preflight( }; let anchor_call = decode_anchor(anchor_tx.input.as_ref())?; // The L1 blocks we need - let l1_state_block_no = anchor_call.l1Height; + let l1_state_block_no = anchor_call.l1BlockId; let l1_inclusion_block_no = l1_state_block_no + 1; println!("block.hash: {:?}", block.header.hash.unwrap()); println!("block.parent_hash: {:?}", block.header.parent_hash); - println!("anchor L1 block id: {:?}", anchor_call.l1Height); - println!("anchor L1 state root: {:?}", anchor_call.l1SignalRoot); + println!("anchor L1 block id: {:?}", anchor_call.l1BlockId); + println!("anchor L1 state root: {:?}", anchor_call.l1StateRoot); // Get the L1 state block header so that we can prove the L1 state root let l1_inclusion_block = get_block(&provider_l1, l1_inclusion_block_no, false).unwrap(); @@ -88,9 +89,9 @@ pub fn preflight( ); // Get the block proposal data - let (proposal_tx, proposal_event) = get_log( + let (proposal_tx, proposal_event) = get_block_proposed_event( l1_rpc_url.clone().unwrap(), - chain_spec_name, + network, l1_inclusion_block.header.hash.unwrap(), l2_block_no, )?; @@ -135,7 +136,6 @@ pub fn preflight( // Create the input struct without the block data set let taiko_guest_input = TaikoGuestInput { - chain_spec_name: chain_spec_name.to_string(), l1_header: to_header(&l1_state_block.header), tx_list, anchor_tx: serde_json::to_string(&anchor_tx).unwrap(), @@ -144,6 +144,7 @@ pub fn preflight( prover_data, }; let input = GuestInput { + network, block_hash: block.header.hash.unwrap().0.try_into().unwrap(), beneficiary: block.header.miner, gas_limit: block.header.gas_limit.try_into().unwrap(), @@ -375,9 +376,9 @@ pub fn get_block(provider: &HttpProvider, block_number: u64, full: bool) -> Resu } } -pub fn get_log( +pub fn get_block_proposed_event( rpc_url: String, - chain_name: &str, + network: Network, block_hash: B256, l2_block_no: u64, ) -> Result<(AlloyRpcTransaction, BlockProposed)> { @@ -386,10 +387,10 @@ pub fn get_log( let tokio_handle = tokio::runtime::Handle::current(); // Get the address that emited the event - let l1_address = get_contracts(chain_name).unwrap().0; + let l1_address = get_network_spec(network).l1_contract.unwrap(); // Get the event signature (value can differ between chains) - let event_signature = if chain_name == "testnet" { + let event_signature = if network == Network::TaikoA6 { TestnetBlockProposed::SIGNATURE_HASH } else { BlockProposed::SIGNATURE_HASH @@ -405,7 +406,7 @@ pub fn get_log( // Run over the logs returned to find the matching event for the specified L2 block number // (there can be multiple blocks proposed in the same block and even same tx) for log in logs { - if chain_name == "testnet" { + if network == Network::TaikoA6 { let event = TestnetBlockProposed::decode_log( &Log::new(log.address, log.topics, log.data).unwrap(), false, diff --git a/raiko-host/src/prover/execution.rs b/raiko-host/src/prover/execution.rs index 319b1512..5e2c47f6 100644 --- a/raiko-host/src/prover/execution.rs +++ b/raiko-host/src/prover/execution.rs @@ -1,8 +1,9 @@ -use std::time::Instant; +use std::{str::FromStr, time::Instant}; use tracing::{info, warn}; use zeth_lib::{ builder::{BlockBuilderStrategy, TaikoStrategy}, + consts::Network, input::{GuestInput, GuestOutput, TaikoProverData}, protocol_instance::{assemble_protocol_instance, EvidenceType}, taiko_utils::HeaderHasher, @@ -136,7 +137,7 @@ pub async fn prepare_input(ctx: &mut Context, req: ProofRequest) -> Result