Skip to content
This repository was archived by the owner on Nov 17, 2025. It is now read-only.

Commit 1b66b3a

Browse files
committed
Add CALLF and RETF instructions
1 parent f2715da commit 1b66b3a

File tree

4 files changed

+21
-6
lines changed

4 files changed

+21
-6
lines changed

include/evmc/instructions.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,8 @@ enum evmc_opcode
175175
OP_CREATE2 = 0xf5,
176176

177177
OP_STATICCALL = 0xfa,
178-
178+
OP_CALLF = 0xfb,
179+
OP_RETF = 0xfc,
179180
OP_REVERT = 0xfd,
180181
OP_INVALID = 0xfe,
181182
OP_SELFDESTRUCT = 0xff

lib/instructions/instruction_metrics.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -283,8 +283,8 @@ static struct evmc_instruction_metrics cancun_metrics[256] = {
283283
/* = 0xf8 */ {UNDEFINED, 0, 0},
284284
/* = 0xf9 */ {UNDEFINED, 0, 0},
285285
/* STATICCALL = 0xfa */ {WARM_STORAGE_READ_COST, 6, -5},
286-
/* = 0xfb */ {UNDEFINED, 0, 0},
287-
/* = 0xfc */ {UNDEFINED, 0, 0},
286+
/* CALLF = 0xfb */ {MID, 0, 0},
287+
/* RETF = 0xfc */ {MID, 0, 0},
288288
/* REVERT = 0xfd */ {ZERO, 2, -2},
289289
/* INVALID = 0xfe */ {ZERO, 0, 0},
290290
/* SELFDESTRUCT = 0xff */ {5000, 1, -1},

lib/instructions/instruction_names.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,8 +256,8 @@ static const char* cancun_names[256] = {
256256
/* 0xf8 */ NULL,
257257
/* 0xf9 */ NULL,
258258
/* 0xfa */ "STATICCALL",
259-
/* 0xfb */ NULL,
260-
/* 0xfc */ NULL,
259+
/* 0xfb */ "CALLF",
260+
/* 0xfc */ "RETF",
261261
/* 0xfd */ "REVERT",
262262
/* 0xfe */ "INVALID",
263263
/* 0xff */ "SELFDESTRUCT",

test/unittests/instructions_test.cpp

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ TEST(instructions, cancun_hard_fork)
404404

405405
for (int op = 0x00; op <= 0xff; ++op)
406406
{
407-
if (op == OP_RJUMP || op == OP_RJUMPI)
407+
if (op == OP_RJUMP || op == OP_RJUMPI || op == OP_CALLF || op == OP_RETF)
408408
continue;
409409
EXPECT_EQ(c[op], s[op]) << op;
410410
EXPECT_STREQ(cn[op], sn[op]) << op;
@@ -423,4 +423,18 @@ TEST(instructions, cancun_hard_fork)
423423
EXPECT_EQ(s[OP_RJUMPI].gas_cost, 0);
424424
EXPECT_EQ(cn[OP_RJUMPI], std::string{"RJUMPI"});
425425
EXPECT_TRUE(sn[OP_RJUMPI] == nullptr);
426+
427+
// EIP-4750: EOF Functions
428+
EXPECT_EQ(c[OP_CALLF].gas_cost, 8);
429+
EXPECT_EQ(c[OP_CALLF].stack_height_required, 0);
430+
EXPECT_EQ(c[OP_CALLF].stack_height_change, 0);
431+
EXPECT_EQ(s[OP_CALLF].gas_cost, 0);
432+
EXPECT_EQ(cn[OP_CALLF], std::string{"CALLF"});
433+
EXPECT_TRUE(sn[OP_CALLF] == nullptr);
434+
EXPECT_EQ(c[OP_RETF].gas_cost, 8);
435+
EXPECT_EQ(c[OP_RETF].stack_height_required, 0);
436+
EXPECT_EQ(c[OP_RETF].stack_height_change, 0);
437+
EXPECT_EQ(s[OP_RETF].gas_cost, 0);
438+
EXPECT_EQ(cn[OP_RETF], std::string{"RETF"});
439+
EXPECT_TRUE(sn[OP_RETF] == nullptr);
426440
}

0 commit comments

Comments
 (0)