Skip to content

test_factory_block_access_list()

Documentation for tests/amsterdam/eip7997_deterministic_factory_predeploy/test_factory.py::test_factory_block_access_list@2119b382.

Generate fixtures for these test cases for Amsterdam with:

fill -v tests/amsterdam/eip7997_deterministic_factory_predeploy/test_factory.py::test_factory_block_access_list --fork Amsterdam

EIP-7928: a factory deployment is captured in the block-level access list. The factory's nonce bump from CREATE2 and the deployed contract's nonce/code initialization both appear under their respective accounts.

Source code in tests/amsterdam/eip7997_deterministic_factory_predeploy/test_factory.py
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
def test_factory_block_access_list(
    state_test: StateTestFiller,
    pre: Alloc,
) -> None:
    """
    EIP-7928: a factory deployment is captured in the block-level
    access list. The factory's nonce bump from `CREATE2` and the
    deployed contract's `nonce`/`code` initialization both appear
    under their respective accounts.
    """
    salt = 0x42
    runtime_code = Op.PUSH1(0x01) + Op.PUSH1(0x00) + Op.RETURN
    initcode = Initcode(deploy_code=runtime_code)
    expected_address = compute_create2_address(FACTORY, salt, initcode)

    sender = pre.fund_eoa()

    state_test(
        pre=pre,
        tx=Transaction(
            sender=sender,
            to=Address(FACTORY),
            data=Hash(salt) + bytes(initcode),
        ),
        post={
            FACTORY: Account(
                nonce=2,
                balance=0,
                code=Spec.FACTORY_BYTECODE,
            ),
            expected_address: Account(nonce=1, code=bytes(runtime_code)),
        },
        expected_block_access_list=BlockAccessListExpectation(
            account_expectations={
                sender: BalAccountExpectation(
                    nonce_changes=[
                        BalNonceChange(block_access_index=1, post_nonce=1),
                    ],
                ),
                Address(FACTORY): BalAccountExpectation(
                    nonce_changes=[
                        BalNonceChange(block_access_index=1, post_nonce=2),
                    ],
                ),
                expected_address: BalAccountExpectation(
                    nonce_changes=[
                        BalNonceChange(block_access_index=1, post_nonce=1),
                    ],
                    code_changes=[
                        BalCodeChange(
                            block_access_index=1,
                            new_code=bytes(runtime_code),
                        ),
                    ],
                ),
            },
        ),
    )

Parametrized Test Cases

This test generates 1 parametrized test case across 1 fork.