Skip to content

Commit d5dc499

Browse files
committed
add bls12_g1msm
Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>
1 parent edaef73 commit d5dc499

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

tests/zkevm/test_worst_compute.py

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -243,11 +243,10 @@ def test_worst_modexp(
243243
],
244244
)
245245
@pytest.mark.parametrize(
246-
"precompile_address,precompile_gas_cost,input,length",
246+
"precompile_address,input,length",
247247
[
248248
pytest.param(
249249
0x01,
250-
3_000,
251250
[
252251
"38D18ACB67D25C8BB9942764B62F18E17054F66A817BD4295423ADF9ED98873E",
253252
"000000000000000000000000000000000000000000000000000000000000001B",
@@ -259,7 +258,6 @@ def test_worst_modexp(
259258
),
260259
pytest.param(
261260
0x06,
262-
150,
263261
[
264262
"18B18ACFB4C2C30276DB5411368E7185B311DD124691610C5D3B74034E093DC9",
265263
"063C909C4720840CB5134CB9F59FA749755796819658D32EFC0D288198F37266",
@@ -271,7 +269,6 @@ def test_worst_modexp(
271269
),
272270
pytest.param(
273271
0x07,
274-
6_000,
275272
[
276273
"1A87B0584CE92F4593D161480614F2989035225609F08058CCFA3D0F940FEBE3",
277274
"1A2F3C951F6DADCC7EE9007DFF81504B0FCD6D7CF59996EFDC33D92BF7F9F8F6",
@@ -282,27 +279,27 @@ def test_worst_modexp(
282279
),
283280
pytest.param(
284281
0x08,
285-
45_000 + 2 * 34_000,
286282
[
283+
# First pairing
287284
"1C76476F4DEF4BB94541D57EBBA1193381FFA7AA76ADA664DD31C16024C43F59",
288285
"3034DD2920F673E204FEE2811C678745FC819B55D3E9D294E45C9B03A76AEF41",
289286
"209DD15EBFF5D46C4BD888E51A93CF99A7329636C63514396B4A452003A35BF7",
290287
"04BF11CA01483BFA8B34B43561848D28905960114C8AC04049AF4B6315A41678",
291288
"2BB8324AF6CFC93537A2AD1A445CFD0CA2A71ACD7AC41FADBF933C2A51BE344D",
292289
"120A2A4CF30C1BF9845F20C6FE39E07EA2CCE61F0C9BB048165FE5E4DE877550",
290+
# Second pairing
293291
"111E129F1CF1097710D41C4AC70FCDFA5BA2023C6FF1CBEAC322DE49D1B6DF7C",
294292
"103188585E2364128FE25C70558F1560F4F9350BAF3959E603CC91486E110936",
295293
"198E9393920D483A7260BFB731FB5D25F1AA493335A9E71297E485B7AEF312C2",
296294
"1800DEEF121F1E76426A00665E5C4479674322D4F75EDADD46DEBD5CD992F6ED",
297295
"090689D0585FF075EC9E99AD690C3395BC4B313370B38EF355ACDADCD122975B",
298296
"12C85EA5DB8C6DEB4AAB71808DCB408FE3D1E7690C43D37B4CE6CC0166FA7DAA",
299297
],
300-
32 * 12,
298+
32 * 2 * 6,
301299
id="bn128_pairing",
302300
),
303301
pytest.param(
304302
0x09,
305-
0xFFFF,
306303
[
307304
"0000FFFF",
308305
"48C9BDF267E6096A3BA7CA8485AE67BB2BF894FE72F36E3CF1361D5F3AF54FA5D182E6AD7F520E511F6C3E2B8C68059B6BBD41FBABD9831F79217E1319CDE05B",
@@ -317,7 +314,6 @@ def test_worst_modexp(
317314
),
318315
pytest.param(
319316
0x0A,
320-
50_000,
321317
[
322318
"01E798154708FE7789429634053CBF9F99B619F9F084048927333FCE637F549B",
323319
"564C0A11A0F704F4FC3E8ACFE0F8245F0AD1347B378FBF96E206DA11A5D36306",
@@ -330,14 +326,23 @@ def test_worst_modexp(
330326
),
331327
pytest.param(
332328
0x0B,
333-
375,
334329
[
335330
"000000000000000000000000000000000572CBEA904D67468808C8EB50A9450C9721DB309128012543902D0AC358A62AE28F75BB8F1C7C42C39A8C5529BF0F4E00000000000000000000000000000000166A9D8CABC673A322FDA673779D8E3822BA3ECB8670E461F73BB9021D5FD76A",
336331
"4C56D9D4CD16BD1BBA86881979749D280000000000000000000000000000000009ECE308F9D1F0131765212DECA99697B112D61F9BE9A5F1F3780A51335B3FF981747A0B2CA2179B96D2C0C9024E522400000000000000000000000000000000032B80D3A6F5B09F8A84623389C5F80C",
337332
],
338333
256,
339334
id="bls12_g1add",
340335
),
336+
pytest.param(
337+
0x0C,
338+
[
339+
"0000000000000000000000000000000017f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb0000000000000000000000000000000008b3f481e3aaa0f1a09e30ed741d8ae4fcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e10000000000000000000000000000000000000000000000000000000000000032",
340+
"000000000000000000000000000000000e12039459c60491672b6a6282355d8765ba6272387fb91a3e9604fa2a81450cf16b870bb446fc3a3e0a187fff6f89450000000000000000000000000000000018b6c1ed9f45d3cbc0b01b9d038dcecacbd702eb26469a0eb3905bd421461712f67f782b4735849644c1772c93fe3d090000000000000000000000000000000000000000000000000000000000000033",
341+
"00000000000000000000000000000000147b327c8a15b39634a426af70c062b50632a744eddd41b5a4686414ef4cd9746bb11d0a53c6c2ff21bbcf331e07ac9200000000000000000000000000000000078c2e9782fa5d9ab4e728684382717aa2b8fad61b5f5e7cf3baa0bc9465f57342bb7c6d7b232e70eebcdbf70f903a450000000000000000000000000000000000000000000000000000000000000034",
342+
],
343+
3 * 160,
344+
id="bls12_g1msm",
345+
),
341346
],
342347
)
343348
def test_worst_precompile_fixed_cost(
@@ -346,7 +351,6 @@ def test_worst_precompile_fixed_cost(
346351
fork: Fork,
347352
gas_limit: int,
348353
precompile_address: Address,
349-
precompile_gas_cost: int,
350354
input: list[str],
351355
length: int,
352356
):
@@ -365,7 +369,7 @@ def test_worst_precompile_fixed_cost(
365369
value_to_store = int.from_bytes(chunk, "big")
366370
calldata += Op.MSTORE(i, value_to_store)
367371

368-
attack_block = Op.POP(Op.STATICCALL(precompile_gas_cost, precompile_address, 0, length, 0, 0))
372+
attack_block = Op.POP(Op.STATICCALL(Op.GAS, precompile_address, 0, length, 0, 0))
369373
code = code_loop_precompile_call(calldata, attack_block)
370374
code_address = pre.deploy_contract(code=bytes(code))
371375

0 commit comments

Comments
 (0)