CREATE2 support in instructions lib
MODIFY
include/evmc/instructions.h
include/evmc/instructions.h
@@ -166,6 +166,7 @@ enum evmc_opcode
OP_CALLCODE = 0xf2,
OP_RETURN = 0xf3,
OP_DELEGATECALL = 0xf4,
+ OP_CREATE2 = 0xf5,
OP_STATICCALL = 0xfa,

MODIFY
lib/instructions/instruction_metrics.c
lib/instructions/instruction_metrics.c
@@ -267,7 +267,7 @@ static struct evmc_instruction_metrics constantinople_metrics[256] = {
/* CALLCODE = 0xf2 */ {700, 7, 1},
/* RETURN = 0xf3 */ {ZERO, 2, 0},
/* DELEGATECALL = 0xf4 */ {700, 6, 1},
- /* = 0xf5 */ {UNDEFINED, 0, 0},
+ /* CREATE2 = 0xf5 */ {32000, 4, 1},
/* = 0xf6 */ {UNDEFINED, 0, 0},
/* = 0xf7 */ {UNDEFINED, 0, 0},
/* = 0xf8 */ {UNDEFINED, 0, 0},

MODIFY
lib/instructions/instruction_names.c
lib/instructions/instruction_names.c
@@ -251,7 +251,7 @@ static const char* constantinople_names[256] = {
/* 0xf2 */ "CALLCODE",
/* 0xf3 */ "RETURN",
/* 0xf4 */ "DELEGATECALL",
- /* 0xf5 */ NULL,
+ /* 0xf5 */ "CREATE2",
/* 0xf6 */ NULL,
/* 0xf7 */ NULL,
/* 0xf8 */ NULL,

MODIFY
test/unittests/test_instructions.cpp
test/unittests/test_instructions.cpp
@@ -88,6 +88,22 @@ TEST(instructions, byzantium_hard_fork)
EXPECT_EQ(sdn[OP_STATICCALL], nullptr);
}
+TEST(instructions, constantinople_hard_fork)
+{
+ const auto c = evmc_get_instruction_metrics_table(EVMC_CONSTANTINOPLE);
+ const auto b = evmc_get_instruction_metrics_table(EVMC_BYZANTIUM);
+ const auto cn = evmc_get_instruction_names_table(EVMC_CONSTANTINOPLE);
+ const auto bn = evmc_get_instruction_names_table(EVMC_BYZANTIUM);
+
+ EXPECT_EQ(c[OP_CREATE2].gas_cost, 32000);
+ EXPECT_EQ(c[OP_CREATE2].num_stack_arguments, 4);
+ EXPECT_EQ(c[OP_CREATE2].num_stack_returned_items, 1);
+ EXPECT_EQ(b[OP_CREATE2].gas_cost, -1);
+ EXPECT_EQ(cn[OP_CREATE2], std::string{"CREATE2"});
+ EXPECT_EQ(bn[OP_CREATE2], nullptr);
+}
+
+
TEST(instructions, name_gas_cost_equivalence)
{
for (auto rev = EVMC_FRONTIER; rev <= EVMC_LATEST_REVISION;

CREATE2 support in instructions lib