Skip to content

test_precompile_during_fork()

Documentation for tests/cancun/eip4844_blobs/test_point_evaluation_precompile.py::test_precompile_during_fork@343274cc.

Generate fixtures for these test cases for Cancun with:

fill -v tests/cancun/eip4844_blobs/test_point_evaluation_precompile.py::test_precompile_during_fork --fork Cancun

Test calling the Point Evaluation Precompile during the appropriate fork.

Source code in tests/cancun/eip4844_blobs/test_point_evaluation_precompile.py
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
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
820
821
822
@pytest.mark.parametrize(
    "z,y,kzg_commitment,kzg_proof,versioned_hash",
    [[Z, 0, INF_POINT, INF_POINT, None]],
    ids=["correct_proof"],
)
@pytest.mark.parametrize("precompile_caller_storage", [{}], ids=[""])
@pytest.mark.parametrize(
    "precompile_caller_balance", [len(PRE_FORK_BLOCK_RANGE)], ids=[""]
)
@pytest.mark.parametrize(
    "precompile_caller_code",
    [
        Op.CALLDATACOPY(0, 0, Op.CALLDATASIZE)
        + Op.SSTORE(
            Op.NUMBER,
            Op.CALL(
                address=Spec.POINT_EVALUATION_PRECOMPILE_ADDRESS,
                value=1,
                args_size=Op.CALLDATASIZE,
            ),
        )
    ],
    ids=[""],
)
@pytest.mark.valid_at_transition_to("Cancun")
def test_precompile_during_fork(
    blockchain_test: BlockchainTestFiller,
    pre: Alloc,
    precompile_caller_address: Address,
    precompile_input: bytes,
    sender: EOA,
) -> None:
    """
    Test calling the Point Evaluation Precompile during the appropriate fork.
    """
    # Blocks before fork
    blocks = [
        Block(
            timestamp=t,
            txs=[
                Transaction(
                    sender=sender,
                    data=precompile_input,
                    to=precompile_caller_address,
                )
            ],
        )
        for t in PRE_FORK_BLOCK_RANGE
    ]
    # Block after fork
    blocks += [
        Block(
            timestamp=FORK_TIMESTAMP,
            txs=[
                Transaction(
                    sender=sender,
                    data=precompile_input,
                    to=precompile_caller_address,
                )
            ],
        )
    ]

    post = {
        precompile_caller_address: Account(
            storage=dict.fromkeys(range(1, len(PRE_FORK_BLOCK_RANGE) + 1), 1),
            # Only the call in the last block's tx fails; storage 0 by default.
        ),
        Address(Spec.POINT_EVALUATION_PRECOMPILE_ADDRESS): Account(
            balance=len(PRE_FORK_BLOCK_RANGE),
        ),
    }

    blockchain_test(
        pre=pre,
        post=post,
        blocks=blocks,
    )

Parametrized Test Cases

This test generates 1 parametrized test case across 1 fork.