Skip to content

Commit 375459f

Browse files
authored
fix: remove dbgs, improve imports (#52)
1 parent d1f3b45 commit 375459f

File tree

4 files changed

+17
-15
lines changed

4 files changed

+17
-15
lines changed

src/evm.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ use crate::{
66
};
77
use alloy_primitives::{Address, Bytes, U256};
88
use revm::{
9-
db::{states::bundle_state::BundleRetention, BundleState},
9+
db::{states::bundle_state::BundleRetention, BundleState, State},
1010
primitives::{
1111
AccountInfo, Bytecode, EVMError, EvmState, ExecutionResult, InvalidTransaction,
1212
ResultAndState, SpecId,
1313
},
14-
Database, DatabaseCommit, DatabaseRef, Evm, State,
14+
Database, DatabaseCommit, DatabaseRef, Evm,
1515
};
1616
use std::{convert::Infallible, fmt};
1717

@@ -892,7 +892,6 @@ impl<'a, Ext, Db: Database> EvmNeedsBlock<'a, Ext, State<Db>> {
892892
/// See [`State::merge_transitions`] and [`State::take_bundle`].
893893
pub fn finish(self) -> BundleState {
894894
let Self { inner: mut evm, .. } = self;
895-
896895
evm.db_mut().merge_transitions(BundleRetention::Reverts);
897896
let bundle = evm.db_mut().take_bundle();
898897

src/ext.rs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use std::collections::HashMap;
22

33
use alloy_primitives::{Address, B256, U256};
44
use revm::{
5-
primitives::{Account, AccountInfo, Bytecode, EvmStorageSlot},
5+
primitives::{Account, AccountInfo, Bytecode, EvmState, EvmStorageSlot},
66
Database, DatabaseCommit,
77
};
88

@@ -48,28 +48,29 @@ pub trait EvmExtUnchecked<Db: Database> {
4848
{
4949
let mut state = HashMap::default();
5050
let mut old = HashMap::default();
51-
for account in changes.into_iter() {
52-
let mut acct = self.account(account)?;
53-
old.insert(account, acct.info.clone());
51+
for addr in changes.into_iter() {
52+
let mut acct = self.account(addr)?;
53+
old.insert(addr, acct.info.clone());
5454
f(&mut acct.info);
5555
acct.mark_touch();
56-
state.insert(account, acct);
56+
state.insert(addr, acct);
5757
}
5858
self.db_mut_ext().commit(state);
5959
Ok(old)
6060
}
6161

6262
/// Modify an account with a closure and commit the modified account.
63-
fn modify_account<F>(&mut self, address: Address, f: F) -> Result<AccountInfo, Db::Error>
63+
fn modify_account<F>(&mut self, addr: Address, f: F) -> Result<AccountInfo, Db::Error>
6464
where
6565
F: FnOnce(&mut AccountInfo),
6666
Db: DatabaseCommit,
6767
{
68-
let mut acct = self.account(address)?;
68+
let mut acct = self.account(addr)?;
6969
let old = acct.info.clone();
7070
f(&mut acct.info);
7171
acct.mark_touch();
72-
let changes = [(address, acct)].into_iter().collect();
72+
73+
let changes: EvmState = [(addr, acct)].into_iter().collect();
7374
self.db_mut_ext().commit(changes);
7475
Ok(old)
7576
}

src/system/eip2935.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,6 @@ impl<'a, Ext, Db: Database + DatabaseCommit> EvmNeedsTx<'a, Ext, Db> {
4646
.block_hash(prev_block)
4747
.map_err(EVMError::Database)?;
4848

49-
dbg!(slot);
50-
dbg!(parent_block_hash);
51-
5249
self.try_set_storage_unchecked(HISTORY_STORAGE_ADDRESS, slot, parent_block_hash.into())
5350
.map_err(EVMError::Database)?;
5451

src/test_utils.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use crate::{EvmNeedsCfg, Trevm, TrevmBuilder};
22
use alloy_primitives::{Address, U256};
33
use revm::{
4-
db::{CacheDB, EmptyDB, InMemoryDB},
4+
db::{CacheDB, EmptyDB, InMemoryDB, State},
55
inspector_handle_register,
66
inspectors::TracerEip3155,
77
primitives::{AccountInfo, Bytecode},
@@ -106,6 +106,11 @@ pub fn test_trevm() -> EvmNeedsCfg<'static, (), CacheDB<EmptyDB>> {
106106
EvmBuilder::default().with_db(CacheDB::new(EmptyDB::default())).build_trevm()
107107
}
108108

109+
/// Make a new [`Trevm`] with an in-memory database wrapped in a [`State`].
110+
pub fn test_state_trevm() -> EvmNeedsCfg<'static, (), State<EmptyDB>> {
111+
EvmBuilder::default().with_db(State::builder().with_bundle_update().build()).build_trevm()
112+
}
113+
109114
/// Make a new [`Trevm`] with an in-memory database and a tracer inspector.
110115
/// The tracer will print all EVM instructions to stdout.
111116
pub fn test_trevm_tracing() -> EvmNeedsCfg<'static, TracerEip3155, CacheDB<EmptyDB>> {

0 commit comments

Comments
 (0)