-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
bug: lookup and return validators from liquid stake accounting functions #17436
Merged
alexanderbez
merged 10 commits into
cosmos:feature/v0.45.x-ics-lsm
from
iqlusioninc:lsm-validator-bond-consensus-error
Aug 18, 2023
Merged
bug: lookup and return validators from liquid stake accounting functions #17436
alexanderbez
merged 10 commits into
cosmos:feature/v0.45.x-ics-lsm
from
iqlusioninc:lsm-validator-bond-consensus-error
Aug 18, 2023
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mpoke
approved these changes
Aug 18, 2023
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.
alexanderbez
merged commit Aug 18, 2023
0af2f4d
into
cosmos:feature/v0.45.x-ics-lsm
23 of 31 checks passed
xlab
pushed a commit
to persistenceOne/cosmos-sdk
that referenced
this pull request
Sep 20, 2023
Related to cosmos#17436 which we didn't merge from upstream there. The validator struct was not updated properly during MsgDelegate / MsgUndelegate is some cases, where there was a validator bond involved.
ajeet97
pushed a commit
to persistenceOne/cosmos-sdk
that referenced
this pull request
Mar 19, 2024
Related to cosmos#17436 which we didn't merge from upstream there. The validator struct was not updated properly during MsgDelegate / MsgUndelegate is some cases, where there was a validator bond involved.
ajeet97
pushed a commit
to persistenceOne/cosmos-sdk
that referenced
this pull request
Mar 20, 2024
Related to cosmos#17436 which we didn't merge from upstream there. The validator struct was not updated properly during MsgDelegate / MsgUndelegate is some cases, where there was a validator bond involved.
ajeet97
pushed a commit
to persistenceOne/cosmos-sdk
that referenced
this pull request
Mar 20, 2024
Related to cosmos#17436 which we didn't merge from upstream there. The validator struct was not updated properly during MsgDelegate / MsgUndelegate is some cases, where there was a validator bond involved.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview of Bug
When re-delegating to an existing validator bond delegation, upstream changes to the validator struct are accidentally overwritten, preventing a validator set update. More specifically, in
msg_server.Delegate
,IncreaseValidatorBondShares
is called with avalidator
struct; however, at this point, the validator struct is stale relative to the underlying validator in the store, which was modified above byk.Delegate
. Thus, the validator in the store is overwritten.[Relevant code]
Solution
The solution to the specific bug was to re-read the validator from the store in
IncreaseValidatorBondShares
so it doesn't accidentally overwrite earlier changes.To be extra cautious, the other validator liquid stake accounting functions were also modified with this same behavior. Additionally, a validator was returned from the function rather than relying on the calling function to refresh the variable with a lookup after. This was not entirely necessary and, there are no bugs in these other functions to our knowledge, but this should give some added protection should these functions be re-ordered in the future.
Old:
New:
Brief Changelog
IncreaseValidatorBond
,SafelyDecreaseValidatorBond
,SafelyIncreaseValidatorLiquidShares
andDecreaseValidatorLiquidShares
to take the val address as a parameter and do a validator lookup at the startSafelyIncreaseValidatorLiquidShares
andDecreaseValidatorLiquidShares
to return the new validator from the function