Skip to content

test_address_collision()

Documentation for tests/osaka/eip7692_eof_v1/eip7620_eof_create/test_eofcreate.py::test_address_collision@21fb11c8.

Generate fixtures for these test cases for Osaka with:

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

Tests address collision.

Source code in tests/osaka/eip7692_eof_v1/eip7620_eof_create/test_eofcreate.py
493
494
495
496
497
498
499
500
501
502
503
504
505
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
def test_address_collision(
    state_test: StateTestFiller,
    pre: Alloc,
):
    """Tests address collision."""
    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: EOFCREATE_FAILURE,  # had an in-transaction collision
                slot_create_address_3: EOFCREATE_FAILURE,  # 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)

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