Skip to content

Commit

Permalink
fix: bumped types
Browse files Browse the repository at this point in the history
  • Loading branch information
bsh98 committed Nov 15, 2024
1 parent f393be2 commit 0e57476
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 17 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

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

7 changes: 5 additions & 2 deletions crates/database/src/alloydb.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand Down Expand Up @@ -67,7 +70,7 @@ impl<T: Transport + Clone, N: Network, P: Provider<T, N>> 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()))
Expand Down
1 change: 1 addition & 0 deletions examples/block_traces/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
34 changes: 19 additions & 15 deletions examples/block_traces/src/main.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand Down Expand Up @@ -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,
Expand All @@ -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;
Expand Down Expand Up @@ -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,
};
Expand Down

0 comments on commit 0e57476

Please sign in to comment.