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

feat: configurable fee collector for DeductFeeDecorator #407

Merged
merged 3 commits into from
Mar 8, 2024

Conversation

JimLarson
Copy link

@JimLarson JimLarson commented Mar 8, 2024

Description

Refs: Agoric/agoric-sdk#9036

Make the fee collector module name in DeductFeeDecorator configurable.

Pulls a customization from Agoric/agoric-sdk into agoric-labs/cosmos-sdk so it can evolve along with cosmos-sdk.


Author Checklist

All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.

I have...

  • included the correct type prefix in the PR title
  • added ! to the type prefix if API or client breaking change
  • targeted the correct branch (see PR Targeting)
  • provided a link to the relevant issue or specification
  • followed the guidelines for building modules
  • included the necessary unit and integration tests
  • added a changelog entry to CHANGELOG.md
  • included comments for documenting Go code
  • updated the relevant documentation or specification
  • reviewed "Files changed" and left comments if necessary
  • confirmed all CI checks have passed

Reviewers Checklist

All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.

I have...

  • confirmed the correct type prefix in the PR title
  • confirmed ! in the type prefix if API or client breaking change
  • confirmed all author checklist items have been addressed
  • reviewed state machine logic
  • reviewed API design and naming
  • reviewed documentation is accurate
  • reviewed tests and test coverage
  • manually tested (if applicable)

@JimLarson JimLarson added enhancement New feature or request C:x/auth agoric-cosmos Agoric tags for cosmos labels Mar 8, 2024
@JimLarson JimLarson self-assigned this Mar 8, 2024
@JimLarson
Copy link
Author

Lint failure expected.

@JimLarson
Copy link
Author

Should be cherry-picked onto a "release" branch. Following past precedent, which it's unnecessary to improve upon, we'll branch Agoric-v0.46.16.2.x off of v0.46.16-alpha.agoric.2 and lay down the tag v0.46.16-alpha.agoric.2.1.

return NewDeductFeeDecoratorWithName(ak, bk, fk, tfc, types.FeeCollectorName)
}

// NewDeductFeeDecorator returns a DeductFeeDecorator using a custom fee collector module account.

Choose a reason for hiding this comment

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

Suggested change
// NewDeductFeeDecorator returns a DeductFeeDecorator using a custom fee collector module account.
// NewDeductFeeDecoratorWithName returns a DeductFeeDecorator using a custom fee collector module account.

Copy link
Author

Choose a reason for hiding this comment

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

Oops, done.

tx, err := s.CreateTestTx(privs, accNums, accSeqs, s.ctx.ChainID())
s.Require().NoError(err)

// Set account with sufficient funds

Choose a reason for hiding this comment

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

Suggested change
// Set account with sufficient funds
// Set transacting account with sufficient funds

Copy link
Author

Choose a reason for hiding this comment

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

Done.

Comment on lines 184 to 188
dfd := ante.NewDeductFeeDecoratorWithName(s.app.AccountKeeper, s.app.BankKeeper, nil, nil, altCollectorName)
antehandler := sdk.ChainAnteDecorators(dfd)

_, err = antehandler(s.ctx, tx, false)
s.Require().NoError(err)

Choose a reason for hiding this comment

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

Suggested change
dfd := ante.NewDeductFeeDecoratorWithName(s.app.AccountKeeper, s.app.BankKeeper, nil, nil, altCollectorName)
antehandler := sdk.ChainAnteDecorators(dfd)
_, err = antehandler(s.ctx, tx, false)
s.Require().NoError(err)
// Run the transaction through a handler chain that deducts fees into altCollectorAcc.
dfd := ante.NewDeductFeeDecoratorWithName(s.app.AccountKeeper, s.app.BankKeeper, nil, nil, altCollectorName)
antehandler := sdk.ChainAnteDecorators(dfd)
_, err = antehandler(s.ctx, tx, false)
s.Require().NoError(err)

Copy link
Author

Choose a reason for hiding this comment

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

Done.

Comment on lines +190 to +192
s.Require().True(s.app.BankKeeper.GetAllBalances(s.ctx, feeCollectorAcc.GetAddress()).Empty())
newAltBalance := s.app.BankKeeper.GetAllBalances(s.ctx, altCollectorAcc.GetAddress())
s.Require().True(newAltBalance.IsAllGTE(altBalance))

Choose a reason for hiding this comment

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

Suggested change
s.Require().True(s.app.BankKeeper.GetAllBalances(s.ctx, feeCollectorAcc.GetAddress()).Empty())
newAltBalance := s.app.BankKeeper.GetAllBalances(s.ctx, altCollectorAcc.GetAddress())
s.Require().True(newAltBalance.IsAllGTE(altBalance))
// Assert that feeCollectorAcc is still empty but the altCollectorAcc balance has increased.
newFeeCollectorBalance := s.app.BankKeeper.GetAllBalances(s.ctx, feeCollectorAcc.GetAddress())
s.Require().True(newFeeCollectorBalance.Empty())
newAltBalance := s.app.BankKeeper.GetAllBalances(s.ctx, altCollectorAcc.GetAddress())
s.Require().True(newAltBalance.IsAllGTE(altBalance))
s.Require().False(newAltBalance.IsEqual(altBalance))

Copy link
Author

Choose a reason for hiding this comment

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

Done.

@JimLarson JimLarson merged commit fd88517 into Agoric Mar 8, 2024
29 of 30 checks passed
@JimLarson JimLarson deleted the 9036-config-fee branch March 8, 2024 20:08
JimLarson added a commit that referenced this pull request Mar 8, 2024
* feat: configurable fee collector for DeductFeeDecorator

* docs: update changelog with PR number

* test: ensure increment of alt account, comments
JimLarson added a commit to Agoric/agoric-sdk that referenced this pull request Mar 9, 2024
michaelfig pushed a commit to Agoric/agoric-sdk that referenced this pull request Mar 11, 2024
gibson042 pushed a commit to Agoric/agoric-sdk that referenced this pull request Mar 11, 2024
gibson042 pushed a commit to Agoric/agoric-sdk that referenced this pull request Mar 11, 2024
JeancarloBarrios pushed a commit that referenced this pull request Sep 28, 2024
* feat: configurable fee collector for DeductFeeDecorator

* docs: update changelog with PR number

* test: ensure increment of alt account, comments
JeancarloBarrios pushed a commit that referenced this pull request Sep 28, 2024
* feat: configurable fee collector for DeductFeeDecorator

* docs: update changelog with PR number

* test: ensure increment of alt account, comments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
agoric-cosmos Agoric tags for cosmos C:x/auth enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants