Skip to content

chore(deps): upgrade to revm23/alloy1.0.5 #104

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

Merged
merged 18 commits into from
May 22, 2025
Merged
Show file tree
Hide file tree
Changes from 3 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
24 changes: 14 additions & 10 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "trevm"
version = "0.20.10"
version = "0.20.11"
rust-version = "1.83.0"
edition = "2021"
authors = ["init4"]
Expand All @@ -27,23 +27,27 @@ option-if-let-else = "warn"
redundant-clone = "warn"

[dependencies]
alloy = { version = "0.12.6", default-features = false, features = ["consensus", "rpc-types-mev", "eips", "k256", "std", "rlp", "sol-types"] }
alloy = { version = "1.0.5", default-features = false, features = [
"consensus",
"rpc-types-mev",
"eips",
"k256",
"std",
"rlp",
"sol-types",
] }

revm = { version = "20.0.0", default-features = false }
revm = { version = "23.1.0", default-features = false }

dashmap = { version = "6.1.0", optional = true }
tracing = { version = "0.1.41", optional = true}
tracing = { version = "0.1.41", optional = true }
thiserror = "2.0.11"

[dev-dependencies]
revm = { version = "20.0.0", features = [
"serde-json",
"std",
"alloydb",
] }
revm = { version = "23.1.0", features = ["serde-json", "std", "alloydb"] }
trevm = { path = ".", features = ["test-utils"] }

alloy = { version = "0.12.6", features = ["providers"]}
alloy = { version = "1.0.5", features = ["providers"] }

