Skip to content

Commit ecb77a5

Browse files
authored
precompiles: Add expmod benchmarks (#1196)
1 parent 62ac627 commit ecb77a5

File tree

2 files changed

+36
-2
lines changed

2 files changed

+36
-2
lines changed

test/precompiles_bench/precompiles_bench.cpp

+35-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
99
#include <array>
1010
#include <memory>
1111

12+
#ifdef EVMONE_PRECOMPILES_GMP
13+
#include <state/precompiles_gmp.hpp>
14+
#endif
15+
1216
#ifdef EVMONE_PRECOMPILES_SILKPRE
1317
#include <state/precompiles_silkpre.hpp>
1418
#endif
@@ -28,11 +32,13 @@ constexpr auto analyze<PrecompileId::identity> = identity_analyze;
2832
template <>
2933
constexpr auto analyze<PrecompileId::ecrecover> = ecrecover_analyze;
3034
template <>
35+
[[maybe_unused]] constexpr auto analyze<PrecompileId::expmod> = expmod_analyze;
36+
template <>
3137
constexpr auto analyze<PrecompileId::ecadd> = ecadd_analyze;
3238
template <>
3339
constexpr auto analyze<PrecompileId::ecmul> = ecmul_analyze;
3440
template <>
35-
[[maybe_unused]] constexpr auto analyze<PrecompileId::ecpairing> = ecpairing_analyze;
41+
constexpr auto analyze<PrecompileId::ecpairing> = ecpairing_analyze;
3642
template <>
3743
constexpr auto analyze<PrecompileId::point_evaluation> = point_evaluation_analyze;
3844

@@ -65,6 +71,22 @@ const inline std::array inputs<PrecompileId::ecrecover>{
6571

6672
};
6773

74+
template <>
75+
const inline std::array inputs<PrecompileId::expmod>{
76+
"0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000203038f57abc91abff7dcbc5b55cd6aa454503850ce62e941f81273ba6008e82a530644e72e131a029b85045b68181585d2833e84879b9709143e1f593efffffff30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001"_hex,
77+
"000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000020239ea33f993130afd678f591cd1685d44779b7717156f2a715220955e10a234830644e72e131a029b85045b68181585d2833e84879b9709143e1f593efffffff30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001"_hex,
78+
"0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000203914aeddf3af39bd5e0e231d09a8438cf38c7d0274a5aa61bd9a2bbcd77fd2c7ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc63254fffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551"_hex,
79+
"00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000002027c816cec3d048eaae22d948c42f9d803d765d0827a7b49e01273031566eed92ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc63254fffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551"_hex,
80+
"0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000200cf7d1e109b5b8f6a682be51e152d3668acc1b4d762ecbf5cdca7a807cc5fe4cffffffff00000001000000000000000000000000fffffffffffffffffffffffdffffffff00000001000000000000000000000000ffffffffffffffffffffffff"_hex,
81+
"0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000203a122fd889a09d3a19c587ab486d5a6a2b39836d6d665c6ebad2a68a615e6736ffffffff00000001000000000000000000000000fffffffffffffffffffffffdffffffff00000001000000000000000000000000ffffffffffffffffffffffff"_hex,
82+
"000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000020161455250ee1d7ff76e4eb2f6a16a636a4bc69dd20416f6ea5647b7fb311e9320000000000000000000000000000000000000000000000000000000000ffffff30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001"_hex,
83+
"0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000200d96428856df2f1b728ce955f28f50befa405a61e8984acbaf678af9be0e0dfd000000000000000000000000000000000000000000000000000000000100000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001"_hex,
84+
"0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000202369f74b39dddb516bb17d20f24ba72c8f0ec09bea7d7f38ad54dbc3cfd4b4760c19139cb84c680a6e14116da060561765e05aa45a1c72a34f082305b61f3f5230644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd47"_hex,
85+
"00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000002019b01e88eb4a62d7df2da453deb859f6113004675370b6f54ff9f20499cfc4cf0c19139cb84c680a6e14116da060561765e05aa45a1c72a34f082305b61f3f5230644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd47"_hex,
86+
"000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000020c943d0f2b95b88d8a3ad7782221659f05cb697047a9793a65ec7db59439afb0a3fffffffffffffffffffffffffffffffffffffffffffffffffffffffbfffff0cfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"_hex,
87+
"000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000020307c38188f3b804fc399b7195579269fd60fddbe7e6d8174b3ad38b64b1bb2fa3fffffffffffffffffffffffffffffffffffffffffffffffffffffffbfffff0cfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"_hex,
88+
};
89+
6890
template <>
6991
const inline std::array inputs<PrecompileId::ecadd>{
7092
"0f25929bcb43d5a57391564615c9e70a992b10eafa4db109709649cf48c50dd2"
@@ -184,6 +206,18 @@ BENCHMARK_TEMPLATE(precompile, PrecompileId::ecrecover, libsecp256k1);
184206
#endif
185207
} // namespace bench_ecrecovery
186208

209+
namespace bench_expmod
210+
{
211+
#ifdef EVMONE_PRECOMPILES_GMP
212+
constexpr auto gmp = expmod_execute;
213+
BENCHMARK(precompile<PrecompileId::expmod, gmp>);
214+
#endif
215+
#ifdef EVMONE_PRECOMPILES_SILKPRE
216+
constexpr auto silkpre = silkpre_expmod_execute;
217+
BENCHMARK(precompile<PrecompileId::expmod, silkpre>);
218+
#endif
219+
} // namespace bench_expmod
220+
187221
namespace bench_ecadd
188222
{
189223
constexpr auto evmmax_cpp = ecadd_execute;

test/state/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ option(EVMONE_PRECOMPILES_GMP "Enable precompiles implementations via the GMP/MP
7878
if(EVMONE_PRECOMPILES_GMP)
7979
find_package(GMP REQUIRED)
8080
target_link_libraries(evmone-state PRIVATE GMP::gmp)
81-
target_compile_definitions(evmone-state PRIVATE EVMONE_PRECOMPILES_GMP=1)
81+
target_compile_definitions(evmone-state PUBLIC EVMONE_PRECOMPILES_GMP=1)
8282
target_sources(
8383
evmone-state PRIVATE
8484
precompiles_gmp.hpp

0 commit comments

Comments
 (0)