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(ecocredit): specify fee in CreateClass #912

Merged
merged 20 commits into from
Mar 25, 2022

Conversation

technicallyty
Copy link
Contributor

@technicallyty technicallyty commented Mar 19, 2022

Description

  • adds fee to CreateClass

ref #728


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)

@codecov
Copy link

codecov bot commented Mar 19, 2022

Codecov Report

Merging #912 (82e3368) into master (fc3df53) will increase coverage by 0.19%.
The diff coverage is 69.23%.

❗ Current head 82e3368 differs from pull request most recent head e5f5df7. Consider uploading reports for the commit e5f5df7 to get more accurate results

@@            Coverage Diff             @@
##           master     #912      +/-   ##
==========================================
+ Coverage   72.39%   72.59%   +0.19%     
==========================================
  Files         194      185       -9     
  Lines       22880    22754     -126     
==========================================
- Hits        16565    16518      -47     
+ Misses       5072     5026      -46     
+ Partials     1243     1210      -33     
Flag Coverage Δ
experimental-codecov 72.47% <69.23%> (+0.18%) ⬆️
stable-codecov 65.65% <53.84%> (+0.13%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

// Charge the admin a fee to create the credit class
err = k.chargeCreditClassFee(sdkCtx, adminAddress, params.CreditClassFee)
err = k.chargeCreditClassFee(sdkCtx, adminAddress, sdk.Coins{sdk.Coin{Denom: req.Fee.Denom, Amount: feeAmt}})
Copy link
Contributor Author

Choose a reason for hiding this comment

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

force the fee to the amount specified by the params, rather than the amount passed, seemed like the proper thing to do?

Copy link
Member

Choose a reason for hiding this comment

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

Correct. We don't want to charge more than the amount in the params but we also don't want to fail if more is provided by the user so we charge the amount specified in the params.

Copy link
Collaborator

Choose a reason for hiding this comment

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

yes, related to my earlier review. I think we should adjust.

@technicallyty technicallyty marked this pull request as ready for review March 21, 2022 20:17
Copy link
Member

@ryanchristo ryanchristo left a comment

Choose a reason for hiding this comment

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

Looks good to me. A couple minor suggestions. Pre-approving.

// Charge the admin a fee to create the credit class
err = k.chargeCreditClassFee(sdkCtx, adminAddress, params.CreditClassFee)
err = k.chargeCreditClassFee(sdkCtx, adminAddress, sdk.Coins{sdk.Coin{Denom: req.Fee.Denom, Amount: feeAmt}})
Copy link
Member

Choose a reason for hiding this comment

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

Correct. We don't want to charge more than the amount in the params but we also don't want to fail if more is provided by the user so we charge the amount specified in the params.

proto/regen/ecocredit/v1/tx.proto Outdated Show resolved Hide resolved
x/ecocredit/server/core/create_class.go Outdated Show resolved Hide resolved
Copy link
Collaborator

@robert-zaremba robert-zaremba left a comment

Choose a reason for hiding this comment

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

I would prefer that we use use a bare denom instead of Fee/ Coin. And definitely let's remove the Fee type.


// fee specifies the fee to pay for the creation of the credit class.
// acceptable fees for creating a credit class can be found in the governance parameters for the ecocredit module.
Fee fee = 5;
Copy link
Collaborator

Choose a reason for hiding this comment

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

  1. why someone would pay a different fee than the required one? Maybe we can use only string denom here and charge the required fee.
  2. If we really need to use both denom and amount, then let's use Coin type and remove Fee message. We can make it required (it's very small, so we in fact optimize the performance) to avoid null checks.

Copy link
Contributor Author

@technicallyty technicallyty Mar 23, 2022

Choose a reason for hiding this comment

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

  1. i believe the intent was to ensure users aren't being charged fees that they are not explicitly setting. i had shared your concern while impl this PR, so might be nice to get more opinions in here. cc: @aaronc @clevinson @ryanchristo

  2. i changed it to coin, but im not sure about the nullable thing. pulsar doesn't support that (not sure if thats planned either?). it might be best to leave out the option knowing we we will switch fully to pulsar eventually

Copy link
Member

Choose a reason for hiding this comment

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

why someone would pay a different fee than the required one? Maybe we can use only string denom here and charge the required fee.

The intention was to have the user explicitly set the fee so that they are aware of the charges incurred for creating a credit class. This currently happens in the background and in some cases the user might overlook the cost of creating a credit class, so having them explicitly set the fee prevents this.

Copy link
Collaborator

Choose a reason for hiding this comment

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

since we are automatically adjusting, then maybe let's update the docs if we want to keep this attribute.


// amount is the amount of fees to pay in the specified denom.
string amount = 2;
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

We don't need that type. Let's use Coin instead.

@@ -46,6 +46,17 @@ func (m *MsgCreateClass) ValidateBasic() error {
}
}

if m.Fee != nil {
Copy link
Collaborator

Choose a reason for hiding this comment

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

ok, if it's required, and a struct is small (even if we use Coin), then we can add option for nullable = false.

@technicallyty technicallyty enabled auto-merge (squash) March 25, 2022 19:30
@technicallyty technicallyty merged commit 1df8b21 into master Mar 25, 2022
@technicallyty technicallyty deleted the ty/728-specify_class_fee branch March 25, 2022 19:32
@ryanchristo ryanchristo mentioned this pull request Mar 27, 2022
8 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants