Skip to content

Commit

Permalink
rename
Browse files Browse the repository at this point in the history
  • Loading branch information
rakita committed Feb 4, 2025
1 parent 057df18 commit 8d4742d
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 23 deletions.
6 changes: 3 additions & 3 deletions bins/revme/src/cmd/statetest/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ pub fn execute_test_suite(
*elapsed.lock().unwrap() += timer.elapsed();

let spec = cfg.spec();
let db = &mut evm.ctx.ctx.journaled_state.database;
let db = &mut evm.data.ctx.journaled_state.database;
// Dump state and traces if test failed
let output = check_evm_execution(
&test,
Expand All @@ -457,7 +457,7 @@ pub fn execute_test_suite(
*elapsed.lock().unwrap() += timer.elapsed();

let spec = cfg.spec();
let db = evm.ctx.ctx.journaled_state.database;
let db = evm.data.ctx.journaled_state.database;
// Dump state and traces if test failed
let output = check_evm_execution(
&test,
Expand Down Expand Up @@ -512,7 +512,7 @@ pub fn execute_test_suite(
println!("\nState before: {cache_state:#?}");
println!(
"\nState after: {:#?}",
evm.ctx.ctx.journaled_state.database.cache
evm.data.ctx.journaled_state.database.cache
);
println!("\nSpecification: {:?}", cfg.spec);
println!("\nTx: {tx:#?}");
Expand Down
14 changes: 7 additions & 7 deletions crates/context/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,21 @@ use primitives::U256;
use specification::hardfork::SpecId;

pub struct Evm<CTX, INSP, I, P> {
pub ctx: Ctx<CTX, INSP>,
pub data: EvmData<CTX, INSP>,
pub enabled_inspection: bool,
pub instruction: I,
pub precompiles: P,
}

pub struct Ctx<CTX, INSP> {
pub struct EvmData<CTX, INSP> {
pub ctx: CTX,
pub inspector: INSP,
}

impl<CTX> Evm<CTX, (), (), ()> {
pub fn new(ctx: CTX) -> Self {
Evm {
ctx: Ctx { ctx, inspector: () },
data: EvmData { ctx, inspector: () },
enabled_inspection: false,
instruction: (),
precompiles: (),
Expand Down Expand Up @@ -79,25 +79,25 @@ impl<CTX: ContextSetters, INSP, I, P> ContextSetters for Evm<CTX, INSP, I, P> {
type Block = <CTX as ContextSetters>::Block;

fn set_tx(&mut self, tx: Self::Tx) {
self.ctx.ctx.set_tx(tx);
self.data.ctx.set_tx(tx);
}

fn set_block(&mut self, block: Self::Block) {
self.ctx.ctx.set_block(block);
self.data.ctx.set_block(block);
}
}

impl<CTX, INSP, I, P> Deref for Evm<CTX, INSP, I, P> {
type Target = CTX;

fn deref(&self) -> &Self::Target {
&self.ctx.ctx
&self.data.ctx
}
}

impl<CTX, INSP, I, P> DerefMut for Evm<CTX, INSP, I, P> {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.ctx.ctx
&mut self.data.ctx
}
}

Expand Down
14 changes: 7 additions & 7 deletions crates/handler/src/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ where
>,
) -> <Self::Instructions as InstructionExecutor>::Output {
let inspect = self.enabled_inspection;
let context = &mut self.ctx.ctx;
let context = &mut self.data.ctx;
let instructions = &mut self.instruction;
let inspector = &mut self.ctx.inspector;
let inspector = &mut self.data.inspector;
if inspect {
let instructions = instructions.inspector_instruction_table();
interpreter.reset_control();
Expand Down Expand Up @@ -100,23 +100,23 @@ where
}

fn ctx(&mut self) -> &mut Self::Context {
&mut self.ctx.ctx
&mut self.data.ctx
}

fn ctx_ref(&self) -> &Self::Context {
&self.ctx.ctx
&self.data.ctx
}

fn ctx_inspector(&mut self) -> (&mut Self::Context, &mut Self::Inspector) {
(&mut self.ctx.ctx, &mut self.ctx.inspector)
(&mut self.data.ctx, &mut self.data.inspector)
}

fn ctx_instructions(&mut self) -> (&mut Self::Context, &mut Self::Instructions) {
(&mut self.ctx.ctx, &mut self.instruction)
(&mut self.data.ctx, &mut self.instruction)
}

fn ctx_precompiles(&mut self) -> (&mut Self::Context, &mut Self::Precompiles) {
(&mut self.ctx.ctx, &mut self.precompiles)
(&mut self.data.ctx, &mut self.precompiles)
}
}

Expand Down
2 changes: 1 addition & 1 deletion crates/inspector/src/gas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ mod tests {
// Run evm.
evm.inspect_previous().unwrap();

let inspector = &evm.ctx.inspector;
let inspector = &evm.data.inspector;

// Starting from 100gas
let steps = vec![
Expand Down
6 changes: 3 additions & 3 deletions crates/revm/src/eth_exec.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::{exec::ExecuteCommitEvm, ExecuteEvm, MainBuilder, MainContext};
use context::{BlockEnv, Cfg, CfgEnv, Context, ContextTrait, Ctx, Evm, JournaledState, TxEnv};
use context::{BlockEnv, Cfg, CfgEnv, Context, ContextTrait, Evm, EvmData, JournaledState, TxEnv};
use context_interface::{
result::{EVMError, ExecutionResult, HaltReason, InvalidTransaction, ResultAndState},
Block, Database, Journal, Transaction,
Expand Down Expand Up @@ -34,7 +34,7 @@ where
EthPrecompiles<Self::Context>,
> {
Evm {
ctx: Ctx {
data: EvmData {
ctx: self,
inspector: NoOpInspector {},
},
Expand All @@ -54,7 +54,7 @@ where
EthPrecompiles<Self::Context>,
> {
Evm {
ctx: Ctx {
data: EvmData {
ctx: self,
inspector,
},
Expand Down
4 changes: 2 additions & 2 deletions crates/revm/src/eth_exec_inspect.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::{
exec::ExecuteCommitEvm, ExecuteEvm, InspectCommitEvm, InspectEvm, MainBuilder, MainContext,
};
use context::{BlockEnv, Cfg, CfgEnv, Context, ContextTrait, Ctx, Evm, JournaledState, TxEnv};
use context::{BlockEnv, Cfg, CfgEnv, Context, ContextTrait, Evm, JournaledState, TxEnv};
use context_interface::{
result::{EVMError, ExecutionResult, HaltReason, InvalidTransaction, ResultAndState},
Block, Database, Journal, Transaction,
Expand Down Expand Up @@ -37,7 +37,7 @@ where
type Inspector = INSP;

fn set_inspector(&mut self, inspector: Self::Inspector) {
self.ctx.inspector = inspector;
self.data.inspector = inspector;
}

fn inspect_previous(&mut self) -> Self::Output {
Expand Down

0 comments on commit 8d4742d

Please sign in to comment.