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

perf: add AmountOfNoValidation for DecCoins #18440

Merged
merged 4 commits into from
Nov 10, 2023

Conversation

fedekunze
Copy link
Collaborator

@fedekunze fedekunze commented Nov 10, 2023

Description

This PR adds AmountOfNoValidation to the DecCoins in a similar fashion as the Coins struct. This improves performance by avoiding calling the mustVerifyDenom function on every call.


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
  • run make lint and make test
  • 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)

Summary by CodeRabbit

  • New Features
    • Introduced a new function that returns the amount of a denomination without validating its correctness.
    • Extended governance configuration and improved proposal querying.
  • Bug Fixes
    • Limited the accepted deposit coins for a proposal to prevent invalid entries.
  • Documentation
    • Updated function comments and changelog to reflect new behaviors and features.

@fedekunze fedekunze requested a review from a team as a code owner November 10, 2023 11:17
Copy link
Contributor

coderabbitai bot commented Nov 10, 2023

Walkthrough

Walkthrough

The recent changes introduce a new function AmountOfNoValidation to the DecCoins type in the types package, which allows for the retrieval of a denom amount without validation. This function is now used internally by the existing AmountOf function after denom validation. Additionally, the governance config has been extended, the accepted deposit coins for a proposal have been limited, and the querying of proposals in the x/gov package has been improved.

Changes

File(s) Change Summary
types/dec_coin.go Introduced a new function AmountOfNoValidation to the DecCoins type. The existing AmountOf function now uses AmountOfNoValidation internally after validating the denom. The comment for AmountOf has been updated to reflect this change.
CHANGELOG.md Documented the addition of AmountOfNoValidation to sdk.DecCoins in the types package. Also noted the extension of governance config, the limitation of accepted deposit coins for a proposal, and the improvement of proposal querying in the x/gov package.

Tips

Chat with CodeRabbit Bot (@coderabbitai)

  • If you reply to a review comment from CodeRabbit, the bot will automatically respond.
  • To engage with CodeRabbit bot directly around the specific lines of code in the PR, mention @coderabbitai in your review comment
  • Note: Review comments are made on code diffs or files, not on the PR overview.
  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai help to get help.
  • @coderabbitai resolve to resolve all the CodeRabbit review comments.

Note: For conversation with the bot, please use the review comments on code diffs or files.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 1

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 04d5fc3 and 1af1d4c.
Files selected for processing (1)
  • types/dec_coin.go (2 hunks)
Additional comments: 2
types/dec_coin.go (2)
  • 451-466: The new function AmountOfNoValidation is introduced to improve performance by skipping the validation of the denom. This function should only be used when the correctness of the denom is already assured.

  • 478-487: The logic of AmountOfNoValidation is correct. It uses binary search to find the denom in the sorted DecCoins, which is efficient.

types/dec_coin.go Show resolved Hide resolved
Copy link
Member

@julienrbrt julienrbrt left a comment

Choose a reason for hiding this comment

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

Can we get a changelog?

@fedekunze
Copy link
Collaborator Author

@julienrbrt done

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 1af1d4c and 20f42cc.
Files selected for processing (1)
  • CHANGELOG.md (1 hunks)
Additional comments: 1
CHANGELOG.md (1)
  • 53-59: > Note: This review was outside of the patch, so it was mapped to the patch with the greatest overlap. Original lines [56-60]

The changes are well documented and provide clear links to the corresponding pull requests for further details. Ensure that the changes mentioned here align with the actual changes made in the code.

@fedekunze fedekunze added this pull request to the merge queue Nov 10, 2023
Merged via the queue into cosmos:main with commit b7fb292 Nov 10, 2023
57 of 59 checks passed
@fedekunze fedekunze deleted the fedekunze/deccoins-amtnovalidation branch November 10, 2023 18:03
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.

2 participants