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

Write back account changes after tracking delegation/undelegation for vesting accounts #8865

Merged
merged 57 commits into from
Apr 8, 2021

Conversation

gsora
Copy link
Contributor

@gsora gsora commented Mar 12, 2021

Description

Before this PR, delegation and undelegation calculations made during accounting operations for vesting accounts were made correct but not written back to the account store.

This PR fixes that behavior.

closes: #8601
closes: #8812


Before we can merge this PR, please make sure that all the following items have been
checked off. If any of the checklist items are not applicable, please leave them but
write a little note why.

  • Targeted PR against correct branch (see CONTRIBUTING.md)
  • Linked to Github issue with discussion and accepted design OR link to spec that describes this work.
  • Code follows the module structure standards.
  • Wrote unit and integration tests
  • Updated relevant documentation (docs/) or specification (x/<module>/spec/)
  • Added relevant godoc comments.
  • Added a relevant changelog entry to the Unreleased section in CHANGELOG.md
  • Re-reviewed Files changed in the Github PR explorer
  • Review Codecov Report in the comment section below once CI passes

@orijbot
Copy link

orijbot commented Mar 12, 2021

Copy link
Contributor

@alessio alessio left a comment

Choose a reason for hiding this comment

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

Sounds like we got this, thank you! A test case is required though

@fdymylja
Copy link
Contributor

fdymylja commented Mar 12, 2021

Do we have a test? IIRC only some vesting account types were failing, and if I'm not mistaken we run tests on vesting accounts delegatio/undelegation tracking (in x/bank I suppose).

Could we add a test here?

On a side note... It feels weird that bank has to update (and test) the vesting accounts types on behalf of auth.

Linking this for context: #8528

@alessio alessio requested a review from zmanian March 12, 2021 17:03
Copy link
Collaborator

@fedekunze fedekunze left a comment

Choose a reason for hiding this comment

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

ACK, pending changelog

Copy link
Member

@tac0turtle tac0turtle left a comment

Choose a reason for hiding this comment

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

LGTM, is there anyway to add a regression test?

Copy link
Contributor

@alessio alessio left a comment

Choose a reason for hiding this comment

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

Blocking this as we need to introduce a few test cases (and we should not accidentally merge this until that work is done)

@orijbot
Copy link

orijbot commented Mar 12, 2021

@gsora
Copy link
Contributor Author

gsora commented Mar 12, 2021

Added a test case in TestDelegateCoins() to test for this specific case.

@zmanian
Copy link
Member

zmanian commented Mar 12, 2021

good find.

@orijbot
Copy link

orijbot commented Mar 12, 2021

@codecov
Copy link

codecov bot commented Mar 12, 2021

Codecov Report

Merging #8865 (34b7961) into master (3a5550a) will increase coverage by 0.01%.
The diff coverage is 62.89%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #8865      +/-   ##
==========================================
+ Coverage   58.95%   58.97%   +0.01%     
==========================================
  Files         574      576       +2     
  Lines       32220    32377     +157     
==========================================
+ Hits        18996    19095      +99     
- Misses      11004    11041      +37     
- Partials     2220     2241      +21     
Impacted Files Coverage Δ
x/auth/keeper/keeper.go 49.29% <ø> (+0.68%) ⬆️
x/auth/keeper/migrations.go 8.33% <8.33%> (ø)
x/auth/module.go 53.65% <60.00%> (-0.40%) ⬇️
x/auth/legacy/v043/store.go 67.14% <67.14%> (ø)
x/bank/keeper/keeper.go 70.93% <100.00%> (+0.28%) ⬆️

Co-authored-by: Alessio Treglia <alessio@tendermint.com>
@orijbot
Copy link

orijbot commented Mar 12, 2021

@alexanderbez
Copy link
Contributor

So was this a regression? What are the repercussions of this on the hub's mainnet?

@alessio
Copy link
Contributor

alessio commented Mar 12, 2021

So was this a regression? What are the repercussions of this on the hub's mainnet?

I think @gsora identified this by going through git log and git blame. It'd be interesting to ultimately determine 1. whether this is a regression 2. and if so, which release introduced it.

@alessio
Copy link
Contributor

alessio commented Mar 12, 2021

I also suspect this change could be state-breaking. Thus the hub would need to go through an automated upgrade.

@alexanderbez
Copy link
Contributor

alexanderbez commented Mar 12, 2021

It must be because it worked on hub 1-3. Specifically, I mean how does this currently affect vesting accounts on the hub right now?

EDIT:

@alessio
Copy link
Contributor

alessio commented Mar 12, 2021

It must be because it worked on hub 1-3. Specifically, I mean how does this currently affect vesting accounts on the hub right now?

EDIT: https://github.com/cosmos/cosmos-sdk/blob/v0.37.15/x/bank/internal/keeper/keeper.go#L77-L81

IIUC @gsora managed to reproduce #8812 - I'm unsure about #8601

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 scanned through this PR again, imo it's ready to be merged. @robert-zaremba proposed some changes #8865 (comment), but we can make them in a follow-up.

@gsora Could you fix the lint errors?

The interfacer linter has been deprecated.
@alessio
Copy link
Contributor

alessio commented Apr 4, 2021

I scanned through this PR again, imo it's ready to be merged. @robert-zaremba proposed some changes #8865 (comment), but we can make them in a follow-up.

@robert-zaremba are you ok with that?

@gsora Could you fix the lint errors?

I took care of the errors

Copy link
Contributor

@jgimeno jgimeno left a comment

Choose a reason for hiding this comment

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

I think we tried as much edge cases as we could, I would merge it. Thanks @gsora

@robert-zaremba
Copy link
Collaborator

@gsora - could you respond on comments?
I would like to solve the queryFn problem correctly here instead of adding a workaround. But if it's more complex we can do it in a followup issue.

@gsora
Copy link
Contributor Author

gsora commented Apr 6, 2021

Hey all sorry for the delay, got caught up in other issues.

I'd say we can merge this right now and work something out as soon as we have an infra-package communication framework.

Copy link
Collaborator

@robert-zaremba robert-zaremba left a comment

Choose a reason for hiding this comment

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

For the ABCI use, I created an issue to track it and highlight the motivation. So won't block on it.

However, it seams that unbonding is still not handled: https://github.com/cosmos/cosmos-sdk/pull/8865/files#r600474696
cc: @boz

}
}

func getDelegatorDelegationsSum(ctx sdk.Context, address string, queryServer grpc.Server) (sdk.Coins, error) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

It seams this is still not done.

x/auth/legacy/v043/store.go Show resolved Hide resolved
@alessio
Copy link
Contributor

alessio commented Apr 7, 2021

For the ABCI use, I created an issue to track it and highlight the motivation. So won't block on it.

However, it seams that unbonding is still not handled: https://github.com/cosmos/cosmos-sdk/pull/8865/files#r600474696
cc: @boz

Looks like it was addressed in fef2d00

Copy link
Contributor

@boz boz left a comment

Choose a reason for hiding this comment

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

🔥

@robert-zaremba
Copy link
Collaborator

Looks like it was addressed in ...

good

@alessio alessio merged commit 93965e0 into master Apr 8, 2021
@alessio alessio deleted the gsora/track-delegation-vesting-accounts branch April 8, 2021 15:20
RiccardoM added a commit to desmos-labs/cosmos-sdk that referenced this pull request May 10, 2021
… vesting accounts (cosmos#8865)

Delegations and undelegations calculations performed during
accounting operations for vesting accounts were correct but
were not written back to the account store.

(cherry picked from commit 93965e0)
@robert-zaremba robert-zaremba mentioned this pull request Jun 2, 2021
42 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet