Skip to content

Commit 0abe773

Browse files
authored
Deprecate and reject code/gas-observability in EOF (#834)
* Deprecate and reject code/gas-observability in EOF * Update `tests` revision for CI
1 parent ccc92f1 commit 0abe773

File tree

4 files changed

+12
-104
lines changed

4 files changed

+12
-104
lines changed

circle.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,7 @@ jobs:
535535
~/tests/EIPTests/BlockchainTests/
536536
- download_execution_tests:
537537
repo: ipsilon/tests
538-
rev: eof-extcode-20240313
538+
rev: eof-deprecate-ops-20240318
539539
legacy: false
540540
- run:
541541
name: "State tests (EOF)"

lib/evmone/baseline_instruction_table.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,12 @@ constexpr auto eof_cost_tables = []() noexcept {
4949
tables[EVMC_PRAGUE][OP_SELFDESTRUCT] = instr::undefined;
5050
tables[EVMC_PRAGUE][OP_CREATE] = instr::undefined;
5151
tables[EVMC_PRAGUE][OP_CREATE2] = instr::undefined;
52+
tables[EVMC_PRAGUE][OP_CODESIZE] = instr::undefined;
53+
tables[EVMC_PRAGUE][OP_CODECOPY] = instr::undefined;
54+
tables[EVMC_PRAGUE][OP_EXTCODESIZE] = instr::undefined;
55+
tables[EVMC_PRAGUE][OP_EXTCODECOPY] = instr::undefined;
56+
tables[EVMC_PRAGUE][OP_EXTCODEHASH] = instr::undefined;
57+
tables[EVMC_PRAGUE][OP_GAS] = instr::undefined;
5258
return tables;
5359
}();
5460

test/unittests/eof_validation_test.cpp

+5-2
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,9 @@ TEST_F(eof_validation, EOF1_undefined_opcodes)
299299
// These opcodes are deprecated since Prague.
300300
// gas_cost table current implementation does not allow to undef instructions.
301301
if (opcode == OP_JUMP || opcode == OP_JUMPI || opcode == OP_PC || opcode == OP_CALLCODE ||
302-
opcode == OP_SELFDESTRUCT || opcode == OP_CREATE || opcode == OP_CREATE2)
302+
opcode == OP_SELFDESTRUCT || opcode == OP_CREATE || opcode == OP_CREATE2 ||
303+
opcode == OP_CODESIZE || opcode == OP_CODECOPY || opcode == OP_EXTCODESIZE ||
304+
opcode == OP_EXTCODECOPY || opcode == OP_EXTCODEHASH || opcode == OP_GAS)
303305
continue;
304306

305307
auto cont =
@@ -574,7 +576,8 @@ TEST_F(eof_validation, EOF1_section_order)
574576

575577
TEST_F(eof_validation, deprecated_instructions)
576578
{
577-
for (auto op : {OP_CALLCODE, OP_SELFDESTRUCT, OP_JUMP, OP_JUMPI, OP_PC, OP_CREATE, OP_CREATE2})
579+
for (auto op : {OP_CALLCODE, OP_SELFDESTRUCT, OP_JUMP, OP_JUMPI, OP_PC, OP_CREATE, OP_CREATE2,
580+
OP_CODESIZE, OP_CODECOPY, OP_EXTCODESIZE, OP_EXTCODECOPY, OP_EXTCODEHASH, OP_GAS})
578581
add_test_case(eof_bytecode(op), EOFValidationError::undefined_instruction);
579582
}
580583

test/unittests/evm_eof_test.cpp

-101
Original file line numberDiff line numberDiff line change
@@ -31,107 +31,6 @@ TEST_P(evm, eof1_execution_with_data_section)
3131
EXPECT_EQ(result.output_size, 0);
3232
}
3333

