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

chore(ecocredit/core): keeper method audit #1160

Merged
merged 13 commits into from
Jun 13, 2022
Merged

Conversation

technicallyty
Copy link
Contributor

@technicallyty technicallyty commented Jun 7, 2022

Description

  • refactors MsgCancel and MsgBridge by taking out the embedded credits, moving to it's own proto struct. This was done to avoid an unnecessary loop over credits just to change their type in the Bridge keeper method.
  • updated errors where user provided values could return a not found error.
  • simplifies timestamppb conversions in CreateBatch
  • updates assertClassIssuer to use naming of key instead of id.
  • removes instances where GetCreditTypeFromBatchDenom could just be CreditTypeTable.Get

ref: #715

Closes: #1171


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)

@technicallyty technicallyty added Scope: x/ecocredit Issues that update the x/ecocredit module module-readiness-checklist Issues that track the audit of modules labels Jun 7, 2022
@technicallyty technicallyty added this to the v4.0 - Llangorse Upgrade milestone Jun 7, 2022
@codecov
Copy link

codecov bot commented Jun 7, 2022

Codecov Report

Merging #1160 (ff010ba) into master (8e1914f) will increase coverage by 5.57%.
The diff coverage is 80.64%.

@@            Coverage Diff             @@
##           master    #1160      +/-   ##
==========================================
+ Coverage   64.02%   69.60%   +5.57%     
==========================================
  Files         218      221       +3     
  Lines       21174    23056    +1882     
==========================================
+ Hits        13557    16047    +2490     
+ Misses       6296     5626     -670     
- Partials     1321     1383      +62     
Flag Coverage Δ
experimental-codecov 69.64% <80.64%> (?)
stable-codecov 64.02% <80.64%> (+<0.01%) ⬆️

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

@technicallyty technicallyty removed the module-readiness-checklist Issues that track the audit of modules label Jun 7, 2022
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.

I was not sure at first on whether or not we should define Credits separately or define within each message but if for some reason we need to change Credits specifically for one message, we could theoretically redefine Credits as needed specifically for that message and avoid breaking changes to the other messages that make use of Credits.

I also don't think this would be a likely scenario and if we were to make changes to Credits, we would likely need to make the same changes to the other uses. We might want to do something similar for BatchIssuance, which I can do in #1161.

x/ecocredit/server/core/create_batch.go Outdated Show resolved Hide resolved
Co-authored-by: Ryan Christoffersen <12519942+ryanchristo@users.noreply.github.com>
@ryanchristo
Copy link
Member

CI is breaking. Looks like unexpected error messages.

@ryanchristo ryanchristo self-requested a review June 9, 2022 04:02
@technicallyty
Copy link
Contributor Author

technicallyty commented Jun 9, 2022

looks like there was an odd edge case in NewDecFromString caught by the CI.. if you pass any form of "NaN" ("NAn", "nAn", etc), it actually doesn't error, but the test expects one 😮

@ryanchristo
Copy link
Member

@aleem1314 can you review when you get a chance? 🙏

@ryanchristo
Copy link
Member

looks like there was an odd edge case in NewDecFromString caught by the CI.. if you pass any form of "NaN" ("NAn", "nAn", etc), it actually doesn't error, but the test expects one open_mouth

Opened #1181

@ryanchristo
Copy link
Member

cc @technicallyty can you resolve conflicts? 🙏

@@ -51,7 +51,7 @@ func (k Keeper) CreateBatch(ctx context.Context, req *core.MsgCreateBatch) (*cor
return nil, err
}

startDate, endDate := timestamppb.New(req.StartDate.UTC()), timestamppb.New(req.EndDate.UTC())
startDate, endDate := timestamppb.New(*req.StartDate), timestamppb.New(*req.EndDate)
Copy link
Member

Choose a reason for hiding this comment

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

I missed this the first time around... I don't think we want to store local times if the user provides a local time. I think we always want to store the UTC time.

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

whoops, nice catch - fixed here 524e2f5

@ryanchristo ryanchristo mentioned this pull request Jun 13, 2022
31 tasks
@ryanchristo ryanchristo merged commit 17dda24 into master Jun 13, 2022
@ryanchristo ryanchristo deleted the ty/ecocredit_core_audit branch June 13, 2022 20:02
@ryanchristo ryanchristo removed this from the v4.0 - Llangorse Upgrade milestone Jun 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Scope: x/ecocredit Issues that update the x/ecocredit module
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ecocredit: return better errors for class/batch.. not found
3 participants