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

Implement transact_create and transact_create2 #211

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

use crate::{
CallCreateTrap, ExitException, ExitResult, ExitSucceed, Machine, Opcode, RuntimeHandle,
RuntimeState,
CallCreateTrap, ExitException, ExitResult, ExitSucceed, Machine, Opcode, RuntimeBackend,
RuntimeEnvironment, RuntimeState,
};
use core::marker::PhantomData;
use core::ops::{BitAnd, BitOr, BitXor, Deref, DerefMut};
Expand Down Expand Up @@ -182,7 +182,9 @@ impl<S, H, Tr> Etable<S, H, Tr> {
}
}

impl<S: AsRef<RuntimeState>, H: RuntimeHandle, Tr: CallCreateTrap> Etable<S, H, Tr> {
impl<S: AsRef<RuntimeState>, H: RuntimeEnvironment + 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 @@ -1220,7 +1222,7 @@ fn eval_unknown<S, H, Tr>(
Control::Exit(ExitException::InvalidOpcode(opcode).into())
}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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