Skip to content

test_insufficient_returncontract_auxdata_gas()

Documentation for tests/osaka/eip7692_eof_v1/eip7620_eof_create/test_eofcreate_failures.py::test_insufficient_returncontract_auxdata_gas@008e492e.

Generate fixtures for these test cases for Osaka with:

fill -v tests/osaka/eip7692_eof_v1/eip7620_eof_create/test_eofcreate_failures.py::test_insufficient_returncontract_auxdata_gas --fork Osaka

Exercises a RETURNCONTRACT when there is not enough gas for the initcode charge.

Source code in tests/osaka/eip7692_eof_v1/eip7620_eof_create/test_eofcreate_failures.py
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
def test_insufficient_returncontract_auxdata_gas(
    state_test: StateTestFiller,
    pre: Alloc,
):
    """Exercises a RETURNCONTRACT when there is not enough gas for the initcode charge."""
    env = Environment()

    auxdata_size = 0x5000
    initcode_container = Container(
        name="Large Initcode Subcontainer",
        sections=[
            Section.Code(
                code=Op.RETURNCONTRACT[0](0, auxdata_size),
            ),
            Section.Container(container=smallest_runtime_subcontainer),
        ],
    )

    sender = pre.fund_eoa()
    contract_address = pre.deploy_contract(
        code=Container(
            sections=[
                Section.Code(
                    code=Op.SSTORE(slot_create_address, Op.EOFCREATE[0](0, 0, 0, 0))
                    + Op.SSTORE(slot_code_should_fail, value_code_worked)
                    + Op.STOP,
                ),
                Section.Container(container=initcode_container),
            ],
        ),
        storage={
            slot_create_address: value_canary_should_not_change,
            slot_code_should_fail: value_canary_should_not_change,
        },
    )
    # enough gas for everything but EVM opcodes and EIP-150 reserves
    initcode_container_words = (len(initcode_container) + 31) // 32
    auxdata_size_words = (auxdata_size + 31) // 32
    gas_limit = (
        21_000
        + 32_000
        + initcode_container_words * 6
        + 3 * auxdata_size_words
        + auxdata_size_words * auxdata_size_words // 512
    )
    # out_of_gas is triggered, so canary won't set value
    # also validate target created contract fails
    post = {
        contract_address: Account(
            storage={
                slot_create_address: value_canary_should_not_change,
                slot_code_should_fail: value_canary_should_not_change,
            },
        ),
        compute_eofcreate_address(contract_address, 0, initcode_container): Account.NONEXISTENT,
    }
    tx = Transaction(
        to=contract_address,
        gas_limit=gas_limit,
        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-state_test
...fork_Osaka-blockchain_test_from_state_test