Skip to content

test_callf_operand_stack_size_max()

Documentation for tests/osaka/eip7692_eof_v1/eip4750_functions/test_callf_execution.py::test_callf_operand_stack_size_max@49a16fac.

Generate fixtures for these test cases for Osaka with:

fill -v tests/osaka/eip7692_eof_v1/eip4750_functions/test_callf_execution.py::test_callf_operand_stack_size_max --fork Osaka

Test operand stack reaching 1024 items.

Source code in tests/osaka/eip7692_eof_v1/eip4750_functions/test_callf_execution.py
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
@pytest.mark.parametrize(
    "container",
    (
        Container(
            name="no_inputs",
            sections=[
                Section.Code(
                    code=Op.PUSH0 * 1023
                    + Op.CALLF[1]
                    + Op.POP * 1023
                    + Op.SSTORE(slot_code_worked, value_code_worked)
                    + Op.RETURN(0, 0),
                    max_stack_height=1023,
                ),
                Section.Code(
                    Op.PUSH0 + Op.POP + Op.RETF,
                    code_inputs=0,
                    code_outputs=0,
                    max_stack_height=1,
                ),
            ],
        ),
        Container(
            name="with_inputs",
            sections=[
                Section.Code(
                    code=Op.PUSH0 * 1023
                    + Op.CALLF[1]
                    + Op.POP * 1023
                    + Op.SSTORE(slot_code_worked, value_code_worked)
                    + Op.RETURN(0, 0),
                    max_stack_height=1023,
                ),
                Section.Code(
                    Op.PUSH0 + Op.POP + Op.RETF,
                    code_inputs=3,
                    code_outputs=3,
                    max_stack_height=4,
                ),
            ],
        ),
        Container(
            name="at_callf",
            sections=[
                Section.Code(
                    code=Op.PUSH0 * 1023
                    + Op.CALLF[1]
                    + Op.POP * 1023
                    + Op.SSTORE(slot_code_worked, value_code_worked)
                    + Op.RETURN(0, 0),
                    max_stack_height=1023,
                ),
                Section.Code(
                    Op.CALLF[2]
                    +
                    # stack has 1024 items
                    Op.POP
                    + Op.RETF,
                    code_inputs=0,
                    code_outputs=0,
                    max_stack_height=1,
                ),
                Section.Code(
                    Op.PUSH0 + Op.RETF,  # stack has 1024 items
                    code_inputs=0,
                    code_outputs=1,
                    max_stack_height=1,
                ),
            ],
        ),
        Container(
            name="at_push0",
            sections=[
                Section.Code(
                    code=Op.PUSH0 * 1022
                    + Op.CALLF[1]
                    + Op.POP * 1022
                    + Op.SSTORE(slot_code_worked, value_code_worked)
                    + Op.RETURN(0, 0),
                    max_stack_height=1022,
                ),
                Section.Code(
                    Op.PUSH0
                    +
                    # stack has 1023 items
                    Op.CALLF[2]
                    + Op.POP
                    + Op.RETF,
                    code_inputs=0,
                    code_outputs=0,
                    max_stack_height=1,
                ),
                Section.Code(
                    Op.PUSH0
                    +
                    # stack has 1024 items
                    Op.POP
                    + Op.RETF,
                    code_inputs=0,
                    code_outputs=0,
                    max_stack_height=1,
                ),
            ],
        ),
        Container(
            name="nested_with_inputs_at_push0",
            sections=[
                Section.Code(
                    code=Op.PUSH0 * 1022
                    + Op.CALLF[1]
                    + Op.POP * 1022
                    + Op.SSTORE(slot_code_worked, value_code_worked)
                    + Op.RETURN(0, 0),
                    max_stack_height=1022,
                ),
                Section.Code(
                    Op.PUSH0
                    +
                    # Stack has 1023 items
                    Op.CALLF[2]
                    + Op.POP
                    + Op.RETF,
                    code_inputs=3,
                    code_outputs=3,
                    max_stack_height=4,
                ),
                Section.Code(
                    Op.PUSH0
                    +
                    # Stack has 1024 items
                    Op.POP
                    + Op.RETF,
                    code_inputs=3,
                    code_outputs=3,
                    max_stack_height=4,
                ),
            ],
        ),
        Container(
            name="store_value_unmodified_by_callf",
            sections=[
                Section.Code(
                    Op.PUSH2[value_code_worked]  # to be stored after CALLF
                    + Op.PUSH0  # input to CALLF
                    + Op.CALLF[1]
                    + Op.PUSH1[slot_code_worked]
                    + Op.SSTORE
                    + Op.STOP,
                    max_stack_height=2,
                ),
                Section.Code(
                    Op.POP  # clear input
                    + Op.PUSH0 * 1023  # reach max stack height
                    + Op.POP * 1023
                    + Op.RETF,  # return nothing
                    code_inputs=1,
                    code_outputs=0,
                    max_stack_height=1023,
                ),
            ],
        ),
        Container(
            name="with_rjumpi",
            sections=[
                Section.Code(
                    Op.PUSH1[1]  # input[1] to CALLF
                    + Op.PUSH0  # input[0] to CALLF
                    + Op.CALLF[1]
                    + Op.SSTORE(slot_code_worked, value_code_worked)
                    + Op.STOP,
                    max_stack_height=2,
                ),
                Section.Code(
                    Op.POP  # clear input[0]
                    + Op.RJUMPI[2 * 1023]  # jump to RETF based on input[1]
                    + Op.PUSH0 * 1023  # reach max stack height
                    + Op.POP * 1023
                    + Op.RETF,  # return nothing
                    code_inputs=2,
                    code_outputs=0,
                    max_stack_height=1023,
                ),
            ],
        ),
    ),
    ids=lambda x: x.name,
)
def test_callf_operand_stack_size_max(eof_state_test: EOFStateTestFiller, container: Container):
    """Test operand stack reaching 1024 items."""
    eof_state_test(
        container=container,
        container_post=Account(storage={slot_code_worked: value_code_worked}),
    )

