Skip to content

test_p256verify()

Documentation for tests/benchmark/compute/precompile/test_p256verify.py::test_p256verify@892e6d1e.

Generate fixtures for these test cases for Amsterdam with:

fill -v tests/benchmark/compute/precompile/test_p256verify.py::test_p256verify --gas-benchmark-values 1

Benchmark P256VERIFY precompile.

Source code in tests/benchmark/compute/precompile/test_p256verify.py
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
@pytest.mark.parametrize(
    "precompile_address,calldata",
    [
        pytest.param(
            p256verify_spec.Spec.P256VERIFY,
            p256verify_spec.Spec.H0
            + p256verify_spec.Spec.R0
            + p256verify_spec.Spec.S0
            + p256verify_spec.Spec.X0
            + p256verify_spec.Spec.Y0,
            id="p256verify",
            marks=[
                pytest.mark.eip_checklist(
                    "precompile/test/excessive_gas_usage", eip=[7951]
                ),
                pytest.mark.repricing,
            ],
        ),
        pytest.param(
            p256verify_spec.Spec.P256VERIFY,
            H(
                value=0x235060CAFE19A407880C272BC3E73600E3A12294F56143ED61929C2FF4525ABB
            )
            + R(
                value=0x182E5CBDF96ACCB859E8EEA1850DE5FF6E430A19D1D9A680ECD5946BBEA8A32B
            )
            + S(
                value=0x76DDFAE6797FA6777CAAB9FA10E75F52E70A4E6CEB117B3C5B2F445D850BD64C
            )
            + X(
                value=0x3828736CDFC4C8696008F71999260329AD8B12287846FEDCEDE3BA1205B12729
            )
            + Y(
                value=0x3E5141734E971A8D55015068D9B3666760F4608A49B11F92E500ACEA647978C7
            ),
            id="p256verify_wrong_endianness",
        ),
        pytest.param(
            p256verify_spec.Spec.P256VERIFY,
            H(
                value=0xBB5A52F42F9C9261ED4361F59422A1E30036E7C32B270C8807A419FECA605023
            )
            + R(
                value=0x000000000000000000000000000000004319055358E8617B0C46353D039CDAAB
            )
            + S(
                value=0xFFFFFFFF00000000FFFFFFFFFFFFFFFFBCE6FAADA7179E84F3B9CAC2FC63254E
            )
            + X(
                value=0x0AD99500288D466940031D72A9F5445A4D43784640855BF0A69874D2DE5FE103
            )
            + Y(
                value=0xC5011E6EF2C42DCD50D5D3D29F99AE6EBA2C80C9244F4C5422F0979FF0C3BA5E
            ),
            id="p256verify_modular_comp_x_coordinate_exceeds_n",
        ),
    ],
)
def test_p256verify(
    benchmark_test: BenchmarkTestFiller,
    fork: Fork,
    precompile_address: Address,
    calldata: bytes,
) -> None:
    """Benchmark P256VERIFY precompile."""
    if precompile_address not in fork.precompiles():
        pytest.skip("Precompile not enabled")

    attack_block = Op.POP(
        Op.STATICCALL(
            gas=Op.GAS, address=precompile_address, args_size=Op.CALLDATASIZE
        ),
    )

    benchmark_test(
        target_opcode=Precompile.P256VERIFY,
        code_generator=JumpLoopGenerator(
            setup=Op.CALLDATACOPY(0, 0, Op.CALLDATASIZE),
            attack_block=attack_block,
            tx_kwargs={"data": calldata},
        ),
    )

Parametrized Test Cases

This test generates 3 parametrized test cases across 3 forks.