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: use loop instead of ragel #19710

Merged
merged 1 commit into from
Mar 8, 2024
Merged

fix: use loop instead of ragel #19710

merged 1 commit into from
Mar 8, 2024

Conversation

tac0turtle
Copy link
Member

@tac0turtle tac0turtle commented Mar 8, 2024

Description

this pr removes the usage of ragel since the generated code caused issues and opts to use a golang loop


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
  • confirmed ! in 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
  • reviewed "Files changed" and left comments if necessary
  • included the necessary unit and integration tests
  • added a changelog entry to CHANGELOG.md
  • updated the relevant documentation or specification, including comments for documenting Go code
  • 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 all author checklist items have been addressed
  • reviewed state machine logic, API design and naming, documentation is accurate, tests and test coverage

Summary by CodeRabbit

  • Refactor
    • Improved the organization of interface and implementation registrations within the codebase.
  • New Features
    • Enhanced denomination validation in the currency system with additional checks and support for more cases.
  • Tests
    • Added new test cases for currency denomination validation to ensure robustness.

Copy link
Contributor

coderabbitai bot commented Mar 8, 2024

Walkthrough

Walkthrough

The recent update focuses on reorganizing the way interfaces and implementations are registered, moving them to a new location within the codebase. Additionally, it enhances the denomination validation in the coin module by refining the MatchDenom function to accept and validate strings, incorporating a new function to check rune validity. Test coverage has been expanded to include more cases for denomination validation, ensuring robustness in handling different input scenarios.

Changes

Files Change Summary
CHANGELOG.md Moved declarations for registering interfaces/implementations to cosmossdk.io/core and its registry
types/coin.go - Added unicode import
- Refactored MatchDenom to use strings
- Added isValidRune function
types/coin_test.go Updated TestValidateDenom with additional test cases for denomination validation

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share

Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit-tests for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit tests for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit tests.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

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 resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

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

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

@tac0turtle tac0turtle marked this pull request as ready for review March 8, 2024 21:51
@tac0turtle tac0turtle requested a review from a team as a code owner March 8, 2024 21:51
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.

So much easier to read and to debug 🙏

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.yml

Commits Files that changed from the base of the PR and between fbff6ff and 08b1b61.
Files selected for processing (3)
  • CHANGELOG.md (2 hunks)
  • types/coin.go (3 hunks)
  • types/coin_test.go (1 hunks)
Additional comments: 7
types/coin.go (4)
  • 10-10: The addition of the "unicode" import is appropriate for the new validation logic introduced in this PR.
  • 887-908: Refactoring MatchDenom to accept a string instead of a byte slice simplifies its usage and is more idiomatic in Go. This change enhances the readability and maintainability of the code.
  • 881-885: The implementation of isValidRune is well-designed, covering all necessary characters for a valid denomination. This addition supports the enhanced validation logic effectively.
  • 887-908: The updates to MatchDenom significantly improve the validation logic for denominations, ensuring they meet specific criteria for length, starting character, and content. This enhancement contributes to the overall robustness and reliability of the code.
types/coin_test.go (1)
  • 1031-1034: The test cases for TestValidateDenom include strings with spaces, which are intended to be invalid denominations. However, the test descriptions and the actual test logic are not directly under review here. It's important to ensure that the validation logic being tested correctly handles these cases according to the defined rules for valid denominations in the Cosmos SDK.
CHANGELOG.md (2)
  • 42-47: > 📝 NOTE

This review was outside the diff hunks, and no overlapping diff hunk was found. Original lines [1-3]

The additions to the changelog under the Features section are well-documented and follow the project's conventions for changelog entries. Each entry is clearly associated with its respective PR, providing easy access to further details.

  • 144-145: The structural changes detailed in the changelog, including the movement of interface registration functions, are clearly documented. It's important to ensure that the documentation and any developer guides are updated to reflect these changes for clarity and consistency.

@tac0turtle
Copy link
Member Author

tests pass locally

