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(math): adding Dec.SdkIntTrim #988

Merged
merged 4 commits into from
Apr 11, 2022
Merged

feat(math): adding Dec.SdkIntTrim #988

merged 4 commits into from
Apr 11, 2022

Conversation

robert-zaremba
Copy link
Collaborator

@robert-zaremba robert-zaremba commented Apr 6, 2022

Description

Closes: #987

Benchmarks:

goos: linux
goarch: amd64
BenchmarkSdkIntTrim/exp-16               1000000              1245 ns/op
BenchmarkSdkIntTrim/quo-integer-16        408232              2490 ns/op
BenchmarkSdkIntTrim/string-16             598272              2685 ns/op

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 Apr 7, 2022

Codecov Report

Merging #988 (077274e) into master (21d4003) will decrease coverage by 0.01%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master     #988      +/-   ##
==========================================
- Coverage   72.35%   72.34%   -0.02%     
==========================================
  Files         212      212              
  Lines       23508    23521      +13     
==========================================
+ Hits        17009    17016       +7     
- Misses       5137     5144       +7     
+ Partials     1362     1361       -1     
Flag Coverage Δ
experimental-codecov 72.14% <100.00%> (-0.09%) ⬇️
stable-codecov 67.16% <100.00%> (+0.01%) ⬆️

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

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.

This looks good to me.

You previously mentioned this was something you would like to see up-streamed to the sdk and said you would prefer @AmauryM and @anilcse to review. Might be good to get a review from @aaronc as well.

types/math/dec_bench_test.go Outdated Show resolved Hide resolved
Copy link
Contributor

@technicallyty technicallyty left a comment

Choose a reason for hiding this comment

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

LGTM. Not sure what will get merged first, so might be nice to create an issue to update buy_direct with this utility function

Co-authored-by: Ryan Christoffersen <[email protected]>
@robert-zaremba
Copy link
Collaborator Author

You previously mentioned this was something you would like to see up-streamed to the sdk

The whole library. In SDK we don't use apd.

@aaronc
Copy link
Member

aaronc commented Apr 8, 2022

We should be thinking about upstreaming this math package to the SDK (as a math go module) in the near future. It has long been known that the current SDK Dec is not ideal (cosmos/cosmos-sdk#7773). Either apd or https://github.com/EricLagergren/decimal should be the basis of what we use in the SDK in the future. If anyone is able to compare those two libraries btw that we be great so we can make an informed decision and best support things upstream. See also cockroachdb/apd#100

@ryanchristo ryanchristo merged commit 404cc06 into master Apr 11, 2022
@ryanchristo ryanchristo deleted the robert/dec-int branch April 11, 2022 16:10
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.

Add a core function to convert from Dec to Int
5 participants