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

Update EIP-2537: Gas pricing MAP, MUL and ADD operations #9097

Merged
merged 6 commits into from
Dec 18, 2024

Conversation

MarekM25
Copy link
Contributor

@MarekM25 MarekM25 commented Dec 6, 2024

Nethermind proposal of MUL and ADD operations. The speed of this precompile measured on Intel NUC 11 Intel Core i7-1165G7 and Nethermind client (EcRecover ~80 mgas/s). Full proposal: https://github.com/Marchhill/bls-precompile-benchmarks/blob/main/proposed-changes.md

g1add-1: 86.61 mgas/s (83.42-90.05)
g1mul-1: 86.90 mgas/s (83.24-90.89)
g2add-1: 82.34 mgas/s (78.50-86.58)
g2mul-1: 93.40 mgas/s (88.11-99.38)
mapfp-1: 89.96 mgas/s (85.91-94.40)

ATTENTION: ERC-RELATED PULL REQUESTS NOW OCCUR IN ETHEREUM/ERCS

--

When opening a pull request to submit a new EIP, please use the suggested template: https://github.com/ethereum/EIPs/blob/master/eip-template.md

We have a GitHub bot that automatically merges some PRs. It will merge yours immediately if certain criteria are met:

  • The PR edits only existing draft PRs.
  • The build passes.
  • Your GitHub username or email address is listed in the 'author' header of all affected PRs, inside .
  • If matching on email address, the email address is the one publicly listed on your GitHub profile.

@MarekM25 MarekM25 requested a review from eth-bot as a code owner December 6, 2024 10:59
@github-actions github-actions bot added c-update Modifies an existing proposal s-review This EIP is in Review t-core labels Dec 6, 2024
@eth-bot
Copy link
Collaborator

eth-bot commented Dec 6, 2024

✅ All reviewers have approved.

@eth-bot eth-bot added the a-review Waiting on author to review label Dec 6, 2024
@eth-bot eth-bot changed the title [EIP-2537] Gas pricing MUL and ADD operations Update EIP-2537: [EIP-2537] Gas pricing MUL and ADD operations Dec 6, 2024
@MarekM25 MarekM25 changed the title Update EIP-2537: [EIP-2537] Gas pricing MUL and ADD operations Update EIP-2537: Gas pricing MUL and ADD operations Dec 6, 2024
@MarekM25 MarekM25 changed the title Update EIP-2537: Gas pricing MUL and ADD operations Update EIP-2537: Gas pricing MAP-G1, MUL and ADD operations Dec 6, 2024
@MarekM25 MarekM25 changed the title Update EIP-2537: Gas pricing MAP-G1, MUL and ADD operations Update EIP-2537: Gas pricing MAP, MUL and ADD operations Dec 6, 2024
EIPS/eip-2537.md Outdated

#### Fp2-to-G2 mapping operation

Fp2 -> G2 mapping is `75000` gas
Fp2 -> G2 mapping is `14055` gas
Copy link
Member

Choose a reason for hiding this comment

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

Maybe let's put 15000 here as you have in your NUC benchmarks. This number of from my BLST benchmarks. Considering this was 5x higher originally and nobody complained...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated to 17000 based on the feedback from @jwasinger

garyschulte added a commit to garyschulte/besu that referenced this pull request Dec 9, 2024
@garyschulte
Copy link
Contributor

👍 from besu, implementing these gas costs and benchmarking on a nuc 13:
https://gist.github.com/garyschulte/c3e7a8015c8014707303e7f3a83dd117

garyschulte added a commit to garyschulte/besu that referenced this pull request Dec 9, 2024
@mratsim
Copy link
Contributor

mratsim commented Dec 16, 2024

On constantine, on a Ryzen 7840U (laptop Zen4 15W~28W, 2023).

If needed, my lowest power PC that can run an Ethereum node (no Rpi4 anymore) has a i3-1220P (28W, 2021).

  • g1add: 500 -> 375
  • g2add: 800 -> 600
  • g2mul: 45000 -> 22500
  • g2map: 75000 -> 23800
git clone https://github.com/mratsim/constantine
cd constantine
CC=clang nimble bench_eth_evm_precompiles

Before

--------------------------------------------------------------------------------------------------------------------------------
BLS12_G1ADD                  500 gas     171.70 MGas/s      343406.593 ops/s         2912 ns/op         9592 CPU cycles (approx)
BLS12_G2ADD                  800 gas     204.08 MGas/s      255102.041 ops/s         3920 ns/op        12913 CPU cycles (approx)
BLS12_G1MUL                12000 gas     143.37 MGas/s       11947.717 ops/s        83698 ns/op       275678 CPU cycles (approx)
BLS12_G2MUL                45000 gas     335.51 MGas/s        7455.843 ops/s       134123 ns/op       441766 CPU cycles (approx)
BLS12_MAP_FP_TO_G1          5500 gas     164.65 MGas/s       29936.535 ops/s        33404 ns/op       110023 CPU cycles (approx)
BLS12_MAP_FP2_TO_G2        75000 gas     680.56 MGas/s        9074.163 ops/s       110203 ns/op       362978 CPU cycles (approx)
--------------------------------------------------------------------------------------------------------------------------------

After

--------------------------------------------------------------------------------------------------------------------------------
BLS12_G1ADD                  375 gas     128.73 MGas/s      343288.706 ops/s         2913 ns/op         9597 CPU cycles (approx)
BLS12_G2ADD                  600 gas     153.37 MGas/s      255623.722 ops/s         3912 ns/op        12887 CPU cycles (approx)
BLS12_G1MUL                12000 gas     140.73 MGas/s       11727.867 ops/s        85267 ns/op       280844 CPU cycles (approx)
BLS12_G2MUL                22500 gas     171.93 MGas/s        7641.521 ops/s       130864 ns/op       431031 CPU cycles (approx)
BLS12_MAP_FP_TO_G1          5500 gas     158.72 MGas/s       28857.530 ops/s        34653 ns/op       114139 CPU cycles (approx)
BLS12_MAP_FP2_TO_G2        23800 gas     217.35 MGas/s        9132.420 ops/s       109500 ns/op       360665 CPU cycles (approx)
--------------------------------------------------------------------------------------------------------------------------------

gas schedule can easily be edited here https://github.com/mratsim/constantine/blob/7cffd2f/benchmarks/bench_eth_evm_precompiles.nim#L45-L61

Copy link
Member

@ralexstokes ralexstokes left a comment

Choose a reason for hiding this comment

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

lgtm

@eth-bot eth-bot enabled auto-merge (squash) December 18, 2024 15:34
Copy link
Collaborator

@eth-bot eth-bot left a comment

Choose a reason for hiding this comment

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

All Reviewers Have Approved; Performing Automatic Merge...

@eth-bot eth-bot merged commit 10de931 into ethereum:master Dec 18, 2024
10 checks passed
danceratopz added a commit to ethereum/execution-spec-tests that referenced this pull request Dec 18, 2024
marioevz pushed a commit to ethereum/execution-spec-tests that referenced this pull request Dec 19, 2024
* chore(tests): pairing ops gas pricing cf ethereum/EIPs#9098

* chore(tests): MAP, MUL & ADD gas pricing cf ethereum/EIPs#9097

* chore(tests): update G1/add G2 msm discount tables ethereum/EIPs#9116
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a-review Waiting on author to review c-update Modifies an existing proposal s-review This EIP is in Review t-core
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants