Skip to content

Commit

Permalink
chore(deps): bump alloy (foundry-rs#8771)
Browse files Browse the repository at this point in the history
* chore(deps): bump alloy

* bump foundry-fork-db

* bump foundry-compilers + revm

* fix(fmt): rm other from `UIfmt` of `Transaction`

* use patch foundry-compilers and alloy

* make utils::apply_chain_and_block_specific_env_changes generic over Network

* make EvmOpts generic over network

* bump block explorers

* use patched core version

* nit

* nit

* squash

* repatch

* anvil: use WithOtherFields<Block<WithOtherFields<T>>

* fix(anvil): otterscan

* fix(anvil): TaskManager

* breaking(anvil): change anvil-api Block return types to WithOtherFields<B<WithOtherFields<Tx>>

* impl UIfmt for WithOtherFields<T>

* fix cast

* fix anvil tests

* nit

* nits

* fix: UIfmt for WithOtherFields

* fix(casttest): interface_no_constructor

* fix UIfmt for WithOtherFields

* nits + allow - evmole in deny

* bump evmole

* use AnyNetworkBlock

* use WithOtherFields in otterscan return types

* bump core to 0.8.1

* Update crates/anvil/src/eth/api.rs

---------

Co-authored-by: DaniPopes <[email protected]>
  • Loading branch information
yash-atreya and DaniPopes authored Sep 6, 2024
1 parent e53255b commit d8f6631
Show file tree
Hide file tree
Showing 42 changed files with 822 additions and 684 deletions.
541 changes: 286 additions & 255 deletions Cargo.lock

Large diffs are not rendered by default.

125 changes: 65 additions & 60 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -157,54 +157,58 @@ foundry-wallets = { path = "crates/wallets" }
foundry-linking = { path = "crates/linking" }

# solc & compilation utilities
foundry-block-explorers = { version = "0.5.1", default-features = false }
foundry-compilers = { version = "0.10.3", default-features = false }
foundry-fork-db = "0.2"
foundry-block-explorers = { version = "0.7.1", default-features = false }
foundry-compilers = { version = "0.11.0", default-features = false }
foundry-fork-db = "0.3"
solang-parser = "=0.3.3"

## revm
# no default features to avoid c-kzg
revm = { version = "13.0.0", default-features = false }
revm-primitives = { version = "8.0.0", default-features = false }
revm-inspectors = { version = "0.5", features = ["serde"] }
revm = { version = "14.0.1", default-features = false }
revm-primitives = { version = "9.0.1", default-features = false }
revm-inspectors = { version = "0.6", features = ["serde"] }

## ethers
ethers-contract-abigen = { version = "2.0.14", default-features = false }

## alloy
alloy-consensus = { version = "0.2.1", default-features = false }
alloy-contract = { version = "0.2.1", default-features = false }
alloy-eips = { version = "0.2.1", default-features = false }
alloy-genesis = { version = "0.2.1", default-features = false }
alloy-json-rpc = { version = "0.2.1", default-features = false }
alloy-network = { version = "0.2.1", default-features = false }
alloy-provider = { version = "0.2.1", default-features = false }
alloy-pubsub = { version = "0.2.1", default-features = false }
alloy-rpc-client = { version = "0.2.1", default-features = false }
alloy-rpc-types = { version = "0.2.1", default-features = true }
alloy-serde = { version = "0.2.1", default-features = false }
alloy-signer = { version = "0.2.1", default-features = false }
alloy-signer-aws = { version = "0.2.1", default-features = false }
alloy-signer-gcp = { version = "0.2.1", default-features = false }
alloy-signer-ledger = { version = "0.2.1", default-features = false }
alloy-signer-local = { version = "0.2.1", default-features = false }
alloy-signer-trezor = { version = "0.2.1", default-features = false }
alloy-transport = { version = "0.2.1", default-features = false }
alloy-transport-http = { version = "0.2.1", default-features = false }
alloy-transport-ipc = { version = "0.2.1", default-features = false }
alloy-transport-ws = { version = "0.2.1", default-features = false }
alloy-consensus = { version = "0.3.1", default-features = false }
alloy-contract = { version = "0.3.1", default-features = false }
alloy-eips = { version = "0.3.1", default-features = false }
alloy-genesis = { version = "0.3.1", default-features = false }
alloy-json-rpc = { version = "0.3.1", default-features = false }
alloy-network = { version = "0.3.1", default-features = false }
alloy-provider = { version = "0.3.1", default-features = false }
alloy-pubsub = { version = "0.3.1", default-features = false }
alloy-rpc-client = { version = "0.3.1", default-features = false }
alloy-rpc-types = { version = "0.3.1", default-features = true }
alloy-serde = { version = "0.3.1", default-features = false }
alloy-signer = { version = "0.3.1", default-features = false }
alloy-signer-aws = { version = "0.3.1", default-features = false }
alloy-signer-gcp = { version = "0.3.1", default-features = false }
alloy-signer-ledger = { version = "0.3.1", default-features = false }
alloy-signer-local = { version = "0.3.1", default-features = false }
alloy-signer-trezor = { version = "0.3.1", default-features = false }
alloy-transport = { version = "0.3.1", default-features = false }
alloy-transport-http = { version = "0.3.1", default-features = false }
alloy-transport-ipc = { version = "0.3.1", default-features = false }
alloy-transport-ws = { version = "0.3.1", default-features = false }

alloy-dyn-abi = "0.7.7"
alloy-json-abi = "0.7.7"
alloy-primitives = { version = "0.7.7", features = ["getrandom", "rand"] }
alloy-sol-macro-expander = "0.7.7"
alloy-sol-macro-input = "0.7.7"
alloy-sol-types = "0.7.7"
syn-solidity = "0.7.7"
## alloy-core
alloy-dyn-abi = "0.8.1"
alloy-json-abi = "0.8.1"
alloy-primitives = { version = "0.8.1", features = ["getrandom", "rand"] }
alloy-sol-macro-expander = "0.8.1"
alloy-sol-macro-input = "0.8.1"
alloy-sol-types = "0.8.1"
syn-solidity = "0.8.1"

alloy-chains = "0.1"
alloy-rlp = "0.3.3"
alloy-trie = "0.4.1"
alloy-rlp = "0.3"
alloy-trie = "0.5.0"

## op-alloy for tests in anvil
op-alloy-rpc-types = "0.2.8"

## misc
async-trait = "0.1"
Expand Down Expand Up @@ -252,7 +256,7 @@ yansi = { version = "1.0", features = ["detect-tty", "detect-env"] }
tempfile = "3.10"
tokio = "1"
rayon = "1"

evmole = "0.5"
axum = "0.7"
hyper = "1.0"
reqwest = { version = "0.12", default-features = false }
Expand All @@ -264,26 +268,27 @@ proptest = "1"
comfy-table = "7"

[patch.crates-io]
alloy-consensus = { git = "https://github.com/alloy-rs/alloy", rev = "511ae98" }
alloy-contract = { git = "https://github.com/alloy-rs/alloy", rev = "511ae98" }
alloy-eips = { git = "https://github.com/alloy-rs/alloy", rev = "511ae98" }
alloy-genesis = { git = "https://github.com/alloy-rs/alloy", rev = "511ae98" }
alloy-json-rpc = { git = "https://github.com/alloy-rs/alloy", rev = "511ae98" }
alloy-network = { git = "https://github.com/alloy-rs/alloy", rev = "511ae98" }
alloy-provider = { git = "https://github.com/alloy-rs/alloy", rev = "511ae98" }
alloy-pubsub = { git = "https://github.com/alloy-rs/alloy", rev = "511ae98" }
alloy-rpc-client = { git = "https://github.com/alloy-rs/alloy", rev = "511ae98" }
alloy-rpc-types = { git = "https://github.com/alloy-rs/alloy", rev = "511ae98" }
alloy-serde = { git = "https://github.com/alloy-rs/alloy", rev = "511ae98" }
alloy-signer = { git = "https://github.com/alloy-rs/alloy", rev = "511ae98" }
alloy-signer-aws = { git = "https://github.com/alloy-rs/alloy", rev = "511ae98" }
alloy-signer-gcp = { git = "https://github.com/alloy-rs/alloy", rev = "511ae98" }
alloy-signer-ledger = { git = "https://github.com/alloy-rs/alloy", rev = "511ae98" }
alloy-signer-local = { git = "https://github.com/alloy-rs/alloy", rev = "511ae98" }
alloy-signer-trezor = { git = "https://github.com/alloy-rs/alloy", rev = "511ae98" }
alloy-transport = { git = "https://github.com/alloy-rs/alloy", rev = "511ae98" }
alloy-transport-http = { git = "https://github.com/alloy-rs/alloy", rev = "511ae98" }
alloy-transport-ipc = { git = "https://github.com/alloy-rs/alloy", rev = "511ae98" }
alloy-transport-ws = { git = "https://github.com/alloy-rs/alloy", rev = "511ae98" }
revm = { git = "https://github.com/bluealloy/revm", rev = "caadc71" }
revm-primitives = { git = "https://github.com/bluealloy/revm", rev = "caadc71" }
# https://github.com/alloy-rs/alloy/pull/1229 + https://github.com/alloy-rs/alloy/pull/1243
alloy-consensus = { git = "https://github.com/alloy-rs/alloy", rev = "7fab7ee" }
alloy-contract = { git = "https://github.com/alloy-rs/alloy", rev = "7fab7ee" }
alloy-eips = { git = "https://github.com/alloy-rs/alloy", rev = "7fab7ee" }
alloy-genesis = { git = "https://github.com/alloy-rs/alloy", rev = "7fab7ee" }
alloy-json-rpc = { git = "https://github.com/alloy-rs/alloy", rev = "7fab7ee" }
alloy-network = { git = "https://github.com/alloy-rs/alloy", rev = "7fab7ee" }
alloy-network-primitives = { git = "https://github.com/alloy-rs/alloy", rev = "7fab7ee" }
alloy-provider = { git = "https://github.com/alloy-rs/alloy", rev = "7fab7ee" }
alloy-pubsub = { git = "https://github.com/alloy-rs/alloy", rev = "7fab7ee" }
alloy-rpc-client = { git = "https://github.com/alloy-rs/alloy", rev = "7fab7ee" }
alloy-rpc-types = { git = "https://github.com/alloy-rs/alloy", rev = "7fab7ee" }
alloy-rpc-types-eth = { git = "https://github.com/alloy-rs/alloy", rev = "7fab7ee" }
alloy-serde = { git = "https://github.com/alloy-rs/alloy", rev = "7fab7ee" }
alloy-signer = { git = "https://github.com/alloy-rs/alloy", rev = "7fab7ee" }
alloy-signer-aws = { git = "https://github.com/alloy-rs/alloy", rev = "7fab7ee" }
alloy-signer-gcp = { git = "https://github.com/alloy-rs/alloy", rev = "7fab7ee" }
alloy-signer-ledger = { git = "https://github.com/alloy-rs/alloy", rev = "7fab7ee" }
alloy-signer-local = { git = "https://github.com/alloy-rs/alloy", rev = "7fab7ee" }
alloy-signer-trezor = { git = "https://github.com/alloy-rs/alloy", rev = "7fab7ee" }
alloy-transport = { git = "https://github.com/alloy-rs/alloy", rev = "7fab7ee" }
alloy-transport-http = { git = "https://github.com/alloy-rs/alloy", rev = "7fab7ee" }
alloy-transport-ipc = { git = "https://github.com/alloy-rs/alloy", rev = "7fab7ee" }
alloy-transport-ws = { git = "https://github.com/alloy-rs/alloy", rev = "7fab7ee" }
1 change: 1 addition & 0 deletions crates/anvil/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ alloy-pubsub.workspace = true
foundry-test-utils.workspace = true
similar-asserts.workspace = true
tokio = { workspace = true, features = ["full"] }
op-alloy-rpc-types.workspace = true

[features]
default = ["cli", "jemalloc"]
Expand Down
5 changes: 0 additions & 5 deletions crates/anvil/core/src/eth/transaction/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,6 @@ pub fn to_alloy_transaction_with_hash_and_sender(
transaction_type: None,
max_fee_per_blob_gas: None,
blob_versioned_hashes: None,
other: Default::default(),
authorization_list: None,
},
TypedTransaction::EIP2930(t) => RpcTransaction {
Expand Down Expand Up @@ -328,7 +327,6 @@ pub fn to_alloy_transaction_with_hash_and_sender(
transaction_type: Some(1),
max_fee_per_blob_gas: None,
blob_versioned_hashes: None,
other: Default::default(),
authorization_list: None,
},
TypedTransaction::EIP1559(t) => RpcTransaction {
Expand Down Expand Up @@ -356,7 +354,6 @@ pub fn to_alloy_transaction_with_hash_and_sender(
transaction_type: Some(2),
max_fee_per_blob_gas: None,
blob_versioned_hashes: None,
other: Default::default(),
authorization_list: None,
},
TypedTransaction::EIP4844(t) => RpcTransaction {
Expand Down Expand Up @@ -384,7 +381,6 @@ pub fn to_alloy_transaction_with_hash_and_sender(
transaction_type: Some(3),
max_fee_per_blob_gas: Some(t.tx().tx().max_fee_per_blob_gas),
blob_versioned_hashes: Some(t.tx().tx().blob_versioned_hashes.clone()),
other: Default::default(),
authorization_list: None,
},
TypedTransaction::EIP7702(t) => RpcTransaction {
Expand Down Expand Up @@ -433,7 +429,6 @@ pub fn to_alloy_transaction_with_hash_and_sender(
transaction_type: None,
max_fee_per_blob_gas: None,
blob_versioned_hashes: None,
other: Default::default(),
authorization_list: None,
},
}
Expand Down
38 changes: 38 additions & 0 deletions crates/anvil/core/src/eth/transaction/optimism.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,44 @@ impl Transaction for DepositTransactionRequest {
fn gas_price(&self) -> Option<u128> {
None
}

fn ty(&self) -> u8 {
0x7E
}

// Below fields are not found in a `DepositTransactionRequest`

fn access_list(&self) -> Option<&alloy_rpc_types::AccessList> {
None
}

fn authorization_list(&self) -> Option<&[revm::primitives::SignedAuthorization]> {
None
}

fn blob_versioned_hashes(&self) -> Option<&[B256]> {
None
}

fn effective_tip_per_gas(&self, _base_fee: u64) -> Option<u128> {
None
}

fn max_fee_per_blob_gas(&self) -> Option<u128> {
None
}

fn max_fee_per_gas(&self) -> u128 {
0
}

fn max_priority_fee_per_gas(&self) -> Option<u128> {
None
}

fn priority_fee_or_price(&self) -> u128 {
0
}
}

impl SignableTransaction<Signature> for DepositTransactionRequest {
Expand Down
23 changes: 12 additions & 11 deletions crates/anvil/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1199,7 +1199,7 @@ latest block number: {latest_block}"
}
}

let block_hash = block.header.hash.unwrap_or_default();
let block_hash = block.header.hash;

let chain_id = if let Some(chain_id) = self.chain_id {
chain_id
Expand All @@ -1218,7 +1218,7 @@ latest block number: {latest_block}"
};
let override_chain_id = self.chain_id;
// apply changes such as difficulty -> prevrandao and chain specifics for current chain id
apply_chain_and_block_specific_env_changes(env, &block);
apply_chain_and_block_specific_env_changes::<AnyNetwork>(env, &block);

let meta = BlockchainDbMeta::new(*env.env.clone(), eth_rpc_url.clone());
let block_chain_db = if self.fork_chain_id.is_some() {
Expand Down Expand Up @@ -1289,18 +1289,19 @@ async fn derive_block_and_transactions(
.ok_or(eyre::eyre!("Failed to get fork block by number"))?;

// Filter out transactions that are after the fork transaction
let filtered_transactions: Vec<&Transaction> = transaction_block
.transactions
.as_transactions()
.ok_or(eyre::eyre!("Failed to get transactions from full fork block"))?
.iter()
.take_while_inclusive(|&transaction| transaction.hash != transaction_hash.0)
.collect();
let filtered_transactions: Vec<&alloy_serde::WithOtherFields<Transaction>> =
transaction_block
.transactions
.as_transactions()
.ok_or(eyre::eyre!("Failed to get transactions from full fork block"))?
.iter()
.take_while_inclusive(|&transaction| transaction.hash != transaction_hash.0)
.collect();

// Convert the transactions to PoolTransactions
let force_transactions = filtered_transactions
.iter()
.map(|&transaction| PoolTransaction::try_from(transaction.clone()))
.map(|&transaction| PoolTransaction::try_from(transaction.clone().inner))
.collect::<Result<Vec<_>, _>>()?;
Ok((transaction_block_number.saturating_sub(1), Some(force_transactions)))
}
Expand Down Expand Up @@ -1461,7 +1462,7 @@ async fn find_latest_fork_block<P: Provider<T, AnyNetwork>, T: Transport + Clone
// leeway
for _ in 0..2 {
if let Some(block) = provider.get_block(num.into(), false.into()).await? {
if block.header.hash.is_some() {
if !block.header.hash.is_zero() {
break;
}
}
Expand Down
Loading

0 comments on commit d8f6631

Please sign in to comment.