Skip to content

bump: alloy + revm + alloy-evm #10454

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 16 commits into
base: zerosnacks/revm-bump-2
Choose a base branch
from
Draft
1,461 changes: 1,008 additions & 453 deletions Cargo.lock

Large diffs are not rendered by default.

90 changes: 47 additions & 43 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -195,63 +195,65 @@ foundry-wallets = { path = "crates/wallets" }
foundry-linking = { path = "crates/linking" }

# solc & compilation utilities
foundry-block-explorers = { version = "0.13.0", default-features = false }
foundry-compilers = { version = "0.14.0", default-features = false }
foundry-block-explorers = { version = "0.14.0", default-features = false }
foundry-compilers = { version = "0.15.0", default-features = false }
foundry-fork-db = "0.12"
solang-parser = "=0.3.3"
solar-parse = { version = "=0.1.2", default-features = false }
solar-sema = { version = "=0.1.2", default-features = false }

## revm
revm = { version = "21.0.0", default-features = false }
revm-inspectors = { version = "0.18.1", features = ["serde"] }
op-revm = { version = "2.0.0", default-features = false }
revm = { version = "23.0.0", default-features = false }
revm-inspectors = { version = "0.20.1", features = ["serde"] }
op-revm = { version = "3.1.0", default-features = false }

## alloy-evm
alloy-evm = "0.6.0"
alloy-op-evm = "0.6.0"

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

