Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

new(tests): EOF - EIP-7620: migrate "embedded container" tests #763

Merged
merged 2 commits into from
Aug 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions converted-ethereum-tests.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ GeneralStateTests/stCreate2/call_then_create2_successful_then_returndatasize.jso
([#598](https://github.com/ethereum/execution-spec-tests/pull/598))
EOFTests/EIP3540/validInvalid.json

EOFTests/efValidation/EOF1_embedded_container_.json
EOFTests/efValidation/EOF1_eofcreate_valid_.json
EOFTests/efValidation/EOF1_section_order_.json
EOFTests/efValidation/EOF1_truncated_section_.json
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,13 @@
code=Op.SSTORE(slot_code_worked, value_code_worked) + Op.RETURNCONTRACT[0](0, 0),
max_stack_height=2,
)
stop_sub_container = Section.Container(container=Container(sections=[Section.Code(code=Op.STOP)]))
return_sub_container = Section.Container(
container=Container(sections=[Section.Code(code=Op.RETURN(0, 0), max_stack_height=2)])
)
revert_sub_container = Section.Container(
container=Container(sections=[Section.Code(code=Op.REVERT(0, 0), max_stack_height=2)])
)
stop_sub_container = Section.Container(Container.Code(Op.STOP))
return_sub_container = Section.Container(Container.Code(Op.RETURN(0, 0)))
revert_sub_container = Section.Container(Container.Code(Op.REVERT(0, 0)))
returncontract_sub_container = Section.Container(
container=Container(
Container(
sections=[
Section.Code(
code=Op.RETURNCONTRACT[0](0, 0),
max_stack_height=2,
),
Section.Code(Op.RETURNCONTRACT[0](0, 0)),
stop_sub_container,
],
)
Expand Down Expand Up @@ -474,9 +467,9 @@ def test_container_both_kinds_different_sub(eof_test: EOFTestFiller):
@pytest.mark.parametrize(
["deepest_container", "exception"],
[
pytest.param(Container(sections=[Section.Code(code=Op.STOP)]), None, id="valid"),
pytest.param(Container.Code(Op.STOP), None, id="valid"),
pytest.param(
Container(sections=[Section.Code(code=Op.PUSH0)]),
Container.Code(code=Op.PUSH0),
EOFException.MISSING_STOP_OPCODE,
id="code-error",
),
Expand Down Expand Up @@ -572,13 +565,71 @@ def test_wide_container(eof_test: EOFTestFiller, width: int, exception: EOFExcep
+ Op.POP
+ Op.STOP
),
Section.Container(Container(sections=[Section.Code(Op.INVALID)])),
Section.Container(Container.Code(Op.INVALID)),
],
expected_bytecode="""
ef0001010004020001000b0300010014040000000080000436600060ff6000ec005000ef000101000402
000100010400000000800000fe""",
),
id="EOF1_eofcreate_valid_0",
id="eofcreate_0",
),
pytest.param(
Container(
sections=[
Section.Code(Op.PUSH1[0] + Op.RJUMP[0] + Op.STOP),
Section.Container(Container.Code(Op.INVALID)),
],
expected_bytecode="""
ef00010100040200010006030001001404000000008000016000e0000000ef0001010004020001000104
00000000800000fe""",
# Originally this test was "valid" because it was created
# before "orphan subcontainer" rule was introduced.
validity_error=EOFException.ORPHAN_SUBCONTAINER,
),
id="orphan_subcontainer_0",
),
pytest.param(
Container(
sections=[
Section.Code(Op.PUSH1[0] + Op.RJUMP[0] + Op.STOP),
Section.Container(Container.Code(Op.INVALID)),
Section.Data(custom_size=2),
],
expected_bytecode="""
ef00010100040200010006030001001404000200008000016000e0000000ef0001010004020001000104
00000000800000fe""",
# Originally this test was "valid" but against the current spec
# it contains two errors: data section truncated and orphan subcontainer.
validity_error=EOFException.TOPLEVEL_CONTAINER_TRUNCATED,
),
id="orphan_subcontainer_0_and_truncated_data",
),
pytest.param(
Container(
sections=[
Section.Code(Op.PUSH1[0] + Op.RJUMP[0] + Op.STOP),
Section.Container(Container.Code(Op.INVALID)),
Section.Data("aabb"),
],
expected_bytecode="""
ef00010100040200010006030001001404000200008000016000e0000000ef0001010004020001000104
00000000800000feaabb""",
# Originally this test was "valid" because it was created
# before "orphan subcontainer" rule was introduced.
validity_error=EOFException.ORPHAN_SUBCONTAINER,
),
id="orphan_subcontainer_0_and_data",
),
pytest.param(
Container(
sections=[
Section.Code(Op.EOFCREATE[0](0, 0, 0, 0) + Op.STOP),
Section.Container("aabbccddeeff"),
],
# The original test has been modified to reference the subcontainer by EOFCREATE.
validity_error=EOFException.INVALID_MAGIC,
),
id="subcontainer_0_with_invalid_prefix",
),
pytest.param(
Container(
Expand All @@ -593,15 +644,31 @@ def test_wide_container(eof_test: EOFTestFiller, width: int, exception: EOFExcep
+ Op.STOP
)
]
+ 2 * [Section.Container(Container(sections=[Section.Code(Op.INVALID)]))],
+ 2 * [Section.Container(Container.Code(Op.INVALID))],
expected_bytecode="""
ef0001010004020001000b03000200140014040000000080000436600060ff6000ec015000ef00010100
0402000100010400000000800000feef000101000402000100010400000000800000fe""",
# Originally this test was "valid" because it was created
# before "orphan subcontainer" rule was introduced.
validity_error=EOFException.ORPHAN_SUBCONTAINER,
),
id="EOF1_eofcreate_valid_1",
id="eofcreate_1_orphan_subcontainer_0",
),
pytest.param(
Container(
sections=[
Section.Code(Op.PUSH1[0] + Op.RJUMP[0] + Op.STOP),
Section.Container(Container.Code(Op.INVALID)),
Section.Container(Container.Code(Op.PUSH0 + Op.PUSH0 + Op.RETURN)),
],
expected_bytecode="""
ef000101000402000100060300020014001604000000008000016000e0000000ef000101000402000100
010400000000800000feef0001010004020001000304000000008000025f5ff3""",
# Originally this test was "valid" because it was created
# before "orphan subcontainer" rule was introduced.
validity_error=EOFException.ORPHAN_SUBCONTAINER,
),
id="two_orphan_subcontainers",
),
pytest.param(
Container(
Expand All @@ -616,12 +683,22 @@ def test_wide_container(eof_test: EOFTestFiller, width: int, exception: EOFExcep
+ Op.STOP
)
]
+ 256 * [Section.Container(Container(sections=[Section.Code(Op.INVALID)]))],
+ 256 * [Section.Container(Container.Code(Op.INVALID))],
# Originally this test was "valid" because it was created
# before "orphan subcontainer" rule was introduced.
validity_error=EOFException.ORPHAN_SUBCONTAINER,
),
id="eofcreate_255_max_orphan_subcontainers",
),
pytest.param(
Container(
sections=[Section.Code(Op.PUSH1[0] + Op.RJUMP[0] + Op.STOP)]
+ 256 * [Section.Container(Container.Code(Op.INVALID))],
# Originally this test was "valid" because it was created
# before "orphan subcontainer" rule was introduced.
validity_error=EOFException.ORPHAN_SUBCONTAINER,
),
id="EOF1_eofcreate_valid_2",
id="max_orphan_subcontainers",
),
],
)
Expand Down
Loading