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@20373115.

Generate fixtures for these test cases for Amsterdam with:

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

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
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
@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],
)
@pytest.mark.exception_test
@pytest.mark.slow()
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],
) -> None:
    """
    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,
    )

Parametrized Test Cases

This test generates 4 parametrized test cases across 4 forks.