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: multiplication_cost for G2 update to make it divisible by 1000 #9245

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

rodiazet
Copy link
Contributor

This PR fixes value of multiplication_cost for G2 which according to comment in the G1/G2 MSM section saying that we want to avoid non-integer arithmetic should be divisible by 1000 the multiplier.
Keeping this as it is now makes the result of the formula depends on the order of multiplications.

@rodiazet rodiazet requested a review from eth-bot as a code owner January 15, 2025 16:44
@github-actions github-actions bot added c-update Modifies an existing proposal s-review This EIP is in Review t-core labels Jan 15, 2025
@eth-bot
Copy link
Collaborator

eth-bot commented Jan 15, 2025

File EIPS/eip-2537.md

Requires 1 more reviewers from @asanso, @ineffectualproperty, @ralexstokes, @shamatar

@eth-bot eth-bot added the a-review Waiting on author to review label Jan 15, 2025
@jochem-brouwer
Copy link
Member

I might be wrong here, but doesn't the formula: (k * multiplication_cost * discount) / multiplier already explicitly state that the numerator should be calculated first and then thus dividing by the multiplier? The discount numbers are not divisibile by 1000 also (except 1000). I think what is meant with "To avoid non-integer arithmetic" that the formula is not: k * multiplication_cost * discount where discount for example could be (2 multiplications): 0.949 and not 949.

@rodiazet
Copy link
Contributor Author

yes but even if we calculate (k * multiplication_cost * discount) we cannot be sure that the result will be divisible by 1000. So we can change to make it divisible or add comment that this division must be integer division.

@chfast
Copy link
Member

chfast commented Jan 15, 2025

I might be wrong here, but doesn't the formula: (k * multiplication_cost * discount) / multiplier already explicitly state that the numerator should be calculated first and then thus dividing by the multiplier? The discount numbers are not divisibile by 1000 also (except 1000). I think what is meant with "To avoid non-integer arithmetic" that the formula is not: k * multiplication_cost * discount where discount for example could be (2 multiplications): 0.949 and not 949.

Not exactly. If you follow the formula strictly e.g. for G2MSM k=3 you get 62302.5. So you would need to specify that the division in the formula is integer division.

But the spec does the opposite. It says that the constants have been chosen carefully so that the division happens without fractions. However, we haven't read the spec and updated the constants so that this is now in conflict.

If we want to pick the "let's do integer division" path, I'd argue the formula should group constants like this

(multiplication_cost * discount // multiplier) * k

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.

4 participants