Skip to content
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

feat: bump revm #10051

Closed
wants to merge 27 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,401 changes: 835 additions & 566 deletions Cargo.lock

Large diffs are not rendered by default.

65 changes: 35 additions & 30 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,8 @@ alloy-sol-types.opt-level = 3
hashbrown.opt-level = 3
foldhash.opt-level = 3
keccak.opt-level = 3
revm-interpreter.opt-level = 3
revm-precompile.opt-level = 3
revm-primitives.opt-level = 3
revm.opt-level = 3
revm-interpreter.opt-level = 3
ruint.opt-level = 3
sha2.opt-level = 3
sha3.opt-level = 3
Expand Down Expand Up @@ -190,37 +188,36 @@ foundry-linking = { path = "crates/linking" }
# solc & compilation utilities
foundry-block-explorers = { version = "0.11.0", default-features = false }
foundry-compilers = { version = "0.13.5", default-features = false }
foundry-fork-db = "0.12"
foundry-fork-db = { git = "https://github.com/foundry-rs/foundry-fork-db", rev = "c168d11" }
solang-parser = "=0.3.3"
solar-parse = { version = "=0.1.1", default-features = false }

## revm
revm = { version = "19.4.0", default-features = false }
revm-primitives = { version = "15.1.0", default-features = false }
revm-inspectors = { version = "0.16.0", features = ["serde"] }
revm = { version = "20.0.0-alpha.7", default-features = false }
revm-inspectors = { version = "0.17.0-alpha.1", features = ["serde"] }

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

## alloy-core
alloy-dyn-abi = "0.8.22"
Expand All @@ -235,13 +232,14 @@ alloy-sol-macro-expander = "0.8.22"
alloy-sol-macro-input = "0.8.22"
alloy-sol-types = "0.8.22"

alloy-evm = "0.1.0-alpha.3"
alloy-chains = "0.1"
alloy-rlp = "0.3"
alloy-trie = "0.7.0"

## op-alloy
op-alloy-consensus = "0.11.0"
op-alloy-rpc-types = "0.11.0"
op-alloy-consensus = "0.11.2"
op-alloy-rpc-types = "0.11.2"

## cli
anstream = "0.6"
Expand Down Expand Up @@ -346,3 +344,10 @@ yansi = { version = "1.0", features = ["detect-tty", "detect-env"] }
# 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" }

## revm
# revm = { git = "https://github.com/bluealloy/revm", rev = "9e39df5" }
# revm-inspectors = { git = "https://github.com/paradigmxyz/revm-inspectors", rev = "2a365e3" }

## foundry
foundry-fork-db = { git = "https://github.com/foundry-rs/foundry-fork-db", rev = "c168d11" }
1 change: 1 addition & 0 deletions crates/anvil/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ revm = { workspace = true, default-features = false, features = [
"c-kzg",
] }

