-
Notifications
You must be signed in to change notification settings - Fork 207
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
[LSM] Prevent ICAs to validator's with slash query in progress #844
Conversation
This pull request has been automatically marked as stale because it has not had any recent activity. It will be closed if no further activity occurs. Thank you! |
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.
Overall much cleaner, but I have questions about if this is actually going to change the expected target outcome of rebalances, unbondings, etc. from what would have happened because of the validators removed from the set being considered. Will this also affect non-lsm related ICAs by removing the validators in these helpers rather than checking at the time of ICA?
…ess during rebalancing
LGTM! This will be much cleaner to think about in the future by splitting it up this way to filter at the validator level instead of carrying the ICQ status all the way until ICAs need to be performed. |
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.
My main question is whether we should exclude from the weight calc in GetTargetValAmtsForHostZone
the weight of the val who has an ICQ in flight
Co-authored-by: riley-stride <104941670+riley-stride@users.noreply.github.com>
How rebalancing work if a ICQ for the val in flight? I not rebalance that validator, wouldn't it break the weight state more than rebalancing with previous ratio? |
The validator's delegations will just remain unchanged (i.e. it will be excluded from rebalancing) |
Context
A race condition can occur between a slash query and an ICA that modifies a validator's delegation. This manifests itself in two flavors:
We identify if the overlap was possible by checking the following in the ICQ Ack:
However, as if this wasn't complex enough already, there is a small edge case where an undelegation and delegation could have simultaneously occurred with equal amounts in between the slash query. This would be an example of case #1, but where our first check is unable to identify the overlap because the net delegation did not actually change.
While the likelihood of this edge case is low, the impact is severe. The solution in this PR is to exclude validator's with a slash query in progress when submitting ICAs.
Brief Changelog
GetTotalValidatorDelegations
function since we have this value on the host zoneImpact described in psuedo-code
Considering it's a bit tough to review this without diving deeper into the code, here's some more detail on the changes to each ICA type.
For context, this is all a consequence of the change to
GetTargetValAmts
which now (a) ignores validators with a slash query in progress and (b) does not sort the array on the host zone struct (it sorts a copy)Delegation
Before:
After:
Undelegation
Before:
After:
Redelegate
Before:
After: