-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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: fix ragel denom validation introduced in #19511 #19701
Conversation
WalkthroughWalkthroughThe recent updates focus on enhancing the regex parsing capabilities for cryptocurrency denominations. These modifications span across various files, introducing refined parsing logic in the regex generator, expanding the denomination pattern to include alphanumeric and special characters, and incorporating comprehensive tests to validate these changes. The core aim remains to improve the accuracy and range of denomination matching within the system. Changes
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? TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Additionally, you can add CodeRabbit Configration File (
|
There was a problem hiding this 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
Files selected for processing (3)
- types/coin_regex.go (2 hunks)
- types/coin_regex.rl (1 hunks)
- types/coin_test.go (1 hunks)
Additional comments: 3
types/coin_regex.rl (1)
- 29-31: The adjustment to
denom_pattern
incoin_regex.rl
, including bothalphabetNumber
andspecial
characters within a repetition range of 2 to 127, is a crucial enhancement for the denomination validation logic. This change effectively tightens the validation criteria, ensuring that denominations adhere to the intended format without spaces. The syntax and logic of the modification are correct and align with the PR objectives.types/coin_regex.go (1)
- 17-467: > 📝 NOTE
This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [1-467]
The modifications in
coin_regex.go
are consistent with the expected output from the adjustments made in the Ragel source file (coin_regex.rl
). These changes to the regex parsing logic, including adjustments to variable declarations, transitions, actions, and indices, are in line with the PR objectives to enhance denomination validation. No new issues are introduced, and the core functionality remains focused on matching denominations within the specified range.types/coin_test.go (1)
- 1024-1046: The new test function
TestValidateDenom
provides comprehensive coverage for the denomination validation logic, including edge cases and special characters. It's a valuable addition to ensure the robustness of the validation logic.
--- FAIL: TestCLITestSuite (0.03s)
--- FAIL: TestCLITestSuite/TestNewCmdSubmitProposal (0.00s)
--- FAIL: TestCLITestSuite/TestNewCmdSubmitProposal/invalid_proposal (0.00s)
tx_test.go:171:
Error Trace: /home/julien/projects/cosmos/cosmos-sdk/x/gov/client/cli/tx_test.go:171
/home/julien/tools/go/pkg/mod/github.com/stretchr/[email protected]/suite/suite.go:115
Error: "invalid character in coin string: -" does not contain "invalid decimal coin expression"
Test: TestCLITestSuite/TestNewCmdSubmitProposal/invalid_proposal
FAIL
FAIL cosmossdk.io/x/gov/client/cli 0.120s
--- FAIL: TestKeeperTestSuite (0.04s)
--- FAIL: TestKeeperTestSuite/TestMsgSetSendEnabled (0.00s)
--- FAIL: TestKeeperTestSuite/TestMsgSetSendEnabled/bad_first_denom_name,_(invalid_send_enabled_denom_present_in_list) (0.00s)
msg_server_test.go:357:
Error Trace: /home/julien/projects/cosmos/cosmos-sdk/x/bank/keeper/msg_server_test.go:357
/home/julien/tools/go/pkg/mod/github.com/stretchr/[email protected]/suite/suite.go:115
Error: An error is expected but got nil.
Test: TestKeeperTestSuite/TestMsgSetSendEnabled/bad_first_denom_name,_(invalid_send_enabled_denom_present_in_list)
--- FAIL: TestKeeperTestSuite/TestMsgSetSendEnabled/bad_second_denom_name,_(invalid_send_enabled_denom_present_in_list) (0.00s)
msg_server_test.go:357:
Error Trace: /home/julien/projects/cosmos/cosmos-sdk/x/bank/keeper/msg_server_test.go:357
/home/julien/tools/go/pkg/mod/github.com/stretchr/[email protected]/suite/suite.go:115
Error: An error is expected but got nil.
Test: TestKeeperTestSuite/TestMsgSetSendEnabled/bad_second_denom_name,_(invalid_send_enabled_denom_present_in_list)
--- FAIL: TestKeeperTestSuite/TestMsgSetSendEnabled/invalid_UseDefaultFor_denom (0.00s)
msg_server_test.go:357:
Error Trace: /home/julien/projects/cosmos/cosmos-sdk/x/bank/keeper/msg_server_test.go:357
/home/julien/tools/go/pkg/mod/github.com/stretchr/[email protected]/suite/suite.go:115
Error: An error is expected but got nil.
Test: TestKeeperTestSuite/TestMsgSetSendEnabled/invalid_UseDefaultFor_denom
FAIL
FAIL cosmossdk.io/x/bank/keeper 0.061s
ok cosmossdk.io/x/bank/simulation 0.024s
ok cosmossdk.io/x/bank/types 0.021s
FAIL
Running unit tests for module cosmossdk.io/x/circuit
? cosmossdk.io/x/circuit [no test files]
ok cosmossdk.io/x/circuit/ante 0.014s
? cosmossdk.io/x/circuit/types [no test files]
ok cosmossdk.io/x/circuit/keeper 0.018s
Running unit tests for module cosmossdk.io/x/distribution
? cosmossdk.io/x/distribution [no test files]
? cosmossdk.io/x/distribution/client/cli [no test files]
ok cosmossdk.io/x/distribution/client/common 0.023s
ok cosmossdk.io/x/distribution/keeper 0.026s
? cosmossdk.io/x/distribution/testutil [no test files]
ok cosmossdk.io/x/distribution/migrations/v4 0.020s
ok cosmossdk.io/x/distribution/simulation 0.028s
ok cosmossdk.io/x/distribution/types 0.019s
Running unit tests for module cosmossdk.io/x/evidence
? cosmossdk.io/x/evidence [no test files]
? cosmossdk.io/x/evidence/client [no test files]
? cosmossdk.io/x/evidence/client/cli [no test files]
? cosmossdk.io/x/evidence/exported [no test files]
? cosmossdk.io/x/evidence/testutil [no test files]
ok cosmossdk.io/x/evidence/keeper 0.042s
ok cosmossdk.io/x/evidence/simulation 0.017s
ok cosmossdk.io/x/evidence/types 0.019s
Running unit tests for module cosmossdk.io/x/feegrant
ok cosmossdk.io/x/feegrant 0.043s
? cosmossdk.io/x/feegrant/testutil [no test files]
ok cosmossdk.io/x/feegrant/client/cli 0.069s
ok cosmossdk.io/x/feegrant/keeper 0.033s
ok cosmossdk.io/x/feegrant/migrations/v2 0.028s
ok cosmossdk.io/x/feegrant/module 0.026s
ok cosmossdk.io/x/feegrant/simulation 0.041s
Running unit tests for module cosmossdk.io/x/gov
? cosmossdk.io/x/gov/client [no test files]
ok cosmossdk.io/x/gov 0.029s [no tests to run]
? cosmossdk.io/x/gov/client/testutil [no test files]
--- FAIL: TestReadGovPropFlags (0.02s)
--- FAIL: TestReadGovPropFlags/only_deposit_invalid_coins (0.00s)
util_test.go:701:
Error Trace: /home/julien/projects/cosmos/cosmos-sdk/x/gov/client/cli/util_test.go:701
Error: Error "invalid deposit: invalid character in denomination: " does not contain "invalid decimal coin expression"
Test: TestReadGovPropFlags/only_deposit_invalid_coins
Messages: ReadGovPropFlags error
util_test.go:701:
Error Trace: /home/julien/projects/cosmos/cosmos-sdk/x/gov/client/cli/util_test.go:701
Error: Error "invalid deposit: invalid character in denomination: " does not contain "not really coins"
Test: TestReadGovPropFlags/only_deposit_invalid_coins
Messages: ReadGovPropFlags error
--- FAIL: TestReadGovPropFlags/only_deposit_coin_1_of_3_bad (0.00s)
util_test.go:701:
Error Trace: /home/julien/projects/cosmos/cosmos-sdk/x/gov/client/cli/util_test.go:701
Error: Error "invalid deposit: invalid character in denomination: ^" does not contain "invalid decimal coin expression"
Test: TestReadGovPropFlags/only_deposit_coin_1_of_3_bad
Messages: ReadGovPropFlags error
util_test.go:701:
Error Trace: /home/julien/projects/cosmos/cosmos-sdk/x/gov/client/cli/util_test.go:701
Error: Error "invalid deposit: invalid character in denomination: ^" does not contain "1bad^coin"
Test: TestReadGovPropFlags/only_deposit_coin_1_of_3_bad
Messages: ReadGovPropFlags error
--- FAIL: TestReadGovPropFlags/only_deposit_coin_2_of_3_bad (0.00s)
util_test.go:701:
Error Trace: /home/julien/projects/cosmos/cosmos-sdk/x/gov/client/cli/util_test.go:701
Error: Error "invalid deposit: invalid character in denomination: ^" does not contain "invalid decimal coin expression"
Test: TestReadGovPropFlags/only_deposit_coin_2_of_3_bad
Messages: ReadGovPropFlags error
util_test.go:701:
Error Trace: /home/julien/projects/cosmos/cosmos-sdk/x/gov/client/cli/util_test.go:701
Error: Error "invalid deposit: invalid character in denomination: ^" does not contain "2bad^coin"
Test: TestReadGovPropFlags/only_deposit_coin_2_of_3_bad
Messages: ReadGovPropFlags error
--- FAIL: TestReadGovPropFlags/only_deposit_coin_3_of_3_bad (0.00s)
util_test.go:701:
Error Trace: /home/julien/projects/cosmos/cosmos-sdk/x/gov/client/cli/util_test.go:701
Error: Error "invalid deposit: invalid character in denomination: ^" does not contain "invalid decimal coin expression"
Test: TestReadGovPropFlags/only_deposit_coin_3_of_3_bad
Messages: ReadGovPropFlags error
util_test.go:701:
Error Trace: /home/julien/projects/cosmos/cosmos-sdk/x/gov/client/cli/util_test.go:701
Error: Error "invalid deposit: invalid character in denomination: ^" does not contain "3bad^coin"
Test: TestReadGovPropFlags/only_deposit_coin_3_of_3_bad
Messages: ReadGovPropFlags error
canceled transaction
--- FAIL: TestCLITestSuite (0.03s)
--- FAIL: TestCLITestSuite/TestCLITxGrantAuthorization (0.00s)
--- FAIL: TestCLITestSuite/TestCLITxGrantAuthorization/invalid_decimal_coin_expression_with_more_than_single_coin (0.00s)
tx_test.go:455:
Error Trace: /home/julien/projects/cosmos/cosmos-sdk/x/authz/client/cli/tx_test.go:455
/home/julien/tools/go/pkg/mod/github.com/stretchr/[email protected]/suite/suite.go:115
Error: "invalid character in denomination: ," does not contain "invalid decimal coin expression"
Test: TestCLITestSuite/TestCLITxGrantAuthorization/invalid_decimal_coin_expression_with_more_than_single_coin
FAIL
FAIL cosmossdk.io/x/authz/client/cli 0.074 Those tests were failing on main since the previous Rachel PR. AFK right now, but I'll run make test once I'm back, as CI runs on the diff only. |
So it seems like |
* 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]>
* 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)
* 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)
* 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]>
* 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]>
* 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]>
Description
Closes: #XXXX
Fixes a bug introduced in #19511.
Spaces are not supposed to be allowed in denominations, whilst existing ragel code allowed did. This PR fixes it.
This bug was previously not found since we do not have any direct test testing
ValidateDenom
. I've also added the test to ensure that this is fully covered.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...
!
in the type prefix if API or client breaking changeCHANGELOG.md
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...
Summary by CodeRabbit