-
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
WIP: ADR 004 implementation #5539
Conversation
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.
Basic changes look OK, left a few minor comments, doesn't build yet.
x/bank/internal/keeper/keeper.go
Outdated
func (keeper BaseSendKeeper) SetCoins(ctx sdk.Context, addr sdk.AccAddress, amt sdk.Coins) error { | ||
for _, coin := range amt { |
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.
Note: this is possibly not equivalent to the old logic, in that it won't set denoms not in amt
to zero.
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're right, this is different. I think the functionality of this function should be like this (with note in CHANGELOG), and a second function should be added to the keeper ClearAllBalances(addr)
, which will set all balances to 0.
Then anyone who wants that original functionality would call clear all balances first, then setcoins
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.
As I understand this semantic differences, I believe requiring the upstream caller to ClearAllBalances(addr)
is more error-prone and could cause bugs easily. I would rather see this function clear balances first (internally) before setting balances.
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.
Why not just call ClearAllBalances(addr)
at the beginning of SetCoins
?
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.
That's exactly what I'm saying, hence my TODO
.
@@ -31,9 +31,6 @@ type SimGenesisAccount struct { | |||
// Validate checks for errors on the vesting and module account parameters | |||
func (sga SimGenesisAccount) Validate() error { | |||
if !sga.OriginalVesting.IsZero() { | |||
if sga.OriginalVesting.IsAnyGT(sga.Coins) { |
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.
note to self/reviewer: This check needs to be handled in InitGenesis
somewhere...
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.
Do you mean like in this function? https://github.com/cosmos/cosmos-sdk/pull/5539/files#diff-12a2c7e5c552684069ea8dd5104cb0e8R11
if !fees.IsValid() { | ||
return sdkerrors.Wrapf(sdkerrors.ErrInsufficientFee, "invalid fee amount: %s", fees) | ||
} | ||
|
||
// verify the account has enough funds to pay for fees |
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.
note to self/reviewer: We will probably benefit from the vesting sub-pkg to have it's own DeductFees
ante decorator. For standard accounts, these changes are fine as SendCoinsFromAccountToModule
will handle accounting errors.
if (baseAccount.Coins.IsZero() && !originalVesting.IsZero()) || originalVesting.IsAnyGT(baseAccount.Coins) { | ||
return &BaseVestingAccount{}, errors.New("vesting amount cannot be greater than total amount") | ||
} | ||
// TODO: Move this check to bank |
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.
note to self/review: Handle this upstream.
Closing this PR as the changes will be too much to review efficiently. I'll instead create two PRs, the first with the core changes (minimal files and most prudent to review) and a second PR with the tests and misc. updates. |
closes #5519
Description
For contributor use:
docs/
) or specification (x/<module>/spec/
)godoc
comments.Unreleased
section inCHANGELOG.md
Files changed
in the Github PR explorerFor admin use:
WIP
,R4R
,docs
, etc)