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.
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
Prune vesting accounts balances #1003
Prune vesting accounts balances #1003
Changes from all commits
033b940
45e42f7
c777e17
e04d1a2
4c85b0d
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
Ah, you check here... and only allow vesting accounts.
Either, "leave unchanged", "prune vesting" or reject.
You should definitely rename this function "EnforceVestingAndPruneBalances", or (my preference) do the vesting interface check in the instantiate method and accept
vestingexported.VestingAccount
as an argument here, which makes it clearer and keeps the 3 cases very explicit in instantiateThere 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.
This was built with the assumption that also other than SDK account types can exists in a chain. The
CoinPruner.PruneBalances
method is an extension point that can be used so that chains can handle their account types and/or vesting account types as they want. Another implementation could also be sending the tokens to the community pool or an escrow (not saying this makes sense).The concrete struct type is
VestingCoinBurner
. I thought this verbose enough and explicit addressing the SDK vesting account types only (or return error).I can add some more code doc to this but switching to VestingAccount types only would not work due to the custom account types. Throwing
types.ErrAccountExists
though would better fit one level where it was before. I will modify the method signature to return ahandled
bool for thisWDYT?
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.
Ah, okay, so this PruneBalances is not on the Keeper, but can easily be set by an external app. Now I understand the design.
No need for
handled
unless you prefer it as well, I think returningtypes.ErrAccountExists
is niceThere 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.
You convinced me that we need to keep the logic here. That does make sense.
However, the name is misleading.
PruneBalances
is what you do when you encounter a vesting account.Maybe
CleanupExistingAccount
would be a better name (as is more general and fits what you want as an extension point). And if it is a vesting account, youPruneBalances
. Maybe other accounts have different cleanup methods? And if there is no cleanup possible (existing module account), returning sometypes.ErrCannotReuseAccount
error or such sounds good.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.
👍
CleanupExistingAccount
makes sense as a more general term. I prefer thehandled
result value, too as it brings back the control flow to the caller.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.
nice test!