# misc
eyre = "0.6"
Expand Down
4 changes: 2 additions & 2 deletions examples/fork_ref_transact.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ async fn main() -> eyre::Result<()> {
// create ethers client and wrap it in Arc<M>
let rpc_url = "https://mainnet.infura.io/v3/c60b0bb42f8a4c6481ecd229eddaca27";

let client = ProviderBuilder::new().on_http(rpc_url.parse()?);
let client = ProviderBuilder::new().connect_http(rpc_url.parse()?);

// ----------------------------------------------------------- //
// Storage slots of UniV2Pair contract //
Expand Down Expand Up @@ -78,7 +78,7 @@ async fn main() -> eyre::Result<()> {
let output = evm.output().expect("Execution halted");

// decode bytes to reserves + ts via alloy's abi decode
let return_vals = getReservesCall::abi_decode_returns(output, true)?;
let return_vals = getReservesCall::abi_decode_returns(output)?;

// Print emulated getReserves() call output
println!("Reserve0: {:#?}", return_vals.reserve0);
Expand Down
15 changes: 12 additions & 3 deletions src/driver/alloy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ use crate::{
trevm_bail, trevm_ensure, trevm_try, Block, BundleDriver, DriveBundleResult,
};
use alloy::{
consensus::{Transaction, TxEip4844Variant, TxEnvelope},
consensus::{
crypto::RecoveryError, transaction::SignerRecoverable, Transaction, TxEip4844Variant,
TxEnvelope,
},
eips::{eip2718::Decodable2718, BlockNumberOrTag},
primitives::{bytes::Buf, keccak256, Address, Bytes, TxKind, U256},
rpc::types::mev::{
Expand Down Expand Up @@ -35,7 +38,7 @@ pub enum BundleError<Db: Database> {
/// An error occurred while decoding a transaction contained in the bundle.
TransactionDecodingError(alloy::eips::eip2718::Eip2718Error),
/// An error occurred while recovering the sender of a transaction.
TransactionSenderRecoveryError(alloy::primitives::SignatureError),
TransactionSenderRecoveryError(alloy::consensus::crypto::RecoveryError),
/// An error occurred while running the EVM.
EVMError {
/// The error that occurred while running the EVM.
Expand Down Expand Up @@ -71,7 +74,7 @@ impl<Db: Database> From<alloy::eips::eip2718::Eip2718Error> for BundleError<Db>

impl<Db: Database> From<alloy::primitives::SignatureError> for BundleError<Db> {
fn from(err: alloy::primitives::SignatureError) -> Self {
Self::TransactionSenderRecoveryError(err)
Self::TransactionSenderRecoveryError(err.into())
}
}

Expand All @@ -91,6 +94,12 @@ impl<Db: Database> std::error::Error for BundleError<Db> {
}
}

impl<Db: Database> From<RecoveryError> for BundleError<Db> {
fn from(err: RecoveryError) -> Self {
Self::TransactionSenderRecoveryError(err)
}
}

impl<Db: Database> core::fmt::Debug for BundleError<Db> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
match self {
Expand Down
60 changes: 28 additions & 32 deletions src/evm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,12 @@ where

/// Deconstruct the [`Trevm`] into the backing DB, dropping all other types.
pub fn into_db(self) -> Db {
self.inner.data.ctx.journaled_state.database
self.inner.ctx.journaled_state.database
}

/// Get the id of the currently running hardfork spec.
pub fn spec_id(&self) -> SpecId {
self.inner.data.ctx.cfg().spec()
self.inner.ctx.cfg().spec()
}

/// Set the [SpecId], modifying the EVM handlers accordingly. This function
Expand Down Expand Up @@ -712,7 +712,7 @@ where
/// [`Eip-170`]: https://eips.ethereum.org/EIPS/eip-170
pub fn set_code_size_limit(&mut self, limit: usize) -> Option<usize> {
let mut csl = None;
self.inner.data.ctx.modify_cfg(|cfg| {
self.inner.ctx.modify_cfg(|cfg| {
csl = cfg.limit_contract_code_size.replace(limit);
});
csl
Expand All @@ -724,7 +724,7 @@ where
/// [`Eip-170`]: https://eips.ethereum.org/EIPS/eip-170
pub fn disable_code_size_limit(&mut self) -> Option<usize> {
let mut csl = None;
self.inner.data.ctx.modify_cfg(|cfg| csl = cfg.limit_contract_code_size.take());
self.inner.ctx.modify_cfg(|cfg| csl = cfg.limit_contract_code_size.take());
csl
}

Expand Down Expand Up @@ -766,7 +766,7 @@ where
cfg.fill_cfg(&mut self.inner);

let mut this = f(self);
this.inner.data.ctx.modify_cfg(|cfg| *cfg = previous);
this.inner.ctx.modify_cfg(|cfg| *cfg = previous);
this
}

Expand Down Expand Up @@ -810,10 +810,7 @@ where
#[cfg(feature = "memory_limit")]
pub fn set_memory_limit(&mut self, new_limit: u64) -> u64 {
let mut ml = 0;
self.inner
.data
.ctx
.modify_cfg(|cfg| ml = core::mem::replace(&mut cfg.memory_limit, new_limit));
self.inner.ctx.modify_cfg(|cfg| ml = core::mem::replace(&mut cfg.memory_limit, new_limit));
ml
}

Expand All @@ -822,13 +819,13 @@ where
/// execution doesn't fail.
#[cfg(feature = "optional_balance_check")]
pub fn disable_balance_check(&mut self) {
self.inner.data.ctx.modify_cfg(|cfg| cfg.disable_balance_check = true)
self.inner.ctx.modify_cfg(|cfg| cfg.disable_balance_check = true)
}

/// Enable balance checks. See [`Self::disable_balance_check`].
#[cfg(feature = "optional_balance_check")]
pub fn enable_balance_check(&mut self) {
self.inner.data.ctx.modify_cfg(|cfg| cfg.disable_balance_check = false)
self.inner.ctx.modify_cfg(|cfg| cfg.disable_balance_check = false)
}

/// Run a closure with balance checks disabled, then restore the previous
Expand All @@ -841,7 +838,7 @@ where
let previous = self.inner.cfg().disable_balance_check;
self.disable_balance_check();
let mut new = f(self);
new.inner.data.ctx.modify_cfg(|cfg| cfg.disable_balance_check = previous);
new.inner.ctx.modify_cfg(|cfg| cfg.disable_balance_check = previous);
new
}

Expand All @@ -850,13 +847,13 @@ where
/// simulating large transactions like forge scripts.
#[cfg(feature = "optional_block_gas_limit")]
pub fn disable_block_gas_limit(&mut self) {
self.inner.data.ctx.modify_cfg(|cfg| cfg.disable_block_gas_limit = true);
self.inner.ctx.modify_cfg(|cfg| cfg.disable_block_gas_limit = true);
}

/// Enable block gas limits. See [`Self::disable_block_gas_limit`].
#[cfg(feature = "optional_block_gas_limit")]
pub fn enable_block_gas_limit(&mut self) {
self.inner.data.ctx.modify_cfg(|cfg| cfg.disable_block_gas_limit = false);
self.inner.ctx.modify_cfg(|cfg| cfg.disable_block_gas_limit = false);
}

/// Run a closure with block gas limits disabled, then restore the previous
Expand All @@ -869,7 +866,7 @@ where
let previous = self.inner.cfg().disable_block_gas_limit;
self.disable_block_gas_limit();
let mut new = f(self);
new.inner.data.ctx.modify_cfg(|cfg| cfg.disable_block_gas_limit = previous);
new.inner.ctx.modify_cfg(|cfg| cfg.disable_block_gas_limit = previous);
new
}

Expand All @@ -879,15 +876,15 @@ where
/// [EIP-3607]: https://eips.ethereum.org/EIPS/eip-3607
#[cfg(feature = "optional_eip3607")]
pub fn disable_eip3607(&mut self) {
self.inner.data.ctx.modify_cfg(|cfg| cfg.disable_eip3607 = true);
self.inner.ctx.modify_cfg(|cfg| cfg.disable_eip3607 = true);
}

/// Enable [EIP-3607]. See [`Self::disable_eip3607`].
///
/// [EIP-3607]: https://eips.ethereum.org/EIPS/eip-3607
#[cfg(feature = "optional_eip3607")]
pub fn enable_eip3607(&mut self) {
self.inner.data.ctx.modify_cfg(|cfg| cfg.disable_eip3607 = false);
self.inner.ctx.modify_cfg(|cfg| cfg.disable_eip3607 = false);
}

/// Run a closure with [EIP-3607] disabled, then restore the previous
Expand All @@ -901,7 +898,7 @@ where
self.disable_eip3607();

let mut new = f(self);
new.inner.data.ctx.modify_cfg(|cfg| cfg.disable_eip3607 = previous);
new.inner.ctx.modify_cfg(|cfg| cfg.disable_eip3607 = previous);
new
}

Expand All @@ -911,15 +908,15 @@ where
/// [EIP-1559]: https://eips.ethereum.org/EIPS/eip-1559
#[cfg(feature = "optional_no_base_fee")]
pub fn disable_base_fee(&mut self) {
self.inner.data.ctx.modify_cfg(|cfg| cfg.disable_base_fee = true)
self.inner.ctx.modify_cfg(|cfg| cfg.disable_base_fee = true)
}

/// Enable [EIP-1559] base fee checks. See [`Self::disable_base_fee`].
///
/// [EIP-1559]: https://eips.ethereum.org/EIPS/eip-1559
#[cfg(feature = "optional_no_base_fee")]
pub fn enable_base_fee(&mut self) {
self.inner.data.ctx.modify_cfg(|cfg| cfg.disable_base_fee = false)
self.inner.ctx.modify_cfg(|cfg| cfg.disable_base_fee = false)
}

/// Run a closure with [EIP-1559] base fee checks disabled, then restore the
Expand All @@ -935,19 +932,19 @@ where
self.disable_base_fee();

let mut new = f(self);
new.inner.data.ctx.modify_cfg(|cfg| cfg.disable_base_fee = previous);
new.inner.ctx.modify_cfg(|cfg| cfg.disable_base_fee = previous);
new
}

/// Disable nonce checks. This allows transactions to be sent with
/// incorrect nonces, and is useful for things like system transactions.
pub fn disable_nonce_check(&mut self) {
self.inner.data.ctx.modify_cfg(|cfg| cfg.disable_nonce_check = true)
self.inner.ctx.modify_cfg(|cfg| cfg.disable_nonce_check = true)
}

/// Enable nonce checks. See [`Self::disable_nonce_check`].
pub fn enable_nonce_check(&mut self) {
self.inner.data.ctx.modify_cfg(|cfg| cfg.disable_nonce_check = false)
self.inner.ctx.modify_cfg(|cfg| cfg.disable_nonce_check = false)
}

/// Run a closure with nonce checks disabled, then restore the previous
Expand All @@ -961,7 +958,7 @@ where
self.disable_nonce_check();

let mut new = f(self);
new.inner.data.ctx.modify_cfg(|cfg| cfg.disable_nonce_check = previous);
new.inner.ctx.modify_cfg(|cfg| cfg.disable_nonce_check = previous);
new
}
}
Expand Down Expand Up @@ -1080,7 +1077,7 @@ where
b.fill_block(&mut self.inner);

let mut this = f(self);
this.inner.data.ctx.set_block(previous);
this.inner.ctx.set_block(previous);
this
}

Expand All @@ -1100,11 +1097,11 @@ where

match f(self) {
Ok(mut evm) => {
evm.inner.data.ctx.set_block(previous);
evm.inner.ctx.set_block(previous);
Ok(evm)
}
Err(mut evm) => {
evm.inner.data.ctx.set_block(previous);
evm.inner.ctx.set_block(previous);
Err(evm)
}
}
Expand Down Expand Up @@ -1363,7 +1360,7 @@ where
let previous = self.inner.tx().clone();
t.fill_tx(&mut self.inner);
let mut this = f(self);
this.inner.data.ctx.set_tx(previous);
this.inner.ctx.set_tx(previous);
this
}

