Skip to content

Commit f231427

Browse files
authored
chore(deps): upgrade to revm 34 (#146)
* chore(deps): upgrade to revm 34 * chore: v34 * dm(maj7)
1 parent 6c03442 commit f231427

File tree

7 files changed

+46
-21
lines changed

7 files changed

+46
-21
lines changed

Cargo.toml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "trevm"
3-
version = "0.33.1"
3+
version = "0.34.0"
44
rust-version = "1.83.0"
55
edition = "2021"
66
authors = ["init4"]
@@ -44,8 +44,8 @@ alloy = { version = "1.4.0", default-features = false, features = [
4444
"sol-types",
4545
] }
4646

47-
revm = { version = "33", default-features = false }
48-
revm-inspectors = { version = "0.33", optional = true }
47+
revm = { version = "34", default-features = false }
48+
revm-inspectors = { version = "0.34", optional = true }
4949

5050
dashmap = { version = "6.1.0", optional = true }
5151
tracing = { version = "0.1.41", optional = true }
@@ -54,10 +54,10 @@ thiserror = "2.0.11"
5454
tokio = { version = "1.44", optional = true }
5555

5656
[dev-dependencies]
57-
revm = { version = "33", features = ["serde-json", "std", "alloydb"] }
57+
revm = { version = "34", features = ["serde-json", "std", "alloydb"] }
5858
trevm = { path = ".", features = ["test-utils"] }
5959

60-
alloy = { version = "1.0.35", features = ["providers", "transports"] }
60+
alloy = { version = "1.4.0", features = ["providers", "transports"] }
6161

6262
# misc
6363
eyre = "0.6"

src/db/cow/mod.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,8 +272,10 @@ mod tests {
272272
let address = Address::with_last_byte(42);
273273

274274
// Write an account with storage at index 0 to the underlying DB
275+
let original_info = AccountInfo { balance: U256::from(5000), ..Default::default() };
275276
let account = Account {
276-
info: AccountInfo { balance: U256::from(5000), ..Default::default() },
277+
original_info: Box::new(original_info.clone()),
278+
info: original_info,
277279
storage: [(U256::from(0), EvmStorageSlot::new_changed(U256::ZERO, U256::from(42), 0))]
278280
.into_iter()
279281
.collect(),
@@ -301,8 +303,10 @@ mod tests {
301303
assert_eq!(cow_db.storage(address, U256::from(1)).unwrap(), U256::ZERO);
302304

303305
// Write a storage item at index 1 to the COW DB
306+
let original_info = AccountInfo { balance: U256::from(5000), ..Default::default() };
304307
let account = Account {
305-
info: AccountInfo { balance: U256::from(5000), ..Default::default() },
308+
original_info: Box::new(original_info.clone()),
309+
info: original_info,
306310
storage: [(U256::from(1), EvmStorageSlot::new_changed(U256::ZERO, U256::from(42), 0))]
307311
.into_iter()
308312
.collect(),

src/db/test_utils.rs

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,12 @@ pub trait DbTestExt: Database + DatabaseCommit {
1414
where
1515
F: FnOnce(&mut AccountInfo),
1616
{
17-
let mut info = self.basic(address).ok().flatten().unwrap_or_default();
17+
let original_info = self.basic(address).ok().flatten().unwrap_or_default();
18+
let mut info = original_info.clone();
1819
f(&mut info);
1920
let account = Account {
2021
info,
22+
original_info: Box::new(original_info),
2123
storage: Default::default(),
2224
status: AccountStatus::Touched,
2325
transaction_id: 0,
@@ -54,7 +56,13 @@ pub trait DbTestExt: Database + DatabaseCommit {
5456
let info = self.basic(address).ok().flatten().unwrap_or_default();
5557
let storage =
5658
HashMap::from_iter([(slot, EvmStorageSlot::new_changed(U256::ZERO, value, 0))]);
57-
let account = Account { info, storage, status: AccountStatus::Touched, transaction_id: 0 };
59+
let account = Account {
60+
info: info.clone(),
61+
original_info: Box::new(info),
62+
storage,
63+
status: AccountStatus::Touched,
64+
transaction_id: 0,
65+
};
5866
self.commit(HashMap::from_iter([(address, account)]));
5967
}
6068

@@ -81,10 +89,12 @@ pub trait TryDbTestExt: Database + TryDatabaseCommit {
8189
where
8290
F: FnOnce(&mut AccountInfo),
8391
{
84-
let mut info = self.basic(address).ok().flatten().unwrap_or_default();
92+
let original_info = self.basic(address).ok().flatten().unwrap_or_default();
93+
let mut info = original_info.clone();
8594
f(&mut info);
8695
let account = Account {
8796
info,
97+
original_info: Box::new(original_info),
8898
storage: Default::default(),
8999
status: AccountStatus::Touched,
90100
transaction_id: 0,
@@ -142,7 +152,13 @@ pub trait TryDbTestExt: Database + TryDatabaseCommit {
142152
let info = self.basic(address).ok().flatten().unwrap_or_default();
143153
let storage =
144154
HashMap::from_iter([(slot, EvmStorageSlot::new_changed(U256::ZERO, value, 0))]);
145-
let account = Account { info, storage, status: AccountStatus::Touched, transaction_id: 0 };
155+
let account = Account {
156+
info: info.clone(),
157+
original_info: Box::new(info),
158+
storage,
159+
status: AccountStatus::Touched,
160+
transaction_id: 0,
161+
};
146162
self.try_commit(HashMap::from_iter([(address, account)]))
147163
}
148164

src/evm/all_states.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use alloy::{
1111
use core::convert::Infallible;
1212
use revm::{
1313
bytecode::opcode::DIFFICULTY,
14-
context::{result::EVMError, Cfg as _, ContextTr},
14+
context::{result::EVMError, ContextTr},
1515
handler::EthPrecompiles,
1616
inspector::NoOpInspector,
1717
interpreter::instructions::block_info,
@@ -155,7 +155,7 @@ where
155155

156156
/// Get the id of the currently running hardfork spec.
157157
pub fn spec_id(&self) -> SpecId {
158-
self.inner.ctx.cfg().spec()
158+
*self.inner.ctx.cfg().spec()
159159
}
160160

161161
/// Set the [SpecId], modifying the EVM handlers accordingly. This function

src/ext.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@ pub trait EvmExtUnchecked<Db: Database> {
1414

1515
/// Load an account from the database.
1616
fn account(&mut self, address: Address) -> Result<Account, Db::Error> {
17-
let info = self.db_mut_ext().basic(address)?;
18-
let created = info.is_none();
19-
let mut acct = Account { info: info.unwrap_or_default(), ..Default::default() };
17+
let info = self.db_mut_ext().basic(address)?.unwrap_or_default();
18+
let created = info.is_empty();
19+
let mut acct =
20+
Account { original_info: Box::new(info.clone()), info, ..Default::default() };
2021
if created {
2122
acct.mark_created();
2223
}

src/inspectors/spanning.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -146,10 +146,10 @@ impl SpanningInspector {
146146
runtime_level_span!(
147147
self.level,
148148
"create",
149-
caller = %inputs.caller,
150-
value = %inputs.value,
151-
gas_limit = inputs.gas_limit,
152-
scheme = ?inputs.scheme,
149+
caller = %inputs.caller(),
150+
value = %inputs.value(),
151+
gas_limit = inputs.gas_limit(),
152+
scheme = ?inputs.scheme(),
153153
)
154154
}
155155

src/journal/coder.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,7 @@ impl JournalDecode for AccountInfo {
499499
balance: JournalDecode::decode(buf)?,
500500
nonce: JournalDecode::decode(buf)?,
501501
code_hash: JournalDecode::decode(buf)?,
502+
account_id: None,
502503
code: None,
503504
})
504505
}
@@ -578,7 +579,7 @@ impl JournalDecode for Bytecode {
578579

579580
match tag {
580581
TAG_BYTECODE_RAW => Ok(Self::new_raw(raw)),
581-
TAG_BYTECODE_7702 => Ok(Self::Eip7702(Eip7702Bytecode::new_raw(raw)?)),
582+
TAG_BYTECODE_7702 => Ok(Self::Eip7702(Eip7702Bytecode::new_raw(raw)?.into())),
582583
_ => Err(JournalDecodeError::InvalidTag { ty_name: "Bytecode", tag, max_expected: 2 }),
583584
}
584585
}
@@ -658,6 +659,7 @@ mod test {
658659
nonce: 38238923,
659660
code_hash: B256::repeat_byte(0xa),
660661
code: None,
662+
account_id: None,
661663
};
662664
roundtrip(&acc_info);
663665
let created_outcome = InfoOutcome::Created(Cow::Owned(acc_info));
@@ -669,12 +671,14 @@ mod test {
669671
nonce: 38,
670672
code_hash: B256::repeat_byte(0xab),
671673
code: None,
674+
account_id: None,
672675
}),
673676
new: Cow::Owned(AccountInfo {
674677
balance: U256::from(38238923),
675678
nonce: 38238923,
676679
code_hash: B256::repeat_byte(0xa),
677680
code: None,
681+
account_id: None,
678682
}),
679683
};
680684
roundtrip(&diff_outcome);

0 commit comments

Comments
 (0)