Skip to content

test_invalid_chain_id_auth_still_charges_intrinsic()

Documentation for tests/amsterdam/eip8037_state_creation_gas_cost_increase/test_state_gas_set_code.py::test_invalid_chain_id_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_chain_id_auth_still_charges_intrinsic --fork Amsterdam

Test an invalid-chain-id authorization still pays the intrinsic base.

An authorization with a mismatched chain ID is skipped during set_delegation and incurs no top-frame charge, but its 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
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
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
@pytest.mark.valid_from("EIP8037")
def test_invalid_chain_id_auth_still_charges_intrinsic(
    state_test: StateTestFiller,
    pre: Alloc,
    fork: Fork,
) -> None:
    """
    Test an invalid-chain-id authorization still pays the intrinsic base.

    An authorization with a mismatched chain ID is skipped during
    ``set_delegation`` and incurs no top-frame charge, but its
    ``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=0,
            chain_id=9999,  # Wrong chain ID -- 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.