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

Refactor: GasedMachine #205

Merged
merged 1 commit into from
Nov 7, 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
64 changes: 32 additions & 32 deletions interpreter/src/eval/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ mod misc;
mod system;

use crate::{
CallCreateTrap, ExitException, ExitResult, ExitSucceed, Machine, Opcode, RuntimeHandler,
CallCreateTrap, ExitException, ExitResult, ExitSucceed, Machine, Opcode, RuntimeBackend,
RuntimeState,
};
use core::marker::PhantomData;
Expand Down Expand Up @@ -179,7 +179,7 @@ impl<S, H, Tr> Etable<S, H, Tr> {
}
}

impl<S: AsRef<RuntimeState>, H: RuntimeHandler, Tr: CallCreateTrap> Etable<S, H, Tr> {
impl<S: AsRef<RuntimeState>, H: RuntimeBackend, Tr: CallCreateTrap> Etable<S, H, Tr> {
/// Runtime Etable.
pub const fn runtime() -> Etable<S, H, Tr> {
let mut table = Self::core();
Expand Down Expand Up @@ -1217,7 +1217,7 @@ fn eval_unknown<S, H, Tr>(
Control::Exit(ExitException::InvalidOpcode(opcode).into())
}

fn eval_sha3<S: AsRef<RuntimeState>, H: RuntimeHandler, Tr>(
fn eval_sha3<S: AsRef<RuntimeState>, H: RuntimeBackend, Tr>(
machine: &mut Machine<S>,
_handle: &mut H,
_opcode: Opcode,
Expand All @@ -1226,7 +1226,7 @@ fn eval_sha3<S: AsRef<RuntimeState>, H: RuntimeHandler, Tr>(
self::system::sha3(machine)
}

fn eval_address<S: AsRef<RuntimeState>, H: RuntimeHandler, Tr>(
fn eval_address<S: AsRef<RuntimeState>, H: RuntimeBackend, Tr>(
machine: &mut Machine<S>,
_handle: &mut H,
_opcode: Opcode,
Expand All @@ -1235,7 +1235,7 @@ fn eval_address<S: AsRef<RuntimeState>, H: RuntimeHandler, Tr>(
self::system::address(machine)
}

fn eval_balance<S: AsRef<RuntimeState>, H: RuntimeHandler, Tr>(
fn eval_balance<S: AsRef<RuntimeState>, H: RuntimeBackend, Tr>(
machine: &mut Machine<S>,
handle: &mut H,
_opcode: Opcode,
Expand All @@ -1244,7 +1244,7 @@ fn eval_balance<S: AsRef<RuntimeState>, H: RuntimeHandler, Tr>(
self::system::balance(machine, handle)
}

fn eval_selfbalance<S: AsRef<RuntimeState>, H: RuntimeHandler, Tr>(
fn eval_selfbalance<S: AsRef<RuntimeState>, H: RuntimeBackend, Tr>(
machine: &mut Machine<S>,
handle: &mut H,
_opcode: Opcode,
Expand All @@ -1253,7 +1253,7 @@ fn eval_selfbalance<S: AsRef<RuntimeState>, H: RuntimeHandler, Tr>(
self::system::selfbalance(machine, handle)
}

fn eval_origin<S: AsRef<RuntimeState>, H: RuntimeHandler, Tr>(
fn eval_origin<S: AsRef<RuntimeState>, H: RuntimeBackend, Tr>(
machine: &mut Machine<S>,
handle: &mut H,
_opcode: Opcode,
Expand All @@ -1262,7 +1262,7 @@ fn eval_origin<S: AsRef<RuntimeState>, H: RuntimeHandler, Tr>(
self::system::origin(machine, handle)
}

fn eval_caller<S: AsRef<RuntimeState>, H: RuntimeHandler, Tr>(
fn eval_caller<S: AsRef<RuntimeState>, H: RuntimeBackend, Tr>(
machine: &mut Machine<S>,
_handle: &mut H,
_opcode: Opcode,
Expand All @@ -1271,7 +1271,7 @@ fn eval_caller<S: AsRef<RuntimeState>, H: RuntimeHandler, Tr>(
self::system::caller(machine)
}

fn eval_callvalue<S: AsRef<RuntimeState>, H: RuntimeHandler, Tr>(
fn eval_callvalue<S: AsRef<RuntimeState>, H: RuntimeBackend, Tr>(
machine: &mut Machine<S>,
_handle: &mut H,
_opcode: Opcode,
Expand All @@ -1280,7 +1280,7 @@ fn eval_callvalue<S: AsRef<RuntimeState>, H: RuntimeHandler, Tr>(
self::system::callvalue(machine)
}

fn eval_gasprice<S: AsRef<RuntimeState>, H: RuntimeHandler, Tr>(
fn eval_gasprice<S: AsRef<RuntimeState>, H: RuntimeBackend, Tr>(
machine: &mut Machine<S>,
handle: &mut H,
_opcode: Opcode,
Expand All @@ -1289,7 +1289,7 @@ fn eval_gasprice<S: AsRef<RuntimeState>, H: RuntimeHandler, Tr>(
self::system::gasprice(machine, handle)
}

fn eval_extcodesize<S: AsRef<RuntimeState>, H: RuntimeHandler, Tr>(
fn eval_extcodesize<S: AsRef<RuntimeState>, H: RuntimeBackend, Tr>(
machine: &mut Machine<S>,
handle: &mut H,
_opcode: Opcode,
Expand All @@ -1298,7 +1298,7 @@ fn eval_extcodesize<S: AsRef<RuntimeState>, H: RuntimeHandler, Tr>(
self::system::extcodesize(machine, handle)
}

fn eval_extcodehash<S: AsRef<RuntimeState>, H: RuntimeHandler, Tr>(
fn eval_extcodehash<S: AsRef<RuntimeState>, H: RuntimeBackend, Tr>(
machine: &mut Machine<S>,
handle: &mut H,
_opcode: Opcode,
Expand All @@ -1307,7 +1307,7 @@ fn eval_extcodehash<S: AsRef<RuntimeState>, H: RuntimeHandler, Tr>(
self::system::extcodehash(machine, handle)
}

fn eval_extcodecopy<S: AsRef<RuntimeState>, H: RuntimeHandler, Tr>(
fn eval_extcodecopy<S: AsRef<RuntimeState>, H: RuntimeBackend, Tr>(
machine: &mut Machine<S>,
handle: &mut H,
_opcode: Opcode,
Expand All @@ -1316,7 +1316,7 @@ fn eval_extcodecopy<S: AsRef<RuntimeState>, H: RuntimeHandler, Tr>(
self::system::extcodecopy(machine, handle)
}

fn eval_returndatasize<S: AsRef<RuntimeState>, H: RuntimeHandler, Tr>(
fn eval_returndatasize<S: AsRef<RuntimeState>, H: RuntimeBackend, Tr>(
machine: &mut Machine<S>,
_handle: &mut H,
_opcode: Opcode,
Expand All @@ -1325,7 +1325,7 @@ fn eval_returndatasize<S: AsRef<RuntimeState>, H: RuntimeHandler, Tr>(
self::system::returndatasize(machine)
}

fn eval_returndatacopy<S: AsRef<RuntimeState>, H: RuntimeHandler, Tr>(
fn eval_returndatacopy<S: AsRef<RuntimeState>, H: RuntimeBackend, Tr>(
machine: &mut Machine<S>,
_handle: &mut H,
_opcode: Opcode,
Expand All @@ -1334,7 +1334,7 @@ fn eval_returndatacopy<S: AsRef<RuntimeState>, H: RuntimeHandler, Tr>(
self::system::returndatacopy(machine)
}

fn eval_blockhash<S: AsRef<RuntimeState>, H: RuntimeHandler, Tr>(
fn eval_blockhash<S: AsRef<RuntimeState>, H: RuntimeBackend, Tr>(
machine: &mut Machine<S>,
handle: &mut H,
_opcode: Opcode,
Expand All @@ -1343,7 +1343,7 @@ fn eval_blockhash<S: AsRef<RuntimeState>, H: RuntimeHandler, Tr>(
self::system::blockhash(machine, handle)
}

fn eval_coinbase<S: AsRef<RuntimeState>, H: RuntimeHandler, Tr>(
fn eval_coinbase<S: AsRef<RuntimeState>, H: RuntimeBackend, Tr>(
machine: &mut Machine<S>,
handle: &mut H,
_opcode: Opcode,
Expand All @@ -1352,7 +1352,7 @@ fn eval_coinbase<S: AsRef<RuntimeState>, H: RuntimeHandler, Tr>(
self::system::coinbase(machine, handle)
}

fn eval_timestamp<S: AsRef<RuntimeState>, H: RuntimeHandler, Tr>(
fn eval_timestamp<S: AsRef<RuntimeState>, H: RuntimeBackend, Tr>(
machine: &mut Machine<S>,
handle: &mut H,
_opcode: Opcode,
Expand All @@ -1361,7 +1361,7 @@ fn eval_timestamp<S: AsRef<RuntimeState>, H: RuntimeHandler, Tr>(
self::system::timestamp(machine, handle)
}

fn eval_number<S: AsRef<RuntimeState>, H: RuntimeHandler, Tr>(
fn eval_number<S: AsRef<RuntimeState>, H: RuntimeBackend, Tr>(
machine: &mut Machine<S>,
handle: &mut H,
_opcode: Opcode,
Expand All @@ -1370,7 +1370,7 @@ fn eval_number<S: AsRef<RuntimeState>, H: RuntimeHandler, Tr>(
self::system::number(machine, handle)
}

fn eval_difficulty<S: AsRef<RuntimeState>, H: RuntimeHandler, Tr>(
fn eval_difficulty<S: AsRef<RuntimeState>, H: RuntimeBackend, Tr>(
machine: &mut Machine<S>,
handle: &mut H,
_opcode: Opcode,
Expand All @@ -1379,7 +1379,7 @@ fn eval_difficulty<S: AsRef<RuntimeState>, H: RuntimeHandler, Tr>(
self::system::prevrandao(machine, handle)
}

fn eval_gaslimit<S: AsRef<RuntimeState>, H: RuntimeHandler, Tr>(
fn eval_gaslimit<S: AsRef<RuntimeState>, H: RuntimeBackend, Tr>(
machine: &mut Machine<S>,
handle: &mut H,
_opcode: Opcode,
Expand All @@ -1388,7 +1388,7 @@ fn eval_gaslimit<S: AsRef<RuntimeState>, H: RuntimeHandler, Tr>(
self::system::gaslimit(machine, handle)
}

fn eval_sload<S: AsRef<RuntimeState>, H: RuntimeHandler, Tr>(
fn eval_sload<S: AsRef<RuntimeState>, H: RuntimeBackend, Tr>(
machine: &mut Machine<S>,
handle: &mut H,
_opcode: Opcode,
Expand All @@ -1397,7 +1397,7 @@ fn eval_sload<S: AsRef<RuntimeState>, H: RuntimeHandler, Tr>(
self::system::sload(machine, handle)
}

fn eval_sstore<S: AsRef<RuntimeState>, H: RuntimeHandler, Tr>(
fn eval_sstore<S: AsRef<RuntimeState>, H: RuntimeBackend, Tr>(
machine: &mut Machine<S>,
handle: &mut H,
_opcode: Opcode,
Expand All @@ -1406,7 +1406,7 @@ fn eval_sstore<S: AsRef<RuntimeState>, H: RuntimeHandler, Tr>(
self::system::sstore(machine, handle)
}

fn eval_gas<S: AsRef<RuntimeState>, H: RuntimeHandler, Tr>(
fn eval_gas<S: AsRef<RuntimeState>, H: RuntimeBackend, Tr>(
machine: &mut Machine<S>,
handle: &mut H,
_opcode: Opcode,
Expand All @@ -1415,7 +1415,7 @@ fn eval_gas<S: AsRef<RuntimeState>, H: RuntimeHandler, Tr>(
self::system::gas(machine, handle)
}

fn eval_log0<S: AsRef<RuntimeState>, H: RuntimeHandler, Tr>(
fn eval_log0<S: AsRef<RuntimeState>, H: RuntimeBackend, Tr>(
machine: &mut Machine<S>,
handle: &mut H,
_opcode: Opcode,
Expand All @@ -1424,7 +1424,7 @@ fn eval_log0<S: AsRef<RuntimeState>, H: RuntimeHandler, Tr>(
self::system::log(machine, 0, handle)
}

fn eval_log1<S: AsRef<RuntimeState>, H: RuntimeHandler, Tr>(
fn eval_log1<S: AsRef<RuntimeState>, H: RuntimeBackend, Tr>(
machine: &mut Machine<S>,
handle: &mut H,
_opcode: Opcode,
Expand All @@ -1433,7 +1433,7 @@ fn eval_log1<S: AsRef<RuntimeState>, H: RuntimeHandler, Tr>(
self::system::log(machine, 1, handle)
}

fn eval_log2<S: AsRef<RuntimeState>, H: RuntimeHandler, Tr>(
fn eval_log2<S: AsRef<RuntimeState>, H: RuntimeBackend, Tr>(
machine: &mut Machine<S>,
handle: &mut H,
_opcode: Opcode,
Expand All @@ -1442,7 +1442,7 @@ fn eval_log2<S: AsRef<RuntimeState>, H: RuntimeHandler, Tr>(
self::system::log(machine, 2, handle)
}

fn eval_log3<S: AsRef<RuntimeState>, H: RuntimeHandler, Tr>(
fn eval_log3<S: AsRef<RuntimeState>, H: RuntimeBackend, Tr>(
machine: &mut Machine<S>,
handle: &mut H,
_opcode: Opcode,
Expand All @@ -1451,7 +1451,7 @@ fn eval_log3<S: AsRef<RuntimeState>, H: RuntimeHandler, Tr>(
self::system::log(machine, 3, handle)
}

fn eval_log4<S: AsRef<RuntimeState>, H: RuntimeHandler, Tr>(
fn eval_log4<S: AsRef<RuntimeState>, H: RuntimeBackend, Tr>(
machine: &mut Machine<S>,
handle: &mut H,
_opcode: Opcode,
Expand All @@ -1460,7 +1460,7 @@ fn eval_log4<S: AsRef<RuntimeState>, H: RuntimeHandler, Tr>(
self::system::log(machine, 4, handle)
}

fn eval_suicide<S: AsRef<RuntimeState>, H: RuntimeHandler, Tr>(
fn eval_suicide<S: AsRef<RuntimeState>, H: RuntimeBackend, Tr>(
machine: &mut Machine<S>,
handle: &mut H,
_opcode: Opcode,
Expand All @@ -1469,7 +1469,7 @@ fn eval_suicide<S: AsRef<RuntimeState>, H: RuntimeHandler, Tr>(
self::system::suicide(machine, handle)
}

fn eval_chainid<S: AsRef<RuntimeState>, H: RuntimeHandler, Tr>(
fn eval_chainid<S: AsRef<RuntimeState>, H: RuntimeBackend, Tr>(
machine: &mut Machine<S>,
handle: &mut H,
_opcode: Opcode,
Expand All @@ -1478,7 +1478,7 @@ fn eval_chainid<S: AsRef<RuntimeState>, H: RuntimeHandler, Tr>(
self::system::chainid(machine, handle)
}

fn eval_basefee<S: AsRef<RuntimeState>, H: RuntimeHandler, Tr>(
fn eval_basefee<S: AsRef<RuntimeState>, H: RuntimeBackend, Tr>(
machine: &mut Machine<S>,
handle: &mut H,
_opcode: Opcode,
Expand Down
Loading
Loading