-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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: Clarify the gast cost calculation formula for MSM #9245
Update EIP-2537: Clarify the gast cost calculation formula for MSM #9245
Conversation
✅ All reviewers have approved. |
I might be wrong here, but doesn't the formula: |
yes but even if we calculate |
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
|
Ah ok good point, I see now. I am rather sure the original intent was for integer division, so the formula should likely have read: (maybe an older version of the BLS gas schedule could work with or without integer division yielding the same results)
EDIT: never mind, if Out of interest, why do you choose to group the formula like this?
(and not I have not tested, but does this yield different results from the first formula when applied to the relevant |
Seems it would, integer division would drop the last significant digit for discounts that are not multiples of 10. |
It seems to be it was the opposite, the constants in the spec were selected in a way the kind of the division don't matter.
Because |
Using formula |
Why cannot we just have a table with exact costs for each input length instead of discount table and the formula? |
I don't see that that this is a problem? As long as we all use the same formula |
@chfast Ah great, thanks for the insight, this makes a lot of sense. For completeness / "correctness" my preference would go to |
acd98fd
to
6b14aa8
Compare
multiplication_cost
for G2 update to make it divisible by 1000
ACD decided to stay with old formula with clarification that we are using an integer division. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Love to clarification for //
being integer division 👍 😄
This PR should be closed without merging |
I think we agreed during ACDE to change this as in this PR. |
6b14aa8
to
e10561f
Compare
@MarekM25 it now just clarifies to use integer division rather than changing gas costs, so I think it's good to merge |
yes, my bad, good to merge indeed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agreed to merge following ethereum/pm#1227
There was a problem hiding this 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 PR fixes value ofmultiplication_cost
for G2 which according to comment in theG1/G2 MSM
section saying that we want to avoid non-integer arithmetic should be divisible by1000
themultiplier
.Keeping this as it is now makes the result of the formula depends on the order of multiplications.
This PR clarifies gas cost formula calculation for MSM precompile.