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

Fix: reject transactions early when paid fees contain denoms unwanted #2470

Merged
merged 2 commits into from
May 5, 2023

Conversation

yaruwangway
Copy link
Contributor

@yaruwangway yaruwangway commented May 4, 2023

Description

In the fee antehandler to check the transaction carried fees, add the logic to reject the transaction early if the feeCoins have more denoms than the fee requirement.
Closes: #XXXX


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

@codecov
Copy link

codecov bot commented May 4, 2023

Codecov Report

Merging #2470 (2376c3b) into main (15406d3) will increase coverage by 0.03%.
The diff coverage is 100.00%.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2470      +/-   ##
==========================================
+ Coverage   84.11%   84.14%   +0.03%     
==========================================
  Files          22       22              
  Lines        1530     1533       +3     
==========================================
+ Hits         1287     1290       +3     
  Misses        195      195              
  Partials       48       48              
Impacted Files Coverage Δ
x/globalfee/ante/fee.go 85.27% <100.00%> (+0.35%) ⬆️

@@ -73,6 +73,11 @@ func (mfd FeeDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, ne
return ctx, err
}

// reject the transaction early if the feeCoins have more denoms than the fee requirement
if feeCoins.Len() > requiredGlobalFees.Len() {
return ctx, sdkerrors.Wrapf(sdkerrors.ErrInvalidCoins, "fee is not a subset of required fees; got %s, required: %s", feeCoins, requiredGlobalFees)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you need to use .String() for both feeCoins and requiredGlobalFees

@sainoe
Copy link
Contributor

sainoe commented May 5, 2023

Nice job @yaruwangway !

@yaruwangway yaruwangway merged commit 26dcfae into main May 5, 2023
@yaruwangway yaruwangway deleted the yaru/patch-globalfee-refactor branch May 5, 2023 09:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

3 participants