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: Remove redundant MUL precompiles #8945

Merged
merged 1 commit into from
Dec 19, 2024

Conversation

chfast
Copy link
Member

@chfast chfast commented Oct 9, 2024

This removes BLS12_G1MUL and BLS12_G2MUL precompiles because they are trivially replaceable by corresponding MSM precompiles.

This reduces the number of precompile's addresses defined in this EIP from 9 to 7. The addresses of remaining 7 precompiles are changed to be continues.

The Rationale entry describes why this change make sense. Additionally, the cost of MSM for single input (k==1) has been corrected to match the original MUL cost. The specification now suggests how this case should be implemented.
Moreover, because of the ABI compatibility between MUL and MSM all existing tests for MULs can be easily converted to tests for MSMs.

The PoC of MUL and MSM precompiles equivalence is provided in evmone PR#1042.

The adjustment of the MSM implementation for single input in evmone PR#1046.

@chfast chfast requested a review from eth-bot as a code owner October 9, 2024 13:12
@github-actions github-actions bot added c-update Modifies an existing proposal s-review This EIP is in Review t-core labels Oct 9, 2024
@eth-bot
Copy link
Collaborator

eth-bot commented Oct 9, 2024

✅ All reviewers have approved.

@eth-bot eth-bot added the a-review Waiting on author to review label Oct 9, 2024
Copy link
Member

@jochem-brouwer jochem-brouwer left a comment

Choose a reason for hiding this comment

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

One comment, some line got deleted which likely should not be deleted

EIPS/eip-2537.md Show resolved Hide resolved
@ralexstokes
Copy link
Member

I think we have historically preferred to not overload precompiles like this, but I'd love to hear what others think

Copy link
Contributor

@cygnusv cygnusv left a comment

Choose a reason for hiding this comment

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

seven

EIPS/eip-2537.md Outdated Show resolved Hide resolved
@asanso
Copy link
Contributor

asanso commented Oct 12, 2024

not sure as well, it's kind of matter of taste here. At this point we could even remove BLS12_G1ADD and BLS12_G2ADD because they are trivially replaceable by corresponding MSM precompiles......

@chfast
Copy link
Member Author

chfast commented Dec 18, 2024

not sure as well, it's kind of matter of taste here. At this point we could even remove BLS12_G1ADD and BLS12_G2ADD because they are trivially replaceable by corresponding MSM precompiles......

The ADD situation is different because: semantic (no subgroup check), ABI (no scalar input), and gas costs differ.

We could actually extend ADD to MULTI_ADD in the future upgrade in (almost) backward compatible manner.

@chfast chfast force-pushed the eip2537/remove_muls branch from 40cc72d to 6ff64d1 Compare December 18, 2024 14:56
@chfast chfast changed the title Update EIP-2537: Remove MUL precompiles Update EIP-2537: Remove redundant MUL precompiles Dec 18, 2024
EIPS/eip-2537.md Outdated
@@ -277,10 +251,12 @@ MSMs are expected to be performed by Pippenger's algorithm (we can also say that

To avoid non-integer arithmetic, the call cost is calculated as `(k * multiplication_cost * discount) / multiplier` where `multiplier = 1000`, `k` is a number of (scalar, point) pairs for the call, `multiplication_cost` is a corresponding single multiplication call cost for G1/G2.
Copy link
Contributor

Choose a reason for hiding this comment

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

We remove MUL, so we have to update this reference: "multiplication_cost"

Copy link
Member

Choose a reason for hiding this comment

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

I think the intent is that removing the precompile is separate from the gas schedule of a multiplication

my read is that multiplication_cost here would be either the G1 or G2 "base" gas cost depending on the nature of the MSM

Copy link
Member

Choose a reason for hiding this comment

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

going to go ahead and approve, we can update this EIP later if needed, but it looks good to me at the moment

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.

thanks for the update! decided to move ahead w/ this on ACDE #202