34-
TEST_P(evm, eof1_codesize)
35-
{
36-
rev = EVMC_PRAGUE;
37-
auto code = eof_bytecode(mstore8(0, OP_CODESIZE) + ret(0, 1), 2);
38-
39-
execute(code);
40-
EXPECT_STATUS(EVMC_SUCCESS);
41-
ASSERT_EQ(result.output_size, 1);
42-
EXPECT_EQ(result.output_data[0], 28);
43-
44-
code = eof_bytecode(mstore8(0, OP_CODESIZE) + ret(0, 1), 2).data("deadbeef");
45-
46-
execute(code);
47-
EXPECT_STATUS(EVMC_SUCCESS);
48-
ASSERT_EQ(result.output_size, 1);
49-
EXPECT_EQ(result.output_data[0], 32);
50-
}
51-
52-
TEST_P(evm, eof1_codecopy_full)
53-
{
54-
rev = EVMC_PRAGUE;
55-
auto code = eof_bytecode(bytecode{31} + 0 + 0 + OP_CODECOPY + ret(0, 31), 3);
56-
57-
execute(code);
58-
EXPECT_STATUS(EVMC_SUCCESS);
59-
EXPECT_EQ(bytes_view(result.output_data, result.output_size),
60-
"ef0001010004020001000c0400000000800003601f6000600039601f6000f3"_hex);
61-
62-
code = eof_bytecode(bytecode{35} + 0 + 0 + OP_CODECOPY + ret(0, 35), 3).data("deadbeef");
63-
64-
execute(code);
65-
EXPECT_STATUS(EVMC_SUCCESS);
66-
EXPECT_EQ(bytes_view(result.output_data, result.output_size),
67-
"ef0001010004020001000c04000400008000036023600060003960236000f3deadbeef"_hex);
68-
}
69-
70-
TEST_P(evm, eof1_codecopy_header)
71-
{
72-
rev = EVMC_PRAGUE;
73-
auto code = eof_bytecode(bytecode{15} + 0 + 0 + OP_CODECOPY + ret(0, 15), 3);
74-
75-
execute(code);
76-
EXPECT_STATUS(EVMC_SUCCESS);
77-
EXPECT_EQ(
78-
bytes_view(result.output_data, result.output_size), "ef0001010004020001000c04000000"_hex);
79-
80-
code = eof_bytecode(bytecode{15} + 0 + 0 + OP_CODECOPY + ret(0, 15), 3).data("deadbeef");
81-
82-
execute(code);
83-
EXPECT_STATUS(EVMC_SUCCESS);
84-
EXPECT_EQ(
85-
bytes_view(result.output_data, result.output_size), "ef0001010004020001000c04000400"_hex);
86-
}
87-
88-
TEST_P(evm, eof1_codecopy_code)
89-
{
90-
rev = EVMC_PRAGUE;
91-
auto code = eof_bytecode(bytecode{12} + 19 + 0 + OP_CODECOPY + ret(0, 12), 3);
92-
93-
execute(code);
94-
EXPECT_STATUS(EVMC_SUCCESS);
95-
EXPECT_EQ(bytes_view(result.output_data, result.output_size), "600c6013600039600c6000f3"_hex);
96-
97-
code = eof_bytecode(bytecode{12} + 19 + 0 + OP_CODECOPY + ret(0, 12), 3).data("deadbeef");
98-
99-
execute(code);
100-
EXPECT_STATUS(EVMC_SUCCESS);
101-
EXPECT_EQ(bytes_view(result.output_data, result.output_size), "600c6013600039600c6000f3"_hex);
102-
}
103-
104-
TEST_P(evm, eof1_codecopy_data)
105-
{
106-
rev = EVMC_PRAGUE;
107-
108-
const auto code =
109-
eof_bytecode(bytecode{4} + 31 + 0 + OP_CODECOPY + ret(0, 4), 3).data("deadbeef");
110-
111-
execute(code);
112-
EXPECT_STATUS(EVMC_SUCCESS);
113-
EXPECT_EQ(bytes_view(result.output_data, result.output_size), "deadbeef"_hex);
114-
}
115-
116-
TEST_P(evm, eof1_codecopy_out_of_bounds)
117-
{
118-
// 4 bytes out of container bounds - result is implicitly 0-padded
119-
rev = EVMC_PRAGUE;
120-
auto code = eof_bytecode(bytecode{35} + 0 + 0 + OP_CODECOPY + ret(0, 35), 3);
121-
122-
execute(code);
123-
EXPECT_STATUS(EVMC_SUCCESS);
124-
EXPECT_EQ(bytes_view(result.output_data, result.output_size),
125-
"ef0001010004020001000c04000000008000036023600060003960236000f300000000"_hex);
126-
127-
code = eof_bytecode(bytecode{39} + 0 + 0 + OP_CODECOPY + ret(0, 39), 3).data("deadbeef");
128-
129-
execute(code);
130-
EXPECT_STATUS(EVMC_SUCCESS);
131-
EXPECT_EQ(bytes_view(result.output_data, result.output_size),
132-
"ef0001010004020001000c04000400008000036027600060003960276000f3deadbeef00000000"_hex);
133-
}
134-
13534
TEST_P(evm, eof_data_only_contract)
13635
{
13736
rev = EVMC_PRAGUE;

0 commit comments

Comments
 (0)