Parametrized Test Cases

This test case is only parametrized by fork and fixture format.

Test ID (Abbreviated) container
...fork_Osaka-eof_test-no_inputs no_inputs
...fork_Osaka-eof_test-with_inputs with_inputs
...fork_Osaka-eof_test-at_callf at_callf
...fork_Osaka-eof_test-at_push0 at_push0
...fork_Osaka-eof_test-nested_with_inputs_at_push0 nested_with_inputs_at_push0
...fork_Osaka-eof_test-store_value_unmodified_by_callf store_value_unmodified_by_callf
...fork_Osaka-eof_test-with_rjumpi with_rjumpi
...fork_Osaka-state_test-no_inputs no_inputs
...fork_Osaka-state_test-with_inputs with_inputs
...fork_Osaka-state_test-at_callf at_callf
...fork_Osaka-state_test-at_push0 at_push0
...fork_Osaka-state_test-nested_with_inputs_at_push0 nested_with_inputs_at_push0
...fork_Osaka-state_test-store_value_unmodified_by_callf store_value_unmodified_by_callf
...fork_Osaka-state_test-with_rjumpi with_rjumpi
...fork_Osaka-blockchain_test-no_inputs no_inputs
...fork_Osaka-blockchain_test-with_inputs with_inputs
...fork_Osaka-blockchain_test-at_callf at_callf
...fork_Osaka-blockchain_test-at_push0 at_push0
...fork_Osaka-blockchain_test-nested_with_inputs_at_push0 nested_with_inputs_at_push0
...fork_Osaka-blockchain_test-store_value_unmodified_by_callf store_value_unmodified_by_callf
...fork_Osaka-blockchain_test-with_rjumpi with_rjumpi