Skip to content

test_invalid_nonce_auth_still_charges_intrinsic()

Documentation for tests/amsterdam/eip8037_state_creation_gas_cost_increase/test_state_gas_set_code.py::test_invalid_nonce_auth_still_charges_intrinsic@26332146.

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_invalid_nonce_auth_still_charges_intrinsic --fork Amsterdam

Test an invalid-nonce authorization still pays the intrinsic base.

An authorization with a wrong nonce is skipped during set_delegation, so it writes no delegation indicator and incurs no top-frame charge. Its state-independent EXECUTION_PER_AUTH_BASE_COST is still charged in the intrinsic, and the authority is left untouched.

Source code in tests/amsterdam/eip8037_state_creation_gas_cost_increase/test_state_gas_set_code.py
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
@pytest.mark.valid_from("EIP8037")
def test_invalid_nonce_auth_still_charges_intrinsic(
    state_test: StateTestFiller,
    pre: Alloc,
    fork: Fork,
) -> None:
    """
    Test an invalid-nonce authorization still pays the intrinsic base.

    An authorization with a wrong nonce is skipped during
    ``set_delegation``, so it writes no delegation indicator and incurs
    no top-frame charge. Its state-independent
    ``EXECUTION_PER_AUTH_BASE_COST`` is still charged in the intrinsic, and
    the authority is left untouched.
    """
    contract = pre.deploy_contract(code=Op.STOP)

    signer = pre.fund_eoa()
    authorization_list = [
        AuthorizationTuple(
            address=contract,
            nonce=99,  # Wrong nonce -- auth will be skipped
            signer=signer,
            creates_account=False,
            writes_delegation=False,
            first_write=False,
        ),
    ]

    intrinsic_execution, top_frame_execution, top_frame_state = _auth_gas(
        fork, authorization_list
    )
    assert top_frame_execution == 0
    assert top_frame_state == 0
    cumulative_gas_used, header_gas_used = _receipt_and_header(
        intrinsic_execution, top_frame_execution, top_frame_state
    )

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

    post = {signer: Account(nonce=0, code=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.