Expand All @@ -1383,11 +1380,11 @@ where
t.fill_tx(&mut self.inner);
match f(self) {
Ok(mut evm) => {
evm.inner.data.ctx.set_tx(previous);
evm.inner.ctx.set_tx(previous);
Ok(evm)
}
Err(mut evm) => {
evm.inner.data.ctx.set_tx(previous);
evm.inner.ctx.set_tx(previous);
Err(evm)
}
}
Expand Down Expand Up @@ -1978,12 +1975,11 @@ where
/// [`SolCall`]: alloy::sol_types::SolCall
pub fn output_sol<T: alloy::sol_types::SolCall>(
&self,
validate: bool,
) -> Option<alloy::sol_types::Result<T::Return>>
where
T::Return: alloy::sol_types::SolType,
{
self.output().map(|output| T::abi_decode_returns(output, validate))
self.output().map(|output| T::abi_decode_returns(output))
}

/// Get the gas used by the transaction.
Expand Down
2 changes: 1 addition & 1 deletion src/ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,6 @@ where
Ctx: ContextTr,
{
fn db_mut_ext(&mut self) -> &mut Ctx::Db {
self.data.ctx.db()
self.ctx.db()
}
}
8 changes: 7 additions & 1 deletion src/fill/alloy.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use alloy::{
consensus::{Signed, TxType},
eips::eip7702::{RecoveredAuthorization, SignedAuthorization},
primitives::U256,
};
use revm::{
Expand Down Expand Up @@ -323,6 +324,11 @@ impl Tx for alloy::rpc::types::TransactionRequest {

*caller = self.from.unwrap_or_default();

let auth_list = self.authorization_list.clone().unwrap_or_default();
let auth_list: Vec<
revm::context::either::Either<SignedAuthorization, RecoveredAuthorization>,
> = auth_list.into_iter().map(revm::context::either::Either::Left).collect();

// NB: this is set to max if not provided, as users will typically
// intend that to mean "as much as possible"
*tx_type = self.transaction_type.unwrap_or(TxType::Eip1559 as u8);
Expand All @@ -337,7 +343,7 @@ impl Tx for alloy::rpc::types::TransactionRequest {
*gas_priority_fee = self.max_priority_fee_per_gas;
*blob_hashes = self.blob_versioned_hashes.clone().unwrap_or_default();
*max_fee_per_blob_gas = self.max_fee_per_blob_gas.unwrap_or_default();
*authorization_list = self.authorization_list.clone().unwrap_or_default();
authorization_list.extend(auth_list);
}
}

Expand Down
Loading
Loading