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

WIP: ADR 004 implementation #5539

Closed
wants to merge 11 commits into from
Closed

WIP: ADR 004 implementation #5539

wants to merge 11 commits into from

Conversation

sunnya97
Copy link
Member

@sunnya97 sunnya97 commented Jan 17, 2020

closes #5519

Description


For contributor use:

  • 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

For admin use:

  • Added appropriate labels to PR (ex. WIP, R4R, docs, etc)
  • Reviewers assigned
  • Squashed all commits, uses message "Merge pull request #XYZ: [title]" (coding standards)

@sunnya97 sunnya97 added WIP T: API Breaking Breaking changes that impact APIs and the SDK only (not state machine). T: State Machine Breaking State machine breaking changes (impacts consensus). C:x/bank C:x/auth labels Jan 17, 2020
Copy link
Contributor

@cwgoes cwgoes left a 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/auth/vesting/exported/exported.go Outdated Show resolved Hide resolved
func (keeper BaseSendKeeper) SetCoins(ctx sdk.Context, addr sdk.AccAddress, amt sdk.Coins) error {
for _, coin := range amt {
Copy link
Contributor

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.

Copy link
Member Author

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

Copy link
Contributor

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.

Copy link
Member

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?

Copy link
Contributor

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.

x/bank/internal/keeper/keeper.go Outdated Show resolved Hide resolved
@@ -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) {
Copy link
Contributor

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...

Copy link
Member

Choose a reason for hiding this comment

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

if !fees.IsValid() {
return sdkerrors.Wrapf(sdkerrors.ErrInsufficientFee, "invalid fee amount: %s", fees)
}

// verify the account has enough funds to pay for fees
Copy link
Contributor

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.

x/auth/vesting/exported/exported.go Outdated Show resolved Hide resolved
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
Copy link
Contributor

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.

@alexanderbez
Copy link
Contributor

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.

@alexanderbez alexanderbez mentioned this pull request Jan 27, 2020
13 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C:x/auth C:x/bank T: API Breaking Breaking changes that impact APIs and the SDK only (not state machine). T: State Machine Breaking State machine breaking changes (impacts consensus).
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ADR 004 Implementation
4 participants