## alloy-core
alloy-dyn-abi = "0.8.22"
alloy-json-abi = "0.8.22"
alloy-primitives = { version = "0.8.22", features = [
alloy-dyn-abi = "1.0"
alloy-json-abi = "1.0"
alloy-primitives = { version = "1.0", features = [
"getrandom",
"rand",
"map-fxhash",
"map-foldhash",
] }
alloy-sol-macro-expander = "0.8.22"
alloy-sol-macro-input = "0.8.22"
alloy-sol-types = "0.8.22"
alloy-sol-macro-expander = "1.0"
alloy-sol-macro-input = "1.0"
alloy-sol-types = "1.0"

alloy-chains = "0.1"
alloy-evm = "0.3.2"
alloy-op-evm = "0.3.2"
alloy-chains = "0.2"
alloy-rlp = "0.3"
alloy-trie = "0.7.0"
alloy-trie = "0.8.0"

## op-alloy
op-alloy-consensus = "0.12.0"
op-alloy-rpc-types = "0.12.0"
op-alloy-consensus = "0.15.4"
op-alloy-rpc-types = "0.15.4"

## cli
anstream = "0.6"
Expand Down Expand Up @@ -298,7 +300,9 @@ mesc = "0.3"
num-format = "0.4"
parking_lot = "0.12"
proptest = "1"
rand = "0.8"
rand = "0.9"
rand_08 = { package = "rand", version = "0.8" }
rand_chacha = "0.9.0"
rayon = "1"
regex = { version = "1", default-features = false }
reqwest = { version = "0.12", default-features = false, features = [
Expand Down Expand Up @@ -369,10 +373,10 @@ idna_adapter = "=1.1.0"
# alloy-transport-ipc = { git = "https://github.com/alloy-rs/alloy", rev = "7fab7ee" }
# alloy-transport-ws = { git = "https://github.com/alloy-rs/alloy", rev = "7fab7ee" }

## revm
revm = { git = "https://github.com/bluealloy/revm.git", rev = "2540c3f3" }
op-revm = { git = "https://github.com/bluealloy/revm.git", rev = "2540c3f3" }
## revm 21 patches
# revm = { git = "https://github.com/bluealloy/revm.git", rev = "2540c3f3" }
# op-revm = { git = "https://github.com/bluealloy/revm.git", rev = "2540c3f3" }
# revm-inspectors = { git = "https://github.com/paradigmxyz/revm-inspectors.git", rev = "a625c04" }

## foundry
foundry-fork-db = { git = "https://github.com/foundry-rs/foundry-fork-db", rev = "6144088" }
foundry-fork-db = { git = "https://github.com/foundry-rs/foundry-fork-db", rev = "cdbbe64" } # Pinned to main
1 change: 1 addition & 0 deletions crates/anvil/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ yansi.workspace = true
tempfile.workspace = true
itertools.workspace = true
rand.workspace = true
rand_08.workspace = true
eyre.workspace = true

# cli
Expand Down
1 change: 1 addition & 0 deletions crates/anvil/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,5 @@ bytes.workspace = true

# misc
rand.workspace = true
rand_08.workspace = true
thiserror.workspace = true
4 changes: 2 additions & 2 deletions crates/anvil/core/src/eth/subscription.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Subscription types
use alloy_primitives::hex;
use rand::{distributions::Alphanumeric, thread_rng, Rng};
use rand::{distr::Alphanumeric, rng, Rng};
use std::fmt;

/// Unique subscription id
Expand Down Expand Up @@ -48,7 +48,7 @@ impl HexIdProvider {
/// Generates a random hex encoded Id
pub fn gen(&self) -> String {
let id: String =
(&mut thread_rng()).sample_iter(Alphanumeric).map(char::from).take(self.len).collect();
(&mut rng()).sample_iter(Alphanumeric).map(char::from).take(self.len).collect();
let out = hex::encode(id);
format!("0x{out}")
}
Expand Down
10 changes: 4 additions & 6 deletions crates/anvil/core/src/eth/transaction/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ use alloy_consensus::{
};
use alloy_eips::eip2718::{Decodable2718, Eip2718Error, Encodable2718};
use alloy_network::{AnyReceiptEnvelope, AnyRpcTransaction, AnyTransactionReceipt, AnyTxEnvelope};
use alloy_primitives::{
Address, Bloom, Bytes, Log, PrimitiveSignature, TxHash, TxKind, B256, U256, U64,
};
use alloy_primitives::{Address, Bloom, Bytes, Log, Signature, TxHash, TxKind, B256, U256, U64};
use alloy_rlp::{length_of_length, Decodable, Encodable, Header};
use alloy_rpc_types::{
request::TransactionRequest, trace::otterscan::OtsReceipt, AccessList, ConversionError,
Expand Down Expand Up @@ -989,14 +987,14 @@ impl TypedTransaction {
}

/// Returns the Signature of the transaction
pub fn signature(&self) -> PrimitiveSignature {
pub fn signature(&self) -> Signature {
match self {
Self::Legacy(tx) => *tx.signature(),
Self::EIP2930(tx) => *tx.signature(),
Self::EIP1559(tx) => *tx.signature(),
Self::EIP4844(tx) => *tx.signature(),
Self::EIP7702(tx) => *tx.signature(),
Self::Deposit(_) => PrimitiveSignature::from_scalars_and_parity(
Self::Deposit(_) => Signature::from_scalars_and_parity(
B256::with_last_byte(1),
B256::with_last_byte(1),
false,
Expand Down Expand Up @@ -1548,7 +1546,7 @@ mod tests {
chain_id: Some(4),
};

let signature = PrimitiveSignature::from_str("0eb96ca19e8a77102767a41fc85a36afd5c61ccb09911cec5d3e86e193d9c5ae3a456401896b1b6055311536bf00a718568c744d8c1f9df59879e8350220ca182b").unwrap();
let signature = Signature::from_str("0eb96ca19e8a77102767a41fc85a36afd5c61ccb09911cec5d3e86e193d9c5ae3a456401896b1b6055311536bf00a718568c744d8c1f9df59879e8350220ca182b").unwrap();

let tx = TypedTransaction::Legacy(Signed::new_unchecked(
tx,
Expand Down
4 changes: 2 additions & 2 deletions crates/anvil/src/cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use core::fmt;
use foundry_common::shell;
use foundry_config::{Chain, Config, FigmentProviders};
use futures::FutureExt;
use rand::{rngs::StdRng, SeedableRng};
use rand_08::{rngs::StdRng, SeedableRng};
use std::{
future::Future,
net::IpAddr,
Expand Down Expand Up @@ -292,7 +292,7 @@ impl NodeArgs {
if let Some(ref mnemonic) = self.mnemonic {
gen = gen.phrase(mnemonic);
} else if let Some(count) = self.mnemonic_random {
let mut rng = rand::thread_rng();
let mut rng = rand_08::thread_rng();
let mnemonic = match Mnemonic::<English>::new_with_count(&mut rng, count) {
Ok(mnemonic) => mnemonic.to_phrase(),
Err(_) => DEFAULT_MNEMONIC.to_string(),
Expand Down
2 changes: 1 addition & 1 deletion crates/anvil/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ use foundry_evm::{
};
use itertools::Itertools;
use parking_lot::RwLock;
use rand::thread_rng;
use rand_08::thread_rng;
use revm::{
context::{BlockEnv, TxEnv},
context_interface::block::BlobExcessGasAndPrice,
Expand Down
2 changes: 1 addition & 1 deletion crates/anvil/src/eth/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ use alloy_network::{
};
use alloy_primitives::{
map::{HashMap, HashSet},
Address, Bytes, PrimitiveSignature as Signature, TxHash, TxKind, B256, B64, U256, U64,
Address, Bytes, Signature, TxHash, TxKind, B256, B64, U256, U64,
};
use alloy_provider::utils::{
eip1559_default_estimator, EIP1559_FEE_ESTIMATION_PAST_BLOCKS,
Expand Down
5 changes: 4 additions & 1 deletion crates/anvil/src/eth/backend/executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,10 @@ impl<DB: Db + ?Sized, V: TransactionValidator> Iterator for &mut TransactionExec
let max_blob_gas = self.blob_gas_used.saturating_add(
transaction.pending_transaction.transaction.transaction.blob_gas().unwrap_or(0),
);
if max_blob_gas > alloy_eips::eip4844::MAX_DATA_GAS_PER_BLOCK {
if max_blob_gas >
(alloy_eips::eip4844::DATA_GAS_PER_BLOB *
alloy_eips::eip7691::MAX_BLOBS_PER_BLOCK_ELECTRA)
{
return Some(TransactionExecutionOutcome::BlobGasExhausted(transaction))
}

Expand Down
9 changes: 6 additions & 3 deletions crates/anvil/src/eth/backend/mem/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ use alloy_consensus::{
transaction::Recovered, Account, BlockHeader, EnvKzgSettings, Header, Receipt,
ReceiptWithBloom, Signed, Transaction as TransactionTrait, TxEnvelope,
};
use alloy_eips::{eip1559::BaseFeeParams, eip4844::MAX_BLOBS_PER_BLOCK};
use alloy_eips::{eip1559::BaseFeeParams, eip7691::MAX_BLOBS_PER_BLOCK_ELECTRA};
use alloy_evm::{eth::EthEvmContext, Database, Evm};
use alloy_network::{
AnyHeader, AnyRpcBlock, AnyRpcHeader, AnyRpcTransaction, AnyTxEnvelope, AnyTxType,
Expand Down Expand Up @@ -3087,8 +3087,11 @@ impl TransactionValidator for Backend {
}

// Ensure the tx does not exceed the max blobs per block.
if blob_count > MAX_BLOBS_PER_BLOCK {
return Err(InvalidTransactionError::TooManyBlobs(blob_count, MAX_BLOBS_PER_BLOCK))
if blob_count > MAX_BLOBS_PER_BLOCK_ELECTRA as usize {
return Err(InvalidTransactionError::TooManyBlobs(
blob_count,
MAX_BLOBS_PER_BLOCK_ELECTRA as usize,
))
}

// Check for any blob validation errors if not impersonating.
Expand Down
4 changes: 2 additions & 2 deletions crates/anvil/src/eth/fees.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use std::{

use alloy_consensus::Header;
use alloy_eips::{
calc_next_block_base_fee, eip1559::BaseFeeParams, eip4844::MAX_DATA_GAS_PER_BLOCK,
calc_next_block_base_fee, eip1559::BaseFeeParams, eip7691::MAX_BLOBS_PER_BLOCK_ELECTRA,
eip7840::BlobParams,
};
use alloy_primitives::B256;
Expand Down Expand Up @@ -270,7 +270,7 @@ impl FeeHistoryService {
let blob_gas_used = block.header.blob_gas_used.map(|g| g as f64);
item.gas_used_ratio = gas_used / block.header.gas_limit as f64;
item.blob_gas_used_ratio =
blob_gas_used.map(|g| g / MAX_DATA_GAS_PER_BLOCK as f64).unwrap_or(0 as f64);
blob_gas_used.map(|g| g / MAX_BLOBS_PER_BLOCK_ELECTRA as f64).unwrap_or(0 as f64);

// extract useful tx info (gas_used, effective_reward)
let mut transactions: Vec<(_, _)> = receipts
Expand Down
2 changes: 1 addition & 1 deletion crates/anvil/src/eth/otterscan/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ pub fn batch_build_ots_traces(traces: Vec<LocalizedTransactionTrace>) -> Vec<Tra
depth: trace.trace.trace_address.len() as u32,
from: call.from,
to: call.to,
value: call.value,
value: Some(call.value),
input: call.input,
output,
}),
Expand Down
2 changes: 1 addition & 1 deletion crates/anvil/src/eth/sign.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::eth::error::BlockchainError;
use alloy_consensus::SignableTransaction;
use alloy_dyn_abi::TypedData;
use alloy_network::TxSignerSync;
use alloy_primitives::{map::AddressHashMap, Address, PrimitiveSignature as Signature, B256, U256};
use alloy_primitives::{map::AddressHashMap, Address, Signature, B256, U256};
use alloy_signer::Signer as AlloySigner;
use alloy_signer_local::PrivateKeySigner;
use anvil_core::eth::transaction::{
Expand Down
21 changes: 8 additions & 13 deletions crates/anvil/tests/it/anvil_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ async fn can_impersonate_contract() {
let res = provider.send_transaction(tx.clone()).await;
res.unwrap_err();

let greeting = greeter_contract.greet().call().await.unwrap()._0;
let greeting = greeter_contract.greet().call().await.unwrap();
assert_eq!("Hello World!", greeting);

api.anvil_impersonate_account(impersonate).await.unwrap();
Expand All @@ -195,7 +195,7 @@ async fn can_impersonate_contract() {
let res = provider.send_transaction(tx).await;
res.unwrap_err();

let greeting = greeter_contract.greet().call().await.unwrap()._0;
let greeting = greeter_contract.greet().call().await.unwrap();
assert_eq!("Hello World!", greeting);
}

Expand Down Expand Up @@ -430,12 +430,11 @@ async fn test_can_set_storage_bsc_fork() {

let busd_contract = BUSD::new(busd_addr, &provider);

let BUSD::balanceOfReturn { _0 } = busd_contract
let balance = busd_contract
.balanceOf(address!("0x0000000000000000000000000000000000000000"))
.call()
.await
.unwrap();
let balance = _0;
assert_eq!(balance, U256::from(12345u64));
}

Expand Down Expand Up @@ -625,20 +624,16 @@ async fn test_fork_revert_call_latest_block_timestamp() {
let multicall_contract =
Multicall::new(address!("0xeefba1e63905ef1d7acba5a8513c70307c1ce441"), &provider);

let Multicall::getCurrentBlockTimestampReturn { timestamp } =
multicall_contract.getCurrentBlockTimestamp().call().await.unwrap();
let timestamp = multicall_contract.getCurrentBlockTimestamp().call().await.unwrap();
assert_eq!(timestamp, U256::from(latest_block.header.timestamp));

let Multicall::getCurrentBlockDifficultyReturn { difficulty } =
multicall_contract.getCurrentBlockDifficulty().call().await.unwrap();
let difficulty = multicall_contract.getCurrentBlockDifficulty().call().await.unwrap();
assert_eq!(difficulty, U256::from(latest_block.header.difficulty));

let Multicall::getCurrentBlockGasLimitReturn { gaslimit } =
multicall_contract.getCurrentBlockGasLimit().call().await.unwrap();
let gaslimit = multicall_contract.getCurrentBlockGasLimit().call().await.unwrap();
assert_eq!(gaslimit, U256::from(latest_block.header.gas_limit));

let Multicall::getCurrentBlockCoinbaseReturn { coinbase } =
multicall_contract.getCurrentBlockCoinbase().call().await.unwrap();
let coinbase = multicall_contract.getCurrentBlockCoinbase().call().await.unwrap();
assert_eq!(coinbase, latest_block.header.beneficiary);
}

Expand Down Expand Up @@ -754,7 +749,7 @@ async fn test_reorg() {
.await
.unwrap();
api.anvil_reorg(ReorgOptions { depth: 3, tx_block_pairs: vec![] }).await.unwrap();
let value = storage.getValue().call().await.unwrap()._0;
let value = storage.getValue().call().await.unwrap();
assert_eq!("initial value".to_string(), value);

api.mine_one().await;
Expand Down
Loading