Skip to content

test_valid_gas_g1msm()

Documentation for tests/prague/eip2537_bls_12_381_precompiles/test_bls12_variable_length_input_contracts.py::test_valid_gas_g1msm@21fb11c8.

Generate fixtures for these test cases for Prague with:

fill -v tests/prague/eip2537_bls_12_381_precompiles/test_bls12_variable_length_input_contracts.py::test_valid_gas_g1msm --fork Prague

Test the BLS12_G1MSM discount gas table in full, by expecting the call to succeed for all possible input lengths because the appropriate amount of gas is provided.

If any of the calls fail, the test will fail.

Source code in tests/prague/eip2537_bls_12_381_precompiles/test_bls12_variable_length_input_contracts.py
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
@pytest.mark.parametrize(
    "precompile_gas_list,precompile_data_length_list",
    [
        pytest.param(
            [G1_GAS(i * G1_MSM_K_INPUT_LENGTH) for i in range(1, len(Spec.G1MSM_DISCOUNT_TABLE))],
            [i * G1_MSM_K_INPUT_LENGTH for i in range(1, len(Spec.G1MSM_DISCOUNT_TABLE))],
            id="exact_gas_full_discount_table",
        ),
        pytest.param(
            [
                G1_GAS(i * G1_MSM_K_INPUT_LENGTH) + 1
                for i in range(1, len(Spec.G1MSM_DISCOUNT_TABLE))
            ],
            [i * G1_MSM_K_INPUT_LENGTH for i in range(1, len(Spec.G1MSM_DISCOUNT_TABLE))],
            id="one_extra_gas_full_discount_table",
        ),
    ],
)
@pytest.mark.parametrize("expected_output", [PointG1()], ids=[""])
@pytest.mark.parametrize("tx_gas_limit", [100_000_000], ids=[""])
@pytest.mark.parametrize("precompile_address", [Spec.G1MSM])
def test_valid_gas_g1msm(
    state_test: StateTestFiller,
    pre: Alloc,
    post: dict,
    tx: Transaction,
):
    """
    Test the BLS12_G1MSM discount gas table in full, by expecting the call to succeed for
    all possible input lengths because the appropriate amount of gas is provided.

    If any of the calls fail, the test will fail.
    """
    state_test(
        env=Environment(),
        pre=pre,
        tx=tx,
        post=post,
    )

Parametrized Test Cases

The interactive table below is also available as a standalone page.

