Skip to content

test_return_data_cleared()

Documentation for tests/prague/eip7692_eof_v1/eip7620_eof_create/test_eofcreate.py::test_return_data_cleared@verkle@v0.0.6.

Generate fixtures for these test cases for Pragueeip7692 with:

Pragueeip7692 only:

fill -v tests/prague/eip7692_eof_v1/eip7620_eof_create/test_eofcreate.py::test_return_data_cleared --fork=PragueEIP7692 --evm-bin=/path/to/evm-tool-dev-version

For all forks up to and including Pragueeip7692:

fill -v tests/prague/eip7692_eof_v1/eip7620_eof_create/test_eofcreate.py::test_return_data_cleared --until=PragueEIP7692

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

Source code in tests/prague/eip7692_eof_v1/eip7620_eof_create/test_eofcreate.py
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
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
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)