-
Notifications
You must be signed in to change notification settings - Fork 607
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
[Uptime Incentives]: Use gauge duration as uptime with appropriate validation and fallback #7417
Conversation
@@ -520,8 +534,24 @@ func (s *KeeperTestSuite) TestDistribute_ExternalIncentives_NoLock() { | |||
"perpetual, 2 coins, paid over 1 epoch": withIsPerpetual(withGaugeCoins(defaultTest, defaultBothCoins), true), | |||
"non-perpetual, 1 coin, paid over 2 epochs": withNumEpochs(defaultTest, 2), | |||
"non-perpetual, 2 coins, paid over 3 epochs": withNumEpochs(withGaugeCoins(defaultTest, defaultBothCoins), 3), | |||
"error: balancer pool id": withError(withPoolId(defaultTest, defaultBalancerPool)), | |||
"error: inactive gauge": withError(withNumEpochs(defaultTest, 0)), |
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.
Note: diff seems to be rendering poorly – these are moved to the end of the block
"error: balancer pool id": withError(withPoolId(defaultTest, defaultBalancerPool)), | ||
"error: inactive gauge": withError(withNumEpochs(defaultTest, 0)), | ||
|
||
// We expect incentives with the set uptime to be created |
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 a huge fan of this test format due to poor readability for more complex test cases, but opted to conform to it since refactoring would be higher overhead to discuss/implement/review
// If uptime is not authorized, we expect to fall back to default | ||
expectedUptime := types.DefaultConcentratedUptime | ||
if tc.authorizedUptime { | ||
expectedUptime = tc.distrTo.Duration | ||
} |
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.
nit: suggest hardcoding the expected uptime in the test case struct as dynamically selecting the expected value in the test case logic is prone to test configuration bugs, especially, as the test case grows
x/incentives/keeper/distribute.go
Outdated
@@ -602,6 +602,27 @@ func (k Keeper) distributeInternal( | |||
// Get distribution epoch duration. This is used to calculate the emission rate. | |||
currentEpoch := k.GetEpochInfo(ctx) | |||
|
|||
// Validate that the gauge's corresponding uptime is authorized. | |||
authorizedUptimes := k.clk.GetParams(ctx).AuthorizedUptimes |
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 think we should pass authorized uptimes as a func input param instead of retrieving it for every single gauge, this could be expensive.
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.
Hmm I agree that this might be expensive, but unfortunately distributeInternal
is used for all gauges, not just CL gauges, so authorized uptimes as a func input would be super odd. Happy to continue discussion offline
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.
This is only in the noLock gauge (not superfluid) and can be altered state compatibly so i'm fine w/ filing this into a GH issue and doing later!
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.
Nice work, I do think the change should be made to not pull module params for every single gauge though before merge.
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.
This looks good to me! Would suggest breaking up this new code into its own function, but good to merge once doing that for me
…lidation and fallback (#7417) * implement validation, fallback, and wiring for using gauge duration as uptime * add changelog * extract uptime fetch into helper
Closes: #7369
What is the purpose of the change
This PR wires up gauge duration to be used as uptime for CL gauges. It also adds validation logic that checks the duration against authorized uptimes and falls back to the default authorized uptime of 1ns if it it invalid or unauthorized. Please see the linked issue for discussion on why this is necessary/important.
Testing and Verifying
All core changes are tested in
distribute_test.go
Documentation and Release Note
Unreleased
section ofCHANGELOG.md
?Where is the change documented?
x/{module}/README.md
)