Skip to content

test_eofcreate_in_initcode_reverts()

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

Generate fixtures for these test cases for Osaka with:

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

Verifies an EOFCREATE occuring in an initcode is rolled back when the initcode reverts.

Source code in tests/osaka/eip7692_eof_v1/eip7620_eof_create/test_eofcreate.py
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
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
def test_eofcreate_in_initcode_reverts(
    state_test: StateTestFiller,
    pre: Alloc,
):
    """Verifies an EOFCREATE occuring in an initcode is rolled back when the initcode reverts."""
    nested_initcode_subcontainer = Container(
        sections=[
            Section.Code(
                code=Op.SSTORE(slot_create_address, Op.EOFCREATE[0](0, 0, 0, 0))
                + Op.SSTORE(slot_code_worked, value_code_worked)
                + Op.REVERT(0, 0),
            ),
            Section.Container(container=smallest_initcode_subcontainer),
        ]
    )

    env = Environment()
    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_worked, value_code_worked)
                    + Op.STOP,
                ),
                Section.Container(container=nested_initcode_subcontainer),
            ]
        ),
        storage={slot_create_address: value_canary_to_be_overwritten},
    )

    outer_address = compute_eofcreate_address(contract_address, 0, nested_initcode_subcontainer)
    inner_address = compute_eofcreate_address(outer_address, 0, smallest_initcode_subcontainer)
    post = {
        contract_address: Account(
            storage={
                slot_create_address: 0,
                slot_code_worked: value_code_worked,
            }
        ),
        outer_address: Account.NONEXISTENT,
        inner_address: Account.NONEXISTENT,
    }
    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