Skip to content

test_invalid_non_multiple_excess_blob_gas()

Documentation for tests/cancun/eip4844_blobs/test_excess_blob_gas.py::test_invalid_non_multiple_excess_blob_gas@21fb11c8.

Generate fixtures for these test cases for Prague with:

fill -v tests/cancun/eip4844_blobs/test_excess_blob_gas.py::test_invalid_non_multiple_excess_blob_gas --fork Prague

Test rejection of blocks where the excessBlobGas changes to a value that is not a multiple of Spec.GAS_PER_BLOB`.

  • Parent block contains TARGET_BLOBS_PER_BLOCK + 1 blobs, but excessBlobGas is off by ±1
  • Parent block contains TARGET_BLOBS_PER_BLOCK - 1 blobs, but excessBlobGas is off by ±1
Source code in tests/cancun/eip4844_blobs/test_excess_blob_gas.py
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
@pytest.mark.parametrize_by_fork(
    "parent_blobs,header_excess_blob_gas_delta",
    lambda fork: [
        (fork.target_blobs_per_block() + 1, 1),
        (fork.target_blobs_per_block() + 1, fork.blob_gas_per_blob() - 1),
        (fork.target_blobs_per_block() - 1, -1),
        (fork.target_blobs_per_block() - 1, -(fork.blob_gas_per_blob() - 1)),
    ],
)
@pytest.mark.parametrize("new_blobs", [1])
@pytest.mark.parametrize_by_fork(
    "parent_excess_blobs",
    lambda fork: [fork.target_blobs_per_block() + 1],
)
def test_invalid_non_multiple_excess_blob_gas(
    blockchain_test: BlockchainTestFiller,
    env: Environment,
    pre: Mapping[Address, Account],
    blocks: List[Block],
    correct_excess_blob_gas: int,
    header_excess_blob_gas: Optional[int],
):
    """
    Test rejection of blocks where the `excessBlobGas` changes to a value that
    is not a multiple of Spec.GAS_PER_BLOB`.

    - Parent block contains `TARGET_BLOBS_PER_BLOCK + 1` blobs, but `excessBlobGas` is off by +/-1
    - Parent block contains `TARGET_BLOBS_PER_BLOCK - 1` blobs, but `excessBlobGas` is off by +/-1
    """
    if header_excess_blob_gas is None:
        raise Exception("test case is badly formatted")

    if header_excess_blob_gas == correct_excess_blob_gas:
        raise Exception("invalid test case")

    blockchain_test(
        pre=pre,
        post={},
        blocks=blocks,
        genesis_environment=env,
        tag="-".join(
            [
                f"correct:{hex(correct_excess_blob_gas)}",
                f"header:{hex(header_excess_blob_gas)}",
            ]
        ),
    )

Parametrized Test Cases

The interactive table below is also available as a standalone page.

Test ID (Abbreviated) parent_excess_blobs parent_blobs header_excess_blob_gas_delta new_blobs
...fork_Cancun-parent_excess_blobs_4-parent_blobs_4-header_excess_blob_gas_delta_1-blockchain_test-new_blobs_1 4 4 1 1
...fork_Cancun-parent_excess_blobs_4-parent_blobs_4-header_excess_blob_gas_delta_131071-blockchain_test-new_blobs_1 4 4 131071 1
...fork_Cancun-parent_excess_blobs_4-parent_blobs_2-header_excess_blob_gas_delta_-1-blockchain_test-new_blobs_1 4 2 -1 1
...fork_Cancun-parent_excess_blobs_4-parent_blobs_2-header_excess_blob_gas_delta_-131071-blockchain_test-new_blobs_1 4 2 -131071 1
...fork_Prague-parent_excess_blobs_7-parent_blobs_7-header_excess_blob_gas_delta_1-blockchain_test-new_blobs_1 7 7 1 1
...fork_Prague-parent_excess_blobs_7-parent_blobs_7-header_excess_blob_gas_delta_131071-blockchain_test-new_blobs_1 7 7 131071 1
...fork_Prague-parent_excess_blobs_7-parent_blobs_5-header_excess_blob_gas_delta_-1-blockchain_test-new_blobs_1 7 5 -1 1
...fork_Prague-parent_excess_blobs_7-parent_blobs_5-header_excess_blob_gas_delta_-131071-blockchain_test-new_blobs_1 7 5 -131071 1
...fork_Osaka-parent_excess_blobs_7-parent_blobs_7-header_excess_blob_gas_delta_1-blockchain_test-new_blobs_1 7 7 1 1
...fork_Osaka-parent_excess_blobs_7-parent_blobs_7-header_excess_blob_gas_delta_131071-blockchain_test-new_blobs_1 7 7 131071 1
...fork_Osaka-parent_excess_blobs_7-parent_blobs_5-header_excess_blob_gas_delta_-1-blockchain_test-new_blobs_1 7 5 -1 1
...fork_Osaka-parent_excess_blobs_7-parent_blobs_5-header_excess_blob_gas_delta_-131071-blockchain_test-new_blobs_1 7 5 -131071 1