-
Notifications
You must be signed in to change notification settings - Fork 592
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
test/feat: incentive accumulator truncation #7395
Conversation
ctx.EventManager().EmitEvent(sdk.NewEvent( | ||
types.IncentiveTruncationPlaceholderName, | ||
sdk.NewAttribute("pool_id", strconv.FormatUint(poolID, 10)), | ||
sdk.NewAttribute("total_liq", liquidityInAccum.String()), | ||
sdk.NewAttribute("per_unit_liq", incentivesPerLiquidity.String()), | ||
sdk.NewAttribute("total_amt", totalEmittedAmount.String()), | ||
)) | ||
|
||
telemetry.IncrCounter(1, types.IncentiveTruncationPlaceholderName) | ||
ctx.Logger().Error(types.IncentiveTruncationPlaceholderName, "pool_id", poolID, "total_liq", liquidityInAccum, "per_unit_liq", incentivesPerLiquidity, "total_amt", totalEmittedAmount) |
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 should create an alert for these and a Grafana dashboard cc: @niccoloraspa @alessandrolomanto
// Reset events | ||
s.Ctx = s.Ctx.WithEventManager(sdk.NewEventManager()) | ||
|
||
s.Ctx = s.Ctx.WithBlockTime(s.Ctx.BlockTime().Add(time.Minute * 51)) |
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.
Shouldn't we only need to add 1 minute here? Since we already went ahead 50 minutes above?
@@ -48,4 +48,6 @@ const ( | |||
AttributeKeySpreadRewardGrowthOppositeDirectionOfLastTraversal = "spread_reward_growth" | |||
AttributeKeyUptimeGrowthOppositeDirectionOfLastTraversal = "uptime_growth" | |||
AttributeNewOwner = "new_owner" | |||
|
|||
IncentiveTruncationPlaceholderName = "concentrated_liquidity_incentive_truncation" |
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 remove placeholder name?
* test/feat: incentive accumulator truncation * updates (cherry picked from commit 8eaaae9)
Closes: #XXX
What is the purpose of the change
This PR shows that there is a chance of incentives being truncated due to large liquidity value.
We observed this in pool 1423 where both tokens have 18 decimal precision.
In such a case, the incentive record is updated correctly, not the global pool accumulator. The reason the pool accumulator is not updated is that it is a per unit of liquidity value (divided by liquidity). This division leads to truncation to zero.
It has been determined that no funds are at risk. The incentives are eventually distributed if either:
a) A long time without an update to the pool state occurs (at least 51 minutes with the current pool setup configuration)
b) Current tick liquidity becomes smaller
We confirmed that other pools are highly unlikely to be affected by setting a breakpoint with a debugger in-place of where the new event is emitted.
Going forward, we will have event, metric and log emitted if truncation happens.
Possible Solutions
To prevent this from happening again, we will evaluate the following approaches: