Skip to content

test_precompile_during_fork()

Documentation for tests/cancun/eip4844_blobs/test_point_evaluation_precompile.py::test_precompile_during_fork@88e9fb8f.

Generate fixtures for these test cases for Osaka with:

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

Test calling the Point Evaluation Precompile during the appropriate fork.

Source code in tests/cancun/eip4844_blobs/test_point_evaluation_precompile.py
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
@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,
                    gas_limit=Spec.POINT_EVALUATION_PRECOMPILE_GAS * 100,
                )
            ],
        )
        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,
                    gas_limit=Spec.POINT_EVALUATION_PRECOMPILE_GAS * 100,
                )
            ],
        )
    ]

    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 case is only parametrized by fork.

Test ID (Abbreviated) precompile_caller_code precompile_caller_balance precompile_caller_storage z y kzg_commitment kzg_proof versioned_hash
...fork_ShanghaiToCancunAtTime15k-blockchain_test----correct_proof 15 {} 44434237462617176941757081182233388991875531411361848851531703873752436619102 0 c0000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 c0000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 None