Skip to content

deps: upgrade gnark-crypto v0.19.1 → v0.20.0#19808

Merged
taratorio merged 2 commits into
mainfrom
yperbasis/gnark
Mar 12, 2026
Merged

deps: upgrade gnark-crypto v0.19.1 → v0.20.0#19808
taratorio merged 2 commits into
mainfrom
yperbasis/gnark

Conversation

@yperbasis

Copy link
Copy Markdown
Member

Summary

  • Upgrade github.com/consensys/gnark-crypto from v0.19.1 to v0.20.0
  • Picks up GLV/wNAF scalar multiplication and pairing pre-computation optimizations benefiting BN254 and BLS12-381 precompiled contracts
  • Transitive dep bits-and-blooms/bitset bumped v1.24.2 → v1.24.4

Test plan

  • go test ./execution/vm/... passes
  • make erigon builds successfully
  • CI green

🤖 Generated with Claude Code

Picks up GLV/wNAF scalar multiplication and pairing pre-computation
optimizations that benefit BN254 and BLS12-381 precompiled contracts.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
gnark-crypto v0.20.0 declares go 1.25.7, which forces our minimum
go version up from 1.25.0. Drop the separate toolchain directive
since go 1.25.7 subsumes it.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@yperbasis yperbasis added performance dependencies Pull requests that update a dependency file labels Mar 11, 2026

@Giulio2002 Giulio2002 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM — dependency bump gnark-crypto v0.19.1 → v0.20.0 and bitset patch update

@yperbasis

Copy link
Copy Markdown
Member Author

Benchmark: bn254 & BLS12-381 precompiles — gnark-crypto v0.20.0 vs v0.19.1

Machine: Apple M2 Max, -benchtime=3s -count=5

Note: Both benchmarks ran concurrently, so the "old" (main) numbers have slightly higher variance due to resource contention. The large improvements on cdetrio12–14 are likely contention artifacts; real improvement for those is probably ~5–7%, consistent with cdetrio11.

                                                        │  old (v0.19.1)  │       new (v0.20.0)                  │
                                                        │     sec/op      │    sec/op     vs base                │
PrecompiledBn254Add/chfast1-Gas=150-12                          1.419µ ± ∞    1.321µ ± ∞   -6.91% (p=0.008 n=5)
PrecompiledBn254Add/chfast2-Gas=150-12                          1.443µ ± ∞    1.330µ ± ∞   -7.83% (p=0.008 n=5)
PrecompiledBn254Add/cdetrio1-Gas=150-12                         53.81n ± ∞    51.59n ± ∞   -4.13% (p=0.008 n=5)
PrecompiledBn254Add/cdetrio3-Gas=150-12                         69.86n ± ∞    67.21n ± ∞   -3.79% (p=0.008 n=5)
PrecompiledBn254Add/cdetrio4-Gas=150-12                         84.83n ± ∞    81.64n ± ∞   -3.76% (p=0.008 n=5)
PrecompiledBn254Add/cdetrio5-Gas=150-12                         55.96n ± ∞    54.92n ± ∞   -1.86% (p=0.008 n=5)
PrecompiledBn254Add/cdetrio7-Gas=150-12                         160.9n ± ∞    148.4n ± ∞   -7.77% (p=0.008 n=5)
PrecompiledBn254Add/cdetrio8-Gas=150-12                         172.0n ± ∞    158.5n ± ∞   -7.85% (p=0.008 n=5)
PrecompiledBn254Add/cdetrio9-Gas=150-12                         149.3n ± ∞    146.0n ± ∞   -2.21% (p=0.008 n=5)
PrecompiledBn254Add/cdetrio10-Gas=150-12                        155.0n ± ∞    148.2n ± ∞   -4.39% (p=0.008 n=5)
PrecompiledBn254Add/cdetrio11-Gas=150-12                        1.545µ ± ∞    1.445µ ± ∞   -6.47% (p=0.008 n=5)
PrecompiledBn254ScalarMul/chfast1-Gas=6000-12                   15.33µ ± ∞    13.96µ ± ∞   -8.93% (p=0.008 n=5)
PrecompiledBn254ScalarMul/chfast2-Gas=6000-12                   35.13µ ± ∞    28.75µ ± ∞  -18.16% (p=0.008 n=5)
PrecompiledBn254ScalarMul/chfast3-Gas=6000-12                   34.25µ ± ∞    36.38µ ± ∞   +6.24% (p=0.008 n=5)
PrecompiledBn254ScalarMul/cdetrio1-Gas=6000-12                  40.42µ ± ∞    36.36µ ± ∞  -10.07% (p=0.008 n=5)
PrecompiledBn254ScalarMul/cdetrio6-Gas=6000-12                  38.25µ ± ∞    36.40µ ± ∞   -4.84% (p=0.008 n=5)
PrecompiledBn254ScalarMul/cdetrio11-Gas=6000-12                 38.12µ ± ∞    36.33µ ± ∞   -4.69% (p=0.008 n=5)
PrecompiledBn254Pairing/jeff1-Gas=113000-12                     904.7µ ± ∞    860.9µ ± ∞   -4.84% (p=0.008 n=5)
PrecompiledBn254Pairing/jeff2-Gas=113000-12                     903.8µ ± ∞    858.7µ ± ∞   -5.00% (p=0.008 n=5)
PrecompiledBn254Pairing/jeff3-Gas=113000-12                     878.1µ ± ∞    856.1µ ± ∞   -2.51% (p=0.008 n=5)
PrecompiledBn254Pairing/jeff4-Gas=147000-12                     1.123m ± ∞    1.099m ± ∞   -2.13% (p=0.008 n=5)
PrecompiledBn254Pairing/jeff5-Gas=147000-12                     1.126m ± ∞    1.103m ± ∞   -1.98% (p=0.008 n=5)
PrecompiledBn254Pairing/jeff6-Gas=113000-12                     878.0µ ± ∞    857.5µ ± ∞   -2.34% (p=0.008 n=5)
PrecompiledBn254Pairing/one_point-Gas=79000-12                  633.0µ ± ∞    617.7µ ± ∞   -2.41% (p=0.008 n=5)
PrecompiledBn254Pairing/two_point_match_3-Gas=113000-12         879.5µ ± ∞    867.6µ ± ∞   -1.36% (p=0.008 n=5)
PrecompiledBn254Pairing/two_point_match_4-Gas=113000-12         877.9µ ± ∞    867.2µ ± ∞   -1.22% (p=0.008 n=5)
PrecompiledBn254Pairing/ten_point_match_1-Gas=385000-12         2.175m ± ∞    2.140m ± ∞   -1.62% (p=0.008 n=5)
PrecompiledBn254Pairing/ten_point_match_2-Gas=385000-12         2.660m ± ∞    2.636m ± ∞   -0.91% (p=0.008 n=5)
geomean                                                         10.47µ        9.593µ       -8.42%

