Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace substrate-bn with matter-labs eip1962 #1520

Open
Rjected opened this issue Jun 13, 2024 · 2 comments
Open

Replace substrate-bn with matter-labs eip1962 #1520

Rjected opened this issue Jun 13, 2024 · 2 comments
Assignees
Labels
feature New feature or lib ability refactor Refactor of the code

Comments

@Rjected
Copy link
Collaborator

Rjected commented Jun 13, 2024

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

@Rjected Rjected self-assigned this Jun 13, 2024
@gakonst
Copy link
Collaborator

gakonst commented Jun 13, 2024

Seems fine (it has parity types in dev deps)

@rakita rakita added feature New feature or lib ability refactor Refactor of the code labels Jun 13, 2024
@DaniPopes
Copy link
Collaborator

DaniPopes commented Jun 14, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or lib ability refactor Refactor of the code
Projects
None yet
Development

No branches or pull requests

4 participants