Test ID (Abbreviated) precompile_address tx_gas_limit expected_output precompile_gas_list precompile_data_length_list
...fork_Prague-state_test-precompile_address_12---exact_gas_full_discount_table 12 100000000 PointG1(x=0, y=0) [12000, 22776, 30528, 38256, 45840, 54000, 61992, 69888, 77652, 85440, 93060, 100512, 107952, 115416, 122760, 129984, 137292, 144504, 151620, 158640, 165816, 172656, 179676, 186624, 193500, 200304, 207360, 214032, 220980, 227520, 234360, 240768, 247500, 254184, 260820, 267408, 273948, 280440, 286884, 293280, 299628, 306432, 312696, 318912, 325620, 331752, 337836, 344448, 350448, 357000, 362916, 369408, 375876, 381672, 388080, 393792, 400140, 406464, 412056, 418320, 424560, 430776, 436212, 442368, 448500, 454608, 460692, 466752, 471960, 477960, 483936, 489888, 495816, 501720, 507600, 513456, 519288, 525096, 530880, 536640, 542376, 548088, 553776, 559440, 565080, 570696, 576288, 581856, 587400, 592920, 598416, 603888, 610452, 615888, 621300, 626688, 632052, 637392, 642708, 648000, 654480, 659736, 664968, 670176, 675360, 681792, 686940, 692064, 697164, 702240, 708624, 713664, 718680, 723672, 728640, 734976, 739908, 744816, 749700, 756000, 760848, 765672, 770472, 776736, 781500, 786240, 792480, 797184] [160, 320, 480, 640, 800, 960, 1120, 1280, 1440, 1600, 1760, 1920, 2080, 2240, 2400, 2560, 2720, 2880, 3040, 3200, 3360, 3520, 3680, 3840, 4000, 4160, 4320, 4480, 4640, 4800, 4960, 5120, 5280, 5440, 5600, 5760, 5920, 6080, 6240, 6400, 6560, 6720, 6880, 7040, 7200, 7360, 7520, 7680, 7840, 8000, 8160, 8320, 8480, 8640, 8800, 8960, 9120, 9280, 9440, 9600, 9760, 9920, 10080, 10240, 10400, 10560, 10720, 10880, 11040, 11200, 11360, 11520, 11680, 11840, 12000, 12160, 12320, 12480, 12640, 12800, 12960, 13120, 13280, 13440, 13600, 13760, 13920, 14080, 14240, 14400, 14560, 14720, 14880, 15040, 15200, 15360, 15520, 15680, 15840, 16000, 16160, 16320, 16480, 16640, 16800, 16960, 17120, 17280, 17440, 17600, 17760, 17920, 18080, 18240, 18400, 18560, 18720, 18880, 19040, 19200, 19360, 19520, 19680, 19840, 20000, 20160, 20320, 20480]
...fork_Prague-state_test-precompile_address_12---one_extra_gas_full_discount_table 12 100000000 PointG1(x=0, y=0) [12001, 22777, 30529, 38257, 45841, 54001, 61993, 69889, 77653, 85441, 93061, 100513, 107953, 115417, 122761, 129985, 137293, 144505, 151621, 158641, 165817, 172657, 179677, 186625, 193501, 200305, 207361, 214033, 220981, 227521, 234361, 240769, 247501, 254185, 260821, 267409, 273949, 280441, 286885, 293281, 299629, 306433, 312697, 318913, 325621, 331753, 337837, 344449, 350449, 357001, 362917, 369409, 375877, 381673, 388081, 393793, 400141, 406465, 412057, 418321, 424561, 430777, 436213, 442369, 448501, 454609, 460693, 466753, 471961, 477961, 483937, 489889, 495817, 501721, 507601, 513457, 519289, 525097, 530881, 536641, 542377, 548089, 553777, 559441, 565081, 570697, 576289, 581857, 587401, 592921, 598417, 603889, 610453, 615889, 621301, 626689, 632053, 637393, 642709, 648001, 654481, 659737, 664969, 670177, 675361, 681793, 686941, 692065, 697165, 702241, 708625, 713665, 718681, 723673, 728641, 734977, 739909, 744817, 749701, 756001, 760849, 765673, 770473, 776737, 781501, 786241, 792481, 797185] [160, 320, 480, 640, 800, 960, 1120, 1280, 1440, 1600, 1760, 1920, 2080, 2240, 2400, 2560, 2720, 2880, 3040, 3200, 3360, 3520, 3680, 3840, 4000, 4160, 4320, 4480, 4640, 4800, 4960, 5120, 5280, 5440, 5600, 5760, 5920, 6080, 6240, 6400, 6560, 6720, 6880, 7040, 7200, 7360, 7520, 7680, 7840, 8000, 8160, 8320, 8480, 8640, 8800, 8960, 9120, 9280, 9440, 9600, 9760, 9920, 10080, 10240, 10400, 10560, 10720, 10880, 11040, 11200, 11360, 11520, 11680, 11840, 12000, 12160, 12320, 12480, 12640, 12800, 12960, 13120, 13280, 13440, 13600, 13760, 13920, 14080, 14240, 14400, 14560, 14720, 14880, 15040, 15200, 15360, 15520, 15680, 15840, 16000, 16160, 16320, 16480, 16640, 16800, 16960, 17120, 17280, 17440, 17600, 17760, 17920, 18080, 18240, 18400, 18560, 18720, 18880, 19040, 19200, 19360, 19520, 19680, 19840, 20000, 20160, 20320, 20480]
...fork_Prague-blockchain_test_from_state_test-precompile_address_12---exact_gas_full_discount_table 12 100000000 PointG1(x=0, y=0) [12000, 22776, 30528, 38256, 45840, 54000, 61992, 69888, 77652, 85440, 93060, 100512, 107952, 115416, 122760, 129984, 137292, 144504, 151620, 158640, 165816, 172656, 179676, 186624, 193500, 200304, 207360, 214032, 220980, 227520, 234360, 240768, 247500, 254184, 260820, 267408, 273948, 280440, 286884, 293280, 299628, 306432, 312696, 318912, 325620, 331752, 337836, 344448, 350448, 357000, 362916, 369408, 375876, 381672, 388080, 393792, 400140, 406464, 412056, 418320, 424560, 430776, 436212, 442368, 448500, 454608, 460692, 466752, 471960, 477960, 483936, 489888, 495816, 501720, 507600, 513456, 519288, 525096, 530880, 536640, 542376, 548088, 553776, 559440, 565080, 570696, 576288, 581856, 587400, 592920, 598416, 603888, 610452, 615888, 621300, 626688, 632052, 637392, 642708, 648000, 654480, 659736, 664968, 670176, 675360, 681792, 686940, 692064, 697164, 702240, 708624, 713664, 718680, 723672, 728640, 734976, 739908, 744816, 749700, 756000, 760848, 765672, 770472, 776736, 781500, 786240, 792480, 797184] [160, 320, 480, 640, 800, 960, 1120, 1280, 1440, 1600, 1760, 1920, 2080, 2240, 2400, 2560, 2720, 2880, 3040, 3200, 3360, 3520, 3680, 3840, 4000, 4160, 4320, 4480, 4640, 4800, 4960, 5120, 5280, 5440, 5600, 5760, 5920, 6080, 6240, 6400, 6560, 6720, 6880, 7040, 7200, 7360, 7520, 7680, 7840, 8000, 8160, 8320, 8480, 8640, 8800, 8960, 9120, 9280, 9440, 9600, 9760, 9920, 10080, 10240, 10400, 10560, 10720, 10880, 11040, 11200, 11360, 11520, 11680, 11840, 12000, 12160, 12320, 12480, 12640, 12800, 12960, 13120, 13280, 13440, 13600, 13760, 13920, 14080, 14240, 14400, 14560, 14720, 14880, 15040, 15200, 15360, 15520, 15680, 15840, 16000, 16160, 16320, 16480, 16640, 16800, 16960, 17120, 17280, 17440, 17600, 17760, 17920, 18080, 18240, 18400, 18560, 18720, 18880, 19040, 19200, 19360, 19520, 19680, 19840, 20000, 20160, 20320, 20480]
...fork_Prague-blockchain_test_from_state_test-precompile_address_12---one_extra_gas_full_discount_table 12 100000000 PointG1(x=0, y=0) [12001, 22777, 30529, 38257, 45841, 54001, 61993, 69889, 77653, 85441, 93061, 100513, 107953, 115417, 122761, 129985, 137293, 144505, 151621, 158641, 165817, 172657, 179677, 186625, 193501, 200305, 207361, 214033, 220981, 227521, 234361, 240769, 247501, 254185, 260821, 267409, 273949, 280441, 286885, 293281, 299629, 306433, 312697, 318913, 325621, 331753, 337837, 344449, 350449, 357001, 362917, 369409, 375877, 381673, 388081, 393793, 400141, 406465, 412057, 418321, 424561, 430777, 436213, 442369, 448501, 454609, 460693, 466753, 471961, 477961, 483937, 489889, 495817, 501721, 507601, 513457, 519289, 525097, 530881, 536641, 542377, 548089, 553777, 559441, 565081, 570697, 576289, 581857, 587401, 592921, 598417, 603889, 610453, 615889, 621301, 626689, 632053, 637393, 642709, 648001, 654481, 659737, 664969, 670177, 675361, 681793, 686941, 692065, 697165, 702241, 708625, 713665, 718681, 723673, 728641, 734977, 739909, 744817, 749701, 756001, 760849, 765673, 770473, 776737, 781501, 786241, 792481, 797185] [160, 320, 480, 640, 800, 960, 1120, 1280, 1440, 1600, 1760, 1920, 2080, 2240, 2400, 2560, 2720, 2880, 3040, 3200, 3360, 3520, 3680, 3840, 4000, 4160, 4320, 4480, 4640, 4800, 4960, 5120, 5280, 5440, 5600, 5760, 5920, 6080, 6240, 6400, 6560, 6720, 6880, 7040, 7200, 7360, 7520, 7680, 7840, 8000, 8160, 8320, 8480, 8640, 8800, 8960, 9120, 9280, 9440, 9600, 9760, 9920, 10080, 10240, 10400, 10560, 10720, 10880, 11040, 11200, 11360, 11520, 11680, 11840, 12000, 12160, 12320, 12480, 12640, 12800, 12960, 13120, 13280, 13440, 13600, 13760, 13920, 14080, 14240, 14400, 14560, 14720, 14880, 15040, 15200, 15360, 15520, 15680, 15840, 16000, 16160, 16320, 16480, 16640, 16800, 16960, 17120, 17280, 17440, 17600, 17760, 17920, 18080, 18240, 18400, 18560, 18720, 18880, 19040, 19200, 19360, 19520, 19680, 19840, 20000, 20160, 20320, 20480]
...fork_Osaka-state_test-precompile_address_12---exact_gas_full_discount_table 12 100000000 PointG1(x=0, y=0) [12000, 22776, 30528, 38256, 45840, 54000, 61992, 69888, 77652, 85440, 93060, 100512, 107952, 115416, 122760, 129984, 137292, 144504, 151620, 158640, 165816, 172656, 179676, 186624, 193500, 200304, 207360, 214032, 220980, 227520, 234360, 240768, 247500, 254184, 260820, 267408, 273948, 280440, 286884, 293280, 299628, 306432, 312696, 318912, 325620, 331752, 337836, 344448, 350448, 357000, 362916, 369408, 375876, 381672, 388080, 393792, 400140, 406464, 412056, 418320, 424560, 430776, 436212, 442368, 448500, 454608, 460692, 466752, 471960, 477960, 483936, 489888, 495816, 501720, 507600, 513456, 519288, 525096, 530880, 536640, 542376, 548088, 553776, 559440, 565080, 570696, 576288, 581856, 587400, 592920, 598416, 603888, 610452, 615888, 621300, 626688, 632052, 637392, 642708, 648000, 654480, 659736, 664968, 670176, 675360, 681792, 686940, 692064, 697164, 702240, 708624, 713664, 718680, 723672, 728640, 734976, 739908, 744816, 749700, 756000, 760848, 765672, 770472, 776736, 781500, 786240, 792480, 797184] [160, 320, 480, 640, 800, 960, 1120, 1280, 1440, 1600, 1760, 1920, 2080, 2240, 2400, 2560, 2720, 2880, 3040, 3200, 3360, 3520, 3680, 3840, 4000, 4160, 4320, 4480, 4640, 4800, 4960, 5120, 5280, 5440, 5600, 5760, 5920, 6080, 6240, 6400, 6560, 6720, 6880, 7040, 7200, 7360, 7520, 7680, 7840, 8000, 8160, 8320, 8480, 8640, 8800, 8960, 9120, 9280, 9440, 9600, 9760, 9920, 10080, 10240, 10400, 10560, 10720, 10880, 11040, 11200, 11360, 11520, 11680, 11840, 12000, 12160, 12320, 12480, 12640, 12800, 12960, 13120, 13280, 13440, 13600, 13760, 13920, 14080, 14240, 14400, 14560, 14720, 14880, 15040, 15200, 15360, 15520, 15680, 15840, 16000, 16160, 16320, 16480, 16640, 16800, 16960, 17120, 17280, 17440, 17600, 17760, 17920, 18080, 18240, 18400, 18560, 18720, 18880, 19040, 19200, 19360, 19520, 19680, 19840, 20000, 20160, 20320, 20480]
...fork_Osaka-state_test-precompile_address_12---one_extra_gas_full_discount_table 12 100000000 PointG1(x=0, y=0) [12001, 22777, 30529, 38257, 45841, 54001, 61993, 69889, 77653, 85441, 93061, 100513, 107953, 115417, 122761, 129985, 137293, 144505, 151621, 158641, 165817, 172657, 179677, 186625, 193501, 200305, 207361, 214033, 220981, 227521, 234361, 240769, 247501, 254185, 260821, 267409, 273949, 280441, 286885, 293281, 299629, 306433, 312697, 318913, 325621, 331753, 337837, 344449, 350449, 357001, 362917, 369409, 375877, 381673, 388081, 393793, 400141, 406465, 412057, 418321, 424561, 430777, 436213, 442369, 448501, 454609, 460693, 466753, 471961, 477961, 483937, 489889, 495817, 501721, 507601, 513457, 519289, 525097, 530881, 536641, 542377, 548089, 553777, 559441, 565081, 570697, 576289, 581857, 587401, 592921, 598417, 603889, 610453, 615889, 621301, 626689, 632053, 637393, 642709, 648001, 654481, 659737, 664969, 670177, 675361, 681793, 686941, 692065, 697165, 702241, 708625, 713665, 718681, 723673, 728641, 734977, 739909, 744817, 749701, 756001, 760849, 765673, 770473, 776737, 781501, 786241, 792481, 797185] [160, 320, 480, 640, 800, 960, 1120, 1280, 1440, 1600, 1760, 1920, 2080, 2240, 2400, 2560, 2720, 2880, 3040, 3200, 3360, 3520, 3680, 3840, 4000, 4160, 4320, 4480, 4640, 4800, 4960, 5120, 5280, 5440, 5600, 5760, 5920, 6080, 6240, 6400, 6560, 6720, 6880, 7040, 7200, 7360, 7520, 7680, 7840, 8000, 8160, 8320, 8480, 8640, 8800, 8960, 9120, 9280, 9440, 9600, 9760, 9920, 10080, 10240, 10400, 10560, 10720, 10880, 11040, 11200, 11360, 11520, 11680, 11840, 12000, 12160, 12320, 12480, 12640, 12800, 12960, 13120, 13280, 13440, 13600, 13760, 13920, 14080, 14240, 14400, 14560, 14720, 14880, 15040, 15200, 15360, 15520, 15680, 15840, 16000, 16160, 16320, 16480, 16640, 16800, 16960, 17120, 17280, 17440, 17600, 17760, 17920, 18080, 18240, 18400, 18560, 18720, 18880, 19040, 19200, 19360, 19520, 19680, 19840, 20000, 20160, 20320, 20480]
...fork_Osaka-blockchain_test_from_state_test-precompile_address_12---exact_gas_full_discount_table 12 100000000 PointG1(x=0, y=0) [12000, 22776, 30528, 38256, 45840, 54000, 61992, 69888, 77652, 85440, 93060, 100512, 107952, 115416, 122760, 129984, 137292, 144504, 151620, 158640, 165816, 172656, 179676, 186624, 193500, 200304, 207360, 214032, 220980, 227520, 234360, 240768, 247500, 254184, 260820, 267408, 273948, 280440, 286884, 293280, 299628, 306432, 312696, 318912, 325620, 331752, 337836, 344448, 350448, 357000, 362916, 369408, 375876, 381672, 388080, 393792, 400140, 406464, 412056, 418320, 424560, 430776, 436212, 442368, 448500, 454608, 460692, 466752, 471960, 477960, 483936, 489888, 495816, 501720, 507600, 513456, 519288, 525096, 530880, 536640, 542376, 548088, 553776, 559440, 565080, 570696, 576288, 581856, 587400, 592920, 598416, 603888, 610452, 615888, 621300, 626688, 632052, 637392, 642708, 648000, 654480, 659736, 664968, 670176, 675360, 681792, 686940, 692064, 697164, 702240, 708624, 713664, 718680, 723672, 728640, 734976, 739908, 744816, 749700, 756000, 760848, 765672, 770472, 776736, 781500, 786240, 792480, 797184] [160, 320, 480, 640, 800, 960, 1120, 1280, 1440, 1600, 1760, 1920, 2080, 2240, 2400, 2560, 2720, 2880, 3040, 3200, 3360, 3520, 3680, 3840, 4000, 4160, 4320, 4480, 4640, 4800, 4960, 5120, 5280, 5440, 5600, 5760, 5920, 6080, 6240, 6400, 6560, 6720, 6880, 7040, 7200, 7360, 7520, 7680, 7840, 8000, 8160, 8320, 8480, 8640, 8800, 8960, 9120, 9280, 9440, 9600, 9760, 9920, 10080, 10240, 10400, 10560, 10720, 10880, 11040, 11200, 11360, 11520, 11680, 11840, 12000, 12160, 12320, 12480, 12640, 12800, 12960, 13120, 13280, 13440, 13600, 13760, 13920, 14080, 14240, 14400, 14560, 14720, 14880, 15040, 15200, 15360, 15520, 15680, 15840, 16000, 16160, 16320, 16480, 16640, 16800, 16960, 17120, 17280, 17440, 17600, 17760, 17920, 18080, 18240, 18400, 18560, 18720, 18880, 19040, 19200, 19360, 19520, 19680, 19840, 20000, 20160, 20320, 20480]
...fork_Osaka-blockchain_test_from_state_test-precompile_address_12---one_extra_gas_full_discount_table 12 100000000 PointG1(x=0, y=0) [12001, 22777, 30529, 38257, 45841, 54001, 61993, 69889, 77653, 85441, 93061, 100513, 107953, 115417, 122761, 129985, 137293, 144505, 151621, 158641, 165817, 172657, 179677, 186625, 193501, 200305, 207361, 214033, 220981, 227521, 234361, 240769, 247501, 254185, 260821, 267409, 273949, 280441, 286885, 293281, 299629, 306433, 312697, 318913, 325621, 331753, 337837, 344449, 350449, 357001, 362917, 369409, 375877, 381673, 388081, 393793, 400141, 406465, 412057, 418321, 424561, 430777, 436213, 442369, 448501, 454609, 460693, 466753, 471961, 477961, 483937, 489889, 495817, 501721, 507601, 513457, 519289, 525097, 530881, 536641, 542377, 548089, 553777, 559441, 565081, 570697, 576289, 581857, 587401, 592921, 598417, 603889, 610453, 615889, 621301, 626689, 632053, 637393, 642709, 648001, 654481, 659737, 664969, 670177, 675361, 681793, 686941, 692065, 697165, 702241, 708625, 713665, 718681, 723673, 728641, 734977, 739909, 744817, 749701, 756001, 760849, 765673, 770473, 776737, 781501, 786241, 792481, 797185] [160, 320, 480, 640, 800, 960, 1120, 1280, 1440, 1600, 1760, 1920, 2080, 2240, 2400, 2560, 2720, 2880, 3040, 3200, 3360, 3520, 3680, 3840, 4000, 4160, 4320, 4480, 4640, 4800, 4960, 5120, 5280, 5440, 5600, 5760, 5920, 6080, 6240, 6400, 6560, 6720, 6880, 7040, 7200, 7360, 7520, 7680, 7840, 8000, 8160, 8320, 8480, 8640, 8800, 8960, 9120, 9280, 9440, 9600, 9760, 9920, 10080, 10240, 10400, 10560, 10720, 10880, 11040, 11200, 11360, 11520, 11680, 11840, 12000, 12160, 12320, 12480, 12640, 12800, 12960, 13120, 13280, 13440, 13600, 13760, 13920, 14080, 14240, 14400, 14560, 14720, 14880, 15040, 15200, 15360, 15520, 15680, 15840, 16000, 16160, 16320, 16480, 16640, 16800, 16960, 17120, 17280, 17440, 17600, 17760, 17920, 18080, 18240, 18400, 18560, 18720, 18880, 19040, 19200, 19360, 19520, 19680, 19840, 20000, 20160, 20320, 20480]