BLS12-381 G1Add partial data (benchmarks killed before all ~500 test vectors completed): no measurable difference (~2930–2950 ns/op on both branches).

Summary: gnark-crypto v0.20.0 is faster across all three bn254 precompiles. Biggest gains in ScalarMul (−5% to −18%), followed by Add (−4% to −8%) and Pairing (−1% to −5%). Geomean: −8.4%.

@taratorio taratorio merged commit 38f2050 into main Mar 12, 2026
38 checks passed
@taratorio taratorio deleted the yperbasis/gnark branch March 12, 2026 02:03
erigon-copilot Bot pushed a commit that referenced this pull request Mar 12, 2026
)"

This reverts commit 38f2050.

gnark-crypto v0.20.0 brings in a go.mod that requires go 1.25.7,
which forces the root go.mod to 1.25.7. This breaks hive CI because
the erigon Dockerfile uses golang:1.25.0-trixie as builder and builds
with GOTOOLCHAIN=local — the version patch sed only matched -alpine.

Co-authored-by: Giulio rebuffo <giulio.rebuffo@gmail.com>

Co-authored-by: Giulio Rebuffo <giulio.rebuffo@gmail.com>
yperbasis added a commit that referenced this pull request Mar 12, 2026
yperbasis added a commit that referenced this pull request Mar 12, 2026
## Summary
- The Hive workflow sed pattern only matched `golang:X.Y.Z-alpine`, but
the upstream Hive `Dockerfile.git` uses `golang:X.Y.Z-trixie`
- This caused the Go version to never be patched, so when #19808 bumped
`go.mod` from `go 1.25.0` to `go 1.25.7`, the Hive container still had
Go 1.25.0 and the build failed with `go: ../../go.mod requires go >=
1.25.7`
- Fix: match any distro suffix
(`s|golang:[0-9.]*-|golang:${go_version}-|`) instead of hardcoding
`-alpine`

Fixes the Hive EEST failure from #19808. Once merged, the gnark-crypto
v0.20.0 upgrade can be re-landed.

## Test plan
- [ ] Verify Hive tests pass on this branch (the workflow fix itself is
exercised when the Hive job runs)
- [ ] After merge, re-land gnark-crypto v0.20.0 upgrade and confirm Hive
EEST passes

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Pull requests that update a dependency file performance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants