diff --git a/include/evmc/instructions.h b/include/evmc/instructions.h index ff6a5cbc3..505a3ce3d 100644 --- a/include/evmc/instructions.h +++ b/include/evmc/instructions.h @@ -94,6 +94,7 @@ enum evmc_opcode OP_GAS = 0x5a, OP_JUMPDEST = 0x5b, + OP_PUSH0 = 0x5f, OP_PUSH1 = 0x60, OP_PUSH2 = 0x61, OP_PUSH3 = 0x62, diff --git a/lib/instructions/instruction_metrics.c b/lib/instructions/instruction_metrics.c index a5413ddc5..92faef9c4 100644 --- a/lib/instructions/instruction_metrics.c +++ b/lib/instructions/instruction_metrics.c @@ -128,7 +128,7 @@ static struct evmc_instruction_metrics shanghai_metrics[256] = { /* = 0x5c */ {UNDEFINED, 0, 0}, /* = 0x5d */ {UNDEFINED, 0, 0}, /* = 0x5e */ {UNDEFINED, 0, 0}, - /* = 0x5f */ {UNDEFINED, 0, 0}, + /* PUSH0 = 0x5f */ {BASE, 0, 1}, /* PUSH1 = 0x60 */ {VERYLOW, 0, 1}, /* PUSH2 = 0x61 */ {VERYLOW, 0, 1}, /* PUSH3 = 0x62 */ {VERYLOW, 0, 1}, diff --git a/lib/instructions/instruction_names.c b/lib/instructions/instruction_names.c index 6a38f8e7e..2dcf4b693 100644 --- a/lib/instructions/instruction_names.c +++ b/lib/instructions/instruction_names.c @@ -100,7 +100,7 @@ static const char* shanghai_names[256] = { /* 0x5c */ NULL, /* 0x5d */ NULL, /* 0x5e */ NULL, - /* 0x5f */ NULL, + /* 0x5f */ "PUSH0", /* 0x60 */ "PUSH1", /* 0x61 */ "PUSH2", /* 0x62 */ "PUSH3", diff --git a/test/unittests/instructions_test.cpp b/test/unittests/instructions_test.cpp index abd06e0dc..3b0655e22 100644 --- a/test/unittests/instructions_test.cpp +++ b/test/unittests/instructions_test.cpp @@ -375,7 +375,17 @@ TEST(instructions, shanghai_hard_fork) for (int op = 0x00; op <= 0xff; ++op) { + if (op == OP_PUSH0) + continue; EXPECT_EQ(s[op], m[op]) << op; EXPECT_STREQ(sn[op], mn[op]) << op; } + + // EIP-3855: PUSH0 instruction + EXPECT_EQ(s[OP_PUSH0].gas_cost, 2); + EXPECT_EQ(s[OP_PUSH0].stack_height_required, 0); + EXPECT_EQ(s[OP_PUSH0].stack_height_change, 1); + EXPECT_EQ(m[OP_PUSH0].gas_cost, 0); + EXPECT_EQ(sn[OP_PUSH0], std::string{"PUSH0"}); + EXPECT_TRUE(mn[OP_PUSH0] == nullptr); }