Skip to content

Commit a454418

Browse files
tests(benchmark): port additional Nethermind cases (#1992)
* refactor: update comment * tests: add extra modexp cases * test: add extra ecpairing cases
1 parent 7b78f3c commit a454418

File tree

1 file changed

+253
-5
lines changed

1 file changed

+253
-5
lines changed

tests/benchmark/test_worst_compute.py

Lines changed: 253 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -655,7 +655,7 @@ def test_worst_precompile_only_data_input(
655655
exponent="03",
656656
modulus=6 * ("00" + 31 * "FF"),
657657
),
658-
id="mod_min_as_base_heavy",
658+
id="mod_min_gas_base_heavy",
659659
),
660660
# Ported from https://github.com/NethermindEth/nethermind/blob/ceb8d57b8530ce8181d7427c115ca593386909d6/tools/EngineRequestsGenerator/TestCases/Modexp.cs#L40
661661
pytest.param(
@@ -664,7 +664,7 @@ def test_worst_precompile_only_data_input(
664664
exponent="07" + 75 * "FF",
665665
modulus=7 * "FF",
666666
),
667-
id="mod_min_as_exp_heavy",
667+
id="mod_min_gas_exp_heavy",
668668
),
669669
# Ported from https://github.com/NethermindEth/nethermind/blob/ceb8d57b8530ce8181d7427c115ca593386909d6/tools/EngineRequestsGenerator/TestCases/Modexp.cs#L42
670670
pytest.param(
@@ -673,7 +673,7 @@ def test_worst_precompile_only_data_input(
673673
exponent="01" + 3 * "FF",
674674
modulus="00" + 38 * "FF",
675675
),
676-
id="mod_min_as_balanced",
676+
id="mod_min_gas_balanced",
677677
),
678678
# Ported from https://github.com/NethermindEth/nethermind/blob/ceb8d57b8530ce8181d7427c115ca593386909d6/tools/EngineRequestsGenerator/TestCases/Modexp.cs#L44
679679
pytest.param(
@@ -781,7 +781,7 @@ def test_worst_precompile_only_data_input(
781781
exponent="07" + 6 * "FF",
782782
modulus="00" + 46 * "FF",
783783
),
784-
id="mod_600_as_balanced",
784+
id="mod_600_gas_balanced",
785785
),
786786
# Ported from https://github.com/NethermindEth/nethermind/blob/ceb8d57b8530ce8181d7427c115ca593386909d6/tools/EngineRequestsGenerator/TestCases/Modexp.cs#L68
787787
pytest.param(
@@ -873,6 +873,94 @@ def test_worst_precompile_only_data_input(
873873
),
874874
id="mod_1360_gas_balanced",
875875
),
876+
pytest.param(
877+
ModExpInput(
878+
base=8 * "FF",
879+
exponent=81 * "FF",
880+
modulus=7 * "FF",
881+
),
882+
id="mod_8_exp_648",
883+
),
884+
pytest.param(
885+
ModExpInput(
886+
base=8 * "FF",
887+
exponent="FF" + 111 * "FF",
888+
modulus=7 * "FF",
889+
),
890+
id="mod_8_exp_896",
891+
),
892+
pytest.param(
893+
ModExpInput(
894+
base=32 * "FF",
895+
exponent=4 * "FF",
896+
modulus="00" + 31 * "FF",
897+
),
898+
id="mod_32_exp_32",
899+
),
900+
pytest.param(
901+
ModExpInput(
902+
base=32 * "FF",
903+
exponent="0D" + 4 * "FF",
904+
modulus="00" + 31 * "FF",
905+
),
906+
id="mod_32_exp_36",
907+
),
908+
pytest.param(
909+
ModExpInput(
910+
base=32 * "FF",
911+
exponent=5 * "FF",
912+
modulus="00" + 31 * "FF",
913+
),
914+
id="mod_32_exp_40",
915+
),
916+
pytest.param(
917+
ModExpInput(
918+
base=32 * "FF",
919+
exponent=8 * "FF",
920+
modulus="00" + 31 * "FF",
921+
),
922+
id="mod_32_exp_64",
923+
),
924+
pytest.param(
925+
ModExpInput(
926+
base=32 * "FF",
927+
exponent="01" + 8 * "FF",
928+
modulus="00" + 31 * "FF",
929+
),
930+
id="mod_32_exp_65",
931+
),
932+
pytest.param(
933+
ModExpInput(
934+
base=32 * "FF",
935+
exponent=16 * "FF",
936+
modulus="00" + 31 * "FF",
937+
),
938+
id="mod_32_exp_128",
939+
),
940+
pytest.param(
941+
ModExpInput(
942+
base=256 * "FF",
943+
exponent="03" + 0 * "FF",
944+
modulus=8 * ("00" + 31 * "FF"),
945+
),
946+
id="mod_256_exp_2",
947+
),
948+
pytest.param(
949+
ModExpInput(
950+
base=264 * "FF",
951+
exponent="03" + 0 * "FF",
952+
modulus=8 * ("00" + 31 * "FF") + 7 * "FF",
953+
),
954+
id="mod_264_exp_2",
955+
),
956+
pytest.param(
957+
ModExpInput(
958+
base=1024 * "FF",
959+
exponent="03",
960+
modulus=32 * ("00" + 31 * "FF"),
961+
),
962+
id="mod_1024_exp_2",
963+
),
876964
# Ported from https://github.com/NethermindEth/nethermind/blob/ceb8d57b8530ce8181d7427c115ca593386909d6/tools/EngineRequestsGenerator/TestCases/ModexpVulnerability.cs#L122
877965
pytest.param(
878966
ModExpInput(
@@ -1161,6 +1249,14 @@ def test_worst_precompile_only_data_input(
11611249
),
11621250
id="mod_vul_common_200n3",
11631251
),
1252+
pytest.param(
1253+
ModExpInput(
1254+
base="ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
1255+
exponent="ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
1256+
modulus="fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe",
1257+
),
1258+
id="mod_vul_zkevm_worst_case",
1259+
),
11641260
],
11651261
)
11661262
def test_worst_modexp(
@@ -1348,7 +1444,159 @@ def test_worst_modexp(
13481444
id="bn128_one_pairing",
13491445
),
13501446
# Ported from https://github.com/NethermindEth/nethermind/blob/ceb8d57b8530ce8181d7427c115ca593386909d6/tools/EngineRequestsGenerator/TestCase.cs#L353
1351-
pytest.param(0x08, [""], id="bn128_two_pairings_empty"),
1447+
pytest.param(0x08, [], id="ec_pairing_zero_input"),
1448+
pytest.param(
1449+
0x08,
1450+
[
1451+
# First pairing
1452+
"2cf44499d5d27bb186308b7af7af02ac5bc9eeb6a3d147c186b21fb1b76e18da",
1453+
"2c0f001f52110ccfe69108924926e45f0b0c868df0e7bde1fe16d3242dc715f6",
1454+
"1fb19bb476f6b9e44e2a32234da8212f61cd63919354bc06aef31e3cfaff3ebc",
1455+
"22606845ff186793914e03e21df544c34ffe2f2f3504de8a79d9159eca2d98d9",
1456+
"2bd368e28381e8eccb5fa81fc26cf3f048eea9abfdd85d7ed3ab3698d63e4f90",
1457+
"2fe02e47887507adf0ff1743cbac6ba291e66f59be6bd763950bb16041a0a85e",
1458+
# Second pairing
1459+
"0000000000000000000000000000000000000000000000000000000000000013",
1460+
"0644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd451",
1461+
"971ff0471b09fa93caaf13cbf443c1aede09cc4328f5a62aad45f40ec133eb40",
1462+
"91058a3141822985733cbdddfed0fd8d6c104e9e9eff40bf5abfef9ab163bc72",
1463+
"a23af9a5ce2ba2796c1f4e453a370eb0af8c212d9dc9acd8fc02c2e907baea22",
1464+
"3a8eb0b0996252cb548a4487da97b02422ebc0e834613f954de6c7e0afdc1fc0",
1465+
],
1466+
id="ec_pairing_2_sets",
1467+
),
1468+
pytest.param(
1469+
0x08,
1470+
[""],
1471+
id="ec_pairing_1_pair",
1472+
),
1473+
pytest.param(
1474+
0x08,
1475+
[
1476+
# First pairing
1477+
"2371e7d92e9fc444d0e11526f0752b520318c80be68bf0131704b36b7976572e",
1478+
"2dca8f05ed5d58e0f2e13c49ae40480c0f99dfcd9268521eea6c81c6387b66c4",
1479+
"051a93d697db02afd3dcf8414ecb906a114a2bfdb6b06c95d41798d1801b3cbd",
1480+
"2e275fef7a0bdb0a2aea77d8ec5817e66e199b3d55bc0fa308dcdda74e85060b",
1481+
"1c7e33c2a72d6e12a31eababad3dbc388525135628102bb64742d9e325f43410",
1482+
"115dc41fa10b2dbf99036f252ad6f00e8876b22f02cb4738dc4413b22ea9b2df",
1483+
# Second pairing
1484+
"09a760ea8f9bd87dc258a949395a03f7d2500c6e72c61f570986328a096b610a",
1485+
"148027063c072345298117eb2cb980ad79601db31cc69bba6bcbe4937ada6720",
1486+
"198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c2",
1487+
"1800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed",
1488+
"090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b",
1489+
"12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa",
1490+
],
1491+
id="ec_pairing_2_pair",
1492+
),
1493+
pytest.param(
1494+
0x08,
1495+
[
1496+
# First pairing
1497+
"0000000000000000000000000000000000000000000000000000000000000000",
1498+
"0000000000000000000000000000000000000000000000000000000000000000",
1499+
"0ef4aac9b7954d5fc6eafae7f4f4c2a732ab05b45f8d50d102cee4973f36eb2c",
1500+
"23db7d30c99e0a2a7f3bb5cd1f04635aaea58732b58887df93d9239c28230d28",
1501+
"2bd99d31a5054f2556d226f2e5ef0e075423d8604178b2e2c08006311caee54f",
1502+
"0f11afb0c6073d12d21b13f4f78210e8ca9a66729206d3fcc2c1b04824c425f2",
1503+
# Second pairing
1504+
"0000000000000000000000000000000000000000000000000000000000000000",
1505+
"198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c2",
1506+
"1800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed",
1507+
"090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b",
1508+
"12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa",
1509+
# Third pairing
1510+
"0000000000000000000000000000000000000000000000000000000000000000",
1511+
"198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c2",
1512+
"1800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed",
1513+
"090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b",
1514+
"12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa",
1515+
],
1516+
id="ec_pairing_3_pair",
1517+
),
1518+
pytest.param(
1519+
0x08,
1520+
[
1521+
# First pairing
1522+
"24ab69f46f3e3333027d67d51af71571141bd5652b9829157a3c5d1268461984",
1523+
"0f0e1495665bccf97d627b714e8a49e9c77c21e8d5b383ad7dde7e50040d0f62",
1524+
"2cab595b9d579f8b82e433249b83ae1d7b62d7073a4f67cb3aeb9b316988907f",
1525+
"1326d1905ffde0c77e8ebd98257aa239b05ae76c8ec7723ec19bbc8282b0debe",
1526+
"130502106676b537e01cc356765e91c005d6c4bd1a75f5f6d41d2556c73e56ac",
1527+
"2dc4cb08068b4aa5f14b7f1096ab35d5c13d78319ec7e66e9f67a1ff20cbbf03",
1528+
# Second pairing
1529+
"1459f4140b271cbc8746de9dfcb477d5b72d50ef95bec5fef4a68dd69ddfdb2e",
1530+
"2c589584551d16a9723b5d356d1ee2066d10381555cdc739e39efca2612fc544",
1531+
"229ab0abdb0a7d1a5f0d93fb36ce41e12a31ba52fd9e3c27bebce524ab6c4e9b",
1532+
"00f8756832b244377d06e2d00eeb95ec8096dcfd81f4e4931b50fea23c04a2fe",
1533+
"29605352ce973ec48d1ab2c8355643c999b70ff771946078b519c556058c3d56",
1534+
"059a65ae6e0189d4e04a966140aa40f781a1345824a90a91bb035e12ad29af1d",
1535+
# Third pairing
1536+
"1459f4140b271cbc8746de9dfcb477d5b72d50ef95bec5fef4a68dd69ddfdb2e",
1537+
"2c589584551d16a9723b5d356d1ee2066d10381555cdc739e39efca2612fc544",
1538+
"229ab0abdb0a7d1a5f0d93fb36ce41e12a31ba52fd9e3c27bebce524ab6c4e9b",
1539+
"00f8756832b244377d06e2d00eeb95ec8096dcfd81f4e4931b50fea23c04a2fe",
1540+
"29605352ce973ec48d1ab2c8355643c999b70ff771946078b519c556058c3d56",
1541+
"059a65ae6e0189d4e04a966140aa40f781a1345824a90a91bb035e12ad29af1d",
1542+
# Fourth pairing
1543+
"24ab69f46f3e3333027d67d51af71571141bd5652b9829157a3c5d1268461984",
1544+
"0f0e1495665bccf97d627b714e8a49e9c77c21e8d5b383ad7dde7e50040d0f62",
1545+
"2cab595b9d579f8b82e433249b83ae1d7b62d7073a4f67cb3aeb9b316988907f",
1546+
"1326d1905ffde0c77e8ebd98257aa239b05ae76c8ec7723ec19bbc8282b0debe",
1547+
"130502106676b537e01cc356765e91c005d6c4bd1a75f5f6d41d2556c73e56ac",
1548+
"2dc4cb08068b4aa5f14b7f1096ab35d5c13d78319ec7e66e9f67a1ff20cbbf03",
1549+
],
1550+
id="ec_pairing_4_pair",
1551+
),
1552+
pytest.param(
1553+
0x08,
1554+
[
1555+
# First pairing
1556+
"1147057b17237df94a3186435acf66924e1d382b8c935fdd493ceb38c38def73",
1557+
"03cd046286139915160357ce5b29b9ea28bfb781b71734455d20ef1a64be76ca",
1558+
"0daa7cc4983cf74c94607519df747f61e317307c449bafb6923f6d6a65299a7e",
1559+
"1d48db8f275830859fd61370addbc5d5ef3f0ce7491d16918e065f7e3727439d",
1560+
"1ca8ac2f4a0f540e5505edbe1d15d13899a2a0dfccb012d068134ac66edec625",
1561+
"2162c315417d1d12c9d7028c5619015391003a9006d4d8979784c7af2c4537a3",
1562+
# Second pairing
1563+
"0d221a19ca86dafa8cb804daff78fd3d1bed30aa32e7d4029b1aa69afda2d750",
1564+
"018628c766a98de1d0cca887a6d90303e68a7729490f25f937b76b57624ba0be",
1565+
"14550ccf7139312da6fa9eb1259c6365b0bd688a27473ccb42bc5cd6f14c8abd",
1566+
"165f8721ee9f614382c8c7edb103c941d3a55c1849c9787f34317777d5d9365b",
1567+
"0d19da7439edb573a1b3e357faade63d5d68b6031771fd911459b7ab0bda9d3f",
1568+
"25a50a44d10c99c5f107e3b3874f717873cb2d4674699a468204df27c0c50a9a",
1569+
# Third pairing
1570+
"0d7136c59b907615e1b45cf730fbfd6cf38b7e126e85e52be804620a23ace4fb",
1571+
"03e80c29d24ed5cc407329ae093bb1be00f9e3c9332f532bc3658937110d7607",
1572+
"2129813bd7247065ac58eac42c81e874044e199f48c12aa749a9fe6bb6e4bddc",
1573+
"1b72b9ab4579283e62445555d5b2921424213d09a776152361c46988b82be8a7",
1574+
"111bc8198f932e379b8f9825f01af0f5e5cacbf8bfe274bf674f6eaa6e338e04",
1575+
"259f58d438fd6391e158c991e155966218e6a432703a84068a32543965749857",
1576+
# Fourth pairing
1577+
"1ba47a91d487cce77aa78390a295df54d9351637d67810c400415fb374278e3f",
1578+
"24318bbc05a4e4d779b9498075841c360c6973c1c51dea254281829bbc9aef33",
1579+
"198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c2",
1580+
"1800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed",
1581+
"090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b",
1582+
"12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa",
1583+
# Fifth pairing
1584+
"1e219772c16eee72450bbf43e9cadae7bf6b2e6ae6637cfeb1d1e8965287acfb",
1585+
"0347e7bf4245debd3d00b6f51d2d50fd718e6769352f4fe1db0efe492fed2fc3",
1586+
"24fdcc7d4ed0953e3dad500c7ef9836fc61ded44ba454ec76f0a6d0687f4c1b4",
1587+
"282b18f7e59c1db4852e622919b2ce9aa5980ca883eac312049c19a3deb79f6d",
1588+
"0c9d6ce303b7811dd7ea506c8fa124837405bd209b8731bda79a66eb7206277b",
1589+
"1ac5dac62d2332faa8069faca3b0d27fcdf95d8c8bafc9074ee72b5c1f33aa70",
1590+
],
1591+
id="ec_pairing_5_pair",
1592+
),
1593+
pytest.param(
1594+
0x08,
1595+
[
1596+
"0000000000000000000000000000000000000000000000000000000000000000",
1597+
],
1598+
id="ec_pairing_1_pair_empty",
1599+
),
13521600
pytest.param(
13531601
Blake2bSpec.BLAKE2_PRECOMPILE_ADDRESS,
13541602
[

0 commit comments

Comments
 (0)