Skip to content

Commit 0b8bda7

Browse files
authored
chore: bump revm to 40.0.0 (#361)
Adapts to revm 40.0.0 breaking changes: - `BalDatabase::set_bal_index` and `State::set_bal_index` now take `BlockAccessIndex` - `revm::state::Account::original_info` is private; construct via `From<AccountInfo>` - `EvmStorageSlot::transaction_id` is now `TransactionId` (use `TransactionId::ZERO`) - `PrecompileProvider::warm_addresses` returns `&AddressSet`
1 parent 686b3c8 commit 0b8bda7

5 files changed

Lines changed: 25 additions & 36 deletions

File tree

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ alloy-rpc-types-eth = { version = "2.0.0", default-features = false }
4949
alloy-rpc-types-engine = { version = "2.0.0", default-features = false }
5050

5151
# revm
52-
revm = { version = "38.0.0", default-features = false }
52+
revm = { version = "40.0.0", default-features = false }
5353

5454
# tracing
5555
tracing = { version = "0.1", default-features = false }

crates/evm/src/block/state.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
//! State database abstraction.
22
33
use crate::Database;
4-
use revm::{database::State, database_interface::bal::BalDatabase, DatabaseCommit};
4+
use revm::{
5+
database::State, database_interface::bal::BalDatabase, state::bal::BlockAccessIndex,
6+
DatabaseCommit,
7+
};
58

69
/// Database that tracks the current block-level access list (BAL) index from EIP-7928.
710
///
@@ -27,7 +30,7 @@ where
2730
Self: Database,
2831
{
2932
fn set_bal_index(&mut self, index: u64) {
30-
self.bal_state.bal_index = index;
33+
self.bal_state.bal_index = BlockAccessIndex::new(index);
3134
}
3235

3336
fn bump_bal_index(&mut self) {
@@ -40,7 +43,7 @@ where
4043
Self: Database,
4144
{
4245
fn set_bal_index(&mut self, index: u64) {
43-
self.bal_state.bal_index = index;
46+
self.bal_state.bal_index = BlockAccessIndex::new(index);
4447
}
4548

4649
fn bump_bal_index(&mut self) {
@@ -63,9 +66,9 @@ mod tests {
6366
let mut db = State::builder().with_database(CacheDB::new(EmptyDB::new())).build();
6467

6568
BalIndexedDatabase::set_bal_index(&mut db, 7);
66-
assert_eq!(db.bal_state.bal_index, 7);
69+
assert_eq!(db.bal_state.bal_index, BlockAccessIndex::new(7));
6770

6871
BalIndexedDatabase::bump_bal_index(&mut db);
69-
assert_eq!(db.bal_state.bal_index, 8);
72+
assert_eq!(db.bal_state.bal_index, BlockAccessIndex::new(8));
7073
}
7174
}

crates/evm/src/block/state_changes.rs

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
//! State changes that are not related to transactions.
22
33
use super::{calc, BlockExecutionError};
4-
use alloc::boxed::Box;
54
use alloy_consensus::BlockHeader;
65
use alloy_eips::eip4895::Withdrawal;
76
use alloy_hardforks::EthereumHardforks;
@@ -120,15 +119,9 @@ where
120119
BlockExecutionError::msg("could not load account for balance increment")
121120
})?;
122121

123-
Ok((
124-
*address,
125-
Account {
126-
info: account.clone(),
127-
original_info: Box::new(account.clone()),
128-
status: AccountStatus::Touched,
129-
..Default::default()
130-
},
131-
))
122+
let mut new_account = Account::from(account.clone());
123+
new_account.status = AccountStatus::Touched;
124+
Ok((*address, new_account))
132125
};
133126

134127
balance_increments

crates/evm/src/overrides.rs

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
//! This module provides helper functions for RPC implementations, including:
44
//! - Block and state overrides
55
6-
use alloc::{boxed::Box, collections::BTreeMap};
6+
use alloc::collections::BTreeMap;
77
use alloy_primitives::{keccak256, map::HashMap, Address, B256, U256};
88
use alloy_rpc_types_eth::{
99
state::{AccountOverride, StateOverride},
@@ -14,7 +14,7 @@ use revm::{
1414
context::BlockEnv,
1515
context_interface::block::BlobExcessGasAndPrice,
1616
database::{CacheDB, State},
17-
state::{Account, AccountStatus, Bytecode, EvmStorageSlot},
17+
state::{Account, AccountStatus, Bytecode, EvmStorageSlot, TransactionId},
1818
Database, DatabaseCommit,
1919
};
2020

@@ -157,13 +157,8 @@ where
157157
}
158158

159159
// Create a new account marked as touched
160-
let mut acc = revm::state::Account {
161-
info: info.clone(),
162-
original_info: Box::new(info),
163-
status: AccountStatus::Touched,
164-
storage: Default::default(),
165-
transaction_id: 0,
166-
};
160+
let mut acc = revm::state::Account::from(info);
161+
acc.status = AccountStatus::Touched;
167162

168163
let storage_diff = match (account_override.state, account_override.state_diff) {
169164
(Some(_), Some(_)) => return Err(StateOverrideError::BothStateAndStateDiff(account)),
@@ -173,13 +168,9 @@ where
173168
// used.
174169
(Some(state), None) => {
175170
// Destroy the account to ensure that its storage is cleared
176-
db.commit(HashMap::from_iter([(
177-
account,
178-
Account {
179-
status: AccountStatus::SelfDestructed | AccountStatus::Touched,
180-
..Default::default()
181-
},
182-
)]));
171+
let mut destroyed = Account::default();
172+
destroyed.status = AccountStatus::SelfDestructed | AccountStatus::Touched;
173+
db.commit(HashMap::from_iter([(account, destroyed)]));
183174
// Mark the account as created to ensure that old storage is not read
184175
acc.mark_created();
185176
Some(state)
@@ -207,7 +198,7 @@ where
207198
original_value: (!value).into(),
208199
present_value: value.into(),
209200
is_cold: false,
210-
transaction_id: 0,
201+
transaction_id: TransactionId::ZERO,
211202
},
212203
);
213204
}

crates/evm/src/precompiles.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
use crate::{Database, EvmInternals};
44
use alloc::{
55
borrow::Cow,
6-
boxed::Box,
76
string::{String, ToString},
87
sync::Arc,
98
vec::Vec,
@@ -566,8 +565,11 @@ where
566565
Ok(Some(precompile_output_to_interpreter_result(precompile_output, inputs.gas_limit)))
567566
}
568567

569-
fn warm_addresses(&self) -> Box<impl Iterator<Item = Address>> {
570-
Box::new(self.addresses().copied())
568+
fn warm_addresses(&self) -> &AddressSet {
569+
match &self.precompiles {
570+
PrecompilesKind::Builtin(precompiles) => precompiles.addresses_set(),
571+
PrecompilesKind::Dynamic(dyn_precompiles) => &dyn_precompiles.addresses,
572+
}
571573
}
572574

573575
fn contains(&self, address: &Address) -> bool {

0 commit comments

Comments
 (0)