Skip to content

test_auth_with_multiple_sstores()

Documentation for tests/amsterdam/eip8037_state_creation_gas_cost_increase/test_state_gas_set_code.py::test_auth_with_multiple_sstores@5c024cbb.

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

Test an authorization combined with multiple recipient SSTOREs.

The existing authority pays the top-frame AUTH_BASE and the recipient performs five distinct zero-to-nonzero SSTOREs, each paying its own regular + state cost during execution. Verifies combined accounting across the top-frame and execution state charges, all drawn from gas_left with no refund.

Source code in tests/amsterdam/eip8037_state_creation_gas_cost_increase/test_state_gas_set_code.py
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
@pytest.mark.valid_from("EIP8037")
def test_auth_with_multiple_sstores(
    state_test: StateTestFiller,
    pre: Alloc,
    fork: Fork,
) -> None:
    """
    Test an authorization combined with multiple recipient SSTOREs.

    The existing authority pays the top-frame ``AUTH_BASE`` and the
    recipient performs five distinct zero-to-nonzero SSTOREs, each paying
    its own regular + state cost during execution. Verifies combined
    accounting across the top-frame and execution state charges, all drawn
    from ``gas_left`` with no refund.
    """
    num_sstores = 5
    storage = Storage()
    code = Bytecode()
    for _ in range(num_sstores):
        code += Op.SSTORE(storage.store_next(1), 1)
    contract = pre.deploy_contract(code=code)
    execution_regular = code.regular_cost(fork)
    execution_state = code.state_cost(fork)

    signer = pre.fund_eoa()
    authorization_list = [
        AuthorizationTuple(
            address=contract,
            nonce=0,
            signer=signer,
            creates_account=False,
            writes_delegation=True,
        ),
    ]

    intrinsic_regular, top_frame_regular, top_frame_state = _auth_gas(
        fork, authorization_list
    )
    _, header_gas_used = _receipt_and_header(
        intrinsic_regular,
        top_frame_regular,
        top_frame_state,
        execution_regular=execution_regular,
        execution_state=execution_state,
    )

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

    post = {
        contract: Account(storage=storage),
        signer: Account(code=Spec7702.delegation_designation(contract)),
    }
    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.