Skip to content

test_invalid_length_g1msm()

Documentation for tests/prague/eip2537_bls_12_381_precompiles/test_bls12_variable_length_input_contracts.py::test_invalid_length_g1msm@49a16fac.

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_invalid_length_g1msm --fork Prague

Test the BLS12_G1MSM discount gas table in full, by expecting the call to fail for all possible input lengths provided because they are too long or short, or zero length.

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

Source code in tests/prague/eip2537_bls_12_381_precompiles/test_bls12_variable_length_input_contracts.py
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
@pytest.mark.parametrize(
    "precompile_gas_list,precompile_data_length_list",
    [
        pytest.param(
            [G1_GAS(G1_MSM_K_INPUT_LENGTH)],
            [0],
            id="zero_length_input",
        ),
        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) - 1 for i in range(1, len(Spec.G1MSM_DISCOUNT_TABLE))],
            id="input_one_byte_too_short_full_discount_table",
        ),
        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) + 1 for i in range(1, len(Spec.G1MSM_DISCOUNT_TABLE))],
            id="input_one_byte_too_long_full_discount_table",
        ),
    ],
)
@pytest.mark.parametrize("expected_output", [Spec.INVALID], ids=[""])
@pytest.mark.parametrize("tx_gas_limit", [100_000_000], ids=[""])
@pytest.mark.parametrize("precompile_address", [Spec.G1MSM])
def test_invalid_length_g1msm(
    state_test: StateTestFiller,
    pre: Alloc,
    post: dict,
    tx: Transaction,
):
    """
    Test the BLS12_G1MSM discount gas table in full, by expecting the call to fail for
    all possible input lengths provided because they are too long or short, or zero length.

    If any of the calls succeeds, 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-blockchain_test-precompile_address_12---zero_length_input 12 100000000 [12000] [0]
...fork_Prague-blockchain_test-precompile_address_12---input_one_byte_too_short_full_discount_table 12 100000000 [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] [159, 319, 479, 639, 799, 959, 1119, 1279, 1439, 1599, 1759, 1919, 2079, 2239, 2399, 2559, 2719, 2879, 3039, 3199, 3359, 3519, 3679, 3839, 3999, 4159, 4319, 4479, 4639, 4799, 4959, 5119, 5279, 5439, 5599, 5759, 5919, 6079, 6239, 6399, 6559, 6719, 6879, 7039, 7199, 7359, 7519, 7679, 7839, 7999, 8159, 8319, 8479, 8639, 8799, 8959, 9119, 9279, 9439, 9599, 9759, 9919, 10079, 10239, 10399, 10559, 10719, 10879, 11039, 11199, 11359, 11519, 11679, 11839, 11999, 12159, 12319, 12479, 12639, 12799, 12959, 13119, 13279, 13439, 13599, 13759, 13919, 14079, 14239, 14399, 14559, 14719, 14879, 15039, 15199, 15359, 15519, 15679, 15839, 15999, 16159, 16319, 16479, 16639, 16799, 16959, 17119, 17279, 17439, 17599, 17759, 17919, 18079, 18239, 18399, 18559, 18719, 18879, 19039, 19199, 19359, 19519, 19679, 19839, 19999, 20159, 20319, 20479]
...fork_Prague-blockchain_test-precompile_address_12---input_one_byte_too_long_full_discount_table 12 100000000 [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] [161, 321, 481, 641, 801, 961, 1121, 1281, 1441, 1601, 1761, 1921, 2081, 2241, 2401, 2561, 2721, 2881, 3041, 3201, 3361, 3521, 3681, 3841, 4001, 4161, 4321, 4481, 4641, 4801, 4961, 5121, 5281, 5441, 5601, 5761, 5921, 6081, 6241, 6401, 6561, 6721, 6881, 7041, 7201, 7361, 7521, 7681, 7841, 8001, 8161, 8321, 8481, 8641, 8801, 8961, 9121, 9281, 9441, 9601, 9761, 9921, 10081, 10241, 10401, 10561, 10721, 10881, 11041, 11201, 11361, 11521, 11681, 11841, 12001, 12161, 12321, 12481, 12641, 12801, 12961, 13121, 13281, 13441, 13601, 13761, 13921, 14081, 14241, 14401, 14561, 14721, 14881, 15041, 15201, 15361, 15521, 15681, 15841, 16001, 16161, 16321, 16481, 16641, 16801, 16961, 17121, 17281, 17441, 17601, 17761, 17921, 18081, 18241, 18401, 18561, 18721, 18881, 19041, 19201, 19361, 19521, 19681, 19841, 20001, 20161, 20321, 20481]
...fork_Prague-state_test-precompile_address_12---zero_length_input 12 100000000 [12000] [0]
...fork_Prague-state_test-precompile_address_12---input_one_byte_too_short_full_discount_table 12 100000000 [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] [159, 319, 479, 639, 799, 959, 1119, 1279, 1439, 1599, 1759, 1919, 2079, 2239, 2399, 2559, 2719, 2879, 3039, 3199, 3359, 3519, 3679, 3839, 3999, 4159, 4319, 4479, 4639, 4799, 4959, 5119, 5279, 5439, 5599, 5759, 5919, 6079, 6239, 6399, 6559, 6719, 6879, 7039, 7199, 7359, 7519, 7679, 7839, 7999, 8159, 8319, 8479, 8639, 8799, 8959, 9119, 9279, 9439, 9599, 9759, 9919, 10079, 10239, 10399, 10559, 10719, 10879, 11039, 11199, 11359, 11519, 11679, 11839, 11999, 12159, 12319, 12479, 12639, 12799, 12959, 13119, 13279, 13439, 13599, 13759, 13919, 14079, 14239, 14399, 14559, 14719, 14879, 15039, 15199, 15359, 15519, 15679, 15839, 15999, 16159, 16319, 16479, 16639, 16799, 16959, 17119, 17279, 17439, 17599, 17759, 17919, 18079, 18239, 18399, 18559, 18719, 18879, 19039, 19199, 19359, 19519, 19679, 19839, 19999, 20159, 20319, 20479]
...fork_Prague-state_test-precompile_address_12---input_one_byte_too_long_full_discount_table 12 100000000 [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] [161, 321, 481, 641, 801, 961, 1121, 1281, 1441, 1601, 1761, 1921, 2081, 2241, 2401, 2561, 2721, 2881, 3041, 3201, 3361, 3521, 3681, 3841, 4001, 4161, 4321, 4481, 4641, 4801, 4961, 5121, 5281, 5441, 5601, 5761, 5921, 6081, 6241, 6401, 6561, 6721, 6881, 7041, 7201, 7361, 7521, 7681, 7841, 8001, 8161, 8321, 8481, 8641, 8801, 8961, 9121, 9281, 9441, 9601, 9761, 9921, 10081, 10241, 10401, 10561, 10721, 10881, 11041, 11201, 11361, 11521, 11681, 11841, 12001, 12161, 12321, 12481, 12641, 12801, 12961, 13121, 13281, 13441, 13601, 13761, 13921, 14081, 14241, 14401, 14561, 14721, 14881, 15041, 15201, 15361, 15521, 15681, 15841, 16001, 16161, 16321, 16481, 16641, 16801, 16961, 17121, 17281, 17441, 17601, 17761, 17921, 18081, 18241, 18401, 18561, 18721, 18881, 19041, 19201, 19361, 19521, 19681, 19841, 20001, 20161, 20321, 20481]
...fork_Osaka-blockchain_test-precompile_address_12---zero_length_input 12 100000000 [12000] [0]
...fork_Osaka-blockchain_test-precompile_address_12---input_one_byte_too_short_full_discount_table 12 100000000 [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] [159, 319, 479, 639, 799, 959, 1119, 1279, 1439, 1599, 1759, 1919, 2079, 2239, 2399, 2559, 2719, 2879, 3039, 3199, 3359, 3519, 3679, 3839, 3999, 4159, 4319, 4479, 4639, 4799, 4959, 5119, 5279, 5439, 5599, 5759, 5919, 6079, 6239, 6399, 6559, 6719, 6879, 7039, 7199, 7359, 7519, 7679, 7839, 7999, 8159, 8319, 8479, 8639, 8799, 8959, 9119, 9279, 9439, 9599, 9759, 9919, 10079, 10239, 10399, 10559, 10719, 10879, 11039, 11199, 11359, 11519, 11679, 11839, 11999, 12159, 12319, 12479, 12639, 12799, 12959, 13119, 13279, 13439, 13599, 13759, 13919, 14079, 14239, 14399, 14559, 14719, 14879, 15039, 15199, 15359, 15519, 15679, 15839, 15999, 16159, 16319, 16479, 16639, 16799, 16959, 17119, 17279, 17439, 17599, 17759, 17919, 18079, 18239, 18399, 18559, 18719, 18879, 19039, 19199, 19359, 19519, 19679, 19839, 19999, 20159, 20319, 20479]
...fork_Osaka-blockchain_test-precompile_address_12---input_one_byte_too_long_full_discount_table 12 100000000 [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] [161, 321, 481, 641, 801, 961, 1121, 1281, 1441, 1601, 1761, 1921, 2081, 2241, 2401, 2561, 2721, 2881, 3041, 3201, 3361, 3521, 3681, 3841, 4001, 4161, 4321, 4481, 4641, 4801, 4961, 5121, 5281, 5441, 5601, 5761, 5921, 6081, 6241, 6401, 6561, 6721, 6881, 7041, 7201, 7361, 7521, 7681, 7841, 8001, 8161, 8321, 8481, 8641, 8801, 8961, 9121, 9281, 9441, 9601, 9761, 9921, 10081, 10241, 10401, 10561, 10721, 10881, 11041, 11201, 11361, 11521, 11681, 11841, 12001, 12161, 12321, 12481, 12641, 12801, 12961, 13121, 13281, 13441, 13601, 13761, 13921, 14081, 14241, 14401, 14561, 14721, 14881, 15041, 15201, 15361, 15521, 15681, 15841, 16001, 16161, 16321, 16481, 16641, 16801, 16961, 17121, 17281, 17441, 17601, 17761, 17921, 18081, 18241, 18401, 18561, 18721, 18881, 19041, 19201, 19361, 19521, 19681, 19841, 20001, 20161, 20321, 20481]
...fork_Osaka-state_test-precompile_address_12---zero_length_input 12 100000000 [12000] [0]
...fork_Osaka-state_test-precompile_address_12---input_one_byte_too_short_full_discount_table 12 100000000 [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] [159, 319, 479, 639, 799, 959, 1119, 1279, 1439, 1599, 1759, 1919, 2079, 2239, 2399, 2559, 2719, 2879, 3039, 3199, 3359, 3519, 3679, 3839, 3999, 4159, 4319, 4479, 4639, 4799, 4959, 5119, 5279, 5439, 5599, 5759, 5919, 6079, 6239, 6399, 6559, 6719, 6879, 7039, 7199, 7359, 7519, 7679, 7839, 7999, 8159, 8319, 8479, 8639, 8799, 8959, 9119, 9279, 9439, 9599, 9759, 9919, 10079, 10239, 10399, 10559, 10719, 10879, 11039, 11199, 11359, 11519, 11679, 11839, 11999, 12159, 12319, 12479, 12639, 12799, 12959, 13119, 13279, 13439, 13599, 13759, 13919, 14079, 14239, 14399, 14559, 14719, 14879, 15039, 15199, 15359, 15519, 15679, 15839, 15999, 16159, 16319, 16479, 16639, 16799, 16959, 17119, 17279, 17439, 17599, 17759, 17919, 18079, 18239, 18399, 18559, 18719, 18879, 19039, 19199, 19359, 19519, 19679, 19839, 19999, 20159, 20319, 20479]
...fork_Osaka-state_test-precompile_address_12---input_one_byte_too_long_full_discount_table 12 100000000 [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] [161, 321, 481, 641, 801, 961, 1121, 1281, 1441, 1601, 1761, 1921, 2081, 2241, 2401, 2561, 2721, 2881, 3041, 3201, 3361, 3521, 3681, 3841, 4001, 4161, 4321, 4481, 4641, 4801, 4961, 5121, 5281, 5441, 5601, 5761, 5921, 6081, 6241, 6401, 6561, 6721, 6881, 7041, 7201, 7361, 7521, 7681, 7841, 8001, 8161, 8321, 8481, 8641, 8801, 8961, 9121, 9281, 9441, 9601, 9761, 9921, 10081, 10241, 10401, 10561, 10721, 10881, 11041, 11201, 11361, 11521, 11681, 11841, 12001, 12161, 12321, 12481, 12641, 12801, 12961, 13121, 13281, 13441, 13601, 13761, 13921, 14081, 14241, 14401, 14561, 14721, 14881, 15041, 15201, 15361, 15521, 15681, 15841, 16001, 16161, 16321, 16481, 16641, 16801, 16961, 17121, 17281, 17441, 17601, 17761, 17921, 18081, 18241, 18401, 18561, 18721, 18881, 19041, 19201, 19361, 19521, 19681, 19841, 20001, 20161, 20321, 20481]