Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generalize machine run/step in call stack #226

Merged
merged 1 commit into from
Nov 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 19 additions & 28 deletions jsontests/src/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use evm::backend::in_memory::{
};
use evm::standard::{Config, Etable, Gasometer, Invoker, TransactArgs};
use evm::utils::u256_to_h256;
use evm::{Capture, RuntimeState};
use evm::{Capture, GasedMachine};
use primitive_types::U256;
use std::collections::{BTreeMap, BTreeSet};

Expand Down Expand Up @@ -59,7 +59,7 @@ pub fn run_test(_filename: &str, _test_name: &str, test: Test, debug: bool) -> R
.collect::<BTreeMap<_, _>>();

let etable = Etable::runtime();
let invoker = Invoker::new(&config);
let invoker = Invoker::<_, Gasometer, _, _, _>::new(&config, &etable);
let args = TransactArgs::Call {
caller: test.transaction.sender,
address: test.transaction.to,
Expand Down Expand Up @@ -93,36 +93,27 @@ pub fn run_test(_filename: &str, _test_name: &str, test: Test, debug: bool) -> R
let mut step_backend = run_backend.clone();

// Run
let run_result = evm::transact::<RuntimeState, Gasometer, _, _, _, _>(
args.clone(),
Some(4),
&mut run_backend,
&invoker,
&etable,
);
let run_result = evm::transact(args.clone(), Some(4), &mut run_backend, &invoker);
run_backend.layers[0].clear_pending();

// Step
if debug {
let _step_result = evm::HeapTransact::<RuntimeState, Gasometer, _, _, _>::new(
args,
&invoker,
&mut step_backend,
)
.and_then(|mut stepper| loop {
{
let machine = stepper.last_machine()?;
println!(
"pc: {}, opcode: {:?}, gas: 0x{:x}",
machine.machine.position(),
machine.machine.peek_opcode(),
machine.gasometer.gas(),
);
}
if let Err(Capture::Exit(result)) = stepper.step(&etable) {
break result;
}
});
let _step_result = evm::HeapTransact::new(args, &invoker, &mut step_backend).and_then(
|mut stepper| loop {
{
let machine: &GasedMachine<_, Gasometer> = stepper.last_machine()?;
println!(
"pc: {}, opcode: {:?}, gas: 0x{:x}",
machine.machine.position(),
machine.machine.peek_opcode(),
machine.gasometer.gas(),
);
}
if let Err(Capture::Exit(result)) = stepper.step() {
break result;
}
},
);
step_backend.layers[0].clear_pending();
}

Expand Down
Loading
Loading