Skip to content

test_bal_gas_limit_boundary()

Documentation for tests/amsterdam/eip7928_block_level_access_lists/test_block_access_lists.py::test_bal_gas_limit_boundary@892e6d1e.

Generate fixtures for these test cases for Amsterdam with:

fill -v tests/amsterdam/eip7928_block_level_access_lists/test_block_access_lists.py::test_bal_gas_limit_boundary --fork Amsterdam

Test the BAL max items gas limit boundary for an empty block.

The consensus rule requires bal_items <= block_gas_limit // BLOCK_ACCESS_LIST_ITEM. The boundary gas limit is derived from the fork's system-contract BAL footprint. At the boundary the check passes; one below it fails.

Source code in tests/amsterdam/eip7928_block_level_access_lists/test_block_access_lists.py
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
@EIPChecklist.BlockLevelConstraint.Test.Boundary.Under()
@EIPChecklist.BlockLevelConstraint.Test.Boundary.Exact()
@EIPChecklist.BlockLevelConstraint.Test.Boundary.Over()
@pytest.mark.parametrize(
    "boundary_offset",
    [
        pytest.param(0, id="at_boundary"),
        pytest.param(
            -1,
            marks=pytest.mark.exception_test,
            id="below_boundary",
        ),
    ],
)
def test_bal_gas_limit_boundary(
    blockchain_test: BlockchainTestFiller,
    pre: Alloc,
    fork: Fork,
    boundary_offset: int,
) -> None:
    """
    Test the BAL max items gas limit boundary for an empty block.

    The consensus rule requires
    ``bal_items <= block_gas_limit // BLOCK_ACCESS_LIST_ITEM``.
    The boundary gas limit is derived from the fork's system-contract
    BAL footprint.  At the boundary the check passes; one below it fails.
    """
    # EIP-7928
    # bal_items <= block_gas_limit // ITEM_COST
    min_gas_limit = (
        fork.empty_block_bal_item_count()
        * fork.gas_costs().BLOCK_ACCESS_LIST_ITEM
    )
    gas_limit = min_gas_limit + boundary_offset

    block = Block(
        txs=[],
        exception=(
            BlockException.BLOCK_ACCESS_LIST_GAS_LIMIT_EXCEEDED
            if boundary_offset < 0
            else None
        ),
    )

    blockchain_test(
        pre=pre,
        blocks=[block],
        post={},
        genesis_environment=Environment(gas_limit=gas_limit),
    )

Parametrized Test Cases

This test generates 2 parametrized test cases across 1 fork.