diff --git a/Cargo.lock b/Cargo.lock index aa537533fa..929271952a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1409,6 +1409,7 @@ dependencies = [ name = "example-block-traces" version = "0.0.0" dependencies = [ + "alloy-consensus", "alloy-eips", "alloy-provider", "anyhow", diff --git a/crates/database/src/alloydb.rs b/crates/database/src/alloydb.rs index 2572a6e70f..2d0277cb96 100644 --- a/crates/database/src/alloydb.rs +++ b/crates/database/src/alloydb.rs @@ -1,6 +1,9 @@ pub use alloy_eips::BlockId; use alloy_provider::{ - network::{BlockResponse, HeaderResponse}, + network::{ + primitives::{BlockTransactionsKind, HeaderResponse}, + BlockResponse, + }, Network, Provider, }; use alloy_transport::{Transport, TransportError}; @@ -67,7 +70,7 @@ impl> DatabaseAsyncRef for A let block = self .provider // SAFETY: We know number <= u64::MAX, so we can safely convert it to u64 - .get_block_by_number(number.into(), false) + .get_block_by_number(number.into(), BlockTransactionsKind::Hashes) .await?; // SAFETY: If the number is given, the block is supposed to be finalized, so unwrapping is safe. Ok(B256::new(*block.unwrap().header().hash())) diff --git a/examples/block_traces/Cargo.toml b/examples/block_traces/Cargo.toml index 818f51e421..f63c732be9 100644 --- a/examples/block_traces/Cargo.toml +++ b/examples/block_traces/Cargo.toml @@ -32,6 +32,7 @@ tokio = { version = "1.40", features = ["rt-multi-thread", "macros"] } # alloy alloy-eips = "0.6" alloy-provider = "0.6" +alloy-consensus = "0.6" # progress bar indicatif = "0.17" diff --git a/examples/block_traces/src/main.rs b/examples/block_traces/src/main.rs index a02ccfbc34..a81665cad4 100644 --- a/examples/block_traces/src/main.rs +++ b/examples/block_traces/src/main.rs @@ -1,8 +1,12 @@ //! Optimism-specific constants, types, and helpers. #![cfg_attr(not(test), warn(unused_crate_dependencies))] +use alloy_consensus::Transaction; use alloy_eips::{BlockId, BlockNumberOrTag}; -use alloy_provider::{network::primitives::BlockTransactions, Provider, ProviderBuilder}; +use alloy_provider::{ + network::primitives::{BlockTransactions, BlockTransactionsKind}, + Provider, ProviderBuilder, +}; use database::{AlloyDB, CacheDB, StateBuilder}; use indicatif::ProgressBar; use inspector::{inspector_handle_register, inspectors::TracerEip3155}; @@ -53,7 +57,10 @@ async fn main() -> anyhow::Result<()> { // Fetch the transaction-rich block let block = match client - .get_block_by_number(BlockNumberOrTag::Number(block_number), true) + .get_block_by_number( + BlockNumberOrTag::Number(block_number), + BlockTransactionsKind::Full, + ) .await { Ok(Some(block)) => block, @@ -75,7 +82,7 @@ async fn main() -> anyhow::Result<()> { .with_external_context(TracerEip3155::new(Box::new(std::io::stdout()))) .modify_block_env(|b| { b.number = U256::from(block.header.number); - b.coinbase = block.header.miner; + b.coinbase = block.header.inner.beneficiary; b.timestamp = U256::from(block.header.timestamp); b.difficulty = block.header.difficulty; @@ -111,23 +118,20 @@ async fn main() -> anyhow::Result<()> { .modify() .modify_tx_env(|etx| { etx.caller = tx.from; - etx.gas_limit = tx.gas; - etx.gas_price = U256::from( - tx.gas_price - .unwrap_or(tx.max_fee_per_gas.unwrap_or_default()), - ); - etx.value = tx.value; - etx.data = tx.input.0.into(); - etx.gas_priority_fee = tx.max_priority_fee_per_gas.map(U256::from); + etx.gas_limit = tx.gas_limit(); + etx.gas_price = U256::from(tx.gas_price().unwrap_or(tx.inner.max_fee_per_gas())); + etx.value = tx.value(); + etx.data = tx.input().to_owned(); + etx.gas_priority_fee = tx.max_priority_fee_per_gas().map(U256::from); etx.chain_id = Some(chain_id); - etx.nonce = tx.nonce; - if let Some(access_list) = tx.access_list { - etx.access_list = access_list; + etx.nonce = tx.nonce(); + if let Some(access_list) = tx.inner.access_list() { + etx.access_list = access_list.to_owned(); } else { etx.access_list = Default::default(); } - etx.transact_to = match tx.to { + etx.transact_to = match tx.to() { Some(to_address) => TxKind::Call(to_address), None => TxKind::Create, };