bluealloy/revm

Replace substrate-bn with matter-labs eip1962

Opened this issue · 2 comments

The alt-bn precompiles from https://github.com/matter-labs/eip1962 are considerably faster than the substrate ones, based on initial benchmarking:

Crypto Precompile benchmarks/precompile bench | arkworks bn128 add precompile
                        time:   [2.7888 µs 2.7939 µs 2.7997 µs]
                        change: [-1.7842% -1.1497% -0.5635%] (p = 0.00 < 0.05)
                        Change within noise threshold.
Crypto Precompile benchmarks/precompile bench | halo2curves bn128 add precompile
                        time:   [2.3058 µs 2.3086 µs 2.3133 µs]
                        change: [-2.9118% -2.2444% -1.6204%] (p = 0.00 < 0.05)
                        Performance has improved.
Crypto Precompile benchmarks/precompile bench | matter bn128 add precompile
                        time:   [1.5072 µs 1.5104 µs 1.5144 µs]
                        change: [-1.4613% -0.9181% -0.3976%] (p = 0.00 < 0.05)
                        Change within noise threshold.
Crypto Precompile benchmarks/precompile bench | bn128 add precompile
                        time:   [2.3209 µs 2.3236 µs 2.3273 µs]
                        change: [-0.3982% -0.2114% -0.0431%] (p = 0.02 < 0.05)
                        Change within noise threshold.

We should use the matter labs implementation, published on crates as eth_pairings

Seems fine (it has parity types in dev deps)

FYI use cargo-criterion to avoid unnecessary output (like Found X outliers among Y measurements) and nice charts in target/criterion :D