Skip to content

test_insufficient_gas_memory_expansion()

Documentation for tests/osaka/eip7692_eof_v1/eip7620_eof_create/test_eofcreate_failures.py::test_insufficient_gas_memory_expansion@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_gas_memory_expansion --fork Osaka

Exercises EOFCREATE when the memory for auxdata has not been expanded but is requested.

Source code in tests/osaka/eip7692_eof_v1/eip7620_eof_create/test_eofcreate_failures.py
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
491
492
493
494
495
496
497
498
499
500
501
502
503
def test_insufficient_gas_memory_expansion(
    state_test: StateTestFiller,
    pre: Alloc,
):
    """Exercises EOFCREATE when the memory for auxdata has not been expanded but is requested."""
    env = Environment()

    auxdata_size = 0x5000
    initcode_container = Container(
        sections=[
            Section.Code(
                code=Op.SSTORE(slot_create_address, Op.EOFCREATE[0](0, 0, 0, auxdata_size))
                + Op.SSTORE(slot_code_should_fail, slot_code_worked)
                + Op.STOP,
            ),
            Section.Container(container=smallest_initcode_subcontainer),
        ],
    )
    sender = pre.fund_eoa()
    contract_address = pre.deploy_contract(
        code=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