diff --git a/lib/evmone/advanced_execution.cpp b/lib/evmone/advanced_execution.cpp index eb9a1a56fa..0eaafb082c 100644 --- a/lib/evmone/advanced_execution.cpp +++ b/lib/evmone/advanced_execution.cpp @@ -33,7 +33,7 @@ evmc_result execute(evmc_vm* /*unused*/, const evmc_host_interface* host, evmc_h const bytes_view container = {code, code_size}; if (is_eof_code(container)) { - if (rev >= EVMC_SHANGHAI) + if (rev >= EVMC_CANCUN) { const auto eof1_header = read_valid_eof1_header(container.begin()); analysis = analyze(rev, {&container[eof1_header.code_begin()], eof1_header.code_size}); diff --git a/lib/evmone/baseline.cpp b/lib/evmone/baseline.cpp index 822822f1d4..d5242ac403 100644 --- a/lib/evmone/baseline.cpp +++ b/lib/evmone/baseline.cpp @@ -76,7 +76,7 @@ CodeAnalysis analyze_eof1(bytes_view eof_container, const EOF1Header& header) CodeAnalysis analyze(evmc_revision rev, bytes_view code) { - if (rev < EVMC_SHANGHAI || !is_eof_code(code)) + if (rev < EVMC_CANCUN || !is_eof_code(code)) return analyze_legacy(code); const auto eof1_header = read_valid_eof1_header(code.begin()); diff --git a/lib/evmone/eof.cpp b/lib/evmone/eof.cpp index 5beeb05c3d..e55aaef073 100644 --- a/lib/evmone/eof.cpp +++ b/lib/evmone/eof.cpp @@ -184,7 +184,7 @@ EOFValidationError validate_eof(evmc_revision rev, bytes_view container) noexcep if (version == 1) { - if (rev < EVMC_SHANGHAI) + if (rev < EVMC_CANCUN) return EOFValidationError::eof_version_unknown; return validate_eof1(rev, container).second; } diff --git a/test/unittests/analysis_test.cpp b/test/unittests/analysis_test.cpp index 4238208a0e..864f050d80 100644 --- a/test/unittests/analysis_test.cpp +++ b/test/unittests/analysis_test.cpp @@ -261,7 +261,7 @@ TEST(analysis, example1_eof1) const auto code = eof1_bytecode( push(0x2a) + push(0x1e) + OP_MSTORE8 + OP_MSIZE + push(0) + OP_SSTORE, "deadbeef"); const auto header = evmone::read_valid_eof1_header(bytes_view(code).begin()); - const auto analysis = analyze(EVMC_SHANGHAI, {&code[header.code_begin()], header.code_size}); + const auto analysis = analyze(EVMC_CANCUN, {&code[header.code_begin()], header.code_size}); ASSERT_EQ(analysis.instrs.size(), 8); diff --git a/test/unittests/eof_validation_test.cpp b/test/unittests/eof_validation_test.cpp index 54925bef1e..f71c9d7f8e 100644 --- a/test/unittests/eof_validation_test.cpp +++ b/test/unittests/eof_validation_test.cpp @@ -14,7 +14,7 @@ namespace { // Can be called as validate_eof(string_view hex, rev) or validate_eof(bytes_view cont, rev). inline EOFValidationError validate_eof( - const bytecode& container, evmc_revision rev = EVMC_SHANGHAI) noexcept + const bytecode& container, evmc_revision rev = EVMC_CANCUN) noexcept { return evmone::validate_eof(rev, container); } @@ -164,13 +164,15 @@ TEST(eof_validation, EOF1_undefined_opcodes) { auto cont = "EF0001 010002 00 0000"_hex; - const auto& gas_table = evmone::instr::gas_costs[EVMC_SHANGHAI]; + const auto& gas_table = evmone::instr::gas_costs[EVMC_CANCUN]; for (uint16_t opcode = 0; opcode <= 0xff; ++opcode) { - // PUSH* require immediate argument to be valid, checked in a separate test + // PUSH*, DUPN, SWAPN require immediate argument to be valid, checked in a separate test if (opcode >= OP_PUSH1 && opcode <= OP_PUSH32) continue; + if (opcode == OP_DUPN || opcode == OP_SWAPN) + continue; cont[cont.size() - 2] = static_cast(opcode); diff --git a/test/unittests/evm_eof_test.cpp b/test/unittests/evm_eof_test.cpp index 819a407062..c4ebe59570 100644 --- a/test/unittests/evm_eof_test.cpp +++ b/test/unittests/evm_eof_test.cpp @@ -10,18 +10,18 @@ TEST_P(evm, eof1_execution) { const auto code = eof1_bytecode(OP_STOP); - rev = EVMC_PARIS; + rev = EVMC_SHANGHAI; execute(code); EXPECT_STATUS(EVMC_UNDEFINED_INSTRUCTION); - rev = EVMC_SHANGHAI; + rev = EVMC_CANCUN; execute(code); EXPECT_STATUS(EVMC_SUCCESS); } TEST_P(evm, eof1_execution_with_data_section) { - rev = EVMC_SHANGHAI; + rev = EVMC_CANCUN; // data section contains ret(0, 1) const auto code = eof1_bytecode(mstore8(0, 1) + OP_STOP, ret(0, 1)); @@ -32,7 +32,7 @@ TEST_P(evm, eof1_execution_with_data_section) TEST_P(evm, eof1_pc) { - rev = EVMC_SHANGHAI; + rev = EVMC_CANCUN; auto code = eof1_bytecode(OP_PC + mstore8(0) + ret(0, 1)); execute(code); @@ -50,7 +50,7 @@ TEST_P(evm, eof1_pc) TEST_P(evm, eof1_jump_inside_code_section) { - rev = EVMC_SHANGHAI; + rev = EVMC_CANCUN; auto code = eof1_bytecode(jump(4) + OP_INVALID + OP_JUMPDEST + mstore8(0, 1) + ret(0, 1)); execute(code); @@ -69,7 +69,7 @@ TEST_P(evm, eof1_jump_inside_code_section) TEST_P(evm, eof1_jumpi_inside_code_section) { - rev = EVMC_SHANGHAI; + rev = EVMC_CANCUN; auto code = eof1_bytecode(jumpi(6, 1) + OP_INVALID + OP_JUMPDEST + mstore8(0, 1) + ret(0, 1)); execute(code); @@ -88,7 +88,7 @@ TEST_P(evm, eof1_jumpi_inside_code_section) TEST_P(evm, eof1_jump_into_data_section) { - rev = EVMC_SHANGHAI; + rev = EVMC_CANCUN; // data section contains OP_JUMPDEST + mstore8(0, 1) + ret(0, 1) const auto code = eof1_bytecode(jump(4) + OP_STOP, OP_JUMPDEST + mstore8(0, 1) + ret(0, 1)); @@ -98,7 +98,7 @@ TEST_P(evm, eof1_jump_into_data_section) TEST_P(evm, eof1_jumpi_into_data_section) { - rev = EVMC_SHANGHAI; + rev = EVMC_CANCUN; // data section contains OP_JUMPDEST + mstore8(0, 1) + ret(0, 1) const auto code = eof1_bytecode(jumpi(6, 1) + OP_STOP, OP_JUMPDEST + mstore8(0, 1) + ret(0, 1)); @@ -108,7 +108,7 @@ TEST_P(evm, eof1_jumpi_into_data_section) TEST_P(evm, eof1_push_byte_in_header) { - rev = EVMC_SHANGHAI; + rev = EVMC_CANCUN; // data section is 0x65 bytes long, so header contains 0x65 (PUSH6) byte, // but it must not affect jumpdest analysis (OP_JUMPDEST stays valid) auto code = eof1_bytecode( @@ -122,7 +122,7 @@ TEST_P(evm, eof1_push_byte_in_header) TEST_P(evm, eof1_codesize) { - rev = EVMC_SHANGHAI; + rev = EVMC_CANCUN; auto code = eof1_bytecode(mstore8(0, OP_CODESIZE) + ret(0, 1)); execute(code); @@ -140,7 +140,7 @@ TEST_P(evm, eof1_codesize) TEST_P(evm, eof1_codecopy_full) { - rev = EVMC_SHANGHAI; + rev = EVMC_CANCUN; auto code = eof1_bytecode(bytecode{19} + 0 + 0 + OP_CODECOPY + ret(0, 19)); execute(code); @@ -158,7 +158,7 @@ TEST_P(evm, eof1_codecopy_full) TEST_P(evm, eof1_codecopy_header) { - rev = EVMC_SHANGHAI; + rev = EVMC_CANCUN; auto code = eof1_bytecode(bytecode{7} + 0 + 0 + OP_CODECOPY + ret(0, 7)); execute(code); @@ -174,7 +174,7 @@ TEST_P(evm, eof1_codecopy_header) TEST_P(evm, eof1_codecopy_code) { - rev = EVMC_SHANGHAI; + rev = EVMC_CANCUN; auto code = eof1_bytecode(bytecode{12} + 7 + 0 + OP_CODECOPY + ret(0, 12)); execute(code); @@ -190,7 +190,7 @@ TEST_P(evm, eof1_codecopy_code) TEST_P(evm, eof1_codecopy_data) { - rev = EVMC_SHANGHAI; + rev = EVMC_CANCUN; const auto code = eof1_bytecode(bytecode{4} + 22 + 0 + OP_CODECOPY + ret(0, 4), "deadbeef"); @@ -202,7 +202,7 @@ TEST_P(evm, eof1_codecopy_data) TEST_P(evm, eof1_codecopy_out_of_bounds) { // 4 bytes out of container bounds - result is implicitly 0-padded - rev = EVMC_SHANGHAI; + rev = EVMC_CANCUN; auto code = eof1_bytecode(bytecode{23} + 0 + 0 + OP_CODECOPY + ret(0, 23)); execute(code); diff --git a/test/unittests/tracing_test.cpp b/test/unittests/tracing_test.cpp index e08a7a020c..caed32d3fd 100644 --- a/test/unittests/tracing_test.cpp +++ b/test/unittests/tracing_test.cpp @@ -297,8 +297,8 @@ TEST_F(tracing, trace_eof) vm.add_tracer(evmone::create_instruction_tracer(trace_stream)); trace_stream << '\n'; - EXPECT_EQ(trace(eof1_bytecode(add(2, 3) + OP_STOP), 0, 0, EVMC_SHANGHAI), R"( -{"depth":0,"rev":"Shanghai","static":false} + EXPECT_EQ(trace(eof1_bytecode(add(2, 3) + OP_STOP), 0, 0, EVMC_CANCUN), R"( +{"depth":0,"rev":"Cancun","static":false} {"pc":0,"op":96,"opName":"PUSH1","gas":1000000,"stack":[],"memorySize":0} {"pc":2,"op":96,"opName":"PUSH1","gas":999997,"stack":["0x3"],"memorySize":0} {"pc":4,"op":1,"opName":"ADD","gas":999994,"stack":["0x3","0x2"],"memorySize":0}