Skip to content

test_delegation_clearing_storage_readable_in_later_tx()

Documentation for tests/prague/eip7702_set_code_tx/test_set_code_txs.py::test_delegation_clearing_storage_readable_in_later_tx@622620d8.

Generate fixtures for these test cases for Amsterdam with:

fill -v tests/prague/eip7702_set_code_tx/test_set_code_txs.py::test_delegation_clearing_storage_readable_in_later_tx --fork Amsterdam

Test that the storage of an authority whose pre-state delegation is cleared is still readable by a later transaction of the same block.

Source code in tests/prague/eip7702_set_code_tx/test_set_code_txs.py
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
def test_delegation_clearing_storage_readable_in_later_tx(
    blockchain_test: BlockchainTestFiller,
    pre: Alloc,
) -> None:
    """
    Test that the storage of an authority whose pre-state delegation is
    cleared is still readable by a later transaction of the same block.
    """
    slot_preserved = 1
    slot_read_back = 2
    slot_marker = 3

    auth_signer = pre.fund_eoa(
        0,
        delegation=pre.deploy_contract(Op.STOP),
        storage=Storage({slot_preserved: 0x2A}),  # type: ignore[dict-item]
    )
    reader = pre.deploy_contract(
        Op.SSTORE(slot_read_back, Op.SLOAD(slot_preserved))
        # The write to an untouched slot forces the storage root to be
        # recomputed from the whole slot set.
        + Op.SSTORE(slot_marker, 1)
        + Op.STOP
    )

    sender = pre.fund_eoa()

    tx_1 = Transaction(
        to=auth_signer,
        value=0,
        authorization_list=[
            AuthorizationTuple(
                address=Spec.RESET_DELEGATION_ADDRESS,  # Reset
                nonce=auth_signer.nonce,
                signer=auth_signer,
            ),
        ],
        sender=sender,
    )
    tx_2 = Transaction(
        to=auth_signer,
        value=0,
        authorization_list=[
            AuthorizationTuple(
                address=reader,
                nonce=auth_signer.nonce + 1,
                signer=auth_signer,
            ),
        ],
        sender=sender,
    )

    blockchain_test(
        pre=pre,
        blocks=[Block(txs=[tx_1, tx_2])],
        post={
            auth_signer: Account(
                nonce=auth_signer.nonce + 2,
                code=Spec.delegation_designation(reader),
                storage={
                    slot_preserved: 0x2A,
                    slot_read_back: 0x2A,
                    slot_marker: 1,
                },
            ),
        },
    )

Parametrized Test Cases

This test generates 1 parametrized test case across 3 forks.