Skip to content

test_fork_transition_bal_size_constraint()

Documentation for tests/amsterdam/eip7928_block_level_access_lists/test_fork_transition.py::test_fork_transition_bal_size_constraint@5c024cbb.

Generate fixtures for these test cases for Amsterdam with:

fill -v tests/amsterdam/eip7928_block_level_access_lists/test_fork_transition.py::test_fork_transition_bal_size_constraint --fork Amsterdam

Verify the BAL size constraint applies only on/after Amsterdam.

  • Pre-fork block at a gas_limit that would fail the post-fork constraint is accepted (the constraint is not yet enforced).
  • Activation block at the exact budget is accepted.
  • Activation block one item over the budget is rejected with BLOCK_ACCESS_LIST_GAS_LIMIT_EXCEEDED.
Source code in tests/amsterdam/eip7928_block_level_access_lists/test_fork_transition.py
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
@EIPChecklist.BlockLevelConstraint.Test.ForkTransition.AcceptedBeforeFork()
@EIPChecklist.BlockLevelConstraint.Test.ForkTransition.AcceptedAfterFork()
@EIPChecklist.BlockLevelConstraint.Test.ForkTransition.RejectedAfterFork()
@pytest.mark.valid_at_transition_to("Amsterdam")
@pytest.mark.parametrize(
    "exceeds_limit_at_fork",
    [
        pytest.param(False, id="at_fork_within_budget"),
        pytest.param(
            True,
            marks=pytest.mark.exception_test,
            id="at_fork_over_budget",
        ),
    ],
)
def test_fork_transition_bal_size_constraint(
    blockchain_test: BlockchainTestFiller,
    pre: Alloc,
    fork: TransitionFork,
    exceeds_limit_at_fork: bool,
) -> None:
    """
    Verify the BAL size constraint applies only on/after Amsterdam.

    - Pre-fork block at a `gas_limit` that *would* fail the post-fork
      constraint is accepted (the constraint is not yet enforced).
    - Activation block at the exact budget is accepted.
    - Activation block one item over the budget is rejected with
      `BLOCK_ACCESS_LIST_GAS_LIMIT_EXCEEDED`.
    """
    amsterdam = fork.transitions_to()
    min_gas_limit = amsterdam.minimum_block_gas_limit()
    over_budget_gas_limit = min_gas_limit - 1

    pre_fork_block = Block(
        timestamp=FORK_TIMESTAMP - 1,
        txs=[],
    )

    if exceeds_limit_at_fork:
        at_fork_block = Block(
            timestamp=FORK_TIMESTAMP,
            txs=[],
            exception=BlockException.BLOCK_ACCESS_LIST_GAS_LIMIT_EXCEEDED,
        )
        block_gas_limit = over_budget_gas_limit
    else:
        at_fork_block = Block(
            timestamp=FORK_TIMESTAMP,
            txs=[],
        )
        block_gas_limit = min_gas_limit

    blockchain_test(
        pre=pre,
        post={},
        blocks=[pre_fork_block, at_fork_block],
        genesis_environment=Environment(gas_limit=block_gas_limit),
    )

Parametrized Test Cases

This test generates 2 parametrized test cases across 1 fork.