@chfast
Copy link
Member Author

chfast commented Dec 19, 2024

I'd like to rebase this on the merged gas cost changes and proof read it.

@ralexstokes
Copy link
Member

I'd like to rebase this on the merged gas cost changes and proof read it.

ah ok, sounds good

it looks like EIP bot is not responding anyway so I think you can do this in this PR

@chfast chfast force-pushed the eip2537/remove_muls branch from 6ff64d1 to 5f042c9 Compare December 19, 2024 17:29
@eth-bot eth-bot enabled auto-merge (squash) December 19, 2024 17:30
eth-bot
eth-bot previously approved these changes Dec 19, 2024
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...

This removes `BLS12_G1MUL` and `BLS12_G2MUL` precompiles because
they are trivially replaceable by corresponding MSM precompiles.

This reduces the number of precompile's addresses defined in this EIP
from 9 to 7. The addresses of remaining 7 precompiles are changed
to be continues.

The Rationale entry describes why this change make sense.
Additionally, the cost of MSM for single input (`k==1`) has been
corrected to match the original MUL cost. The specification now
suggests how this case should be implemented.
Moreover, because of the ABI compatibility between MUL and MSM
all existing tests for MULs can be easily converted to tests for MSMs.

The PoC of MUL and MSM precompiles equivalence is provided in
[evmone PR#1042](ethereum/evmone#1042).
auto-merge was automatically disabled December 19, 2024 17:36

Head branch was pushed to by a user without write access

@chfast chfast force-pushed the eip2537/remove_muls branch from 5f042c9 to b412323 Compare December 19, 2024 17:36
@eth-bot eth-bot enabled auto-merge (squash) December 19, 2024 17:37
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 eb4715f into ethereum:master Dec 19, 2024
10 checks passed
garyschulte added a commit to garyschulte/besu that referenced this pull request Dec 19, 2024
garyschulte added a commit to garyschulte/besu that referenced this pull request Dec 19, 2024
garyschulte added a commit to garyschulte/besu that referenced this pull request Dec 20, 2024
garyschulte added a commit to garyschulte/besu that referenced this pull request Dec 20, 2024
garyschulte added a commit to garyschulte/besu that referenced this pull request Dec 20, 2024
siladu pushed a commit to siladu/besu that referenced this pull request Dec 20, 2024
https://github.com/ethereum/EIPs/pull/9097/files
https://github.com/ethereum/EIPs/pull/9098/files
https://github.com/ethereum/EIPs/pull/9116/files

Signed-off-by: garyschulte <[email protected]>

adjust unit test gas costs, fix offset-by-one bug in the discount table

Signed-off-by: garyschulte <[email protected]>

implement bump in gas cost for bls map functions according to ethereum/EIPs@92c94cf

Signed-off-by: garyschulte <[email protected]>

using Pawel's suggested discount table from ethereum/EIPs#9116 (comment)

Signed-off-by: garyschulte <[email protected]>

use bls pairing costs from https://github.com/ethereum/EIPs/pull/9098/files

Signed-off-by: garyschulte <[email protected]>

remove MUL per ethereum/EIPs#8945

Signed-off-by: garyschulte <[email protected]>

fix g1 msm max discount case, add g2 msm max discount case

Signed-off-by: garyschulte <[email protected]>

remove bls mul ops from benchmark subcommand

Signed-off-by: garyschulte <[email protected]>

use besu-native 1.1.1

Signed-off-by: garyschulte <[email protected]>
gurukamath added a commit to gurukamath/execution-specs that referenced this pull request Dec 20, 2024
gurukamath added a commit to gurukamath/execution-specs that referenced this pull request Dec 20, 2024
chfast added a commit to ethereum/evmone that referenced this pull request Dec 20, 2024
Remove redundant G1/G2 MUL precompiles easily replaceable with MSMs.
Spec update: ethereum/EIPs#8945.
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.

7 participants