cosmos / cosmos-sdk

:chains: A Framework for Building High Value Public Blockchains :sparkles:
https://cosmos.network/
Apache License 2.0
6.24k stars 3.6k forks source link

Track delegation not work for vesting account #8601

Closed cyborgshead closed 3 years ago

cyborgshead commented 3 years ago

Summary of Bug

Delegation (and undelegation) from vesting account are not tracked. I tried to make delegation from account (in my case periodic vesting account) and found that there are no updates to delegated vesting amount. Looking to the code, there is not SetAccount here

Note: it was worked in 0.39.0

Version

SDK 0.41.0

Steps to Reproduce

  1. Vest some account's tokens
  2. Make delegation from this account

For Admin Use

amaury1093 commented 3 years ago

@litvintech Would you like to create a PR with a test?

alexanderbez commented 3 years ago

Continuous and delayed accounts do track delegations and undelegations. I cannot speak for periodic account types because that was an external contribution.

alessio commented 3 years ago

Thank you very much for taking the time to file this issue and contribute to making Cosmos SDK better.

@litvintech dixit:

Looking to the code, there is not SetAccount here

True that, and yet addCoins() is called here:

https://github.com/cosmos/cosmos-sdk/blob/8f7cdafc32776955fd9751b2b3546e0b77412f25/x/bank/keeper/keeper.go#L367

addCoins() subsequently calls setBalance():

https://github.com/cosmos/cosmos-sdk/blob/8f7cdafc32776955fd9751b2b3546e0b77412f25/x/bank/keeper/send.go#L216

Which in turn sets the new balance for the account:

https://github.com/cosmos/cosmos-sdk/blob/8f7cdafc32776955fd9751b2b3546e0b77412f25/x/bank/keeper/send.go#L270

@litvintech can you write a test case, please? Meanwhile, I'm labeling this accordingly.

karzak commented 3 years ago

Continuous and delayed accounts do track delegations and undelegations. I cannot speak for periodic account types because that was an external contribution.

Haven't used v0.41, but PeriodVestingAccount delegation tracking works on v0.39 and it looks to me like it should track delegations as normal here: https://github.com/cosmos/cosmos-sdk/blob/4b4768d242b2ae12cbd9fee8b1e8e4063767abe0/x/bank/keeper/keeper.go#L117

https://github.com/cosmos/cosmos-sdk/blob/4b4768d242b2ae12cbd9fee8b1e8e4063767abe0/x/bank/keeper/keeper.go#L423