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@88e9fb8f.

Generate fixtures for these test cases for Osaka with:

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

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
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
@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,
        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