From 57aa0984f01fe21ed87f429068d4174918d47080 Mon Sep 17 00:00:00 2001 From: Andrei Maiboroda Date: Tue, 11 Jul 2023 21:03:55 +0200 Subject: [PATCH] Move EOF activation to Prague --- lib/evmone/advanced_execution.cpp | 2 +- lib/evmone/baseline.cpp | 2 +- lib/evmone/baseline_instruction_table.cpp | 28 ++++++------ lib/evmone/eof.cpp | 2 +- lib/evmone/instructions_calls.cpp | 2 +- lib/evmone/instructions_storage.cpp | 1 + lib/evmone/instructions_traits.hpp | 44 +++++++++---------- test/eofparse/eofparse.cpp | 2 +- test/eofparsefuzz/eofparsefuzz.cpp | 2 +- .../statetest/eof/invalid_eof_in_state.json | 2 +- test/state/host.cpp | 4 +- test/statetest/statetest_loader.cpp | 2 +- test/unittests/analysis_test.cpp | 2 +- test/unittests/eof_test.cpp | 2 +- test/unittests/eof_validation_test.cpp | 8 ++-- test/unittests/evm_eip663_dupn_swapn_test.cpp | 12 ++--- test/unittests/evm_eof_calls_test.cpp | 4 +- test/unittests/evm_eof_function_test.cpp | 12 ++--- test/unittests/evm_eof_rjump_test.cpp | 20 ++++----- test/unittests/evm_eof_test.cpp | 30 ++++++------- test/unittests/evm_fixture.hpp | 2 +- test/unittests/evm_memory_test.cpp | 2 +- test/unittests/state_transition_eof_test.cpp | 2 +- test/unittests/statetest_loader_test.cpp | 2 +- test/unittests/tracing_test.cpp | 4 +- 25 files changed, 98 insertions(+), 97 deletions(-) diff --git a/lib/evmone/advanced_execution.cpp b/lib/evmone/advanced_execution.cpp index 2176bfcbaa..c5ad791e78 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_container(container)) { - if (rev >= EVMC_CANCUN) + if (rev >= EVMC_PRAGUE) { const auto eof1_header = read_valid_eof1_header(container); analysis = analyze(rev, eof1_header.get_code(container, 0)); diff --git a/lib/evmone/baseline.cpp b/lib/evmone/baseline.cpp index af1fc7653c..56ab443c89 100644 --- a/lib/evmone/baseline.cpp +++ b/lib/evmone/baseline.cpp @@ -85,7 +85,7 @@ CodeAnalysis analyze_eof1(bytes_view container) CodeAnalysis analyze(evmc_revision rev, bytes_view code) { - if (rev < EVMC_CANCUN || !is_eof_container(code)) + if (rev < EVMC_PRAGUE || !is_eof_container(code)) return analyze_legacy(code); return analyze_eof1(code); } diff --git a/lib/evmone/baseline_instruction_table.cpp b/lib/evmone/baseline_instruction_table.cpp index c04774a6d7..e018cd3a41 100644 --- a/lib/evmone/baseline_instruction_table.cpp +++ b/lib/evmone/baseline_instruction_table.cpp @@ -24,25 +24,25 @@ constexpr auto common_cost_tables = []() noexcept { constexpr auto legacy_cost_tables = []() noexcept { auto tables = common_cost_tables; - tables[EVMC_CANCUN][OP_RJUMP] = instr::undefined; - tables[EVMC_CANCUN][OP_RJUMPI] = instr::undefined; - tables[EVMC_CANCUN][OP_RJUMPV] = instr::undefined; - tables[EVMC_CANCUN][OP_CALLF] = instr::undefined; - tables[EVMC_CANCUN][OP_RETF] = instr::undefined; - tables[EVMC_CANCUN][OP_DATALOAD] = instr::undefined; - tables[EVMC_CANCUN][OP_DATALOADN] = instr::undefined; - tables[EVMC_CANCUN][OP_DATASIZE] = instr::undefined; - tables[EVMC_CANCUN][OP_DATACOPY] = instr::undefined; + tables[EVMC_PRAGUE][OP_RJUMP] = instr::undefined; + tables[EVMC_PRAGUE][OP_RJUMPI] = instr::undefined; + tables[EVMC_PRAGUE][OP_RJUMPV] = instr::undefined; + tables[EVMC_PRAGUE][OP_CALLF] = instr::undefined; + tables[EVMC_PRAGUE][OP_RETF] = instr::undefined; + tables[EVMC_PRAGUE][OP_DATALOAD] = instr::undefined; + tables[EVMC_PRAGUE][OP_DATALOADN] = instr::undefined; + tables[EVMC_PRAGUE][OP_DATASIZE] = instr::undefined; + tables[EVMC_PRAGUE][OP_DATACOPY] = instr::undefined; return tables; }(); constexpr auto eof_cost_tables = []() noexcept { auto tables = common_cost_tables; - tables[EVMC_CANCUN][OP_JUMP] = instr::undefined; - tables[EVMC_CANCUN][OP_JUMPI] = instr::undefined; - tables[EVMC_CANCUN][OP_PC] = instr::undefined; - tables[EVMC_CANCUN][OP_CALLCODE] = instr::undefined; - tables[EVMC_CANCUN][OP_SELFDESTRUCT] = instr::undefined; + tables[EVMC_PRAGUE][OP_JUMP] = instr::undefined; + tables[EVMC_PRAGUE][OP_JUMPI] = instr::undefined; + tables[EVMC_PRAGUE][OP_PC] = instr::undefined; + tables[EVMC_PRAGUE][OP_CALLCODE] = instr::undefined; + tables[EVMC_PRAGUE][OP_SELFDESTRUCT] = instr::undefined; return tables; }(); diff --git a/lib/evmone/eof.cpp b/lib/evmone/eof.cpp index f796a432cb..52e300c658 100644 --- a/lib/evmone/eof.cpp +++ b/lib/evmone/eof.cpp @@ -553,7 +553,7 @@ EOFValidationError validate_eof(evmc_revision rev, bytes_view container) noexcep if (version == 1) { - if (rev < EVMC_CANCUN) + if (rev < EVMC_PRAGUE) return EOFValidationError::eof_version_unknown; const auto header_or_error = validate_eof1(rev, container); diff --git a/lib/evmone/instructions_calls.cpp b/lib/evmone/instructions_calls.cpp index 86fe7a8274..0e677d36b0 100644 --- a/lib/evmone/instructions_calls.cpp +++ b/lib/evmone/instructions_calls.cpp @@ -98,7 +98,7 @@ Result call_impl(StackTop stack, int64_t gas_left, ExecutionState& state) noexce if constexpr (Op == OP_DELEGATECALL) { - if (state.rev >= EVMC_CANCUN && is_eof_container(state.original_code)) + if (state.rev >= EVMC_PRAGUE && is_eof_container(state.original_code)) { // The code targeted by DELEGATECALL must also be an EOF. // This restriction has been added to EIP-3540 in diff --git a/lib/evmone/instructions_storage.cpp b/lib/evmone/instructions_storage.cpp index 0d7474a847..136d1fd849 100644 --- a/lib/evmone/instructions_storage.cpp +++ b/lib/evmone/instructions_storage.cpp @@ -39,6 +39,7 @@ constexpr auto storage_cost_spec = []() noexcept { tbl[EVMC_PARIS] = tbl[EVMC_LONDON]; tbl[EVMC_SHANGHAI] = tbl[EVMC_LONDON]; tbl[EVMC_CANCUN] = tbl[EVMC_LONDON]; + tbl[EVMC_PRAGUE] = tbl[EVMC_LONDON]; return tbl; }(); diff --git a/lib/evmone/instructions_traits.hpp b/lib/evmone/instructions_traits.hpp index 5d17508c54..abf45c9717 100644 --- a/lib/evmone/instructions_traits.hpp +++ b/lib/evmone/instructions_traits.hpp @@ -165,19 +165,19 @@ constexpr inline GasCostTable gas_costs = []() noexcept { table[EVMC_CANCUN] = table[EVMC_SHANGHAI]; table[EVMC_CANCUN][OP_MCOPY] = 3; - table[EVMC_CANCUN][OP_DUPN] = 3; - table[EVMC_CANCUN][OP_SWAPN] = 3; - table[EVMC_CANCUN][OP_RJUMP] = 2; - table[EVMC_CANCUN][OP_RJUMPI] = 4; - table[EVMC_CANCUN][OP_RJUMPV] = 4; - table[EVMC_CANCUN][OP_CALLF] = 5; - table[EVMC_CANCUN][OP_RETF] = 3; - table[EVMC_CANCUN][OP_DATALOAD] = 3; - table[EVMC_CANCUN][OP_DATALOADN] = 2; - table[EVMC_CANCUN][OP_DATASIZE] = 2; - table[EVMC_CANCUN][OP_DATACOPY] = 3; table[EVMC_PRAGUE] = table[EVMC_CANCUN]; + table[EVMC_PRAGUE][OP_DUPN] = 3; + table[EVMC_PRAGUE][OP_SWAPN] = 3; + table[EVMC_PRAGUE][OP_RJUMP] = 2; + table[EVMC_PRAGUE][OP_RJUMPI] = 4; + table[EVMC_PRAGUE][OP_RJUMPV] = 4; + table[EVMC_PRAGUE][OP_CALLF] = 5; + table[EVMC_PRAGUE][OP_RETF] = 3; + table[EVMC_PRAGUE][OP_DATALOAD] = 3; + table[EVMC_PRAGUE][OP_DATALOADN] = 2; + table[EVMC_PRAGUE][OP_DATASIZE] = 2; + table[EVMC_PRAGUE][OP_DATACOPY] = 3; return table; }(); @@ -298,10 +298,10 @@ constexpr inline std::array traits = []() noexcept { table[OP_MSIZE] = {"MSIZE", 0, false, 0, 1, EVMC_FRONTIER}; table[OP_GAS] = {"GAS", 0, false, 0, 1, EVMC_FRONTIER}; table[OP_JUMPDEST] = {"JUMPDEST", 0, false, 0, 0, EVMC_FRONTIER}; - table[OP_RJUMP] = {"RJUMP", 2, false, 0, 0, EVMC_CANCUN}; - table[OP_RJUMPI] = {"RJUMPI", 2, false, 1, -1, EVMC_CANCUN}; + table[OP_RJUMP] = {"RJUMP", 2, false, 0, 0, EVMC_PRAGUE}; + table[OP_RJUMPI] = {"RJUMPI", 2, false, 1, -1, EVMC_PRAGUE}; table[OP_RJUMPV] = { - "RJUMPV", 1 /* 1 byte static immediate + dynamic immediate */, false, 1, -1, EVMC_CANCUN}; + "RJUMPV", 1 /* 1 byte static immediate + dynamic immediate */, false, 1, -1, EVMC_PRAGUE}; table[OP_PUSH0] = {"PUSH0", 0, false, 0, 1, EVMC_SHANGHAI}; @@ -378,13 +378,13 @@ constexpr inline std::array traits = []() noexcept { table[OP_LOG3] = {"LOG3", 0, false, 5, -5, EVMC_FRONTIER}; table[OP_LOG4] = {"LOG4", 0, false, 6, -6, EVMC_FRONTIER}; - table[OP_DUPN] = {"DUPN", 1, false, 0, 1, EVMC_CANCUN}; - table[OP_SWAPN] = {"SWAPN", 1, false, 0, 0, EVMC_CANCUN}; + table[OP_DUPN] = {"DUPN", 1, false, 0, 1, EVMC_PRAGUE}; + table[OP_SWAPN] = {"SWAPN", 1, false, 0, 0, EVMC_PRAGUE}; table[OP_MCOPY] = {"MCOPY", 0, false, 3, -3, EVMC_CANCUN}; - table[OP_DATALOAD] = {"DATALOAD", 0, false, 1, 0, EVMC_CANCUN}; - table[OP_DATALOADN] = {"DATALOADN", 2, false, 0, 1, EVMC_CANCUN}; - table[OP_DATASIZE] = {"DATASIZE", 0, false, 0, 1, EVMC_CANCUN}; - table[OP_DATACOPY] = {"DATACOPY", 0, false, 3, -3, EVMC_CANCUN}; + table[OP_DATALOAD] = {"DATALOAD", 0, false, 1, 0, EVMC_PRAGUE}; + table[OP_DATALOADN] = {"DATALOADN", 2, false, 0, 1, EVMC_PRAGUE}; + table[OP_DATASIZE] = {"DATASIZE", 0, false, 0, 1, EVMC_PRAGUE}; + table[OP_DATACOPY] = {"DATACOPY", 0, false, 3, -3, EVMC_PRAGUE}; table[OP_CREATE] = {"CREATE", 0, false, 3, -2, EVMC_FRONTIER}; table[OP_CALL] = {"CALL", 0, false, 7, -6, EVMC_FRONTIER}; @@ -393,8 +393,8 @@ constexpr inline std::array traits = []() noexcept { table[OP_DELEGATECALL] = {"DELEGATECALL", 0, false, 6, -5, EVMC_HOMESTEAD}; table[OP_CREATE2] = {"CREATE2", 0, false, 4, -3, EVMC_CONSTANTINOPLE}; table[OP_STATICCALL] = {"STATICCALL", 0, false, 6, -5, EVMC_BYZANTIUM}; - table[OP_CALLF] = {"CALLF", 2, false, 0, 0, EVMC_CANCUN}; - table[OP_RETF] = {"RETF", 0, true, 0, 0, EVMC_CANCUN}; + table[OP_CALLF] = {"CALLF", 2, false, 0, 0, EVMC_PRAGUE}; + table[OP_RETF] = {"RETF", 0, true, 0, 0, EVMC_PRAGUE}; table[OP_REVERT] = {"REVERT", 0, true, 2, -2, EVMC_BYZANTIUM}; table[OP_INVALID] = {"INVALID", 0, true, 0, 0, EVMC_FRONTIER}; table[OP_SELFDESTRUCT] = {"SELFDESTRUCT", 0, true, 1, -1, EVMC_FRONTIER}; diff --git a/test/eofparse/eofparse.cpp b/test/eofparse/eofparse.cpp index 6fd9937bbc..fcaf7e27df 100644 --- a/test/eofparse/eofparse.cpp +++ b/test/eofparse/eofparse.cpp @@ -52,7 +52,7 @@ int main() } const auto& eof = *o; - const auto err = evmone::validate_eof(EVMC_CANCUN, eof); + const auto err = evmone::validate_eof(EVMC_PRAGUE, eof); if (err != evmone::EOFValidationError::success) { std::cout << "err: " << evmone::get_error_message(err) << "\n"; diff --git a/test/eofparsefuzz/eofparsefuzz.cpp b/test/eofparsefuzz/eofparsefuzz.cpp index e786abc2a5..95477912c7 100644 --- a/test/eofparsefuzz/eofparsefuzz.cpp +++ b/test/eofparsefuzz/eofparsefuzz.cpp @@ -7,7 +7,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t data_size) noexcept { const evmone::bytes_view eof{data, data_size}; - if (evmone::validate_eof(EVMC_CANCUN, eof) == evmone::EOFValidationError::success) + if (evmone::validate_eof(EVMC_PRAGUE, eof) == evmone::EOFValidationError::success) (void)evmone::read_valid_eof1_header(eof); return 0; } diff --git a/test/integration/statetest/eof/invalid_eof_in_state.json b/test/integration/statetest/eof/invalid_eof_in_state.json index db0384bd14..05a3e6dcbb 100644 --- a/test/integration/statetest/eof/invalid_eof_in_state.json +++ b/test/integration/statetest/eof/invalid_eof_in_state.json @@ -11,7 +11,7 @@ "currentTimestamp": "0x03e8" }, "post": { - "Cancun": [ + "Prague": [ { "hash": "0xe8010ce590f401c9d61fef8ab05bea9bcec24281b795e5868809bc4e515aa530", "indexes": { diff --git a/test/state/host.cpp b/test/state/host.cpp index 6d254fa1d9..2ee1d91f09 100644 --- a/test/state/host.cpp +++ b/test/state/host.cpp @@ -199,7 +199,7 @@ evmc::Result Host::create(const evmc_message& msg) noexcept create_msg.input_data = nullptr; create_msg.input_size = 0; - if (m_rev >= EVMC_CANCUN && (is_eof_container(initcode) || is_eof_container(sender_acc.code))) + if (m_rev >= EVMC_PRAGUE && (is_eof_container(initcode) || is_eof_container(sender_acc.code))) { if (validate_eof(m_rev, initcode) != EOFValidationError::success) return evmc::Result{EVMC_CONTRACT_VALIDATION_FAILURE}; @@ -228,7 +228,7 @@ evmc::Result Host::create(const evmc_message& msg) noexcept evmc::Result{EVMC_FAILURE}; } - if (m_rev >= EVMC_CANCUN && (is_eof_container(initcode) || is_eof_container(code))) + if (m_rev >= EVMC_PRAGUE && (is_eof_container(initcode) || is_eof_container(code))) { if (validate_eof(m_rev, code) != EOFValidationError::success) return evmc::Result{EVMC_CONTRACT_VALIDATION_FAILURE}; diff --git a/test/statetest/statetest_loader.cpp b/test/statetest/statetest_loader.cpp index db8ce8b4c0..344d3ba2c7 100644 --- a/test/statetest/statetest_loader.cpp +++ b/test/statetest/statetest_loader.cpp @@ -380,7 +380,7 @@ void validate_deployed_code(const state::State& state, evmc_revision rev) { if (is_eof_container(acc.code)) { - if (rev >= EVMC_CANCUN) + if (rev >= EVMC_PRAGUE) { if (const auto result = validate_eof(rev, acc.code); result != EOFValidationError::success) diff --git a/test/unittests/analysis_test.cpp b/test/unittests/analysis_test.cpp index a7b2661c3c..2e4312b7d8 100644 --- a/test/unittests/analysis_test.cpp +++ b/test/unittests/analysis_test.cpp @@ -260,7 +260,7 @@ TEST(analysis, example1_eof1) const auto code = eof1_bytecode( push(0x2a) + push(0x1e) + OP_MSTORE8 + OP_MSIZE + push(0) + OP_SSTORE, 2, "deadbeef"); const auto header = evmone::read_valid_eof1_header(code); - const auto analysis = analyze(EVMC_CANCUN, header.get_code(code, 0)); + const auto analysis = analyze(EVMC_PRAGUE, header.get_code(code, 0)); ASSERT_EQ(analysis.instrs.size(), 8); diff --git a/test/unittests/eof_test.cpp b/test/unittests/eof_test.cpp index 0655fe863c..f47b5b678c 100644 --- a/test/unittests/eof_test.cpp +++ b/test/unittests/eof_test.cpp @@ -61,7 +61,7 @@ TEST(eof, read_valid_eof1_header) for (const auto& test_case : test_cases) { const auto code = from_spaced_hex(test_case.code).value(); - EXPECT_EQ(validate_eof(EVMC_CANCUN, code), EOFValidationError::success) << test_case.code; + EXPECT_EQ(validate_eof(EVMC_PRAGUE, code), EOFValidationError::success) << test_case.code; const auto header = read_valid_eof1_header(code); EXPECT_EQ(header.code_sizes, test_case.code_sizes) << test_case.code; diff --git a/test/unittests/eof_validation_test.cpp b/test/unittests/eof_validation_test.cpp index f9180baf2f..5a67bc2018 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_CANCUN) noexcept + const bytecode& container, evmc_revision rev = EVMC_PRAGUE) noexcept { return evmone::validate_eof(rev, container); } @@ -222,7 +222,7 @@ TEST(eof_validation, EOF1_code_section_offset) { const auto eof = "EF0001 010008 02000200030001 040004 00 00000001 00000000 6001fe fe 0000 0000"_hex; - ASSERT_EQ(validate_eof(EVMC_CANCUN, eof), EOFValidationError::success); + ASSERT_EQ(validate_eof(EVMC_PRAGUE, eof), EOFValidationError::success); const auto header = read_valid_eof1_header(eof); ASSERT_EQ(header.code_sizes.size(), 2); @@ -313,7 +313,7 @@ TEST(eof_validation, EOF1_too_many_code_sections) TEST(eof_validation, EOF1_undefined_opcodes) { - const auto& gas_table = evmone::instr::gas_costs[EVMC_CANCUN]; + const auto& gas_table = evmone::instr::gas_costs[EVMC_PRAGUE]; for (uint16_t opcode = 0; opcode <= 0xff; ++opcode) { @@ -323,7 +323,7 @@ TEST(eof_validation, EOF1_undefined_opcodes) opcode == OP_SWAPN || opcode == OP_RJUMP || opcode == OP_RJUMPI || opcode == OP_CALLF || opcode == OP_RJUMPV || opcode == OP_DATALOADN) continue; - // These opcodes are deprecated since Cancun. + // These opcodes are deprecated since Prague. // gas_cost table current implementation does not allow to undef instructions. if (opcode == OP_JUMP || opcode == OP_JUMPI || opcode == OP_PC || opcode == OP_CALLCODE || opcode == OP_SELFDESTRUCT) diff --git a/test/unittests/evm_eip663_dupn_swapn_test.cpp b/test/unittests/evm_eip663_dupn_swapn_test.cpp index acc77911f4..117b3cf340 100644 --- a/test/unittests/evm_eip663_dupn_swapn_test.cpp +++ b/test/unittests/evm_eip663_dupn_swapn_test.cpp @@ -16,7 +16,7 @@ TEST_P(evm, dupn) if (evm::is_advanced()) return; - rev = EVMC_CANCUN; + rev = EVMC_PRAGUE; auto pushes = bytecode{}; for (uint64_t i = 1; i <= 20; ++i) @@ -44,7 +44,7 @@ TEST_P(evm, swapn) if (evm::is_advanced()) return; - rev = EVMC_CANCUN; + rev = EVMC_PRAGUE; auto pushes = bytecode{}; for (uint64_t i = 1; i <= 20; ++i) @@ -84,7 +84,7 @@ TEST_P(evm, dupn_full_stack) if (evm::is_advanced()) return; - rev = EVMC_CANCUN; + rev = EVMC_PRAGUE; auto full_stack_code = bytecode{}; for (uint64_t i = 1023; i >= 1; --i) full_stack_code += push(i); @@ -111,7 +111,7 @@ TEST_P(evm, swapn_full_stack) if (evm::is_advanced()) return; - rev = EVMC_CANCUN; + rev = EVMC_PRAGUE; auto full_stack_code = bytecode{}; for (uint64_t i = 1024; i >= 1; --i) full_stack_code += push(i); @@ -139,7 +139,7 @@ TEST_P(evm, dupn_dup_consistency) if (evm::is_advanced()) return; - rev = EVMC_CANCUN; + rev = EVMC_PRAGUE; auto pushes = bytecode{}; for (uint64_t i = 32; i >= 1; --i) pushes += push(i); @@ -167,7 +167,7 @@ TEST_P(evm, swapn_swap_consistency) if (evm::is_advanced()) return; - rev = EVMC_CANCUN; + rev = EVMC_PRAGUE; auto pushes = bytecode{}; for (uint64_t i = 32; i >= 1; --i) pushes += push(i); diff --git a/test/unittests/evm_eof_calls_test.cpp b/test/unittests/evm_eof_calls_test.cpp index 350c2a6e03..304db86991 100644 --- a/test/unittests/evm_eof_calls_test.cpp +++ b/test/unittests/evm_eof_calls_test.cpp @@ -10,7 +10,7 @@ using namespace evmc::literals; TEST_P(evm, eof1_delegatecall_eof1) { - rev = EVMC_CANCUN; + rev = EVMC_PRAGUE; constexpr auto callee = 0xca11ee_address; host.accounts[callee].code = eof1_bytecode(OP_STOP); bytes call_output{0x01, 0x02, 0x03}; @@ -30,7 +30,7 @@ TEST_P(evm, eof1_delegatecall_eof1) TEST_P(evm, eof1_delegatecall_legacy) { - rev = EVMC_CANCUN; + rev = EVMC_PRAGUE; constexpr auto callee = 0xca11ee_address; host.access_account(callee); diff --git a/test/unittests/evm_eof_function_test.cpp b/test/unittests/evm_eof_function_test.cpp index 69a148da97..14038cb2f3 100644 --- a/test/unittests/evm_eof_function_test.cpp +++ b/test/unittests/evm_eof_function_test.cpp @@ -13,7 +13,7 @@ TEST_P(evm, eof_function_example1) if (is_advanced()) return; - rev = EVMC_CANCUN; + rev = EVMC_PRAGUE; const auto code = "EF00 01 010008 020002 000f 0002 040000 00 00000002 02010002" + /* func0: */ push(1) + push(8) + OP_CALLF + "0001" + ret_top() + /* func1: */ OP_SUB + OP_RETF; @@ -31,7 +31,7 @@ TEST_P(evm, eof_function_example2) if (is_advanced()) return; - rev = EVMC_CANCUN; + rev = EVMC_PRAGUE; const auto code = "ef0001 01000c 020003 003b 0017 001d 040000 00 00000004 01010003 01010004" "60043560003560e01c63c76652678114e1001c63c6c2ea178114e100065050600080fd50e30002600052602060" @@ -62,7 +62,7 @@ TEST_P(evm, callf_stack_size_1024) if (is_advanced()) return; - rev = EVMC_CANCUN; + rev = EVMC_PRAGUE; const auto code = bytecode{"ef0001 010008 020002 0BFF 0004 040000 00 000003FF 00000001"_hex} + 1023 * push(1) + OP_CALLF + bytecode{"0x0001"_hex} + 1021 * OP_POP + OP_RETURN + push(1) + OP_POP + OP_RETF; @@ -78,7 +78,7 @@ TEST_P(evm, callf_stack_overflow) if (is_advanced()) return; - rev = EVMC_CANCUN; + rev = EVMC_PRAGUE; const auto code = bytecode{"ef0001 010008 020002 0BFF 0007 040000 00 000003FF 00000002"_hex} + // EOF header 1023 * push(1) + OP_CALLF + bytecode{"0x0001"_hex} + 1021 * OP_POP + OP_RETURN + @@ -95,7 +95,7 @@ TEST_P(evm, callf_call_stack_size_1024) if (is_advanced()) return; - rev = EVMC_CANCUN; + rev = EVMC_PRAGUE; const auto code = bytecode{"ef0001 010008 020002 0007 000e 040000 00 00000001 01000002"_hex} + push(1023) + OP_CALLF + bytecode{"0x0001"_hex} + OP_STOP + OP_DUP1 + OP_RJUMPI + bytecode{"0x0002"_hex} + OP_POP + OP_RETF + push(1) + OP_SWAP1 + @@ -112,7 +112,7 @@ TEST_P(evm, callf_call_stack_size_1025) if (is_advanced()) return; - rev = EVMC_CANCUN; + rev = EVMC_PRAGUE; const auto code = bytecode{"ef0001 010008 020002 0007 000e 040000 00 00000001 01000002"_hex} + push(1024) + OP_CALLF + bytecode{"0x0001"_hex} + OP_STOP + OP_DUP1 + OP_RJUMPI + bytecode{"0x0002"_hex} + OP_POP + OP_RETF + push(1) + OP_SWAP1 + diff --git a/test/unittests/evm_eof_rjump_test.cpp b/test/unittests/evm_eof_rjump_test.cpp index 9c71ee990c..91e1a321b3 100644 --- a/test/unittests/evm_eof_rjump_test.cpp +++ b/test/unittests/evm_eof_rjump_test.cpp @@ -14,7 +14,7 @@ TEST_P(evm, eof1_rjump) if (is_advanced()) return; - rev = EVMC_CANCUN; + rev = EVMC_PRAGUE; auto code = eof1_bytecode(rjumpi(3, 0) + rjump(1) + OP_INVALID + mstore8(0, 1) + ret(0, 1), 2); execute(code); @@ -37,7 +37,7 @@ TEST_P(evm, eof1_rjump_backward) if (is_advanced()) return; - rev = EVMC_CANCUN; + rev = EVMC_PRAGUE; auto code = eof1_bytecode(rjump(10) + mstore8(0, 1) + ret(0, 1) + rjump(-13), 2); execute(code); @@ -59,7 +59,7 @@ TEST_P(evm, eof1_rjump_0_offset) if (is_advanced()) return; - rev = EVMC_CANCUN; + rev = EVMC_PRAGUE; auto code = eof1_bytecode(rjump(0) + mstore8(0, 1) + ret(0, 1), 2); execute(code); @@ -74,7 +74,7 @@ TEST_P(evm, eof1_rjumpi) if (is_advanced()) return; - rev = EVMC_CANCUN; + rev = EVMC_PRAGUE; auto code = eof1_bytecode( rjumpi(10, calldataload(0)) + mstore8(0, 2) + ret(0, 1) + mstore8(0, 1) + ret(0, 1), 2); @@ -97,7 +97,7 @@ TEST_P(evm, eof1_rjumpi_backwards) if (is_advanced()) return; - rev = EVMC_CANCUN; + rev = EVMC_PRAGUE; auto code = eof1_bytecode(rjump(10) + mstore8(0, 1) + ret(0, 1) + rjumpi(-16, calldataload(0)) + mstore8(0, 2) + ret(0, 1), 2); @@ -121,7 +121,7 @@ TEST_P(evm, eof1_rjumpi_0_offset) if (is_advanced()) return; - rev = EVMC_CANCUN; + rev = EVMC_PRAGUE; auto code = eof1_bytecode(rjumpi(0, calldataload(0)) + mstore8(0, 1) + ret(0, 1), 2); // RJUMPI condition is true @@ -143,7 +143,7 @@ TEST_P(evm, eof1_rjumpv_single_offset) if (is_advanced()) return; - rev = EVMC_CANCUN; + rev = EVMC_PRAGUE; auto code = eof1_bytecode(rjumpv({3}, 0) + OP_JUMPDEST + OP_JUMPDEST + OP_STOP + 20 + 40 + 0 + OP_CODECOPY + ret(0, 20), 3, "ef000101000402000100010300000000000000fe"); @@ -161,7 +161,7 @@ TEST_P(evm, eof1_rjumpv_multiple_offsets) if (is_advanced()) return; - rev = EVMC_CANCUN; + rev = EVMC_PRAGUE; auto code = eof1_bytecode(rjump(12) + 10 + 68 + 0 + OP_CODECOPY + ret(0, 10) + rjumpv({12, -22, 0}, 1) + 10 + 78 + 0 + OP_CODECOPY + ret(0, 10) + 20 + 68 + 0 + OP_CODECOPY + ret(0, 20), @@ -200,7 +200,7 @@ TEST_P(evm, eof1_rjumpv_long_jumps) if (is_advanced()) return; - rev = EVMC_CANCUN; + rev = EVMC_PRAGUE; auto code = rjump(0x7fff - 3 - 5) + (0x7fff - 3 - 2 - 8 - 5) * bytecode{OP_JUMPDEST} + 7 + ret_top(); @@ -223,7 +223,7 @@ TEST_P(evm, eof1_rjumpv_long_jumps) TEST_P(evm, rjumps_undefined_in_legacy) { - rev = EVMC_CANCUN; + rev = EVMC_PRAGUE; auto code = rjump(1) + OP_INVALID + mstore8(0, 1) + ret(0, 1); execute(code); diff --git a/test/unittests/evm_eof_test.cpp b/test/unittests/evm_eof_test.cpp index f3b168850b..db6bcfd41c 100644 --- a/test/unittests/evm_eof_test.cpp +++ b/test/unittests/evm_eof_test.cpp @@ -11,18 +11,18 @@ TEST_P(evm, eof1_execution) { const auto code = eof1_bytecode(OP_STOP); - rev = EVMC_SHANGHAI; + rev = EVMC_CANCUN; execute(code); EXPECT_STATUS(EVMC_UNDEFINED_INSTRUCTION); - rev = EVMC_CANCUN; + rev = EVMC_PRAGUE; execute(code); EXPECT_STATUS(EVMC_SUCCESS); } TEST_P(evm, eof1_execution_with_data_section) { - rev = EVMC_CANCUN; + rev = EVMC_PRAGUE; // data section contains ret(0, 1) const auto code = eof1_bytecode(mstore8(0, 1) + OP_STOP, 2, ret(0, 1)); @@ -33,7 +33,7 @@ TEST_P(evm, eof1_execution_with_data_section) TEST_P(evm, eof1_codesize) { - rev = EVMC_CANCUN; + rev = EVMC_PRAGUE; auto code = eof1_bytecode(mstore8(0, OP_CODESIZE) + ret(0, 1), 2); execute(code); @@ -51,7 +51,7 @@ TEST_P(evm, eof1_codesize) TEST_P(evm, eof1_codecopy_full) { - rev = EVMC_CANCUN; + rev = EVMC_PRAGUE; auto code = eof1_bytecode(bytecode{31} + 0 + 0 + OP_CODECOPY + ret(0, 31), 3); execute(code); @@ -69,7 +69,7 @@ TEST_P(evm, eof1_codecopy_full) TEST_P(evm, eof1_codecopy_header) { - rev = EVMC_CANCUN; + rev = EVMC_PRAGUE; auto code = eof1_bytecode(bytecode{15} + 0 + 0 + OP_CODECOPY + ret(0, 15), 3); execute(code); @@ -87,7 +87,7 @@ TEST_P(evm, eof1_codecopy_header) TEST_P(evm, eof1_codecopy_code) { - rev = EVMC_CANCUN; + rev = EVMC_PRAGUE; auto code = eof1_bytecode(bytecode{12} + 19 + 0 + OP_CODECOPY + ret(0, 12), 3); execute(code); @@ -103,7 +103,7 @@ TEST_P(evm, eof1_codecopy_code) TEST_P(evm, eof1_codecopy_data) { - rev = EVMC_CANCUN; + rev = EVMC_PRAGUE; const auto code = eof1_bytecode(bytecode{4} + 31 + 0 + OP_CODECOPY + ret(0, 4), 3, "deadbeef"); @@ -115,7 +115,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_CANCUN; + rev = EVMC_PRAGUE; auto code = eof1_bytecode(bytecode{35} + 0 + 0 + OP_CODECOPY + ret(0, 35), 3); execute(code); @@ -133,7 +133,7 @@ TEST_P(evm, eof1_codecopy_out_of_bounds) TEST_P(evm, eof_data_only_contract) { - rev = EVMC_CANCUN; + rev = EVMC_PRAGUE; auto code = "EF0001 010004 020001 0001 04daaa 00 00000000 FE"_hex; const auto data_size_ptr = &code[code.find(0xda)]; @@ -156,7 +156,7 @@ TEST_P(evm, eof1_dataload) if (is_advanced()) return; - rev = EVMC_CANCUN; + rev = EVMC_PRAGUE; // data is 64 bytes long const auto data = bytes(8, 0x0) + bytes(8, 0x11) + bytes(8, 0x22) + bytes(8, 0x33) + bytes(8, 0xaa) + bytes(8, 0xbb) + bytes(8, 0xcc) + bytes(8, 0xdd); @@ -199,7 +199,7 @@ TEST_P(evm, eof1_dataloadn) if (is_advanced()) return; - rev = EVMC_CANCUN; + rev = EVMC_PRAGUE; // data is 64 bytes long const auto data = bytes(8, 0x0) + bytes(8, 0x11) + bytes(8, 0x22) + bytes(8, 0x33) + bytes(8, 0xaa) + bytes(8, 0xbb) + bytes(8, 0xcc) + bytes(8, 0xdd); @@ -232,7 +232,7 @@ TEST_P(evm, eof1_datasize) if (is_advanced()) return; - rev = EVMC_CANCUN; + rev = EVMC_PRAGUE; // no data section auto code = eof1_bytecode(bytecode(OP_DATASIZE) + ret_top(), 2); @@ -276,7 +276,7 @@ TEST_P(evm, eof1_datacopy) if (is_advanced()) return; - rev = EVMC_CANCUN; + rev = EVMC_PRAGUE; // data is 64 bytes long const auto data = bytes(8, 0x0) + bytes(8, 0x11) + bytes(8, 0x22) + bytes(8, 0x33) + bytes(8, 0xaa) + bytes(8, 0xbb) + bytes(8, 0xcc) + bytes(8, 0xdd); @@ -332,7 +332,7 @@ TEST_P(evm, datacopy_memory_cost) if (is_advanced()) return; - rev = EVMC_CANCUN; + rev = EVMC_PRAGUE; const auto data = bytes{0}; const auto code = eof1_bytecode(bytecode(1) + 0 + 0 + OP_DATACOPY + OP_STOP, 3, data); execute(18, code); diff --git a/test/unittests/evm_fixture.hpp b/test/unittests/evm_fixture.hpp index a5c6fc2cfb..226eed6a16 100644 --- a/test/unittests/evm_fixture.hpp +++ b/test/unittests/evm_fixture.hpp @@ -80,7 +80,7 @@ class evm : public testing::TestWithParam host.access_account(msg.recipient); } - if (rev >= EVMC_CANCUN && is_eof_container(code)) + if (rev >= EVMC_PRAGUE && is_eof_container(code)) { ASSERT_EQ(get_error_message(validate_eof(rev, code)), get_error_message(EOFValidationError::success)); diff --git a/test/unittests/evm_memory_test.cpp b/test/unittests/evm_memory_test.cpp index a0df336256..6315bf4c1c 100644 --- a/test/unittests/evm_memory_test.cpp +++ b/test/unittests/evm_memory_test.cpp @@ -179,7 +179,7 @@ TEST_P(evm, memory_access) { // This test checks if instructions accessing memory properly respond with out-of-gas // error for combinations of memory offset and memory size arguments. - rev = EVMC_CANCUN; + rev = EVMC_PRAGUE; for (const auto& p : memory_access_test_cases) { diff --git a/test/unittests/state_transition_eof_test.cpp b/test/unittests/state_transition_eof_test.cpp index fdcef37313..1d74c96aa3 100644 --- a/test/unittests/state_transition_eof_test.cpp +++ b/test/unittests/state_transition_eof_test.cpp @@ -13,7 +13,7 @@ TEST_F(state_transition, eof_invalid_initcode) // TODO: Correction of this address is not verified. static constexpr auto create_address = 0x864bbda5c698ac34b47a9ea3bd4228802cc5ce3b_address; - rev = EVMC_CANCUN; + rev = EVMC_PRAGUE; tx.to = To; pre.insert(*tx.to, { diff --git a/test/unittests/statetest_loader_test.cpp b/test/unittests/statetest_loader_test.cpp index 3244dfcc78..4a574d869a 100644 --- a/test/unittests/statetest_loader_test.cpp +++ b/test/unittests/statetest_loader_test.cpp @@ -130,7 +130,7 @@ TEST(statetest_loader, validate_deployed_code_test) { state::State state; state.insert(0xadd4_address, {.code = "EF0001010000020001000103000100FEDA"_hex}); - EXPECT_THAT([&] { validate_deployed_code(state, EVMC_CANCUN); }, + EXPECT_THAT([&] { validate_deployed_code(state, EVMC_PRAGUE); }, ThrowsMessage( "EOF container at 0x000000000000000000000000000000000000add4 is invalid: " "zero_section_size")); diff --git a/test/unittests/tracing_test.cpp b/test/unittests/tracing_test.cpp index 0d5054a719..63249206a2 100644 --- a/test/unittests/tracing_test.cpp +++ b/test/unittests/tracing_test.cpp @@ -299,8 +299,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, 2), 0, 0, EVMC_CANCUN), R"( -{"depth":0,"rev":"Cancun","static":false} + EXPECT_EQ(trace(eof1_bytecode(add(2, 3) + OP_STOP, 2), 0, 0, EVMC_PRAGUE), R"( +{"depth":0,"rev":"Prague","static":false} {"pc":0,"op":96,"opName":"PUSH1","gas":0xf4240,"stack":[],"memorySize":0} {"pc":2,"op":96,"opName":"PUSH1","gas":0xf423d,"stack":["0x3"],"memorySize":0} {"pc":4,"op":1,"opName":"ADD","gas":0xf423a,"stack":["0x3","0x2"],"memorySize":0}