Skip to content

feat(deps): bump revm #114

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 19 commits into from
Jul 1, 2025
Merged
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
11 changes: 5 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "trevm"
version = "0.23.8"
version = "0.27.0"
rust-version = "1.83.0"
edition = "2021"
authors = ["init4"]
Expand Down Expand Up @@ -34,7 +34,7 @@ name = "fork_ref_transact"
required-features = ["alloy-db"]

[dependencies]
alloy = { version = "1.0.5", default-features = false, features = [
alloy = { version = "1.0.13", default-features = false, features = [
"consensus",
"rpc-types-mev",
"eips",
Expand All @@ -44,7 +44,7 @@ alloy = { version = "1.0.5", default-features = false, features = [
"sol-types",
] }

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

dashmap = { version = "6.1.0", optional = true }
tracing = { version = "0.1.41", optional = true }
Expand All @@ -53,10 +53,10 @@ thiserror = "2.0.11"
tokio = { version = "1.44", optional = true }

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

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

# misc
eyre = "0.6"
Expand Down Expand Up @@ -87,7 +87,6 @@ estimate_gas = ["optional_eip3607", "optional_no_base_fee", "dep:tracing"]
test-utils = ["revm/std", "revm/serde-json", "revm/alloydb"]

secp256k1 = ["revm/secp256k1"]
secp256r1 = ["revm/secp256r1"]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

was this revm feature removed?

Copy link
Member Author

@Evalir Evalir Jun 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it was removed as a feature and it's now included by default—but only activated on the Osaka spec onwards. means we need to enable it/inject it ourselves wherever else we actually want to use the Opcode

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

c-kzg = ["revm/c-kzg"]
blst = ["revm/blst"]

Expand Down
34 changes: 17 additions & 17 deletions src/driver/alloy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@ impl<Db: Database> core::fmt::Display for BundleError<Db> {
Self::BundleEmpty => write!(f, "bundle has no transactions"),
Self::Eip4844BlobGasExceeded => write!(f, "max blob gas limit exceeded"),
Self::UnsupportedTransactionType => write!(f, "unsupported transaction type"),
Self::TransactionDecodingError(err) => write!(f, "transaction decoding error: {}", err),
Self::TransactionDecodingError(err) => write!(f, "transaction decoding error: {err}"),
Self::TransactionSenderRecoveryError(err) => {
write!(f, "transaction sender recovery error: {}", err)
write!(f, "transaction sender recovery error: {err}")
}
Self::EVMError { inner } => write!(f, "internal EVM error: {}", inner),
Self::EVMError { inner } => write!(f, "internal EVM error: {inner}"),
}
}
}
Expand Down Expand Up @@ -107,11 +107,11 @@ impl<Db: Database> core::fmt::Debug for BundleError<Db> {
Self::BlockNumberMismatch => write!(f, "BlockNumberMismatch"),
Self::BundleEmpty => write!(f, "BundleEmpty"),
Self::BundleReverted => write!(f, "BundleReverted"),
Self::TransactionDecodingError(e) => write!(f, "TransactionDecodingError({:?})", e),
Self::TransactionDecodingError(e) => write!(f, "TransactionDecodingError({e:?})"),
Self::UnsupportedTransactionType => write!(f, "UnsupportedTransactionType"),
Self::Eip4844BlobGasExceeded => write!(f, "Eip4844BlobGasExceeded"),
Self::TransactionSenderRecoveryError(e) => {
write!(f, "TransactionSenderRecoveryError({:?})", e)
write!(f, "TransactionSenderRecoveryError({e:?})")
}
Self::EVMError { .. } => write!(f, "EVMError"),
}
Expand Down Expand Up @@ -278,7 +278,7 @@ where
) -> DriveBundleResult<Self, Db, Insp> {
// Check if the block we're in is valid for this bundle. Both must match
trevm_ensure!(
trevm.inner().block.number == self.bundle.block_number,
trevm.inner().block.number == U256::from(self.bundle.block_number),
trevm,
BundleError::BlockNumberMismatch
);
Expand All @@ -296,7 +296,7 @@ where

// Set the state block number this simulation was based on
self.response.state_block_number =
self.bundle.state_block_number.as_number().unwrap_or(trevm.inner().block.number);
self.bundle.state_block_number.as_number().unwrap_or(trevm.block_number().to());

let bundle_filler = BundleBlockFiller::from(&self.bundle);

Expand Down Expand Up @@ -416,15 +416,15 @@ where
{
// Check if the block we're in is valid for this bundle. Both must match
trevm_ensure!(
trevm.inner().block.number == self.bundle.block_number,
trevm.block_number() == U256::from(self.bundle.block_number),
trevm,
BundleError::BlockNumberMismatch
);

// Check for start timestamp range validity
if let Some(min_timestamp) = self.bundle.min_timestamp {
trevm_ensure!(
trevm.inner().block.timestamp >= min_timestamp,
trevm.block_timestamp() >= U256::from(min_timestamp),
trevm,
BundleError::TimestampOutOfRange
);
Expand All @@ -433,7 +433,7 @@ where
// Check for end timestamp range validity
if let Some(max_timestamp) = self.bundle.max_timestamp {
trevm_ensure!(
trevm.inner().block.timestamp <= max_timestamp,
trevm.block_timestamp() <= U256::from(max_timestamp),
trevm,
BundleError::TimestampOutOfRange
);
Expand Down Expand Up @@ -503,9 +503,9 @@ struct BundleBlockFiller {
impl Block for BundleBlockFiller {
fn fill_block_env(&self, block_env: &mut revm::context::block::BlockEnv) {
if let Some(timestamp) = self.timestamp {
block_env.timestamp = timestamp;
block_env.timestamp = U256::from(timestamp);
} else {
block_env.timestamp += 12;
block_env.timestamp += U256::from(12);
}
if let Some(gas_limit) = self.gas_limit {
block_env.gas_limit = gas_limit;
Expand All @@ -517,7 +517,7 @@ impl Block for BundleBlockFiller {
block_env.basefee = base_fee.try_into().unwrap_or(u64::MAX);
}
if let Some(block_number) = self.block_number.as_number() {
block_env.number = block_number;
block_env.number = U256::from(block_number);
}
}
}
Expand Down Expand Up @@ -559,7 +559,7 @@ where
) -> DriveBundleResult<Self, Db, Insp> {
// Check if the block we're in is valid for this bundle. Both must match
trevm_ensure!(
trevm.inner().block.number == self.block_number,
trevm.block_number() == U256::from(self.block_number),
trevm,
BundleError::BlockNumberMismatch
);
Expand Down Expand Up @@ -650,7 +650,7 @@ where
) -> DriveBundleResult<Self, Db, Insp> {
// Check if the block we're in is valid for this bundle. Both must match
trevm_ensure!(
trevm.inner().block.number == self.block_number,
trevm.block_number() == U256::from(self.block_number),
trevm,
BundleError::BlockNumberMismatch
);
Expand All @@ -659,7 +659,7 @@ where

if let Some(min_timestamp) = self.min_timestamp {
trevm_ensure!(
trevm.inner().block.timestamp >= min_timestamp,
trevm.block_timestamp() >= U256::from(min_timestamp),
trevm,
BundleError::TimestampOutOfRange
);
Expand All @@ -668,7 +668,7 @@ where
// Check for end timestamp range validity
if let Some(max_timestamp) = self.max_timestamp {
trevm_ensure!(
trevm.inner().block.timestamp <= max_timestamp,
trevm.block_timestamp() <= U256::from(max_timestamp),
trevm,
BundleError::TimestampOutOfRange
);
Expand Down
40 changes: 20 additions & 20 deletions src/evm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ where
&mut self,
address: Address,
) -> Result<Option<AccountInfo>, <Db as Database>::Error> {
self.inner.db().basic(address)
self.inner.db_mut().basic(address)
}

/// Get the current nonce for a specific address
Expand All @@ -300,7 +300,7 @@ where
address: Address,
slot: U256,
) -> Result<U256, <Db as Database>::Error> {
self.inner.db().storage(address, slot)
self.inner.db_mut().storage(address, slot)
}

/// Get the code at the given account, if any.
Expand All @@ -312,7 +312,7 @@ where
) -> Result<Option<Bytecode>, <Db as Database>::Error> {
let acct_info = self.try_read_account(address)?;
match acct_info {
Some(acct) => Ok(Some(self.inner.db().code_by_hash(acct.code_hash)?)),
Some(acct) => Ok(Some(self.inner.db_mut().code_by_hash(acct.code_hash)?)),
None => Ok(None),
}
}
Expand Down Expand Up @@ -409,7 +409,7 @@ where
///
/// Note: due to revm's DB model, this requires a mutable pointer.
pub fn read_account(&mut self, address: Address) -> Option<AccountInfo> {
self.inner.db().basic(address).expect("infallible")
self.inner.db_mut().basic(address).expect("infallible")
}

/// Get the current nonce for a specific address
Expand All @@ -430,15 +430,15 @@ where
///
/// Note: due to revm's DB model, this requires a mutable pointer.
pub fn read_storage(&mut self, address: Address, slot: U256) -> U256 {
self.inner.db().storage(address, slot).expect("infallible")
self.inner.db_mut().storage(address, slot).expect("infallible")
}

/// Get the code at the given account, if any.
///
/// Note: due to revm's DB model, this requires a mutable pointer.
pub fn read_code(&mut self, address: Address) -> Option<Bytecode> {
let acct_info = self.read_account(address)?;
Some(self.inner.db().code_by_hash(acct_info.code_hash).expect("infallible"))
Some(self.inner.db_mut().code_by_hash(acct_info.code_hash).expect("infallible"))
}
}

Expand Down Expand Up @@ -493,7 +493,7 @@ where
where
Db: DatabaseCommit,
{
self.inner.db().commit(state);
self.inner.db_mut().commit(state);
}

/// Modify an account with a closure and commit the modified account. This
Expand Down Expand Up @@ -735,7 +735,7 @@ where
/// Set the [EIP-161] state clear flag, activated in the Spurious Dragon
/// hardfork.
pub fn set_state_clear_flag(&mut self, flag: bool) {
self.inner.db().set_state_clear_flag(flag)
self.inner.db_mut().set_state_clear_flag(flag)
}
}

Expand All @@ -753,7 +753,7 @@ where
&mut self,
flag: bool,
) -> Result<(), <Db as TryStateAcc>::Error> {
self.inner.db().try_set_state_clear_flag(flag)
self.inner.db_mut().try_set_state_clear_flag(flag)
}
}

Expand Down Expand Up @@ -1129,12 +1129,12 @@ where
}

/// Get the current block number.
pub fn block_number(&self) -> u64 {
pub fn block_number(&self) -> U256 {
self.block().number()
}

/// Get the current block timestamp.
pub fn block_timestamp(&self) -> u64 {
pub fn block_timestamp(&self) -> U256 {
self.block().timestamp()
}

Expand Down Expand Up @@ -1204,8 +1204,8 @@ where
/// [`State::take_bundle`]: revm::database::State::take_bundle
pub fn finish(self) -> BundleState {
let Self { inner: mut evm, .. } = self;
evm.db().merge_transitions(BundleRetention::Reverts);
let bundle = evm.db().take_bundle();
evm.db_mut().merge_transitions(BundleRetention::Reverts);
let bundle = evm.db_mut().take_bundle();

bundle
}
Expand All @@ -1231,7 +1231,7 @@ where
pub fn try_finish(
mut self,
) -> Result<BundleState, EvmErrored<Db, Insp, <Db as TryStateAcc>::Error>> {
let db = self.inner.db();
let db = self.inner.db_mut();

trevm_try!(db.try_merge_transitions(BundleRetention::Reverts), self);

Expand Down Expand Up @@ -1544,7 +1544,7 @@ where
overrides.fill_block(&mut self.inner);

if let Some(hashes) = overrides.block_hash.as_ref() {
self.inner.db().set_block_hashes(hashes)
self.inner.db_mut().set_block_hashes(hashes)
}

self
Expand Down Expand Up @@ -1590,7 +1590,7 @@ where
overrides.fill_block(&mut self.inner);

if let Some(hashes) = overrides.block_hash.as_ref() {
trevm_try!(self.inner.db().try_set_block_hashes(hashes), self);
trevm_try!(self.inner.db_mut().try_set_block_hashes(hashes), self);
}

Ok(self)
Expand Down Expand Up @@ -1636,10 +1636,10 @@ where
}

/// Execute the loaded transaction. This is a wrapper around
/// [`InspectEvm::inspect_replay`] and produces either [`EvmTransacted`] or
/// [`InspectEvm::inspect_tx`] and produces either [`EvmTransacted`] or
/// [`EvmErrored`].
pub fn run(mut self) -> Result<EvmTransacted<Db, Insp>, EvmErrored<Db, Insp>> {
let result = self.inner.inspect_replay();
let result = self.inner.inspect_tx(self.tx().clone());

let Self { inner, .. } = self;

Expand Down Expand Up @@ -2110,7 +2110,7 @@ where
{
let Self { mut inner, state: TransactedState { result } } = self;

inner.db().commit(result.state);
inner.db_mut().commit(result.state);

(result.result, Trevm { inner, state: NeedsTx::new() })
}
Expand All @@ -2133,7 +2133,7 @@ where
{
let Self { mut inner, state: TransactedState { result } } = self;

trevm_try!(inner.db().try_commit(result.state), Trevm { inner, state: NeedsTx::new() });
trevm_try!(inner.db_mut().try_commit(result.state), Trevm { inner, state: NeedsTx::new() });
Ok((result.result, Trevm { inner, state: NeedsTx::new() }))
}

Expand Down
6 changes: 3 additions & 3 deletions src/ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ pub trait EvmExtUnchecked<Db: Database> {
let mut acct = self.account(address)?;
let old = self.storage(address, index)?;

let change = EvmStorageSlot::new_changed(old, value);
let change = EvmStorageSlot::new_changed(old, value, 0);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is this new arg? how does it work? where is it used in revm?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for posterity: it is either a transaction_id and/or a transition_id (both terms are used in revm code) and the EVM internal journal uses it when reverting transitions while executing multiple transactions without commiting them to the db.

acct.storage.insert(index, change);
acct.mark_touch();

Expand Down Expand Up @@ -171,11 +171,11 @@ pub trait EvmExtUnchecked<Db: Database> {
}
}

impl<Ctx, Insp, Inst, Prec> EvmExtUnchecked<Ctx::Db> for Evm<Ctx, Insp, Inst, Prec>
impl<Ctx, Insp, Inst, Prec, Frame> EvmExtUnchecked<Ctx::Db> for Evm<Ctx, Insp, Inst, Prec, Frame>
where
Ctx: ContextTr,
{
fn db_mut_ext(&mut self) -> &mut Ctx::Db {
self.ctx.db()
self.ctx.db_mut()
}
}
Loading