-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Explicit bounds for premium config params in VRFCoordinatorV2_5 #12314
Explicit bounds for premium config params in VRFCoordinatorV2_5 #12314
Conversation
ibrajer
commented
Mar 6, 2024
•
edited
Loading
edited
- setConfig method will revert if premium percentages are above 155
- added unit tests for coverage
I see that you haven't updated any CHANGELOG files. Would it make sense to do so? |
Go solidity wrappers are out-of-date, regenerate them via the |
@@ -179,6 +180,9 @@ contract VRFCoordinatorV2_5 is VRF, SubscriptionAPI, IVRFCoordinatorV2Plus { | |||
if (fulfillmentFlatFeeNativePPM > 0 && fulfillmentFlatFeeLinkDiscountPPM >= fulfillmentFlatFeeNativePPM) { | |||
revert LinkDiscountTooHigh(fulfillmentFlatFeeLinkDiscountPPM, fulfillmentFlatFeeNativePPM); | |||
} | |||
if (nativePremiumPercentage > 100 || linkPremiumPercentage > 100) { |
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.
You could define a MAX_PREMIUM_PERCENTAGE
constant similar to the MAX_REQUEST_CONFIRMATIONS
above. Don't worry about gas cost as constants are replaced during compile time. Defining such a constant will make the boundaries for the config clearer as well.
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.
Makes sense!
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.
Is there a situation where we would like to charge nativePremiumPercentage or linkPremiumPercentage as 150%. For example, when the value of LINK is very low against native.
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.
According to this piece of code I figured that 100 should be the upper bound limit. As for your question about the described situation and what should we do in this case, probably @jinhoonbang is a better person to answer that.
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.
Setting the premium percentage as 150% means we are charging 250% of the gas cost. I don't think the LINK / Native price matters here as we're still getting the same value just denominated in different tokens. I would think the ability to set the premium percentages differently for native or link acts another mechanism to incentive people to pay in one of them.
If we want to be very safe, we can set the limit to the max of 155
@@ -179,6 +180,9 @@ contract VRFCoordinatorV2_5 is VRF, SubscriptionAPI, IVRFCoordinatorV2Plus { | |||
if (fulfillmentFlatFeeNativePPM > 0 && fulfillmentFlatFeeLinkDiscountPPM >= fulfillmentFlatFeeNativePPM) { | |||
revert LinkDiscountTooHigh(fulfillmentFlatFeeLinkDiscountPPM, fulfillmentFlatFeeNativePPM); | |||
} | |||
if (nativePremiumPercentage > 100 || linkPremiumPercentage > 100) { | |||
revert InvalidPremiumPercentage(nativePremiumPercentage, linkPremiumPercentage); |
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.
Not too sure if we need to follow the pattern of emitting the max value in the event.
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.
Where did you see this pattern so I can take a look?
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.
Seems like the errors are emitting the allowable values as well.
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.
I see - would that mean I have to create two categories of errors, one for native and another one for LINK? Or would just one be enough and you should be able to figure it out based on the have
and want
values returned? Consider I don't want to blow up the contract size just because I want to keep things clear.
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.
I would say just the max value is enough? And since each premium percentage has the same max value, we could just keep it to a single error.
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.
Should we send a string "native" or "link" in the event to identify which premium is over the bounds?
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.
We can but I don't think it's needed? Like just stare at the two numbers and see which is over the limit. lol
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.
I thought about it at the beginning, but I agree with @leeyikjiun here. Just by looking at the numbers, it should be clear which one is it. No need to increase the contract size with additional data.
bc8a2a3
to
973ebae
Compare
c54f031
to
656ad0e
Compare
@ibrajer Please address the merge conflicts |
21e4dcf
to
6548ae0
Compare
* setConfig method will revert if premium percentages are above 100 * added unit tests for coverage
6548ae0
to
9315d5d
Compare
Quality Gate passedIssues Measures |
* Explicit bounds for premium config params in VRFCoordinatorV2_5 * setConfig method will revert if premium percentages are above 100 * added unit tests for coverage * Generated Go wrappers and executed prettier tool * Added constants for percentage bounds and changed revert error * Removed min boundary * Added changeset * Changed upper premium percentage boundary to 155
* Explicit bounds for premium config params in VRFCoordinatorV2_5 * setConfig method will revert if premium percentages are above 100 * added unit tests for coverage * Generated Go wrappers and executed prettier tool * Added constants for percentage bounds and changed revert error * Removed min boundary * Added changeset * Changed upper premium percentage boundary to 155
* Explicit bounds for premium config params in VRFCoordinatorV2_5 * setConfig method will revert if premium percentages are above 100 * added unit tests for coverage * Generated Go wrappers and executed prettier tool * Added constants for percentage bounds and changed revert error * Removed min boundary * Added changeset * Changed upper premium percentage boundary to 155
* Explicit bounds for premium config params in VRFCoordinatorV2_5 * setConfig method will revert if premium percentages are above 100 * added unit tests for coverage * Generated Go wrappers and executed prettier tool * Added constants for percentage bounds and changed revert error * Removed min boundary * Added changeset * Changed upper premium percentage boundary to 155
* Explicit bounds for premium config params in VRFCoordinatorV2_5 * setConfig method will revert if premium percentages are above 100 * added unit tests for coverage * Generated Go wrappers and executed prettier tool * Added constants for percentage bounds and changed revert error * Removed min boundary * Added changeset * Changed upper premium percentage boundary to 155
* Explicit bounds for premium config params in VRFCoordinatorV2_5 * setConfig method will revert if premium percentages are above 100 * added unit tests for coverage * Generated Go wrappers and executed prettier tool * Added constants for percentage bounds and changed revert error * Removed min boundary * Added changeset * Changed upper premium percentage boundary to 155