Skip to content

Commit ae29f0d

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

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
@@ -264,11 +264,10 @@ def test_worst_modexp(
264264
],
265265
)
266266
@pytest.mark.parametrize(
267-
"precompile_address,precompile_gas_cost,input,length",
267+
"precompile_address,input,length",
268268
[
269269
pytest.param(
270270
0x01,
271-
3_000,
272271
[
273272
"38D18ACB67D25C8BB9942764B62F18E17054F66A817BD4295423ADF9ED98873E",
274273
"000000000000000000000000000000000000000000000000000000000000001B",
@@ -280,7 +279,6 @@ def test_worst_modexp(
280279
),
281280
pytest.param(
282281
0x06,
283-
150,
284282
[
285283
"18B18ACFB4C2C30276DB5411368E7185B311DD124691610C5D3B74034E093DC9",
286284
"063C909C4720840CB5134CB9F59FA749755796819658D32EFC0D288198F37266",
@@ -292,7 +290,6 @@ def test_worst_modexp(
292290
),
293291
pytest.param(
294292
0x07,
295-
6_000,
296293
[
297294
"1A87B0584CE92F4593D161480614F2989035225609F08058CCFA3D0F940FEBE3",
298295
"1A2F3C951F6DADCC7EE9007DFF81504B0FCD6D7CF59996EFDC33D92BF7F9F8F6",
@@ -303,27 +300,27 @@ def test_worst_modexp(
303300
),
304301
pytest.param(
305302
0x08,
306-
45_000 + 2 * 34_000,
307303
[
304+
# First pairing
308305
"1C76476F4DEF4BB94541D57EBBA1193381FFA7AA76ADA664DD31C16024C43F59",
309306
"3034DD2920F673E204FEE2811C678745FC819B55D3E9D294E45C9B03A76AEF41",
310307
"209DD15EBFF5D46C4BD888E51A93CF99A7329636C63514396B4A452003A35BF7",
311308
"04BF11CA01483BFA8B34B43561848D28905960114C8AC04049AF4B6315A41678",
312309
"2BB8324AF6CFC93537A2AD1A445CFD0CA2A71ACD7AC41FADBF933C2A51BE344D",
313310
"120A2A4CF30C1BF9845F20C6FE39E07EA2CCE61F0C9BB048165FE5E4DE877550",
311+
# Second pairing
314312
"111E129F1CF1097710D41C4AC70FCDFA5BA2023C6FF1CBEAC322DE49D1B6DF7C",
315313
"103188585E2364128FE25C70558F1560F4F9350BAF3959E603CC91486E110936",
316314
"198E9393920D483A7260BFB731FB5D25F1AA493335A9E71297E485B7AEF312C2",
317315
"1800DEEF121F1E76426A00665E5C4479674322D4F75EDADD46DEBD5CD992F6ED",
318316
"090689D0585FF075EC9E99AD690C3395BC4B313370B38EF355ACDADCD122975B",
319317
"12C85EA5DB8C6DEB4AAB71808DCB408FE3D1E7690C43D37B4CE6CC0166FA7DAA",
320318
],
321-
32 * 12,
319+
32 * 2 * 6,
322320
id="bn128_pairing",
323321
),
324322
pytest.param(
325323
0x09,
326-
0xFFFF,
327324
[
328325
"0000FFFF",
329326
"48C9BDF267E6096A3BA7CA8485AE67BB2BF894FE72F36E3CF1361D5F3AF54FA5D182E6AD7F520E511F6C3E2B8C68059B6BBD41FBABD9831F79217E1319CDE05B",
@@ -338,7 +335,6 @@ def test_worst_modexp(
338335
),
339336
pytest.param(
340337
0x0A,
341-
50_000,
342338
[
343339
"01E798154708FE7789429634053CBF9F99B619F9F084048927333FCE637F549B",
344340
"564C0A11A0F704F4FC3E8ACFE0F8245F0AD1347B378FBF96E206DA11A5D36306",
@@ -351,14 +347,23 @@ def test_worst_modexp(
351347
),
352348
pytest.param(
353349
0x0B,
354-
375,
355350
[
356351
"000000000000000000000000000000000572CBEA904D67468808C8EB50A9450C9721DB309128012543902D0AC358A62AE28F75BB8F1C7C42C39A8C5529BF0F4E00000000000000000000000000000000166A9D8CABC673A322FDA673779D8E3822BA3ECB8670E461F73BB9021D5FD76A",
357352
"4C56D9D4CD16BD1BBA86881979749D280000000000000000000000000000000009ECE308F9D1F0131765212DECA99697B112D61F9BE9A5F1F3780A51335B3FF981747A0B2CA2179B96D2C0C9024E522400000000000000000000000000000000032B80D3A6F5B09F8A84623389C5F80C",
358353
],
359354
256,
360355
id="bls12_g1add",
361356
),
357+
pytest.param(
358+
0x0C,
359+
[
360+
"0000000000000000000000000000000017f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb0000000000000000000000000000000008b3f481e3aaa0f1a09e30ed741d8ae4fcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e10000000000000000000000000000000000000000000000000000000000000032",
361+
"000000000000000000000000000000000e12039459c60491672b6a6282355d8765ba6272387fb91a3e9604fa2a81450cf16b870bb446fc3a3e0a187fff6f89450000000000000000000000000000000018b6c1ed9f45d3cbc0b01b9d038dcecacbd702eb26469a0eb3905bd421461712f67f782b4735849644c1772c93fe3d090000000000000000000000000000000000000000000000000000000000000033",
362+
"00000000000000000000000000000000147b327c8a15b39634a426af70c062b50632a744eddd41b5a4686414ef4cd9746bb11d0a53c6c2ff21bbcf331e07ac9200000000000000000000000000000000078c2e9782fa5d9ab4e728684382717aa2b8fad61b5f5e7cf3baa0bc9465f57342bb7c6d7b232e70eebcdbf70f903a450000000000000000000000000000000000000000000000000000000000000034",
363+
],
364+
3 * 160,
365+
id="bls12_g1msm",
366+
),
362367
],
363368
)
364369
def test_worst_precompile_fixed_cost(
@@ -367,7 +372,6 @@ def test_worst_precompile_fixed_cost(
367372
fork: Fork,
368373
gas_limit: int,
369374
precompile_address: Address,
370-
precompile_gas_cost: int,
371375
input: list[str],
372376
length: int,
373377
):
@@ -386,7 +390,7 @@ def test_worst_precompile_fixed_cost(
386390
value_to_store = int.from_bytes(chunk, "big")
387391
calldata += Op.MSTORE(i, value_to_store)
388392

389-
attack_block = Op.POP(Op.STATICCALL(precompile_gas_cost, precompile_address, 0, length, 0, 0))
393+
attack_block = Op.POP(Op.STATICCALL(Op.GAS, precompile_address, 0, length, 0, 0))
390394
code = code_loop_precompile_call(calldata, attack_block)
391395
code_address = pre.deploy_contract(code=bytes(code))
392396

0 commit comments

Comments
 (0)