Skip to content

test_multi_block_dimension_flip()

Documentation for tests/amsterdam/eip8037_state_creation_gas_cost_increase/test_block_2d_gas_accounting.py::test_multi_block_dimension_flip@622620d8.

Generate fixtures for these test cases for Amsterdam with:

fill -v tests/amsterdam/eip8037_state_creation_gas_cost_increase/test_block_2d_gas_accounting.py::test_multi_block_dimension_flip --fork Amsterdam

Verify gas_used across blocks where dominant dimension flips.

Block 1: STOP txs only (execution dominates). Block 2: SSTORE txs only (state dominates). Each block independently computes its own 2D max.

Source code in tests/amsterdam/eip8037_state_creation_gas_cost_increase/test_block_2d_gas_accounting.py
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
@pytest.mark.valid_from("EIP8037")
def test_multi_block_dimension_flip(
    blockchain_test: BlockchainTestFiller,
    pre: Alloc,
    fork: Fork,
) -> None:
    """
    Verify gas_used across blocks where dominant dimension flips.

    Block 1: STOP txs only (execution dominates).
    Block 2: SSTORE txs only (state dominates).
    Each block independently computes its own 2D max.
    """
    n = 3
    intrinsic_gas = fork.transaction_intrinsic_cost_calculator()()
    tx_execution, tx_state = sstore_tx_gas(fork)

    # Block 1 has no state gas at all, execution leads by default;
    block_1_execution = n * intrinsic_gas
    block_2_execution, block_2_state = n * tx_execution, n * tx_state
    assert block_2_state > block_2_execution, "block 2 must lead on state"

    block_1 = stop_txs(pre, fork, n)
    block_2, post_2 = sstore_txs(pre, fork, n)

    blockchain_test(
        pre=pre,
        blocks=[
            Block(
                txs=block_1,
                header_verify=Header(gas_used=block_1_execution),
            ),
            Block(
                txs=block_2,
                header_verify=Header(gas_used=block_2_state),
            ),
        ],
        post=post_2,
    )

Parametrized Test Cases

This test generates 1 parametrized test case across 1 fork.