Skip to content

Commit 7a4da88

Browse files
committed
fix: mutable db access is now explicit
1 parent 4ec5af7 commit 7a4da88

File tree

2 files changed

+19
-19
lines changed

2 files changed

+19
-19
lines changed

src/evm.rs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ where
275275
&mut self,
276276
address: Address,
277277
) -> Result<Option<AccountInfo>, <Db as Database>::Error> {
278-
self.inner.db().basic(address)
278+
self.inner.db_mut().basic(address)
279279
}
280280

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

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

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

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

@@ -493,7 +493,7 @@ where
493493
where
494494
Db: DatabaseCommit,
495495
{
496-
self.inner.db().commit(state);
496+
self.inner.db_mut().commit(state);
497497
}
498498

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

@@ -753,7 +753,7 @@ where
753753
&mut self,
754754
flag: bool,
755755
) -> Result<(), <Db as TryStateAcc>::Error> {
756-
self.inner.db().try_set_state_clear_flag(flag)
756+
self.inner.db_mut().try_set_state_clear_flag(flag)
757757
}
758758
}
759759

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

12101210
bundle
12111211
}
@@ -1231,7 +1231,7 @@ where
12311231
pub fn try_finish(
12321232
mut self,
12331233
) -> Result<BundleState, EvmErrored<Db, Insp, <Db as TryStateAcc>::Error>> {
1234-
let db = self.inner.db();
1234+
let db = self.inner.db_mut();
12351235

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

@@ -1544,7 +1544,7 @@ where
15441544
overrides.fill_block(&mut self.inner);
15451545

15461546
if let Some(hashes) = overrides.block_hash.as_ref() {
1547-
self.inner.db().set_block_hashes(hashes)
1547+
self.inner.db_mut().set_block_hashes(hashes)
15481548
}
15491549

15501550
self
@@ -1590,7 +1590,7 @@ where
15901590
overrides.fill_block(&mut self.inner);
15911591

15921592
if let Some(hashes) = overrides.block_hash.as_ref() {
1593-
trevm_try!(self.inner.db().try_set_block_hashes(hashes), self);
1593+
trevm_try!(self.inner.db_mut().try_set_block_hashes(hashes), self);
15941594
}
15951595

15961596
Ok(self)
@@ -2110,7 +2110,7 @@ where
21102110
{
21112111
let Self { mut inner, state: TransactedState { result } } = self;
21122112

2113-
inner.db().commit(result.state);
2113+
inner.db_mut().commit(result.state);
21142114

21152115
(result.result, Trevm { inner, state: NeedsTx::new() })
21162116
}
@@ -2133,7 +2133,7 @@ where
21332133
{
21342134
let Self { mut inner, state: TransactedState { result } } = self;
21352135

2136-
trevm_try!(inner.db().try_commit(result.state), Trevm { inner, state: NeedsTx::new() });
2136+
trevm_try!(inner.db_mut().try_commit(result.state), Trevm { inner, state: NeedsTx::new() });
21372137
Ok((result.result, Trevm { inner, state: NeedsTx::new() }))
21382138
}
21392139

src/helpers.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use revm::{
2-
context::{BlockEnv, CfgEnv, TxEnv},
2+
context::{BlockEnv, CfgEnv, FrameStack, TxEnv},
33
context_interface::context::ContextError,
44
handler::{instructions::EthInstructions, EthPrecompiles},
55
inspector::NoOpInspector,
@@ -11,8 +11,8 @@ use revm::{
1111
pub type Ctx<Db, J = Journal<Db>, C = ()> = Context<BlockEnv, TxEnv, CfgEnv, Db, J, C>;
1212

1313
/// EVM with default env types and adjustable DB.
14-
pub type Evm<Db, Insp = NoOpInspector, Inst = Instructions<Db>, Prec = EthPrecompiles> =
15-
revm::context::Evm<Ctx<Db>, Insp, Inst, Prec, Frame>;
14+
pub type Evm<Db, Frame, Insp = NoOpInspector, Inst = Instructions<Db>, Prec = EthPrecompiles> =
15+
revm::context::Evm<Ctx<Db>, Insp, Inst, Prec, FrameStack<Frame>>;
1616

1717
/// Handler table for EVM opcodes.
1818
pub type Instructions<Db> = EthInstructions<EthInterpreter, Ctx<Db>>;

0 commit comments

Comments
 (0)