Skip to content

Commit 8caa0d5

Browse files
authored
new(tests): EOF - EIP-7692: migrate CALLF execution tests (ethereum#914)
1 parent 29a90ad commit 8caa0d5

File tree

2 files changed

+106
-1
lines changed

2 files changed

+106
-1
lines changed

osaka/eip7692_eof_v1/eip4750_functions/test_callf_execution.py

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,65 @@ def test_callf_fibonacci(eof_state_test: EOFStateTestFiller, n, result):
111111
)
112112

113113

114+
@pytest.mark.parametrize(
115+
"container",
116+
(
117+
Container(
118+
name="callf_sub_retf",
119+
sections=[
120+
Section.Code(
121+
Op.SSTORE(
122+
slot_code_worked,
123+
Op.PUSH1[1] + Op.PUSH2[value_code_worked + 1] + Op.CALLF[1],
124+
)
125+
+ Op.STOP,
126+
max_stack_height=2,
127+
),
128+
Section.Code(
129+
Op.SUB + Op.RETF,
130+
code_inputs=2,
131+
code_outputs=1,
132+
max_stack_height=2,
133+
),
134+
],
135+
),
136+
Container(
137+
name="max_code_sections_retf2",
138+
sections=[
139+
Section.Code(
140+
Op.CALLF[1] + Op.SSTORE + Op.STOP,
141+
max_stack_height=2,
142+
)
143+
]
144+
+ [
145+
Section.Code(
146+
Op.CALLF[i] + Op.RETF,
147+
code_inputs=0,
148+
code_outputs=2,
149+
max_stack_height=2,
150+
)
151+
for i in range(2, 1024)
152+
]
153+
+ [
154+
Section.Code(
155+
Op.PUSH2[value_code_worked] + Op.PUSH1[slot_code_worked] + Op.RETF,
156+
code_inputs=0,
157+
code_outputs=2,
158+
max_stack_height=2,
159+
),
160+
],
161+
),
162+
),
163+
ids=lambda x: x.name,
164+
)
165+
def test_callf(eof_state_test: EOFStateTestFiller, container: Container):
166+
"""Test basic usage of CALLF and RETF instructions"""
167+
eof_state_test(
168+
data=container,
169+
container_post=Account(storage={slot_code_worked: value_code_worked}),
170+
)
171+
172+
114173
@pytest.mark.parametrize(
115174
"container",
116175
(
@@ -237,6 +296,52 @@ def test_callf_fibonacci(eof_state_test: EOFStateTestFiller, n, result):
237296
),
238297
],
239298
),
299+
Container(
300+
name="store_value_unmodified_by_callf",
301+
sections=[
302+
Section.Code(
303+
Op.PUSH2[value_code_worked] # to be stored after CALLF
304+
+ Op.PUSH0 # input to CALLF
305+
+ Op.CALLF[1]
306+
+ Op.PUSH1[slot_code_worked]
307+
+ Op.SSTORE
308+
+ Op.STOP,
309+
max_stack_height=2,
310+
),
311+
Section.Code(
312+
Op.POP # clear input
313+
+ Op.PUSH0 * 1023 # reach max stack height
314+
+ Op.POP * 1023
315+
+ Op.RETF, # return nothing
316+
code_inputs=1,
317+
code_outputs=0,
318+
max_stack_height=1023,
319+
),
320+
],
321+
),
322+
Container(
323+
name="with_rjumpi",
324+
sections=[
325+
Section.Code(
326+
Op.PUSH1[1] # input[1] to CALLF
327+
+ Op.PUSH0 # input[0] to CALLF
328+
+ Op.CALLF[1]
329+
+ Op.SSTORE(slot_code_worked, value_code_worked)
330+
+ Op.STOP,
331+
max_stack_height=2,
332+
),
333+
Section.Code(
334+
Op.POP # clear input[0]
335+
+ Op.RJUMPI[2 * 1023] # jump to RETF based on input[1]
336+
+ Op.PUSH0 * 1023 # reach max stack height
337+
+ Op.POP * 1023
338+
+ Op.RETF, # return nothing
339+
code_inputs=2,
340+
code_outputs=0,
341+
max_stack_height=1023,
342+
),
343+
],
344+
),
240345
),
241346
ids=lambda x: x.name,
242347
)

osaka/eip7692_eof_v1/eof_tracker.md

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

326326
### Execution
327327

328-
- [ ] Max stack size (1024) in CALLF-ed function (ethereum/tests: src/EIPTestsFiller/StateTests/stEOF/stEIP4200/EOF1_CALLF_ExecutionFiller.yml)
328+
- [x] Max stack size (1024) in CALLF-ed function ([`tests/osaka/eip7692_eof_v1/eip4750_functions/test_callf_execution.py::test_callf_operand_stack_size_max`](./eip4750_functions/test_callf_execution/test_callf_operand_stack_size_max.md)
329329

330330

331331
## EIP-6206: EOF - JUMPF and non-returning functions

0 commit comments

Comments
 (0)