We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent c982f26 commit dfbbf88Copy full SHA for dfbbf88
4 files changed
include/evmc/instructions.h
@@ -93,6 +93,8 @@ enum evmc_opcode
93
OP_MSIZE = 0x59,
94
OP_GAS = 0x5a,
95
OP_JUMPDEST = 0x5b,
96
+ OP_RJUMP = 0x5c,
97
+ OP_RJUMPI = 0x5d,
98
99
OP_PUSH0 = 0x5f,
100
OP_PUSH1 = 0x60,
lib/instructions/instruction_metrics.c
@@ -127,8 +127,8 @@ static struct evmc_instruction_metrics cancun_metrics[256] = {
127
/* MSIZE = 0x59 */ {BASE, 0, 1},
128
/* GAS = 0x5a */ {BASE, 0, 1},
129
/* JUMPDEST = 0x5b */ {1, 0, 0},
130
- /* = 0x5c */ {UNDEFINED, 0, 0},
131
- /* = 0x5d */ {UNDEFINED, 0, 0},
+ /* RJUMP = 0x5c */ {BASE, 0, 0},
+ /* RJUMPI = 0x5d */ {4, 1, -1},
132
/* = 0x5e */ {UNDEFINED, 0, 0},
133
/* PUSH0 = 0x5f */ {BASE, 0, 1},
134
/* PUSH1 = 0x60 */ {VERYLOW, 0, 1},
@@ -386,8 +386,8 @@ static struct evmc_instruction_metrics shanghai_metrics[256] = {
386
387
388
389
390
391
392
393
lib/instructions/instruction_names.c
@@ -97,8 +97,8 @@ static const char* cancun_names[256] = {
/* 0x59 */ "MSIZE",
/* 0x5a */ "GAS",
/* 0x5b */ "JUMPDEST",
- /* 0x5c */ NULL,
101
- /* 0x5d */ NULL,
+ /* 0x5c */ "RJUMP",
+ /* 0x5d */ "RJUMPI",
102
/* 0x5e */ NULL,
103
/* 0x5f */ "PUSH0",
104
/* 0x60 */ "PUSH1",
@@ -356,8 +356,8 @@ static const char* shanghai_names[256] = {
356
357
358
359
360
361
362
363
test/unittests/instructions_test.cpp
@@ -394,3 +394,33 @@ TEST(instructions, shanghai_hard_fork)
394
EXPECT_EQ(sn[OP_PUSH0], std::string{"PUSH0"});
395
EXPECT_TRUE(pn[OP_PUSH0] == nullptr);
396
}
397
+
398
+TEST(instructions, cancun_hard_fork)
399
+{
400
+ const auto c = evmc_get_instruction_metrics_table(EVMC_CANCUN);
401
+ const auto s = evmc_get_instruction_metrics_table(EVMC_SHANGHAI);
402
+ const auto cn = evmc_get_instruction_names_table(EVMC_CANCUN);
403
+ const auto sn = evmc_get_instruction_names_table(EVMC_SHANGHAI);
404
405
+ for (int op = 0x00; op <= 0xff; ++op)
406
+ {
407
+ if (op == OP_RJUMP || op == OP_RJUMPI)
408
+ continue;
409
+ EXPECT_EQ(c[op], s[op]) << op;
410
+ EXPECT_STREQ(cn[op], sn[op]) << op;
411
+ }
412
413
+ // EIP-4200: Static relative jumps
414
+ EXPECT_EQ(c[OP_RJUMP].gas_cost, 5);
415
+ EXPECT_EQ(c[OP_RJUMP].stack_height_required, 0);
416
+ EXPECT_EQ(c[OP_RJUMP].stack_height_change, 0);
417
+ EXPECT_EQ(s[OP_RJUMP].gas_cost, 0);
418
+ EXPECT_EQ(cn[OP_RJUMP], std::string{"RJUMP"});
419
+ EXPECT_TRUE(sn[OP_RJUMP] == nullptr);
420
+ EXPECT_EQ(c[OP_RJUMPI].gas_cost, 7);
421
+ EXPECT_EQ(c[OP_RJUMPI].stack_height_required, 1);
422
+ EXPECT_EQ(c[OP_RJUMPI].stack_height_change, -1);
423
+ EXPECT_EQ(s[OP_RJUMPI].gas_cost, 0);
424
+ EXPECT_EQ(cn[OP_RJUMPI], std::string{"RJUMPI"});
425
+ EXPECT_TRUE(sn[OP_RJUMPI] == nullptr);
426
+}
0 commit comments