@tac0turtle tac0turtle added this pull request to the merge queue Mar 8, 2024
Merged via the queue into main with commit 8a2035f Mar 8, 2024
59 of 61 checks passed
@tac0turtle tac0turtle deleted the marko/loop-regex branch March 8, 2024 22:26
mattverse pushed a commit to osmosis-labs/cosmos-sdk that referenced this pull request Mar 13, 2024
czarcas7ic added a commit to osmosis-labs/cosmos-sdk that referenced this pull request Mar 16, 2024
* feat(x/bank): Replace regex parsing of denom validation to generated parsing (cosmos#19511)

* fix: fix ragel denom validation introduced in cosmos#19511 (cosmos#19701)

* fix: use loop instead of ragel (cosmos#19710)

* Fix test

* Fix integration test as well

* Try linting

* Fix lint

* Fix lint

* add changelog

---------

Co-authored-by: Marko <[email protected]>
Co-authored-by: Adam Tucker <[email protected]>
Co-authored-by: Adam Tucker <[email protected]>
mergify bot pushed a commit to osmosis-labs/cosmos-sdk that referenced this pull request Mar 16, 2024
* feat(x/bank): Replace regex parsing of denom validation to generated parsing (cosmos#19511)

* fix: fix ragel denom validation introduced in cosmos#19511 (cosmos#19701)

* fix: use loop instead of ragel (cosmos#19710)

* Fix test

* Fix integration test as well

* Try linting

* Fix lint

* Fix lint

* add changelog

---------

Co-authored-by: Marko <[email protected]>
Co-authored-by: Adam Tucker <[email protected]>
Co-authored-by: Adam Tucker <[email protected]>
(cherry picked from commit ab4bc05)
mergify bot pushed a commit to osmosis-labs/cosmos-sdk that referenced this pull request Mar 16, 2024
* feat(x/bank): Replace regex parsing of denom validation to generated parsing (cosmos#19511)

* fix: fix ragel denom validation introduced in cosmos#19511 (cosmos#19701)

* fix: use loop instead of ragel (cosmos#19710)

* Fix test

* Fix integration test as well

* Try linting

* Fix lint

* Fix lint

* add changelog

---------

Co-authored-by: Marko <[email protected]>
Co-authored-by: Adam Tucker <[email protected]>
Co-authored-by: Adam Tucker <[email protected]>
(cherry picked from commit ab4bc05)
czarcas7ic pushed a commit to osmosis-labs/cosmos-sdk that referenced this pull request Mar 16, 2024
* feat(x/bank): Replace regex parsing of denom validation to generated parsing (cosmos#19511)

* fix: fix ragel denom validation introduced in cosmos#19511 (cosmos#19701)

* fix: use loop instead of ragel (cosmos#19710)

* Fix test

* Fix integration test as well

* Try linting

* Fix lint

* Fix lint

* add changelog

---------

Co-authored-by: Marko <[email protected]>
Co-authored-by: Adam Tucker <[email protected]>
Co-authored-by: Adam Tucker <[email protected]>
(cherry picked from commit ab4bc05)

Co-authored-by: Matt, Park <[email protected]>
czarcas7ic pushed a commit to osmosis-labs/cosmos-sdk that referenced this pull request Mar 16, 2024
* feat(x/bank): Replace regex parsing of denom validation to generated parsing (cosmos#19511)

* fix: fix ragel denom validation introduced in cosmos#19511 (cosmos#19701)

* fix: use loop instead of ragel (cosmos#19710)

* Fix test

* Fix integration test as well

* Try linting

* Fix lint

* Fix lint

* add changelog

---------

Co-authored-by: Marko <[email protected]>
Co-authored-by: Adam Tucker <[email protected]>
Co-authored-by: Adam Tucker <[email protected]>
(cherry picked from commit ab4bc05)

Co-authored-by: Matt, Park <[email protected]>
czarcas7ic added a commit to osmosis-labs/cosmos-sdk that referenced this pull request May 9, 2024
* feat(x/bank): Replace regex parsing of denom validation to generated parsing (cosmos#19511)

* fix: fix ragel denom validation introduced in cosmos#19511 (cosmos#19701)

* fix: use loop instead of ragel (cosmos#19710)

* Fix test

* Fix integration test as well

* Try linting

* Fix lint

* Fix lint

* add changelog

---------

Co-authored-by: Marko <[email protected]>
Co-authored-by: Adam Tucker <[email protected]>
Co-authored-by: Adam Tucker <[email protected]>
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.

4 participants