alloy-evm.workspace = true
alloy-primitives = { workspace = true, features = ["serde", "rlp"] }
alloy-rpc-types = { workspace = true, features = ["anvil", "trace"] }
alloy-serde.workspace = true
Expand Down
6 changes: 4 additions & 2 deletions crates/anvil/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,15 @@ use foundry_config::Config;
use foundry_evm::{
backend::{BlockchainDb, BlockchainDbMeta, SharedBackend},
constants::DEFAULT_CREATE2_DEPLOYER,
revm::primitives::{BlockEnv, CfgEnv, CfgEnvWithHandlerCfg, EnvWithHandlerCfg, SpecId, TxEnv},
revm::primitives::{
hardfork::SpecId, BlockEnv, CfgEnv, CfgEnvWithHandlerCfg, EnvWithHandlerCfg, TxEnv,
},
utils::apply_chain_and_block_specific_env_changes,
};
use itertools::Itertools;
use parking_lot::RwLock;
use rand::thread_rng;
use revm::primitives::BlobExcessGasAndPrice;
use revm::context_interface::block::BlobExcessGasAndPrice;
use serde_json::{json, Value};
use std::{
fmt::Write as FmtWrite,
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 @@ -90,7 +90,7 @@ use foundry_evm::{
};
use futures::channel::{mpsc::Receiver, oneshot};
use parking_lot::RwLock;
use revm::primitives::Bytecode;
use revm::bytecode::Bytecode;
use std::{future::Future, sync::Arc, time::Duration};

/// The client version: `anvil/v{major}.{minor}.{patch}`
Expand Down
2 changes: 1 addition & 1 deletion crates/anvil/src/eth/backend/executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ use foundry_evm::{
traces::CallTraceNode,
utils::odyssey_handler_register,
};
use revm::db::WrapDatabaseRef;
use revm::database::WrapDatabaseRef;
use std::sync::Arc;

/// Represents an executed transaction (transacted on the DB)
Expand Down
2 changes: 1 addition & 1 deletion crates/anvil/src/eth/backend/fork.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ use parking_lot::{
lock_api::{RwLockReadGuard, RwLockWriteGuard},
RawRwLock, RwLock,
};
use revm::primitives::BlobExcessGasAndPrice;
use revm::context_interface::block::BlobExcessGasAndPrice;
use std::{sync::Arc, time::Duration};
use tokio::sync::RwLock as AsyncRwLock;

Expand Down
2 changes: 1 addition & 1 deletion crates/anvil/src/eth/backend/mem/fork_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use foundry_evm::{
fork::database::ForkDbStateSnapshot,
revm::{primitives::BlockEnv, Database},
};
use revm::{db::DbAccount, DatabaseRef};
use revm::{database::DbAccount, DatabaseRef};

pub use foundry_evm::fork::database::ForkedDatabase;

Expand Down
5 changes: 3 additions & 2 deletions crates/anvil/src/eth/backend/mem/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,9 @@ use futures::channel::mpsc::{unbounded, UnboundedSender};
use op_alloy_consensus::{TxDeposit, DEPOSIT_TX_TYPE_ID};
use parking_lot::{Mutex, RwLock};
use revm::{
db::WrapDatabaseRef,
primitives::{BlobExcessGasAndPrice, HashMap, OptimismFields, ResultAndState},
context_interface::{block::BlobExcessGasAndPrice, result::ResultAndState},
database::WrapDatabaseRef,
primitives::{HashMap, OptimismFields},
};
use std::{
collections::BTreeMap,
Expand Down
3 changes: 1 addition & 2 deletions crates/anvil/src/eth/backend/mem/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ use anvil_core::eth::{
};
use anvil_rpc::error::RpcError;
use foundry_evm::{
backend::MemDb,
revm::primitives::Env,
backend::{Env, MemDb},
traces::{
CallKind, FourByteInspector, GethTraceBuilder, ParityTraceBuilder, TracingInspectorConfig,
},
Expand Down
14 changes: 7 additions & 7 deletions crates/anvil/src/eth/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,8 @@ pub enum InvalidTransactionError {
/// Thrown when there are no `blob_hashes` in the transaction, and it is an EIP-4844 tx.
#[error("`blob_hashes` are required for EIP-4844 transactions")]
NoBlobHashes,
#[error("too many blobs in one transaction, have: {0}")]
TooManyBlobs(usize),
#[error("too many blobs in one transaction, have: {0}, max: {1}")]
TooManyBlobs(usize, usize),
/// Thrown when there's a blob validation error
#[error(transparent)]
BlobTransactionValidationError(#[from] alloy_consensus::BlobTransactionValidationError),
Expand All @@ -265,12 +265,12 @@ pub enum InvalidTransactionError {
AuthorizationListNotSupported,
/// Forwards error from the revm
#[error(transparent)]
Revm(revm::primitives::InvalidTransaction),
Revm(revm::context::result::InvalidTransaction),
}

impl From<revm::primitives::InvalidTransaction> for InvalidTransactionError {
fn from(err: revm::primitives::InvalidTransaction) -> Self {
use revm::primitives::InvalidTransaction;
impl From<revm::context::result::InvalidTransaction> for InvalidTransactionError {
fn from(err: revm::context::result::InvalidTransaction) -> Self {
use revm::context::result::InvalidTransaction;
match err {
InvalidTransaction::InvalidChainId => Self::InvalidChainId,
InvalidTransaction::PriorityFeeGreaterThanMaxFee => Self::TipAboveFeeCap,
Expand Down Expand Up @@ -300,7 +300,7 @@ impl From<revm::primitives::InvalidTransaction> for InvalidTransactionError {
InvalidTransaction::BlobCreateTransaction => Self::BlobCreateTransaction,
InvalidTransaction::BlobVersionNotSupported => Self::BlobVersionNotSupported,
InvalidTransaction::EmptyBlobs => Self::EmptyBlobs,
InvalidTransaction::TooManyBlobs { have } => Self::TooManyBlobs(have),
InvalidTransaction::TooManyBlobs { max, have } => Self::TooManyBlobs(have, max),
InvalidTransaction::AuthorizationListNotSupported => {
Self::AuthorizationListNotSupported
}
Expand Down
6 changes: 3 additions & 3 deletions crates/anvil/src/evm.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use alloy_primitives::Address;
use foundry_evm::revm::precompile::Precompile;
use foundry_evm::{backend::Env, revm::precompile::Precompile};
use std::{fmt::Debug, sync::Arc};

/// Object-safe trait that enables injecting extra precompiles when using
Expand Down Expand Up @@ -33,7 +33,7 @@ mod tests {
use crate::{evm::inject_precompiles, PrecompileFactory};
use alloy_primitives::Address;
use foundry_evm::revm::primitives::{address, Bytes, Precompile, PrecompileResult, SpecId};
use revm::primitives::PrecompileOutput;
use revm::precompile::PrecompileOutput;

#[test]
fn build_evm_with_extra_precompiles() {
Expand All @@ -53,7 +53,7 @@ mod tests {
}

let db = revm::db::EmptyDB::default();
let env = Box::<revm::primitives::Env>::default();
let env = Box::<Env>::default();
let spec = SpecId::LATEST;
let handler_cfg = revm::primitives::HandlerCfg::new(spec);
let inspector = revm::inspectors::NoOpInspector;
Expand Down
2 changes: 1 addition & 1 deletion crates/cheatcodes/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use foundry_config::UnresolvedEnvVarError;
use foundry_evm_core::backend::{BackendError, DatabaseError};
use foundry_wallets::error::WalletSignerError;
use k256::ecdsa::signature::Error as SignatureError;
use revm::primitives::EVMError;
use revm::context_interface::result::EVMError;
use std::{borrow::Cow, fmt};

/// Cheatcode result type.
Expand Down
5 changes: 4 additions & 1 deletion crates/cheatcodes/src/evm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ use foundry_evm_core::{
use foundry_evm_traces::StackSnapshotType;
use itertools::Itertools;
use rand::Rng;
use revm::primitives::{Account, Bytecode, SpecId, KECCAK_EMPTY};
use revm::{
bytecode::Bytecode,
primitives::{hardfork::SpecId, Account, KECCAK_EMPTY},
};
use std::{
collections::{btree_map::Entry, BTreeMap},
fmt::Display,
Expand Down
17 changes: 9 additions & 8 deletions crates/cheatcodes/src/inspector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ use foundry_evm_core::{
abi::Vm::stopExpectSafeMemoryCall,
backend::{DatabaseError, DatabaseExt, RevertDiagnostic},
constants::{CHEATCODE_ADDRESS, HARDHAT_CONSOLE_ADDRESS, MAGIC_ASSUME},
utils::new_evm_with_existing_context,
utils::new_evm_with_context,
InspectorExt,
};
use foundry_evm_traces::{TracingInspector, TracingInspectorConfig};
Expand All @@ -45,15 +45,16 @@ use itertools::Itertools;
use proptest::test_runner::{RngAlgorithm, TestRng, TestRunner};
use rand::Rng;
use revm::{
bytecode::EOF_MAGIC_BYTES,
context::{BlockEnv, CreateScheme, EVMError},
context_interface::{transaction::SignedAuthorization, EVMError},
interpreter::{
opcode as op, CallInputs, CallOutcome, CallScheme, CallValue, CreateInputs, CreateOutcome,
EOFCreateInputs, EOFCreateKind, Gas, InstructionResult, Interpreter, InterpreterAction,
InterpreterResult,
},
primitives::{
BlockEnv, CreateScheme, EVMError, EvmStorageSlot, SignedAuthorization, SpecId,
EOF_MAGIC_BYTES,
},
primitives::hardfork::SpecId,
state::EvmStorageSlot,
EvmContext, InnerEvmContext, Inspector,
};
use serde_json::Value;
Expand Down Expand Up @@ -164,7 +165,7 @@ where
l1_block_info,
};

let mut evm = new_evm_with_existing_context(inner, &mut *inspector);
let mut evm = new_evm_with_context(inner, &mut *inspector);

let res = f(&mut evm)?;

Expand Down Expand Up @@ -1385,7 +1386,7 @@ impl Inspector<&mut dyn DatabaseExt> for Cheatcodes {
outcome.result.output = error.abi_encode().into();
outcome
}
}
};
} else {
// Call didn't revert, reset `assume_no_revert` state.
self.assume_no_revert = None;
Expand Down Expand Up @@ -1837,7 +1838,7 @@ impl Cheatcodes {
let (key, target_address) = if interpreter.current_opcode() == op::SLOAD {
(try_or_return!(interpreter.stack().peek(0)), interpreter.contract().target_address)
} else {
return
return;
};

let Ok(value) = ecx.sload(target_address, key) else {
Expand Down
2 changes: 1 addition & 1 deletion crates/cheatcodes/src/script.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use alloy_signer_local::PrivateKeySigner;
use alloy_sol_types::SolValue;
use foundry_wallets::{multi_wallet::MultiWallet, WalletSigner};
use parking_lot::Mutex;
use revm::primitives::{Bytecode, SignedAuthorization};
use revm::{bytecode::Bytecode, context_interface::transaction::SignedAuthorization};
use std::sync::Arc;

impl Cheatcode for broadcast_0Call {
Expand Down
2 changes: 1 addition & 1 deletion crates/common/fmt/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ alloy-serde.workspace = true
serde.workspace = true
serde_json.workspace = true
chrono.workspace = true
revm-primitives.workspace = true
revm.workspace = true
comfy-table.workspace = true
yansi.workspace = true

Expand Down
7 changes: 3 additions & 4 deletions crates/common/fmt/src/eof.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use comfy_table::{modifiers::UTF8_ROUND_CORNERS, ContentArrangement, Table};
use revm_primitives::{
use revm::bytecode::{
eof::{EofBody, EofHeader},
Eof,
};
Expand All @@ -16,8 +16,7 @@ pub fn pretty_eof(eof: &Eof) -> Result<String, fmt::Error> {
sum_code_sizes: _,
sum_container_sizes: _,
},
body:
EofBody { types_section, code_section, container_section, data_section, is_data_filled: _ },
body: EofBody { code_info, code_section, container_section, data_section, .. },
raw: _,
} = eof;

Expand All @@ -43,7 +42,7 @@ pub fn pretty_eof(eof: &Eof) -> Result<String, fmt::Error> {
table.apply_modifier(UTF8_ROUND_CORNERS);
table.set_content_arrangement(ContentArrangement::Dynamic);
table.set_header(vec!["", "Inputs", "Outputs", "Max stack height", "Code"]);
for (idx, (code, type_section)) in code_section.iter().zip(types_section).enumerate() {
for (idx, (code, type_section)) in code_section.iter().zip(code_info).enumerate() {
table.add_row(vec![
&idx.to_string(),
&type_section.inputs.to_string(),
Expand Down
2 changes: 1 addition & 1 deletion crates/config/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ foundry-compilers = { workspace = true, features = ["svm-solc"] }

alloy-chains = { workspace = true, features = ["serde"] }
alloy-primitives = { workspace = true, features = ["serde"] }
revm-primitives.workspace = true
revm.workspace = true

solar-parse.workspace = true

Expand Down
2 changes: 1 addition & 1 deletion crates/config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ use foundry_compilers::{
RestrictionsWithVersion, VyperLanguage,
};
use regex::Regex;
use revm_primitives::{map::AddressHashMap, FixedBytes, SpecId};
use revm::primitives::{hardfork::SpecId, map::AddressHashMap, FixedBytes};
use semver::Version;
use serde::{Deserialize, Serialize, Serializer};
use std::{
Expand Down
2 changes: 1 addition & 1 deletion crates/config/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use foundry_compilers::artifacts::{
remappings::{Remapping, RemappingError},
EvmVersion,
};
use revm_primitives::SpecId;
use revm::primitives::hardfork::SpecId;
use serde::{de::Error, Deserialize, Deserializer};
use std::{
io,
Expand Down
Loading
Loading