From 66cfd8fce6ac1d1e838d69a5166866e6592d53f9 Mon Sep 17 00:00:00 2001 From: akokoshn Date: Mon, 12 Aug 2024 17:33:19 +0300 Subject: [PATCH] Add cas cost for posh0, shr and missed log1 instruction --- lib/assigner/evmone/instructions.hpp | 4 ++++ lib/assigner/evmone/instructions_traits.hpp | 3 +++ lib/assigner/evmone/instructions_xmacro.hpp | 1 + 3 files changed, 8 insertions(+) diff --git a/lib/assigner/evmone/instructions.hpp b/lib/assigner/evmone/instructions.hpp index 47e21f55..8990cad6 100644 --- a/lib/assigner/evmone/instructions.hpp +++ b/lib/assigner/evmone/instructions.hpp @@ -1194,6 +1194,10 @@ struct instructions { state.rw_trace.push_back(stack_operation(state.call_id, (uint16_t)(stack.size(state.stack_space.bottom()) - addr), state.rw_trace.size(), true, stack[addr - 1])); } + static void log(StackTop /*stack*/, ExecutionState& /*state*/) noexcept { + // do nothing + } + static code_iterator dupn(StackTop stack, ExecutionState& state, code_iterator pos) noexcept { const uint16_t n = pos[1] + 1; diff --git a/lib/assigner/evmone/instructions_traits.hpp b/lib/assigner/evmone/instructions_traits.hpp index 5d24e733..dadcc6bb 100644 --- a/lib/assigner/evmone/instructions_traits.hpp +++ b/lib/assigner/evmone/instructions_traits.hpp @@ -99,6 +99,8 @@ constexpr inline GasCostTable gas_costs = []() noexcept { table[EVMC_FRONTIER][OP_MSIZE] = 2; table[EVMC_FRONTIER][OP_GAS] = 2; table[EVMC_FRONTIER][OP_JUMPDEST] = 1; + table[EVMC_FRONTIER][OP_SHR] = 3; + table[EVMC_FRONTIER][OP_PUSH0] = 2; for (auto op = size_t{OP_PUSH1}; op <= OP_PUSH32; ++op) table[EVMC_FRONTIER][op] = 3; for (auto op = size_t{OP_DUP1}; op <= OP_DUP16; ++op) @@ -116,6 +118,7 @@ constexpr inline GasCostTable gas_costs = []() noexcept { table[EVMC_FRONTIER][OP_RETURN] = 0; table[EVMC_FRONTIER][OP_INVALID] = 0; table[EVMC_FRONTIER][OP_SELFDESTRUCT] = 0; + table[EVMC_FRONTIER][OP_LOG1] = 0; table[EVMC_HOMESTEAD] = table[EVMC_FRONTIER]; table[EVMC_HOMESTEAD][OP_DELEGATECALL] = 40; diff --git a/lib/assigner/evmone/instructions_xmacro.hpp b/lib/assigner/evmone/instructions_xmacro.hpp index de15311b..ed220816 100644 --- a/lib/assigner/evmone/instructions_xmacro.hpp +++ b/lib/assigner/evmone/instructions_xmacro.hpp @@ -211,6 +211,7 @@ \ ON_OPCODE_IDENTIFIER(OP_SWAP, instructions::template swap<0>) \ ON_OPCODE_IDENTIFIER(OP_DUP, instructions::template dup<0>) \ + ON_OPCODE_IDENTIFIER(OP_LOG1, instructions::log) \ ON_OPCODE_UNDEFINED(0xa8) \ ON_OPCODE_UNDEFINED(0xa9) \ ON_OPCODE_UNDEFINED(0xaa) \