Skip to content

execution/vm: optimize KZG point evaluation precompile (~24% faster)#20273

Merged
yperbasis merged 4 commits intomainfrom
yperbasis/point_evaluation
Apr 7, 2026
Merged

execution/vm: optimize KZG point evaluation precompile (~24% faster)#20273
yperbasis merged 4 commits intomainfrom
yperbasis/point_evaluation

Conversation

@yperbasis
Copy link
Copy Markdown
Member

@yperbasis yperbasis commented Apr 1, 2026

Part of #14522

Summary

Benchmark (Apple M2 Max)

name                                    old time/op    new time/op    delta
PrecompiledPointEvaluation/Gas=50000      1.287ms        0.978ms      -24%

name                                    old mgas/s     new mgas/s     delta
PrecompiledPointEvaluation/Gas=50000      38.9           51.0         +31%

name                                    old allocs/op  new allocs/op  delta
PrecompiledPointEvaluation/Gas=50000      47             30           -36%

name                                    old bytes/op   new bytes/op   delta
PrecompiledPointEvaluation/Gas=50000      6424           4488         -30%

Test plan

  • go test -run TestPrecompiledPointEvaluation ./execution/vm/
  • All go-eth-kzg consensus spec tests pass
  • CI

🤖 Generated with Claude Code

Use optimized go-eth-kzg with JointScalarMultiplication and
PairingCheckFixedQ for the EIP-4844 point evaluation precompile.

Upstream PR: crate-crypto/go-eth-kzg#131

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@yperbasis yperbasis marked this pull request as ready for review April 1, 2026 16:25
@yperbasis yperbasis requested review from awskii and chfast April 1, 2026 16:26
Copy link
Copy Markdown
Member

@chfast chfast left a comment

Choose a reason for hiding this comment

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

Really cool. I guess we wait for the upstream review?

@yperbasis
Copy link
Copy Markdown
Member Author

Really cool. I guess we wait for the upstream review?

I think we can use the optimization in branch main of erigon even before it's upstreamed to go-eth-kzg, given that the tests passed and we'll have time to test it further before cutting release 3.5.

Copy link
Copy Markdown
Collaborator

@Giulio2002 Giulio2002 left a comment

Choose a reason for hiding this comment

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

LGTM — dependency bump replacing go-eth-kzg with erigontech fork for KZG optimization, go.mod/go.sum only

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR aims to speed up the EIP-4844 KZG point evaluation precompile by switching the build to an optimized go-eth-kzg implementation (via a go.mod replace to an erigontech fork/pinned commit).

Changes:

  • Add a replace directive to redirect github.com/crate-crypto/go-eth-kzg to github.com/erigontech/go-eth-kzg at a specific pseudo-version.
  • Update go.sum to reflect the new module source and remove the old sums for the replaced module.

Reviewed changes

Copilot reviewed 1 out of 2 changed files in this pull request and generated 2 comments.

File Description
go.mod Adds a replace override for go-eth-kzg to use an erigontech fork/pinned commit.
go.sum Removes sums for the old crate-crypto module version and adds sums for the replacement module version.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread go.mod
google.golang.org/protobuf/cmd/protoc-gen-go
)

replace github.com/crate-crypto/go-eth-kzg => github.com/erigontech/go-eth-kzg v0.0.0-20260401161010-070339460d07
Copy link

Copilot AI Apr 6, 2026

Choose a reason for hiding this comment

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

The PR title/description describes runtime changes to the EIP-4844 point evaluation precompile, but this diff only introduces a module replacement. If the precompile optimizations are part of this PR, include the corresponding code changes; otherwise update the PR title/description to reflect that this is a dependency override only.

Copilot uses AI. Check for mistakes.
Comment thread go.mod
Comment on lines +482 to +483

replace github.com/crate-crypto/go-eth-kzg => github.com/erigontech/go-eth-kzg v0.0.0-20260401161010-070339460d07
Copy link

Copilot AI Apr 6, 2026

Choose a reason for hiding this comment

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

This replace directive is impactful and currently lacks any in-file context (e.g., why a fork is needed and when it should be removed). Consider adding an inline comment with the upstream PR/link and grouping this replace near the existing replace directives at the top of the file to keep go.mod structure consistent.

Copilot uses AI. Check for mistakes.
@yperbasis yperbasis added this pull request to the merge queue Apr 7, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Apr 7, 2026
@yperbasis yperbasis added this pull request to the merge queue Apr 7, 2026
Merged via the queue into main with commit d81bdea Apr 7, 2026
40 checks passed
@yperbasis yperbasis deleted the yperbasis/point_evaluation branch April 7, 2026 14:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants