Skip to content

Commit

Permalink
chore: bumps select alloy crates to 0.6 (#1854)
Browse files Browse the repository at this point in the history
* chore: update select alloy crates to 0.6

* fix: bumped types

* Update examples/block_traces/src/main.rs

* Update examples/block_traces/src/main.rs

* Update examples/block_traces/src/main.rs
  • Loading branch information
bsh98 authored Dec 6, 2024
1 parent 56ed6a3 commit 64f3843
Show file tree
Hide file tree
Showing 8 changed files with 156 additions and 76 deletions.
168 changes: 120 additions & 48 deletions Cargo.lock

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions crates/database/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ tokio = { version = "1.40", features = [
"rt-multi-thread",
"macros",
], optional = true }
alloy-provider = { version = "0.4.2", optional = true, default-features = false }
alloy-eips = { version = "0.4.2", optional = true, default-features = false }
alloy-transport = { version = "0.4.2", optional = true, default-features = false }
alloy-provider = { version = "0.6", optional = true, default-features = false }
alloy-eips = { version = "0.6", optional = true, default-features = false }
alloy-transport = { version = "0.6", optional = true, default-features = false }


[dev-dependencies]
Expand Down
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 @@ -78,7 +81,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
2 changes: 1 addition & 1 deletion crates/revm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ indicatif = "0.17"
reqwest = { version = "0.12" }
rstest = "0.22.0"

alloy-provider = "0.4.2"
alloy-provider = "0.6"

[features]
default = ["std", "c-kzg", "secp256k1", "portable", "blst"]
Expand Down
5 changes: 3 additions & 2 deletions examples/block_traces/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@ inspector = { workspace = true, features = ["std", "serde-json"] }
tokio = { version = "1.40", features = ["rt-multi-thread", "macros"] }

# alloy
alloy-eips = "0.4.2"
alloy-provider = "0.4.2"
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::{inspectors::TracerEip3155, InspectorContext, InspectorEthFrame, InspectorMainEvm};
Expand Down Expand Up @@ -56,7 +60,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 @@ -79,7 +86,7 @@ async fn main() -> anyhow::Result<()> {
.with_db(&mut state)
.modify_block_chained(|b| {
b.number = U256::from(block.header.number);
b.beneficiary = block.header.miner;
b.beneficiary = block.header.beneficiary;
b.timestamp = U256::from(block.header.timestamp);

b.difficulty = block.header.difficulty;
Expand Down Expand Up @@ -120,23 +127,20 @@ async fn main() -> anyhow::Result<()> {
for tx in transactions {
evm.context.inner.modify_tx(|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.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
4 changes: 2 additions & 2 deletions examples/uniswap_get_reserves/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ tokio = { version = "1.40", features = ["rt-multi-thread", "macros"] }
alloy-sol-types = { version = "0.8.2", default-features = false, features = [
"std",
] }
alloy-eips = "0.4.2"
alloy-provider = "0.4.2"
alloy-eips = "0.6"
alloy-provider = "0.6"

# mics
anyhow = "1.0.89"
6 changes: 3 additions & 3 deletions examples/uniswap_v2_usdc_swap/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ tokio = { version = "1.40", features = ["rt-multi-thread", "macros"] }
alloy-sol-types = { version = "0.8.2", default-features = false, features = [
"std",
] }
alloy-eips = "0.4.2"
alloy-transport-http = "0.4.2"
alloy-provider = "0.4.2"
alloy-eips = "0.6"
alloy-transport-http = "0.6"
alloy-provider = "0.6"
reqwest = { version = "0.12" }
anyhow = "1.0.89"

0 comments on commit 64f3843

Please sign in to comment.