Skip to content

Commit 3e1a847

Browse files
committed
Move EOF activation to Prague
1 parent 3b30d24 commit 3e1a847

25 files changed

+100
-99
lines changed

lib/evmone/advanced_execution.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ evmc_result execute(evmc_vm* /*unused*/, const evmc_host_interface* host, evmc_h
3333
const bytes_view container = {code, code_size};
3434
if (is_eof_container(container))
3535
{
36-
if (rev >= EVMC_CANCUN)
36+
if (rev >= EVMC_PRAGUE)
3737
{
3838
const auto eof1_header = read_valid_eof1_header(container);
3939
analysis = analyze(rev, eof1_header.get_code(container, 0));

lib/evmone/baseline.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ CodeAnalysis analyze_eof1(bytes_view container)
8585

8686
CodeAnalysis analyze(evmc_revision rev, bytes_view code)
8787
{
88-
if (rev < EVMC_CANCUN || !is_eof_container(code))
88+
if (rev < EVMC_PRAGUE || !is_eof_container(code))
8989
return analyze_legacy(code);
9090
return analyze_eof1(code);
9191
}

lib/evmone/baseline_instruction_table.cpp

+14-14
Original file line numberDiff line numberDiff line change
@@ -24,25 +24,25 @@ constexpr auto common_cost_tables = []() noexcept {
2424

2525
constexpr auto legacy_cost_tables = []() noexcept {
2626
auto tables = common_cost_tables;
27-
tables[EVMC_CANCUN][OP_RJUMP] = instr::undefined;
28-
tables[EVMC_CANCUN][OP_RJUMPI] = instr::undefined;
29-
tables[EVMC_CANCUN][OP_RJUMPV] = instr::undefined;
30-
tables[EVMC_CANCUN][OP_CALLF] = instr::undefined;
31-
tables[EVMC_CANCUN][OP_RETF] = instr::undefined;
32-
tables[EVMC_CANCUN][OP_DATALOAD] = instr::undefined;
33-
tables[EVMC_CANCUN][OP_DATALOADN] = instr::undefined;
34-
tables[EVMC_CANCUN][OP_DATASIZE] = instr::undefined;
35-
tables[EVMC_CANCUN][OP_DATACOPY] = instr::undefined;
27+
tables[EVMC_PRAGUE][OP_RJUMP] = instr::undefined;
28+
tables[EVMC_PRAGUE][OP_RJUMPI] = instr::undefined;
29+
tables[EVMC_PRAGUE][OP_RJUMPV] = instr::undefined;
30+
tables[EVMC_PRAGUE][OP_CALLF] = instr::undefined;
31+
tables[EVMC_PRAGUE][OP_RETF] = instr::undefined;
32+
tables[EVMC_PRAGUE][OP_DATALOAD] = instr::undefined;
33+
tables[EVMC_PRAGUE][OP_DATALOADN] = instr::undefined;
34+
tables[EVMC_PRAGUE][OP_DATASIZE] = instr::undefined;
35+
tables[EVMC_PRAGUE][OP_DATACOPY] = instr::undefined;
3636
return tables;
3737
}();
3838

3939
constexpr auto eof_cost_tables = []() noexcept {
4040
auto tables = common_cost_tables;
41-
tables[EVMC_CANCUN][OP_JUMP] = instr::undefined;
42-
tables[EVMC_CANCUN][OP_JUMPI] = instr::undefined;
43-
tables[EVMC_CANCUN][OP_PC] = instr::undefined;
44-
tables[EVMC_CANCUN][OP_CALLCODE] = instr::undefined;
45-
tables[EVMC_CANCUN][OP_SELFDESTRUCT] = instr::undefined;
41+
tables[EVMC_PRAGUE][OP_JUMP] = instr::undefined;
42+
tables[EVMC_PRAGUE][OP_JUMPI] = instr::undefined;
43+
tables[EVMC_PRAGUE][OP_PC] = instr::undefined;
44+
tables[EVMC_PRAGUE][OP_CALLCODE] = instr::undefined;
45+
tables[EVMC_PRAGUE][OP_SELFDESTRUCT] = instr::undefined;
4646
return tables;
4747
}();
4848

lib/evmone/eof.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -553,7 +553,7 @@ EOFValidationError validate_eof(evmc_revision rev, bytes_view container) noexcep
553553

554554
if (version == 1)
555555
{
556-
if (rev < EVMC_CANCUN)
556+
if (rev < EVMC_PRAGUE)
557557
return EOFValidationError::eof_version_unknown;
558558

559559
const auto header_or_error = validate_eof1(rev, container);

lib/evmone/instructions_calls.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ Result call_impl(StackTop stack, int64_t gas_left, ExecutionState& state) noexce
9898

9999
if constexpr (Op == OP_DELEGATECALL)
100100
{
101-
if (state.rev >= EVMC_CANCUN && is_eof_container(state.original_code))
101+
if (state.rev >= EVMC_PRAGUE && is_eof_container(state.original_code))
102102
{
103103
// The code targeted by DELEGATECALL must also be an EOF.
104104
// This restriction has been added to EIP-3540 in

lib/evmone/instructions_storage.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ constexpr auto storage_cost_spec = []() noexcept {
3939
tbl[EVMC_PARIS] = tbl[EVMC_LONDON];
4040
tbl[EVMC_SHANGHAI] = tbl[EVMC_LONDON];
4141
tbl[EVMC_CANCUN] = tbl[EVMC_LONDON];
42+
tbl[EVMC_PRAGUE] = tbl[EVMC_LONDON];
4243
return tbl;
4344
}();
4445

lib/evmone/instructions_traits.hpp

+22-22
Original file line numberDiff line numberDiff line change
@@ -165,19 +165,19 @@ constexpr inline GasCostTable gas_costs = []() noexcept {
165165

166166
table[EVMC_CANCUN] = table[EVMC_SHANGHAI];
167167
table[EVMC_CANCUN][OP_MCOPY] = 3;
168-
table[EVMC_CANCUN][OP_DUPN] = 3;
169-
table[EVMC_CANCUN][OP_SWAPN] = 3;
170-
table[EVMC_CANCUN][OP_RJUMP] = 2;
171-
table[EVMC_CANCUN][OP_RJUMPI] = 4;
172-
table[EVMC_CANCUN][OP_RJUMPV] = 4;
173-
table[EVMC_CANCUN][OP_CALLF] = 5;
174-
table[EVMC_CANCUN][OP_RETF] = 3;
175-
table[EVMC_CANCUN][OP_DATALOAD] = 3;
176-
table[EVMC_CANCUN][OP_DATALOADN] = 2;
177-
table[EVMC_CANCUN][OP_DATASIZE] = 2;
178-
table[EVMC_CANCUN][OP_DATACOPY] = 3;
179168

180169
table[EVMC_PRAGUE] = table[EVMC_CANCUN];
170+
table[EVMC_PRAGUE][OP_DUPN] = 3;
171+
table[EVMC_PRAGUE][OP_SWAPN] = 3;
172+
table[EVMC_PRAGUE][OP_RJUMP] = 2;
173+
table[EVMC_PRAGUE][OP_RJUMPI] = 4;
174+
table[EVMC_PRAGUE][OP_RJUMPV] = 4;
175+
table[EVMC_PRAGUE][OP_CALLF] = 5;
176+
table[EVMC_PRAGUE][OP_RETF] = 3;
177+
table[EVMC_PRAGUE][OP_DATALOAD] = 3;
178+
table[EVMC_PRAGUE][OP_DATALOADN] = 2;
179+
table[EVMC_PRAGUE][OP_DATASIZE] = 2;
180+
table[EVMC_PRAGUE][OP_DATACOPY] = 3;
181181

182182
return table;
183183
}();
@@ -298,10 +298,10 @@ constexpr inline std::array<Traits, 256> traits = []() noexcept {
298298
table[OP_MSIZE] = {"MSIZE", 0, false, 0, 1, EVMC_FRONTIER};
299299
table[OP_GAS] = {"GAS", 0, false, 0, 1, EVMC_FRONTIER};
300300
table[OP_JUMPDEST] = {"JUMPDEST", 0, false, 0, 0, EVMC_FRONTIER};
301-
table[OP_RJUMP] = {"RJUMP", 2, false, 0, 0, EVMC_CANCUN};
302-
table[OP_RJUMPI] = {"RJUMPI", 2, false, 1, -1, EVMC_CANCUN};
301+
table[OP_RJUMP] = {"RJUMP", 2, false, 0, 0, EVMC_PRAGUE};
302+
table[OP_RJUMPI] = {"RJUMPI", 2, false, 1, -1, EVMC_PRAGUE};
303303
table[OP_RJUMPV] = {
304-
"RJUMPV", 1 /* 1 byte static immediate + dynamic immediate */, false, 1, -1, EVMC_CANCUN};
304+
"RJUMPV", 1 /* 1 byte static immediate + dynamic immediate */, false, 1, -1, EVMC_PRAGUE};
305305

306306
table[OP_PUSH0] = {"PUSH0", 0, false, 0, 1, EVMC_SHANGHAI};
307307

@@ -378,13 +378,13 @@ constexpr inline std::array<Traits, 256> traits = []() noexcept {
378378
table[OP_LOG3] = {"LOG3", 0, false, 5, -5, EVMC_FRONTIER};
379379
table[OP_LOG4] = {"LOG4", 0, false, 6, -6, EVMC_FRONTIER};
380380

381-
table[OP_DUPN] = {"DUPN", 1, false, 0, 1, EVMC_CANCUN};
382-
table[OP_SWAPN] = {"SWAPN", 1, false, 0, 0, EVMC_CANCUN};
381+
table[OP_DUPN] = {"DUPN", 1, false, 0, 1, EVMC_PRAGUE};
382+
table[OP_SWAPN] = {"SWAPN", 1, false, 0, 0, EVMC_PRAGUE};
383383
table[OP_MCOPY] = {"MCOPY", 0, false, 3, -3, EVMC_CANCUN};
384-
table[OP_DATALOAD] = {"DATALOAD", 0, false, 1, 0, EVMC_CANCUN};
385-
table[OP_DATALOADN] = {"DATALOADN", 2, false, 0, 1, EVMC_CANCUN};
386-
table[OP_DATASIZE] = {"DATASIZE", 0, false, 0, 1, EVMC_CANCUN};
387-
table[OP_DATACOPY] = {"DATACOPY", 0, false, 3, -3, EVMC_CANCUN};
384+
table[OP_DATALOAD] = {"DATALOAD", 0, false, 1, 0, EVMC_PRAGUE};
385+
table[OP_DATALOADN] = {"DATALOADN", 2, false, 0, 1, EVMC_PRAGUE};
386+
table[OP_DATASIZE] = {"DATASIZE", 0, false, 0, 1, EVMC_PRAGUE};
387+
table[OP_DATACOPY] = {"DATACOPY", 0, false, 3, -3, EVMC_PRAGUE};
388388

389389
table[OP_CREATE] = {"CREATE", 0, false, 3, -2, EVMC_FRONTIER};
390390
table[OP_CALL] = {"CALL", 0, false, 7, -6, EVMC_FRONTIER};
@@ -393,8 +393,8 @@ constexpr inline std::array<Traits, 256> traits = []() noexcept {
393393
table[OP_DELEGATECALL] = {"DELEGATECALL", 0, false, 6, -5, EVMC_HOMESTEAD};
394394
table[OP_CREATE2] = {"CREATE2", 0, false, 4, -3, EVMC_CONSTANTINOPLE};
395395
table[OP_STATICCALL] = {"STATICCALL", 0, false, 6, -5, EVMC_BYZANTIUM};
396-
table[OP_CALLF] = {"CALLF", 2, false, 0, 0, EVMC_CANCUN};
397-
table[OP_RETF] = {"RETF", 0, true, 0, 0, EVMC_CANCUN};
396+
table[OP_CALLF] = {"CALLF", 2, false, 0, 0, EVMC_PRAGUE};
397+
table[OP_RETF] = {"RETF", 0, true, 0, 0, EVMC_PRAGUE};
398398
table[OP_REVERT] = {"REVERT", 0, true, 2, -2, EVMC_BYZANTIUM};
399399
table[OP_INVALID] = {"INVALID", 0, true, 0, 0, EVMC_FRONTIER};
400400
table[OP_SELFDESTRUCT] = {"SELFDESTRUCT", 0, true, 1, -1, EVMC_FRONTIER};

test/eofparse/eofparse.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ int main()
5252
}
5353

5454
const auto& eof = *o;
55-
const auto err = evmone::validate_eof(EVMC_CANCUN, eof);
55+
const auto err = evmone::validate_eof(EVMC_PRAGUE, eof);
5656
if (err != evmone::EOFValidationError::success)
5757
{
5858
std::cout << "err: " << evmone::get_error_message(err) << "\n";

test/eofparsefuzz/eofparsefuzz.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t data_size) noexcept
88
{
99
const evmone::bytes_view eof{data, data_size};
10-
if (evmone::validate_eof(EVMC_CANCUN, eof) == evmone::EOFValidationError::success)
10+
if (evmone::validate_eof(EVMC_PRAGUE, eof) == evmone::EOFValidationError::success)
1111
(void)evmone::read_valid_eof1_header(eof);
1212
return 0;
1313
}

test/integration/statetest/eof/invalid_eof_in_state.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"currentTimestamp": "0x03e8"
1212
},
1313
"post": {
14-
"Cancun": [
14+
"Prague": [
1515
{
1616
"hash": "0xe8010ce590f401c9d61fef8ab05bea9bcec24281b795e5868809bc4e515aa530",
1717
"indexes": {

test/state/host.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ evmc::Result Host::create(const evmc_message& msg) noexcept
199199
create_msg.input_data = nullptr;
200200
create_msg.input_size = 0;
201201

202-
if (m_rev >= EVMC_CANCUN && (is_eof_container(initcode) || is_eof_container(sender_acc.code)))
202+
if (m_rev >= EVMC_PRAGUE && (is_eof_container(initcode) || is_eof_container(sender_acc.code)))
203203
{
204204
if (validate_eof(m_rev, initcode) != EOFValidationError::success)
205205
return evmc::Result{EVMC_CONTRACT_VALIDATION_FAILURE};
@@ -228,7 +228,7 @@ evmc::Result Host::create(const evmc_message& msg) noexcept
228228
evmc::Result{EVMC_FAILURE};
229229
}
230230

231-
if (m_rev >= EVMC_CANCUN && (is_eof_container(initcode) || is_eof_container(code)))
231+
if (m_rev >= EVMC_PRAGUE && (is_eof_container(initcode) || is_eof_container(code)))
232232
{
233233
if (validate_eof(m_rev, code) != EOFValidationError::success)
234234
return evmc::Result{EVMC_CONTRACT_VALIDATION_FAILURE};

test/statetest/statetest_loader.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ void validate_deployed_code(const state::State& state, evmc_revision rev)
380380
{
381381
if (is_eof_container(acc.code))
382382
{
383-
if (rev >= EVMC_CANCUN)
383+
if (rev >= EVMC_PRAGUE)
384384
{
385385
if (const auto result = validate_eof(rev, acc.code);
386386
result != EOFValidationError::success)

test/unittests/analysis_test.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ TEST(analysis, example1_eof1)
260260
const auto code = eof1_bytecode(
261261
push(0x2a) + push(0x1e) + OP_MSTORE8 + OP_MSIZE + push(0) + OP_SSTORE, 2, "deadbeef");
262262
const auto header = evmone::read_valid_eof1_header(code);
263-
const auto analysis = analyze(EVMC_CANCUN, header.get_code(code, 0));
263+
const auto analysis = analyze(EVMC_PRAGUE, header.get_code(code, 0));
264264

265265
ASSERT_EQ(analysis.instrs.size(), 8);
266266

test/unittests/eof_test.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ TEST(eof, read_valid_eof1_header)
6161
for (const auto& test_case : test_cases)
6262
{
6363
const auto code = from_spaced_hex(test_case.code).value();
64-
EXPECT_EQ(validate_eof(EVMC_CANCUN, code), EOFValidationError::success) << test_case.code;
64+
EXPECT_EQ(validate_eof(EVMC_PRAGUE, code), EOFValidationError::success) << test_case.code;
6565

6666
const auto header = read_valid_eof1_header(code);
6767
EXPECT_EQ(header.code_sizes, test_case.code_sizes) << test_case.code;

test/unittests/eof_validation_test.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ namespace
1414
{
1515
// Can be called as validate_eof(string_view hex, rev) or validate_eof(bytes_view cont, rev).
1616
inline EOFValidationError validate_eof(
17-
const bytecode& container, evmc_revision rev = EVMC_CANCUN) noexcept
17+
const bytecode& container, evmc_revision rev = EVMC_PRAGUE) noexcept
1818
{
1919
return evmone::validate_eof(rev, container);
2020
}
@@ -222,7 +222,7 @@ TEST(eof_validation, EOF1_code_section_offset)
222222
{
223223
const auto eof =
224224
"EF0001 010008 02000200030001 040004 00 00000001 00000000 6001fe fe 0000 0000"_hex;
225-
ASSERT_EQ(validate_eof(EVMC_CANCUN, eof), EOFValidationError::success);
225+
ASSERT_EQ(validate_eof(EVMC_PRAGUE, eof), EOFValidationError::success);
226226

227227
const auto header = read_valid_eof1_header(eof);
228228
ASSERT_EQ(header.code_sizes.size(), 2);
@@ -313,7 +313,7 @@ TEST(eof_validation, EOF1_too_many_code_sections)
313313

314314
TEST(eof_validation, EOF1_undefined_opcodes)
315315
{
316-
const auto& gas_table = evmone::instr::gas_costs[EVMC_CANCUN];
316+
const auto& gas_table = evmone::instr::gas_costs[EVMC_PRAGUE];
317317

318318
for (uint16_t opcode = 0; opcode <= 0xff; ++opcode)
319319
{
@@ -323,7 +323,7 @@ TEST(eof_validation, EOF1_undefined_opcodes)
323323
opcode == OP_SWAPN || opcode == OP_RJUMP || opcode == OP_RJUMPI || opcode == OP_CALLF ||
324324
opcode == OP_RJUMPV || opcode == OP_DATALOADN)
325325
continue;
326-
// These opcodes are deprecated since Cancun.
326+
// These opcodes are deprecated since Prague.
327327
// gas_cost table current implementation does not allow to undef instructions.
328328
if (opcode == OP_JUMP || opcode == OP_JUMPI || opcode == OP_PC || opcode == OP_CALLCODE ||
329329
opcode == OP_SELFDESTRUCT)

test/unittests/evm_eip663_dupn_swapn_test.cpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ TEST_P(evm, dupn)
1616
if (evm::is_advanced())
1717
return;
1818

19-
rev = EVMC_CANCUN;
19+
rev = EVMC_PRAGUE;
2020

2121
auto pushes = bytecode{};
2222
for (uint64_t i = 1; i <= 20; ++i)
@@ -44,7 +44,7 @@ TEST_P(evm, swapn)
4444
if (evm::is_advanced())
4545
return;
4646

47-
rev = EVMC_CANCUN;
47+
rev = EVMC_PRAGUE;
4848

4949
auto pushes = bytecode{};
5050
for (uint64_t i = 1; i <= 20; ++i)
@@ -84,7 +84,7 @@ TEST_P(evm, dupn_full_stack)
8484
if (evm::is_advanced())
8585
return;
8686

87-
rev = EVMC_CANCUN;
87+
rev = EVMC_PRAGUE;
8888
auto full_stack_code = bytecode{};
8989
for (uint64_t i = 1023; i >= 1; --i)
9090
full_stack_code += push(i);
@@ -111,7 +111,7 @@ TEST_P(evm, swapn_full_stack)
111111
if (evm::is_advanced())
112112
return;
113113

114-
rev = EVMC_CANCUN;
114+
rev = EVMC_PRAGUE;
115115
auto full_stack_code = bytecode{};
116116
for (uint64_t i = 1024; i >= 1; --i)
117117
full_stack_code += push(i);
@@ -139,7 +139,7 @@ TEST_P(evm, dupn_dup_consistency)
139139
if (evm::is_advanced())
140140
return;
141141

142-
rev = EVMC_CANCUN;
142+
rev = EVMC_PRAGUE;
143143
auto pushes = bytecode{};
144144
for (uint64_t i = 32; i >= 1; --i)
145145
pushes += push(i);
@@ -167,7 +167,7 @@ TEST_P(evm, swapn_swap_consistency)
167167
if (evm::is_advanced())
168168
return;
169169

170-
rev = EVMC_CANCUN;
170+
rev = EVMC_PRAGUE;
171171
auto pushes = bytecode{};
172172
for (uint64_t i = 32; i >= 1; --i)
173173
pushes += push(i);

test/unittests/evm_eof_calls_test.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ using namespace evmc::literals;
1010

1111
TEST_P(evm, eof1_delegatecall_eof1)
1212
{
13-
rev = EVMC_CANCUN;
13+
rev = EVMC_PRAGUE;
1414
constexpr auto callee = 0xca11ee_address;
1515
host.accounts[callee].code = eof1_bytecode(OP_STOP);
1616
bytes call_output{0x01, 0x02, 0x03};
@@ -30,7 +30,7 @@ TEST_P(evm, eof1_delegatecall_eof1)
3030

3131
TEST_P(evm, eof1_delegatecall_legacy)
3232
{
33-
rev = EVMC_CANCUN;
33+
rev = EVMC_PRAGUE;
3434
constexpr auto callee = 0xca11ee_address;
3535
host.access_account(callee);
3636

0 commit comments

Comments
 (0)