Skip to content

test_access_list_intrinsic_surcharge()

Documentation for tests/amsterdam/eip8038_state_access_gas_cost_increase/test_access_list_gas.py::test_access_list_intrinsic_surcharge@5c024cbb.

Generate fixtures for these test cases for Amsterdam with:

fill -v tests/amsterdam/eip8038_state_access_gas_cost_increase/test_access_list_gas.py::test_access_list_intrinsic_surcharge --fork Amsterdam

Assert the per-entry intrinsic access-list surcharge.

The intrinsic-cost delta from adding the access list, minus the EIP-7981 floor-token contribution, must equal n_addr * TX_ACCESS_LIST_ADDRESS + n_keys * TX_ACCESS_LIST_STORAGE_KEY. A simple value-less transaction then exercises the access list end to end.

Source code in tests/amsterdam/eip8038_state_access_gas_cost_increase/test_access_list_gas.py
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
@EIPChecklist.GasCostChanges.Test.GasUpdatesMeasurement()
@pytest.mark.parametrize("n_addr,n_keys_each,duplicate", ACCESS_LIST_SHAPES)
def test_access_list_intrinsic_surcharge(
    state_test: StateTestFiller,
    pre: Alloc,
    fork: Fork,
    n_addr: int,
    n_keys_each: int,
    duplicate: bool,
) -> None:
    """
    Assert the per-entry intrinsic access-list surcharge.

    The intrinsic-cost delta from adding the access list, minus the
    EIP-7981 floor-token contribution, must equal
    ``n_addr * TX_ACCESS_LIST_ADDRESS + n_keys * TX_ACCESS_LIST_STORAGE_KEY``.
    A simple value-less transaction then exercises the access list end to
    end.
    """
    gas_costs = fork.gas_costs()
    intrinsic = fork.transaction_intrinsic_cost_calculator()

    access_list = _make_access_list(n_addr, n_keys_each, duplicate=duplicate)
    n_keys = n_addr * n_keys_each

    base = intrinsic(return_cost_deducted_prior_execution=True)
    with_al = intrinsic(
        access_list=access_list,
        return_cost_deducted_prior_execution=True,
    )
    surcharge = (
        with_al - base - _access_list_floor_token_gas(access_list, fork)
    )
    expected = (
        n_addr * gas_costs.TX_ACCESS_LIST_ADDRESS
        + n_keys * gas_costs.TX_ACCESS_LIST_STORAGE_KEY
    )
    assert surcharge == expected

    contract = pre.deploy_contract(code=Op.STOP)
    tx = Transaction(
        to=contract,
        sender=pre.fund_eoa(),
        access_list=access_list if access_list else None,
    )

    state_test(pre=pre, post={}, tx=tx)

Parametrized Test Cases

This test generates 5 parametrized test cases across 1 fork.