Skip to content

test_duplicate_signer_authorizations()

Documentation for tests/amsterdam/eip8037_state_creation_gas_cost_increase/test_state_gas_set_code.py::test_duplicate_signer_authorizations@87aba1a3.

Generate fixtures for these test cases for Amsterdam with:

fill -v tests/amsterdam/eip8037_state_creation_gas_cost_increase/test_state_gas_set_code.py::test_duplicate_signer_authorizations --fork Amsterdam

Test two authorizations from the same signer with increasing nonces.

The first authorization (nonce 0) sets a fresh delegation on the existing authority, paying the first-write ACCOUNT_WRITE and the top-frame AUTH_BASE. The second (nonce 1) overwrites it to a different target; the authority is already written and already had a delegation set in this transaction, so it pays nothing beyond the intrinsic base. The authority ends delegated to the second target with nonce 2.

Source code in tests/amsterdam/eip8037_state_creation_gas_cost_increase/test_state_gas_set_code.py
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
@pytest.mark.valid_from("EIP8037")
def test_duplicate_signer_authorizations(
    state_test: StateTestFiller,
    pre: Alloc,
    fork: Fork,
) -> None:
    """
    Test two authorizations from the same signer with increasing nonces.

    The first authorization (nonce 0) sets a fresh delegation on the
    existing authority, paying the first-write ``ACCOUNT_WRITE`` and the
    top-frame ``AUTH_BASE``. The second (nonce 1) overwrites it to a
    different target; the authority is already written and already had a
    delegation set in this transaction, so it pays nothing beyond the
    intrinsic base. The authority ends delegated to the second target
    with nonce 2.
    """
    contract_a = pre.deploy_contract(code=Op.STOP)
    contract_b = pre.deploy_contract(code=Op.STOP)

    signer = pre.fund_eoa()
    authorization_list = [
        AuthorizationTuple(
            address=contract_a,
            nonce=0,
            signer=signer,
            creates_account=False,
            writes_delegation=True,
        ),
        AuthorizationTuple(
            address=contract_b,
            nonce=1,
            signer=signer,
            creates_account=False,
            writes_delegation=False,
            first_write=False,
        ),
    ]

    intrinsic_regular, top_frame_regular, top_frame_state = _auth_gas(
        fork, authorization_list
    )
    cumulative_gas_used, header_gas_used = _receipt_and_header(
        intrinsic_regular, top_frame_regular, top_frame_state
    )

    tx = Transaction(
        to=contract_a,
        authorization_list=authorization_list,
        sender=pre.fund_eoa(),
        expected_receipt=TransactionReceipt(
            cumulative_gas_used=cumulative_gas_used,
        ),
    )

    post = {
        signer: Account(
            nonce=2,
            code=Spec7702.delegation_designation(contract_b),
        ),
    }
    state_test(
        pre=pre,
        post=post,
        tx=tx,
        blockchain_test_header_verify=Header(gas_used=header_gas_used),
    )

Parametrized Test Cases

This test generates 1 parametrized test case across 1 fork.