Skip to content

test_address_collision()

Documentation for tests/prague/eip7692_eof_v1/eip7620_eof_create/test_eofcreate.py::test_address_collision@a86d4327.

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_address_collision --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_address_collision --until=PragueEIP7692

Verifies a simple EOFCREATE case

Source code in tests/prague/eip7692_eof_v1/eip7620_eof_create/test_eofcreate.py
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
504
505
506
507
508
509
510
511
512
513
514
def test_address_collision(
    state_test: StateTestFiller,
    pre: Alloc,
):
    """
    Verifies a simple EOFCREATE case
    """
    env = Environment()

    slot_create_address_2 = slot_last_slot * 2 + slot_create_address
    slot_create_address_3 = slot_last_slot * 3 + slot_create_address
    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_create_address_2, Op.EOFCREATE[0](0, 0, 0, 0))
                    + Op.SSTORE(slot_create_address_3, Op.EOFCREATE[0](0, 1, 0, 0))
                    + Op.SSTORE(slot_code_worked, value_code_worked)
                    + Op.STOP,
                ),
                Section.Container(container=smallest_initcode_subcontainer),
            ],
        )
    )
    salt_zero_address = compute_eofcreate_address(
        contract_address, 0, smallest_initcode_subcontainer
    )
    salt_one_address = compute_eofcreate_address(
        contract_address, 1, smallest_initcode_subcontainer
    )

    # Hard-code address for collision, no other way to do this.
    # We should mark tests that do this, and fail on unmarked tests.
    pre[salt_one_address] = Account(balance=1, nonce=1)

    post = {
        contract_address: Account(
            storage={
                slot_create_address: salt_zero_address,
                slot_create_address_2: value_create_failed,  # had an in-transaction collision
                slot_create_address_3: value_create_failed,  # had a pre-existing collision
                slot_code_worked: value_code_worked,
            }
        )
    }

    # Multiple create fails is expensive, use an absurd amount of gas
    tx = Transaction(
        to=contract_address,
        gas_limit=300_000_000_000,
        gas_price=10,
        protected=False,
        sender=sender,
    )
    state_test(env=env, pre=pre, post=post, tx=tx)