We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent aefb67e commit 428b2f3Copy full SHA for 428b2f3
lib/evmone/instructions.hpp
@@ -915,6 +915,11 @@ inline evmc_status_code dataload(StackTop stack, ExecutionState& state) noexcept
915
return EVMC_SUCCESS;
916
}
917
918
+inline void datasize(StackTop stack, ExecutionState& state) noexcept
919
+{
920
+ stack.push(state.data.size());
921
+}
922
+
923
template <size_t NumTopics>
924
inline evmc_status_code log(StackTop stack, ExecutionState& state) noexcept
925
{
lib/evmone/instructions_opcodes.hpp
@@ -164,6 +164,7 @@ enum Opcode : uint8_t
164
OP_SWAPN = 0xb6,
165
166
OP_DATALOAD = 0xb7,
167
+ OP_DATASIZE = 0xb8,
168
169
OP_CREATE = 0xf0,
170
OP_CALL = 0xf1,
lib/evmone/instructions_traits.hpp
@@ -172,6 +172,7 @@ constexpr inline GasCostTable gas_costs = []() noexcept {
172
table[EVMC_CANCUN][OP_CALLF] = 5;
173
table[EVMC_CANCUN][OP_RETF] = 3;
174
table[EVMC_CANCUN][OP_DATALOAD] = 3;
175
+ table[EVMC_CANCUN][OP_DATASIZE] = 2;
176
177
table[EVMC_PRAGUE] = table[EVMC_CANCUN];
178
@@ -377,6 +378,7 @@ constexpr inline std::array<Traits, 256> traits = []() noexcept {
377
378
table[OP_DUPN] = {"DUPN", 1, false, 0, 1, EVMC_CANCUN};
379
table[OP_SWAPN] = {"SWAPN", 1, false, 0, 0, EVMC_CANCUN};
380
table[OP_DATALOAD] = {"DATALOAD", 0, false, 1, 0, EVMC_CANCUN};
381
+ table[OP_DATASIZE] = {"DATASIZE", 0, false, 0, 1, EVMC_CANCUN};
382
383
table[OP_CREATE] = {"CREATE", 0, false, 3, -2, EVMC_FRONTIER};
384
table[OP_CALL] = {"CALL", 0, false, 7, -6, EVMC_FRONTIER};
lib/evmone/instructions_xmacro.hpp
@@ -227,7 +227,7 @@
227
ON_OPCODE_IDENTIFIER(OP_DUPN, dupn) \
228
ON_OPCODE_IDENTIFIER(OP_SWAPN, swapn) \
229
ON_OPCODE_IDENTIFIER(OP_DATALOAD, dataload) \
230
- ON_OPCODE_UNDEFINED(0xb8) \
+ ON_OPCODE_IDENTIFIER(OP_DATASIZE, datasize) \
231
ON_OPCODE_UNDEFINED(0xb9) \
232
ON_OPCODE_UNDEFINED(0xba) \
233
ON_OPCODE_UNDEFINED(0xbb) \
test/unittests/instructions_test.cpp
@@ -111,6 +111,7 @@ constexpr bool instruction_only_in_evmone(evmc_revision rev, Opcode op) noexcept
111
case OP_DUPN:
112
case OP_SWAPN:
113
case OP_DATALOAD:
114
+ case OP_DATASIZE:
115
return true;
116
default:
117
return false;
0 commit comments