evmone
evmone copied to clipboard
Optimize BN254 ecmul with the field endomorphism
- ecmul is optimized using curve endomorphism and "Shamir's trick" multiplication.
- Based on Faster Point Multiplication on Elliptic Curves with Efficient Endomorphisms
- v1 and v2 vectors taken from cloudflare implementation
Before:
(vvenv) rodia@MacBook-Pro-2 evmone % ./build/bin/evmone-precompiles-bench --benchmark_filter=ecmul
Unable to determine clock rate from sysctl: hw.cpufrequency: No such file or directory
This does not affect benchmark measurements, only the metadata output.
***WARNING*** Failed to set thread affinity. Estimated CPU frequency may be incorrect.
2025-12-02T12:37:39+01:00
Running ./build/bin/evmone-precompiles-bench
Run on (12 X 24 MHz CPU s)
CPU Caches:
L1 Data 64 KiB
L1 Instruction 128 KiB
L2 Unified 4096 KiB (x12)
Load Average: 1.82, 2.09, 1.99
------------------------------------------------------------------------------------------------------
Benchmark Time CPU Iterations UserCounters...
------------------------------------------------------------------------------------------------------
precompile<PrecompileId::ecmul, evmmax_cpp> 56080 ns 56081 ns 12380 gas_rate=106.989M/s gas_used=60k
After:
(vvenv) rodia@MacBook-Pro-2 evmone % ./build/bin/evmone-precompiles-bench --benchmark_filter=ecmul
Unable to determine clock rate from sysctl: hw.cpufrequency: No such file or directory
This does not affect benchmark measurements, only the metadata output.
***WARNING*** Failed to set thread affinity. Estimated CPU frequency may be incorrect.
2025-12-02T12:38:10+01:00
Running ./build/bin/evmone-precompiles-bench
Run on (12 X 24 MHz CPU s)
CPU Caches:
L1 Data 64 KiB
L1 Instruction 128 KiB
L2 Unified 4096 KiB (x12)
Load Average: 1.75, 2.05, 1.97
------------------------------------------------------------------------------------------------------
Benchmark Time CPU Iterations UserCounters...
------------------------------------------------------------------------------------------------------
precompile<PrecompileId::ecmul, evmmax_cpp> 37996 ns 37987 ns 18480 gas_rate=157.947M/s gas_used=60k
Codecov Report
:x: Patch coverage is 96.50000% with 7 lines in your changes missing coverage. Please review.
:white_check_mark: Project coverage is 81.66%. Comparing base (eeb288a) to head (c09a5a9).
:warning: Report is 1 commits behind head on master.
| Files with missing lines | Patch % | Lines |
|---|---|---|
| test/unittests/evmmax_bn254_mul_test.cpp | 96.64% | 0 Missing and 5 partials :warning: |
| lib/evmone_precompiles/ecc.hpp | 95.34% | 1 Missing and 1 partial :warning: |
Additional details and impacted files
@@ Coverage Diff @@
## master #1389 +/- ##
==========================================
+ Coverage 81.44% 81.66% +0.22%
==========================================
Files 152 152
Lines 13396 13596 +200
Branches 3211 3226 +15
==========================================
+ Hits 10910 11103 +193
- Misses 342 343 +1
- Partials 2144 2150 +6
| Flag | Coverage Δ | |
|---|---|---|
| eest-develop | 91.13% <100.00%> (+0.04%) |
:arrow_up: |
| eest-develop-gmp | 29.08% <17.00%> (-0.26%) |
:arrow_down: |
| eest-legacy | 15.32% <0.00%> (-0.23%) |
:arrow_down: |
| eest-legacy-silkpre | 24.42% <17.00%> (-0.19%) |
:arrow_down: |
| evmone-unittests | 76.21% <96.50%> (+0.30%) |
:arrow_up: |
Flags with carried forward coverage won't be shown. Click here to find out more.
| Components | Coverage Δ | |
|---|---|---|
| core | 94.42% <96.07%> (+0.01%) |
:arrow_up: |
| tooling | 83.63% <ø> (ø) |
|
| tests | 73.55% <96.64%> (+0.46%) |
:arrow_up: |
| Files with missing lines | Coverage Δ | |
|---|---|---|
| lib/evmone_precompiles/bn254.cpp | 100.00% <100.00%> (ø) |
|
| lib/evmone_precompiles/ecc.hpp | 95.81% <95.34%> (-0.10%) |
:arrow_down: |
| test/unittests/evmmax_bn254_mul_test.cpp | 92.26% <96.64%> (+34.36%) |
:arrow_up: |
:rocket: New features to boost your workflow:
- :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
Improvement 72 Mgas/s → 117 Mgas/s (+63%).
Comparing o/ecmul to o/ecmul-endo
Benchmark Time CPU Time Old Time New CPU Old CPU New
-------------------------------------------------------------------------------------------------------------------------------------------------
precompile<PrecompileId::ecmul, evmmax_cpp>_pvalue 0.0001 0.0001 U Test, Repetitions: 11 vs 11
precompile<PrecompileId::ecmul, evmmax_cpp>_mean -0.3707 -0.3707 80940 50937 80920 50925
precompile<PrecompileId::ecmul, evmmax_cpp>_median -0.3695 -0.3695 80762 50922 80746 50909
precompile<PrecompileId::ecmul, evmmax_cpp>_stddev -0.8101 -0.8133 367 70 371 69
precompile<PrecompileId::ecmul, evmmax_cpp>_cv -0.6982 -0.7034 0 0 0 0
OVERALL_GEOMEAN -0.3707 -0.3707 0 0 0 0
The cost of decompose is 0.20%, out of which 0.14% is the division by DET.