Skip to content

Commit 5a195ee

Browse files
chfastpdobacz
andauthored
new(tests): test for CALLF to non-returning section (#1126)
This adds tests for previously uncovered EOF validation error of CALLF to nonreturning sections. Co-authored-by: pdobacz <[email protected]>
1 parent 51a889a commit 5a195ee

File tree

5 files changed

+77
-1
lines changed

5 files changed

+77
-1
lines changed

converted-ethereum-tests.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ EOFTests/EIP3540/validInvalid.json
1414

1515
EOFTests/EIP3670/validInvalid.json
1616
EOFTests/EIP4200/validInvalid.json
17+
EOFTests/efValidation/callf_into_nonreturning_.json
1718
EOFTests/efValidation/EOF1_embedded_container_.json
1819
EOFTests/efValidation/EOF1_eofcreate_valid_.json
1920
EOFTests/efValidation/EOF1_callf_truncated_.json

src/ethereum_clis/clis/evmone.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,4 +184,7 @@ def _mapping_data(self):
184184
ExceptionMessage(
185185
EOFException.INVALID_CODE_SECTION_INDEX, "err: invalid_code_section_index"
186186
),
187+
ExceptionMessage(
188+
EOFException.CALLF_TO_NON_RETURNING, "err: callf_to_non_returning_function"
189+
),
187190
]

src/ethereum_test_exceptions/exceptions.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -754,6 +754,10 @@ class EOFException(ExceptionBase):
754754
"""
755755
Header parsing encounterd a section kind it wasn't expecting
756756
"""
757+
CALLF_TO_NON_RETURNING = auto()
758+
"""
759+
CALLF instruction targeting a non-returning code section
760+
"""
757761

758762

759763
"""

tests/osaka/eip7692_eof_v1/eip6206_jumpf/test_nonreturning_validation.py

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,3 +138,71 @@ def test_jumpf_in_nonreturning(eof_test: EOFTestFiller, first: bool, code_prefix
138138
validity_error=EOFException.INVALID_NON_RETURNING_FLAG,
139139
)
140140
)
141+
142+
143+
@pytest.mark.parametrize(
144+
"container",
145+
[
146+
Container(
147+
name="0_to_1",
148+
sections=[
149+
Section.Code(
150+
Op.CALLF[1],
151+
),
152+
Section.Code(
153+
Op.STOP,
154+
),
155+
],
156+
),
157+
Container(
158+
name="self_0",
159+
sections=[
160+
Section.Code(
161+
Op.CALLF[0] + Op.STOP,
162+
)
163+
],
164+
),
165+
Container(
166+
name="self_1",
167+
sections=[
168+
Section.Code(
169+
Op.JUMPF[1],
170+
),
171+
Section.Code(
172+
Op.CALLF[1] + Op.STOP,
173+
),
174+
],
175+
),
176+
Container(
177+
name="1_to_0",
178+
sections=[
179+
Section.Code(
180+
Op.CALLF[1] + Op.STOP,
181+
),
182+
Section.Code(
183+
Op.CALLF[0] + Op.RETF,
184+
code_outputs=0,
185+
),
186+
],
187+
),
188+
Container(
189+
name="1_to_2",
190+
sections=[
191+
Section.Code(
192+
Op.CALLF[1] + Op.STOP,
193+
),
194+
Section.Code(
195+
Op.CALLF[2] + Op.RETF,
196+
code_outputs=0,
197+
),
198+
Section.Code(
199+
Op.INVALID,
200+
),
201+
],
202+
),
203+
],
204+
ids=lambda x: x.name,
205+
)
206+
def test_callf_to_nonreturning(eof_test: EOFTestFiller, container: Container):
207+
"""Test EOF validation failing due to CALLF to non-returning section."""
208+
eof_test(data=container, expect_exception=EOFException.CALLF_TO_NON_RETURNING)

tests/osaka/eip7692_eof_v1/eof_tracker.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@
334334

335335
- [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)
336336
- [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)
337-
- [ ] CALLF into non-returning function (ethereum/tests: src/EOFTestsFiller/efValidation/callf_into_nonreturning_Copier.json)
337+
- [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))
338338
- [ ] Valid JUMPF into sections with equal number of outputs (ethereum/tests: src/EOFTestsFiller/efValidation/jumpf_equal_outputs_Copier.json)
339339
- [ ] Valid JUMPF into sections with different but compatible number of outputs (ethereum/tests: src/EOFTestsFiller/efValidation/jumpf_compatible_outputs_Copier.json)
340340
- [ ] JUMPF into sections with incompatible outputs (ethereum/tests: src/EOFTestsFiller/efValidation/jumpf_incompatible_outputs_Copier.json)

0 commit comments

Comments
 (0)