Skip to content
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

fix: fix the cancel unbond #12967

Merged
merged 21 commits into from
Aug 24, 2022
Merged

fix: fix the cancel unbond #12967

merged 21 commits into from
Aug 24, 2022

Conversation

gsk967
Copy link
Contributor

@gsk967 gsk967 commented Aug 19, 2022

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: #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 in the PR title
  • added ! to the type prefix if API or client breaking change
  • targeted the correct branch (see PR Targeting)
  • provided a link to the relevant issue or specification
  • followed the guidelines for building modules
  • included the necessary unit and integration tests
  • added a changelog entry to CHANGELOG.md
  • included comments for documenting Go code
  • 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 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)

@gsk967 gsk967 marked this pull request as ready for review August 19, 2022 07:43
@gsk967 gsk967 requested a review from a team as a code owner August 19, 2022 07:43
test.go Fixed Show fixed Hide fixed
x/staking/migrations/v5/store.go Fixed Show fixed Hide fixed
@codecov
Copy link

codecov bot commented Aug 19, 2022

Codecov Report

Merging #12967 (c6654a8) into main (07c549b) will decrease coverage by 0.15%.
The diff coverage is 62.85%.

❗ Current head c6654a8 differs from pull request most recent head eb38e0e. Consider uploading reports for the commit eb38e0e to get more accurate results

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #12967      +/-   ##
==========================================
- Coverage   55.84%   55.68%   -0.16%     
==========================================
  Files         649      644       -5     
  Lines       55022    54935      -87     
==========================================
- Hits        30726    30591     -135     
- Misses      21822    21878      +56     
+ Partials     2474     2466       -8     
Impacted Files Coverage Δ
x/staking/types/delegation.go 55.50% <0.00%> (-4.61%) ⬇️
x/staking/migrations/v4/store.go 82.81% <84.61%> (+7.81%) ⬆️
x/genutil/gentx.go 0.00% <0.00%> (-83.88%) ⬇️
x/genutil/module.go 9.09% <0.00%> (-9.10%) ⬇️
tx/textual/valuerenderer/int.go
tx/textual/valuerenderer/bytes.go
tx/textual/valuerenderer/dec.go
tx/textual/valuerenderer/timestamp.go
tx/textual/valuerenderer/valuerenderer.go

@gsk967 gsk967 requested a review from atheeshp August 19, 2022 10:06
Copy link
Contributor

@atheeshp atheeshp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good, except few doubts.

CHANGELOG.md Outdated Show resolved Hide resolved
x/staking/keeper/delegation.go Outdated Show resolved Hide resolved
x/staking/migrations/v5/store.go Outdated Show resolved Hide resolved
x/staking/types/delegation.go Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
x/staking/migrations/v5/store.go Outdated Show resolved Hide resolved
x/staking/migrations/v5/store.go Outdated Show resolved Hide resolved
x/staking/migrations/v5/store.go Outdated Show resolved Hide resolved
x/staking/migrations/v5/store.go Outdated Show resolved Hide resolved
x/staking/types/delegation.go Outdated Show resolved Hide resolved
x/staking/types/delegation.go Show resolved Hide resolved
Copy link
Contributor

@likhita-809 likhita-809 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Copy link
Contributor

@atheeshp atheeshp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gsk967 can you recheck the logic at store migration

x/staking/migrations/v5/store.go Outdated Show resolved Hide resolved
x/staking/migrations/v5/store.go Outdated Show resolved Hide resolved
x/staking/migrations/v5/store.go Outdated Show resolved Hide resolved
x/staking/migrations/v5/store.go Outdated Show resolved Hide resolved
Copy link
Contributor

@amaury1093 amaury1093 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the solution, good work. Will make a more thorough review tomorrow.

x/staking/module.go Outdated Show resolved Hide resolved
@@ -130,8 +130,27 @@ func NewUnbondingDelegation(

// AddEntry - append entry to the unbonding delegation
func (ubd *UnbondingDelegation) AddEntry(creationHeight int64, minTime time.Time, balance math.Int) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's add a unit test for this function

Copy link
Contributor

@amaury1093 amaury1093 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Logic looks good to me, but let's add a unit test for AddEntry before merging.

A nice to have would be a migration test, but not blocking.

x/staking/migrations/v4/store.go Outdated Show resolved Hide resolved
@@ -130,8 +130,27 @@ func NewUnbondingDelegation(

// AddEntry - append entry to the unbonding delegation
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's update this godoc too

x/staking/types/delegation.go Show resolved Hide resolved
@gsk967
Copy link
Contributor Author

gsk967 commented Aug 24, 2022

@AmauryM I added store migrations and tests, can you please look into those changes.

@gsk967 gsk967 requested review from amaury1093 and atheeshp and removed request for amaury1093 and atheeshp August 24, 2022 06:49
Copy link
Contributor

@atheeshp atheeshp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, few nits(mostly spell checks) & Amaury's comments.

x/staking/keeper/delegation_test.go Outdated Show resolved Hide resolved
x/staking/migrations/v4/migrations_test.go Outdated Show resolved Hide resolved
x/staking/migrations/v4/migrations_test.go Outdated Show resolved Hide resolved
x/staking/migrations/v4/migrations_test.go Outdated Show resolved Hide resolved
x/staking/migrations/v4/migrations_test.go Outdated Show resolved Hide resolved
x/staking/migrations/v4/migrations_test.go Outdated Show resolved Hide resolved
x/staking/migrations/v4/store.go Outdated Show resolved Hide resolved
x/staking/migrations/v4/store.go Outdated Show resolved Hide resolved
Copy link
Contributor

@amaury1093 amaury1093 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, just pending latest naming nits

x/staking/migrations/v4/migrations_test.go Outdated Show resolved Hide resolved
@amaury1093 amaury1093 added the A:automerge Automatically merge PR once all prerequisites pass. label Aug 24, 2022
@amaury1093 amaury1093 added backport/0.46.x PR scheduled for inclusion in the v0.46's next stable release and removed backport/0.46.x PR scheduled for inclusion in the v0.46's next stable release labels Aug 24, 2022
@mergify mergify bot merged commit 81028cf into cosmos:main Aug 24, 2022
Wryhder pushed a commit to Wryhder/cosmos-sdk that referenced this pull request Oct 26, 2022
## 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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A:automerge Automatically merge PR once all prerequisites pass. C:x/staking
Projects
None yet
5 participants