Skip to content

Commit

Permalink
new(tests): EOF - EIP-6206: add new JUMPF tests (#1161)
Browse files Browse the repository at this point in the history
This adds two new JUMPF execution tests and clean ups tracker files
around the JUMPF instruction.
  • Loading branch information
chfast authored Jan 31, 2025
1 parent b22e901 commit 59ae588
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 5 deletions.
5 changes: 4 additions & 1 deletion converted-ethereum-tests.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ EOFTests/efValidation/EOF1_truncated_section_.json
EOFTests/efValidation/EOF1_undefined_opcodes_.json
EOFTests/efValidation/EOF1_truncated_push_.json
EOFTests/efValidation/deprecated_instructions_.json
EOFTests/efValidation/jumpf_compatible_outputs_.json
EOFTests/efValidation/jumpf_equal_outputs_.json
EOFTests/efValidation/jumpf_incompatible_outputs_.json
EOFTests/efValidation/non_returning_status_.json
EOFTests/efValidation/unreachable_code_sections_.json

Expand Down Expand Up @@ -70,4 +73,4 @@ GeneralStateTests/Cancun/stEIP1153-transientStorage/20_oogUndoesTransientStoreIn
GeneralStateTests/VMTests/vmTests/push.json

([#1067](https://github.com/ethereum/execution-spec-tests/pull/1067))
GeneralStateTests/stPreCompiledContracts/blake2B.json
GeneralStateTests/stPreCompiledContracts/blake2B.json
38 changes: 38 additions & 0 deletions tests/osaka/eip7692_eof_v1/eip6206_jumpf/test_jumpf_execution.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,44 @@ def test_jumpf_forward(
),
],
),
Container(
name="equal_outputs",
sections=[
Section.Code(
Op.CALLF[1] + Op.SSTORE + Op.STOP,
max_stack_height=2,
),
Section.Code(
Op.JUMPF[2],
code_outputs=2,
max_stack_height=0,
),
Section.Code(
Op.PUSH2[value_code_worked] + Op.PUSH2[slot_code_worked] + Op.RETF,
code_outputs=2,
max_stack_height=2,
),
],
),
Container(
name="compatible_outputs",
sections=[
Section.Code(
code=Op.CALLF[1] + Op.SSTORE + Op.STOP,
max_stack_height=2,
),
Section.Code(
Op.PUSH2[value_code_worked] + Op.JUMPF[2],
code_outputs=2,
max_stack_height=1,
),
Section.Code(
Op.PUSH2[slot_code_worked] + Op.RETF,
code_outputs=1,
max_stack_height=1,
),
],
),
],
ids=lambda container: container.name,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ def test_jumpf_incompatible_outputs(
stack_height: int,
expected_exception: EOFException,
):
"""Tests jumpf into fuction with incorrect output sizes."""
"""Tests JUMPF into a section with incorrect number of outputs."""
current_section_outputs = 1
if (current_section_outputs + target_inputs - target_outputs) != stack_height:
assert expected_exception is not None
Expand Down
6 changes: 3 additions & 3 deletions tests/osaka/eip7692_eof_v1/eof_tracker.md
Original file line number Diff line number Diff line change
Expand Up @@ -336,9 +336,9 @@
- [x] Zero section returning ([`tests/osaka/eip7692_eof_v1/eip6206_jumpf/test_nonreturning_validation.py::test_first_section_returning`](./eip6206_jumpf/test_nonreturning_validation/test_first_section_returning.md), ethereum/tests: ./src/EOFTestsFiller/efExample/validInvalidFiller.yml src/EOFTestsFiller/EIP4750/validInvalidFiller.yml)
- [x] Zero section declared non-returning but ends with RETF ([`tests/osaka/eip7692_eof_v1/eip6206_jumpf/test_nonreturning_validation.py::test_retf_in_nonreturning`](./eip6206_jumpf/test_nonreturning_validation/test_retf_in_nonreturning.md), ethereum/tests: src/EOFTestsFiller/EIP4750/validInvalidFiller.yml)
- [x] CALLF into non-returning function ([`tests/osaka/eip7692_eof_v1/eip6206_jumpf/test_nonreturning_validation.py::test_callf_to_nonreturning`](./eip6206_jumpf/test_nonreturning_validation/test_callf_to_nonreturning.md))
- [ ] Valid JUMPF into sections with equal number of outputs (ethereum/tests: src/EOFTestsFiller/efValidation/jumpf_equal_outputs_Copier.json)
- [ ] Valid JUMPF into sections with different but compatible number of outputs (ethereum/tests: src/EOFTestsFiller/efValidation/jumpf_compatible_outputs_Copier.json)
- [ ] JUMPF into sections with incompatible outputs (ethereum/tests: src/EOFTestsFiller/efValidation/jumpf_incompatible_outputs_Copier.json)
- [x] Valid JUMPF into sections with equal number of outputs ([`tests/osaka/eip7692_eof_v1/eip6206_jumpf/test_jumpf_execution.py::test_jumpf_to_retf`](./eip6206_jumpf/test_jumpf_execution/test_jumpf_to_retf.md))
- [x] Valid JUMPF into sections with different but compatible number of outputs ([`tests/osaka/eip7692_eof_v1/eip6206_jumpf/test_jumpf_execution.py::test_jumpf_to_retf`](./eip6206_jumpf/test_jumpf_execution/test_jumpf_to_retf.md))
- [x] JUMPF into sections with incompatible outputs ([`tests/osaka/eip7692_eof_v1/eip6206_jumpf/test_jumpf_stack.py::test_jumpf_incompatible_outputs`](./eip6206_jumpf/test_jumpf_stack/test_jumpf_incompatible_outputs.md))
- [x] Non-returning section without JUMPF ([`tests/osaka/eip7692_eof_v1/eip6206_jumpf/test_jumpf_execution.py::test_jumpf_forward`](./eip6206_jumpf/test_jumpf_execution/test_jumpf_forward.md))
- [x] Non-returning section with JUMPF ([`tests/osaka/eip7692_eof_v1/eip6206_jumpf/test_nonreturning_validation.py::test_jumpf_in_nonreturning`](./eip6206_jumpf/test_nonreturning_validation/test_jumpf_in_nonreturning.md))
- [x] Returning section with RETF ([`tests/osaka/eip7692_eof_v1/eip4750_functions/test_callf_execution.py::test_callf`](./eip4750_functions/test_callf_execution/test_callf.md))
Expand Down

0 comments on commit 59ae588

Please sign in to comment.