diff --git a/interpreter/src/etable.rs b/interpreter/src/etable.rs index 45aa98917..515897176 100644 --- a/interpreter/src/etable.rs +++ b/interpreter/src/etable.rs @@ -146,6 +146,7 @@ impl Etable { table[Opcode::MULMOD.as_usize()] = eval_mulmod as _; table[Opcode::EXP.as_usize()] = eval_exp as _; table[Opcode::SIGNEXTEND.as_usize()] = eval_signextend as _; + table[Opcode::LT.as_usize()] = eval_lt as _; table[Opcode::GT.as_usize()] = eval_gt as _; table[Opcode::SLT.as_usize()] = eval_slt as _; @@ -157,22 +158,27 @@ impl Etable { table[Opcode::XOR.as_usize()] = eval_xor as _; table[Opcode::NOT.as_usize()] = eval_not as _; table[Opcode::BYTE.as_usize()] = eval_byte as _; + table[Opcode::SHL.as_usize()] = eval_shl as _; table[Opcode::SHR.as_usize()] = eval_shr as _; table[Opcode::SAR.as_usize()] = eval_sar as _; - table[Opcode::CODESIZE.as_usize()] = eval_codesize as _; - table[Opcode::CODECOPY.as_usize()] = eval_codecopy as _; + table[Opcode::CALLDATALOAD.as_usize()] = eval_calldataload as _; table[Opcode::CALLDATASIZE.as_usize()] = eval_calldatasize as _; table[Opcode::CALLDATACOPY.as_usize()] = eval_calldatacopy as _; + table[Opcode::CODESIZE.as_usize()] = eval_codesize as _; + table[Opcode::CODECOPY.as_usize()] = eval_codecopy as _; + table[Opcode::POP.as_usize()] = eval_pop as _; table[Opcode::MLOAD.as_usize()] = eval_mload as _; table[Opcode::MSTORE.as_usize()] = eval_mstore as _; table[Opcode::MSTORE8.as_usize()] = eval_mstore8 as _; + table[Opcode::JUMP.as_usize()] = eval_jump as _; table[Opcode::JUMPI.as_usize()] = eval_jumpi as _; table[Opcode::PC.as_usize()] = eval_pc as _; table[Opcode::MSIZE.as_usize()] = eval_msize as _; + table[Opcode::JUMPDEST.as_usize()] = eval_jumpdest as _; table[Opcode::PUSH0.as_usize()] = eval_push0 as _; @@ -244,7 +250,9 @@ impl Etable { table[Opcode::SWAP16.as_usize()] = eval_swap16 as _; table[Opcode::RETURN.as_usize()] = eval_return as _; + table[Opcode::REVERT.as_usize()] = eval_revert as _; + table[Opcode::INVALID.as_usize()] = eval_invalid as _; Self(table, PhantomData) @@ -261,43 +269,52 @@ where let mut table = Self::core(); table.0[Opcode::SHA3.as_usize()] = eval_sha3 as _; + table.0[Opcode::ADDRESS.as_usize()] = eval_address as _; table.0[Opcode::BALANCE.as_usize()] = eval_balance as _; - table.0[Opcode::SELFBALANCE.as_usize()] = eval_selfbalance as _; table.0[Opcode::ORIGIN.as_usize()] = eval_origin as _; table.0[Opcode::CALLER.as_usize()] = eval_caller as _; table.0[Opcode::CALLVALUE.as_usize()] = eval_callvalue as _; + table.0[Opcode::GASPRICE.as_usize()] = eval_gasprice as _; table.0[Opcode::EXTCODESIZE.as_usize()] = eval_extcodesize as _; - table.0[Opcode::EXTCODEHASH.as_usize()] = eval_extcodehash as _; table.0[Opcode::EXTCODECOPY.as_usize()] = eval_extcodecopy as _; table.0[Opcode::RETURNDATASIZE.as_usize()] = eval_returndatasize as _; table.0[Opcode::RETURNDATACOPY.as_usize()] = eval_returndatacopy as _; + table.0[Opcode::EXTCODEHASH.as_usize()] = eval_extcodehash as _; + table.0[Opcode::BLOCKHASH.as_usize()] = eval_blockhash as _; table.0[Opcode::COINBASE.as_usize()] = eval_coinbase as _; table.0[Opcode::TIMESTAMP.as_usize()] = eval_timestamp as _; table.0[Opcode::NUMBER.as_usize()] = eval_number as _; table.0[Opcode::DIFFICULTY.as_usize()] = eval_difficulty as _; table.0[Opcode::GASLIMIT.as_usize()] = eval_gaslimit as _; + table.0[Opcode::CHAINID.as_usize()] = eval_chainid as _; + table.0[Opcode::SELFBALANCE.as_usize()] = eval_selfbalance as _; + table.0[Opcode::BASEFEE.as_usize()] = eval_basefee as _; + table.0[Opcode::SLOAD.as_usize()] = eval_sload as _; table.0[Opcode::SSTORE.as_usize()] = eval_sstore as _; + table.0[Opcode::GAS.as_usize()] = eval_gas as _; + table.0[Opcode::LOG0.as_usize()] = eval_log0 as _; table.0[Opcode::LOG1.as_usize()] = eval_log1 as _; table.0[Opcode::LOG2.as_usize()] = eval_log2 as _; table.0[Opcode::LOG3.as_usize()] = eval_log3 as _; table.0[Opcode::LOG4.as_usize()] = eval_log4 as _; - table.0[Opcode::SUICIDE.as_usize()] = eval_suicide as _; - table.0[Opcode::CHAINID.as_usize()] = eval_chainid as _; - table.0[Opcode::BASEFEE.as_usize()] = eval_basefee as _; table.0[Opcode::CREATE.as_usize()] = eval_call_create_trap as _; - table.0[Opcode::CREATE2.as_usize()] = eval_call_create_trap as _; table.0[Opcode::CALL.as_usize()] = eval_call_create_trap as _; table.0[Opcode::CALLCODE.as_usize()] = eval_call_create_trap as _; + table.0[Opcode::DELEGATECALL.as_usize()] = eval_call_create_trap as _; + table.0[Opcode::CREATE2.as_usize()] = eval_call_create_trap as _; + table.0[Opcode::STATICCALL.as_usize()] = eval_call_create_trap as _; + table.0[Opcode::SUICIDE.as_usize()] = eval_suicide as _; + table } } diff --git a/interpreter/src/opcode.rs b/interpreter/src/opcode.rs index 25b668d2b..b6003ff54 100644 --- a/interpreter/src/opcode.rs +++ b/interpreter/src/opcode.rs @@ -57,6 +57,13 @@ impl Opcode { /// `BYTE` pub const BYTE: Opcode = Opcode(0x1a); + /// `SHL` + pub const SHL: Opcode = Opcode(0x1b); + /// `SHR` + pub const SHR: Opcode = Opcode(0x1c); + /// `SAR` + pub const SAR: Opcode = Opcode(0x1d); + /// `CALLDATALOAD` pub const CALLDATALOAD: Opcode = Opcode(0x35); /// `CALLDATASIZE` @@ -68,13 +75,6 @@ impl Opcode { /// `CODECOPY` pub const CODECOPY: Opcode = Opcode(0x39); - /// `SHL` - pub const SHL: Opcode = Opcode(0x1b); - /// `SHR` - pub const SHR: Opcode = Opcode(0x1c); - /// `SAR` - pub const SAR: Opcode = Opcode(0x1d); - /// `POP` pub const POP: Opcode = Opcode(0x50); /// `MLOAD` @@ -83,6 +83,7 @@ impl Opcode { pub const MSTORE: Opcode = Opcode(0x52); /// `MSTORE8` pub const MSTORE8: Opcode = Opcode(0x53); + /// `JUMP` pub const JUMP: Opcode = Opcode(0x56); /// `JUMPI` @@ -91,6 +92,7 @@ impl Opcode { pub const PC: Opcode = Opcode(0x58); /// `MSIZE` pub const MSIZE: Opcode = Opcode(0x59); + /// `JUMPDEST` pub const JUMPDEST: Opcode = Opcode(0x5b); @@ -165,48 +167,48 @@ impl Opcode { pub const SWAP15: Opcode = Opcode(0x9e); pub const SWAP16: Opcode = Opcode(0x9f); + /// See [EIP-3541](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-3541.md) + pub const EOFMAGIC: Opcode = Opcode(0xef); + /// `RETURN` pub const RETURN: Opcode = Opcode(0xf3); + /// `REVERT` pub const REVERT: Opcode = Opcode(0xfd); /// `INVALID` pub const INVALID: Opcode = Opcode(0xfe); - - /// See [EIP-3541](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-3541.md) - pub const EOFMAGIC: Opcode = Opcode(0xef); } // External opcodes impl Opcode { /// `SHA3` pub const SHA3: Opcode = Opcode(0x20); + /// `ADDRESS` pub const ADDRESS: Opcode = Opcode(0x30); /// `BALANCE` pub const BALANCE: Opcode = Opcode(0x31); - /// `SELFBALANCE` - pub const SELFBALANCE: Opcode = Opcode(0x47); - /// `BASEFEE` - pub const BASEFEE: Opcode = Opcode(0x48); /// `ORIGIN` pub const ORIGIN: Opcode = Opcode(0x32); /// `CALLER` pub const CALLER: Opcode = Opcode(0x33); /// `CALLVALUE` pub const CALLVALUE: Opcode = Opcode(0x34); + /// `GASPRICE` pub const GASPRICE: Opcode = Opcode(0x3a); /// `EXTCODESIZE` pub const EXTCODESIZE: Opcode = Opcode(0x3b); /// `EXTCODECOPY` pub const EXTCODECOPY: Opcode = Opcode(0x3c); - /// `EXTCODEHASH` - pub const EXTCODEHASH: Opcode = Opcode(0x3f); /// `RETURNDATASIZE` pub const RETURNDATASIZE: Opcode = Opcode(0x3d); /// `RETURNDATACOPY` pub const RETURNDATACOPY: Opcode = Opcode(0x3e); + /// `EXTCODEHASH` + pub const EXTCODEHASH: Opcode = Opcode(0x3f); + /// `BLOCKHASH` pub const BLOCKHASH: Opcode = Opcode(0x40); /// `COINBASE` @@ -219,34 +221,45 @@ impl Opcode { pub const DIFFICULTY: Opcode = Opcode(0x44); /// `GASLIMIT` pub const GASLIMIT: Opcode = Opcode(0x45); + /// `CHAINID` + pub const CHAINID: Opcode = Opcode(0x46); + /// `SELFBALANCE` + pub const SELFBALANCE: Opcode = Opcode(0x47); + /// `BASEFEE` + pub const BASEFEE: Opcode = Opcode(0x48); + /// `SLOAD` pub const SLOAD: Opcode = Opcode(0x54); /// `SSTORE` pub const SSTORE: Opcode = Opcode(0x55); + /// `GAS` pub const GAS: Opcode = Opcode(0x5a); + /// `LOGn` pub const LOG0: Opcode = Opcode(0xa0); pub const LOG1: Opcode = Opcode(0xa1); pub const LOG2: Opcode = Opcode(0xa2); pub const LOG3: Opcode = Opcode(0xa3); pub const LOG4: Opcode = Opcode(0xa4); + /// `CREATE` pub const CREATE: Opcode = Opcode(0xf0); - /// `CREATE2` - pub const CREATE2: Opcode = Opcode(0xf5); /// `CALL` pub const CALL: Opcode = Opcode(0xf1); /// `CALLCODE` pub const CALLCODE: Opcode = Opcode(0xf2); + /// `DELEGATECALL` pub const DELEGATECALL: Opcode = Opcode(0xf4); + /// `CREATE2` + pub const CREATE2: Opcode = Opcode(0xf5); + /// `STATICCALL` pub const STATICCALL: Opcode = Opcode(0xfa); + /// `SUICIDE` pub const SUICIDE: Opcode = Opcode(0xff); - /// `CHAINID` - pub const CHAINID: Opcode = Opcode(0x46); } impl Opcode {