Skip to content

test_return_data_cleared()

Documentation for tests/osaka/eip7692_eof_v1/eip7620_eof_create/test_eofcreate.py::test_return_data_cleared@83970623.

Generate fixtures for these test cases for Osaka with:

fill -v tests/osaka/eip7692_eof_v1/eip7620_eof_create/test_eofcreate.py::test_return_data_cleared --fork Osaka

Verifies the return data is not re-used from a extcall but is cleared upon eofcreate.

Source code in tests/osaka/eip7692_eof_v1/eip7620_eof_create/test_eofcreate.py
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
def test_return_data_cleared(
    state_test: StateTestFiller,
    pre: Alloc,
):
    """Verifies the return data is not re-used from a extcall but is cleared upon eofcreate."""
    env = Environment()
    value_return_canary = 0x4158675309
    value_return_canary_size = 5
    callable_address = pre.deploy_contract(
        code=Container(
            sections=[
                Section.Code(
                    code=Op.MSTORE(0, value_return_canary)
                    + Op.RETURN(0, value_return_canary_size),
                )
            ]
        )
    )

    slot_returndata_size_2 = slot_last_slot * 2 + slot_returndata_size
    sender = pre.fund_eoa()
    contract_address = pre.deploy_contract(
        code=Container(
            sections=[
                Section.Code(
                    code=Op.SSTORE(slot_call_result, Op.EXTCALL(callable_address, 0, 0, 0))
                    + Op.SSTORE(slot_returndata_size, Op.RETURNDATASIZE)
                    + Op.SSTORE(slot_create_address, Op.EOFCREATE[0](0, 0, 0, 0))
                    + Op.SSTORE(slot_returndata_size_2, Op.RETURNDATASIZE)
                    + Op.SSTORE(slot_code_worked, value_code_worked)
                    + Op.STOP,
                ),
                Section.Container(container=smallest_initcode_subcontainer),
            ],
        )
    )

    new_contract_address = compute_eofcreate_address(
        contract_address, 0, smallest_initcode_subcontainer
    )
    post = {
        contract_address: Account(
            storage={
                slot_call_result: EXTCALL_SUCCESS,
                slot_returndata_size: value_return_canary_size,
                slot_create_address: new_contract_address,
                slot_returndata_size_2: 0,
                slot_code_worked: value_code_worked,
            },
            nonce=2,
        ),
        callable_address: Account(nonce=1),
        new_contract_address: Account(nonce=1),
    }
    tx = Transaction(
        to=contract_address,
        gas_limit=10_000_000,
        gas_price=10,
        protected=False,
        sender=sender,
    )

    state_test(env=env, pre=pre, post=post, tx=tx)

Parametrized Test Cases

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

Test ID (Abbreviated)
...fork_Osaka-blockchain_test
...fork_Osaka-state_test