-
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
staking msgServer.CancelUnbondingDelegation
could possibly choose mismatching UnbondingDelegationEntry
to cancel
#12931
Comments
This we discussed internally with @gsk967 and possible solution can be:
cc @gsk967 |
We can update the docs now to clarify this behavior and introduce a breaking chage in next release which would allow delegator to either force cancel-ubd with exact amount or allow a partical cancellation of ubd. |
I think there are two issues here:
|
It is expected behavior as per the implementation. But best solution can be giving an option for the
Yes, that should fix your simulations. You can consider multiple unbondings from different delegators<>validator combo if required. |
I think the current behavior is misleading. |
Yes, the fix for this can be either to consdier unbonding-entry input from user or match exact amount |
For better UX, I would advise for matching exact amount instead of asking user to input the ubd entry. If there are multiple entries of same amount, I don't see any problem in cancelling any one of them. |
agreed. |
…e` failure (#12933) ## Description --- This is a temporary fix targeted at staking module simulation for #12931. We should randomly choose the unbonding entry `CreationHeight`, and then fetch the first entry that matches the `CreationHeight` to make sure we can get the correct entry balance. ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [ ] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] added `!` to the type prefix if API or client breaking change - [ ] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/main/CONTRIBUTING.md#pr-targeting)) - [ ] provided a link to the relevant issue or specification - [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/main/docs/building-modules) - [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/main/CONTRIBUTING.md#testing) - [ ] added a changelog entry to `CHANGELOG.md` - [ ] included comments for [documenting Go code](https://blog.golang.org/godoc) - [ ] updated the relevant documentation or specification - [ ] reviewed "Files changed" and left comments if necessary - [ ] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed `!` in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed - [ ] reviewed state machine logic - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage - [ ] manually tested (if applicable)
@anilcse @marbar3778 @alexanderbez When delegator broadcast the multiple unbonding delegations msgs on same height, we are generating the multiple records with same instead of this way, can't we just update the Sample Querysimd q staking unbonding-delegations cosmos1huplz9naax6qe0g2pdaupjcmv4y0fxvhhkte73
pagination:
next_key: null
total: "0"
unbonding_responses:
- delegator_address: cosmos1huplz9naax6qe0g2pdaupjcmv4y0fxvhhkte73
entries:
- balance: "100"
completion_time: "2022-09-08T10:35:22.277275812Z"
creation_height: "110"
initial_balance: "100"
- balance: "20"
completion_time: "2022-09-08T10:35:22.277275812Z"
creation_height: "110"
initial_balance: "20"
- balance: "30"
completion_time: "2022-09-08T10:35:22.277275812Z"
creation_height: "110"
initial_balance: "30"
validator_address: cosmosvaloper16q08najdx3gu3gk5zyh4p7sa94knz4ukj5kclz
Solution:// AddEntry - append entry to the unbonding delegation
func (ubd *UnbondingDelegation) AddEntry(creationHeight int64, minTime time.Time, balance math.Int) {
// Check the entries exists with creation_height and complete_time
var entryIndex int64 = -1
for index, ubdEntry := ranage ubd.Entries {
if ubdEntry.CreationHeight == creationHeight && ubdEntry.CompletionTime.Equal(minTime){
entryIndex = index
break
}
}
// entryIndex exists
if entryIndex != -1 {
ubdEntry = ubd.Entries[entryIndex]
ubdEntry.Balance = ubdEntry.Balance.Add(balance)
ubdEntry.InitialBalance = ubdEntry.InitialBalance.Add(balance)
// update the entry
ubd.Entries[entryIndex] = ubdEntry
}else{
// append the new unbond delegation entry
entry := NewUnbondingDelegationEntry(creationHeight, minTime, balance)
ubd.Entries = append(ubd.Entries, entry)
}
} |
This would save us some storage too. Agree with this |
@gsk967 I can't see why that wouldn't work. I think it makes sense. Let's do it! |
…e` failure (#12933) ## Description --- This is a temporary fix targeted at staking module simulation for #12931. We should randomly choose the unbonding entry `CreationHeight`, and then fetch the first entry that matches the `CreationHeight` to make sure we can get the correct entry balance. ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [ ] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] added `!` to the type prefix if API or client breaking change - [ ] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/main/CONTRIBUTING.md#pr-targeting)) - [ ] provided a link to the relevant issue or specification - [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/main/docs/building-modules) - [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/main/CONTRIBUTING.md#testing) - [ ] added a changelog entry to `CHANGELOG.md` - [ ] included comments for [documenting Go code](https://blog.golang.org/godoc) - [ ] updated the relevant documentation or specification - [ ] reviewed "Files changed" and left comments if necessary - [ ] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed `!` in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed - [ ] reviewed state machine logic - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage - [ ] manually tested (if applicable) (cherry picked from commit e130915) # Conflicts: # go.work.sum
## Description This pull request contains the fix regarding cancel unbonding delegations It will remove duplicate ubdEntries which have same `creation_height` and create new ubdEntry with updated `balance` and `initial_balance` Closes: cosmos#12931 --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [ ] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] added `!` to the type prefix if API or client breaking change - [ ] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/main/CONTRIBUTING.md#pr-targeting)) - [ ] provided a link to the relevant issue or specification - [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/main/docs/building-modules) - [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/main/CONTRIBUTING.md#testing) - [ ] added a changelog entry to `CHANGELOG.md` - [ ] included comments for [documenting Go code](https://blog.golang.org/godoc) - [ ] updated the relevant documentation or specification - [ ] reviewed "Files changed" and left comments if necessary - [ ] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed `!` in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed - [ ] reviewed state machine logic - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage - [ ] manually tested (if applicable)
Summary of Bug
this is an issue found in cronos latest simulation: crypto-org-chain/cronos#645.
Generally speaking, two
UnbondingDelegationEntry
could have the sameCreationHeight
, and the current unbond entry matching logic ofmsgServer.CancelUnbondingDelegation
is ambiguous when dealing with this case.Version
main and v0.46
Steps to Reproduce
refer to crypto-org-chain/cronos#645
The text was updated successfully, but these errors were encountered: