Skip to content

test_invalid_negative_excess_blob_gas()

Documentation for tests/cancun/eip4844_blobs/test_excess_blob_gas.py::test_invalid_negative_excess_blob_gas@892e6d1e.

Generate fixtures for these test cases for Amsterdam with:

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

Test rejection of blocks where the excessBlobGas changes to the two's complement equivalent of the negative value after subtracting target blobs.

Reasoning is that the excessBlobGas is a uint64, so it cannot be negative, and we test for a potential underflow here.

Source code in tests/cancun/eip4844_blobs/test_excess_blob_gas.py
728
729
730
731
732
733
734
735
736
737
738
739
740
741
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
@pytest.mark.parametrize_by_fork(
    "header_excess_blob_gas",
    lambda fork: [
        (2**64 + (x * fork.blob_gas_per_blob()))
        for x in range(-fork.target_blobs_per_block(), 0)
    ],
)
@pytest.mark.parametrize_by_fork(
    "parent_blobs",
    lambda fork: range(fork.target_blobs_per_block()),
)
@pytest.mark.parametrize("new_blobs", [1])
@pytest.mark.parametrize_by_fork(
    "parent_excess_blobs",
    lambda fork: range(fork.target_blobs_per_block()),
)
@pytest.mark.exception_test
@pytest.mark.slow()
def test_invalid_negative_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 the two's
    complement equivalent of the negative value after subtracting target blobs.

    Reasoning is that the `excessBlobGas` is a `uint64`, so it cannot be
    negative, and we test for a potential underflow here.
    """
    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 2744 parametrized test cases across 4 forks.