diff --git a/circle.yml b/circle.yml index 918d1aa2fc..2e83c59598 100644 --- a/circle.yml +++ b/circle.yml @@ -535,7 +535,7 @@ jobs: ~/tests/EIPTests/BlockchainTests/ - download_execution_tests: repo: ipsilon/tests - rev: eof-extcode-20240313 + rev: eof-deprecate-ops-20240318 legacy: false - run: name: "State tests (EOF)" diff --git a/lib/evmone/baseline_instruction_table.cpp b/lib/evmone/baseline_instruction_table.cpp index 8a44770316..cefcd0a05b 100644 --- a/lib/evmone/baseline_instruction_table.cpp +++ b/lib/evmone/baseline_instruction_table.cpp @@ -49,6 +49,12 @@ constexpr auto eof_cost_tables = []() noexcept { tables[EVMC_PRAGUE][OP_SELFDESTRUCT] = instr::undefined; tables[EVMC_PRAGUE][OP_CREATE] = instr::undefined; tables[EVMC_PRAGUE][OP_CREATE2] = instr::undefined; + tables[EVMC_PRAGUE][OP_CODESIZE] = instr::undefined; + tables[EVMC_PRAGUE][OP_CODECOPY] = instr::undefined; + tables[EVMC_PRAGUE][OP_EXTCODESIZE] = instr::undefined; + tables[EVMC_PRAGUE][OP_EXTCODECOPY] = instr::undefined; + tables[EVMC_PRAGUE][OP_EXTCODEHASH] = instr::undefined; + tables[EVMC_PRAGUE][OP_GAS] = instr::undefined; return tables; }(); diff --git a/test/unittests/eof_validation_test.cpp b/test/unittests/eof_validation_test.cpp index 92aec9c14b..fcf2152747 100644 --- a/test/unittests/eof_validation_test.cpp +++ b/test/unittests/eof_validation_test.cpp @@ -299,7 +299,9 @@ TEST_F(eof_validation, EOF1_undefined_opcodes) // 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 || opcode == OP_CREATE || opcode == OP_CREATE2) + opcode == OP_SELFDESTRUCT || opcode == OP_CREATE || opcode == OP_CREATE2 || + opcode == OP_CODESIZE || opcode == OP_CODECOPY || opcode == OP_EXTCODESIZE || + opcode == OP_EXTCODECOPY || opcode == OP_EXTCODEHASH || opcode == OP_GAS) continue; auto cont = @@ -574,7 +576,8 @@ TEST_F(eof_validation, EOF1_section_order) TEST_F(eof_validation, deprecated_instructions) { - for (auto op : {OP_CALLCODE, OP_SELFDESTRUCT, OP_JUMP, OP_JUMPI, OP_PC, OP_CREATE, OP_CREATE2}) + for (auto op : {OP_CALLCODE, OP_SELFDESTRUCT, OP_JUMP, OP_JUMPI, OP_PC, OP_CREATE, OP_CREATE2, + OP_CODESIZE, OP_CODECOPY, OP_EXTCODESIZE, OP_EXTCODECOPY, OP_EXTCODEHASH, OP_GAS}) add_test_case(eof_bytecode(op), EOFValidationError::undefined_instruction); } diff --git a/test/unittests/evm_eof_test.cpp b/test/unittests/evm_eof_test.cpp index fcfdeee7f8..209d5dab5d 100644 --- a/test/unittests/evm_eof_test.cpp +++ b/test/unittests/evm_eof_test.cpp @@ -31,107 +31,6 @@ TEST_P(evm, eof1_execution_with_data_section) EXPECT_EQ(result.output_size, 0); } -TEST_P(evm, eof1_codesize) -{ - rev = EVMC_PRAGUE; - auto code = eof_bytecode(mstore8(0, OP_CODESIZE) + ret(0, 1), 2); - - execute(code); - EXPECT_STATUS(EVMC_SUCCESS); - ASSERT_EQ(result.output_size, 1); - EXPECT_EQ(result.output_data[0], 28); - - code = eof_bytecode(mstore8(0, OP_CODESIZE) + ret(0, 1), 2).data("deadbeef"); - - execute(code); - EXPECT_STATUS(EVMC_SUCCESS); - ASSERT_EQ(result.output_size, 1); - EXPECT_EQ(result.output_data[0], 32); -} - -TEST_P(evm, eof1_codecopy_full) -{ - rev = EVMC_PRAGUE; - auto code = eof_bytecode(bytecode{31} + 0 + 0 + OP_CODECOPY + ret(0, 31), 3); - - execute(code); - EXPECT_STATUS(EVMC_SUCCESS); - EXPECT_EQ(bytes_view(result.output_data, result.output_size), - "ef0001010004020001000c0400000000800003601f6000600039601f6000f3"_hex); - - code = eof_bytecode(bytecode{35} + 0 + 0 + OP_CODECOPY + ret(0, 35), 3).data("deadbeef"); - - execute(code); - EXPECT_STATUS(EVMC_SUCCESS); - EXPECT_EQ(bytes_view(result.output_data, result.output_size), - "ef0001010004020001000c04000400008000036023600060003960236000f3deadbeef"_hex); -} - -TEST_P(evm, eof1_codecopy_header) -{ - rev = EVMC_PRAGUE; - auto code = eof_bytecode(bytecode{15} + 0 + 0 + OP_CODECOPY + ret(0, 15), 3); - - execute(code); - EXPECT_STATUS(EVMC_SUCCESS); - EXPECT_EQ( - bytes_view(result.output_data, result.output_size), "ef0001010004020001000c04000000"_hex); - - code = eof_bytecode(bytecode{15} + 0 + 0 + OP_CODECOPY + ret(0, 15), 3).data("deadbeef"); - - execute(code); - EXPECT_STATUS(EVMC_SUCCESS); - EXPECT_EQ( - bytes_view(result.output_data, result.output_size), "ef0001010004020001000c04000400"_hex); -} - -TEST_P(evm, eof1_codecopy_code) -{ - rev = EVMC_PRAGUE; - auto code = eof_bytecode(bytecode{12} + 19 + 0 + OP_CODECOPY + ret(0, 12), 3); - - execute(code); - EXPECT_STATUS(EVMC_SUCCESS); - EXPECT_EQ(bytes_view(result.output_data, result.output_size), "600c6013600039600c6000f3"_hex); - - code = eof_bytecode(bytecode{12} + 19 + 0 + OP_CODECOPY + ret(0, 12), 3).data("deadbeef"); - - execute(code); - EXPECT_STATUS(EVMC_SUCCESS); - EXPECT_EQ(bytes_view(result.output_data, result.output_size), "600c6013600039600c6000f3"_hex); -} - -TEST_P(evm, eof1_codecopy_data) -{ - rev = EVMC_PRAGUE; - - const auto code = - eof_bytecode(bytecode{4} + 31 + 0 + OP_CODECOPY + ret(0, 4), 3).data("deadbeef"); - - execute(code); - EXPECT_STATUS(EVMC_SUCCESS); - EXPECT_EQ(bytes_view(result.output_data, result.output_size), "deadbeef"_hex); -} - -TEST_P(evm, eof1_codecopy_out_of_bounds) -{ - // 4 bytes out of container bounds - result is implicitly 0-padded - rev = EVMC_PRAGUE; - auto code = eof_bytecode(bytecode{35} + 0 + 0 + OP_CODECOPY + ret(0, 35), 3); - - execute(code); - EXPECT_STATUS(EVMC_SUCCESS); - EXPECT_EQ(bytes_view(result.output_data, result.output_size), - "ef0001010004020001000c04000000008000036023600060003960236000f300000000"_hex); - - code = eof_bytecode(bytecode{39} + 0 + 0 + OP_CODECOPY + ret(0, 39), 3).data("deadbeef"); - - execute(code); - EXPECT_STATUS(EVMC_SUCCESS); - EXPECT_EQ(bytes_view(result.output_data, result.output_size), - "ef0001010004020001000c04000400008000036027600060003960276000f3deadbeef00000000"_hex); -} - TEST_P(evm, eof_data_only_contract) { rev = EVMC_PRAGUE;