-
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
refactor(x/genutil)!: remove Address.String() #19926
Conversation
Warning Rate Limit Exceeded@JulianToledano has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 10 minutes and 51 seconds before requesting another review. How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. WalkthroughThe overarching change involves the introduction of an address codec across various modules in the codebase. This shift necessitates the modification of method signatures to include the address codec as a parameter, removal of global variable reliance, and enhancement of address handling logic. It aligns with efforts to eliminate global usage of bech32 prefixes and improve modularity and safety in address manipulation. Changes
Possibly related issues
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.
Actionable comments posted: 2
Review Status
Configuration used: .coderabbit.yml
Files selected for processing (14)
- CHANGELOG.md (1 hunks)
- simapp/simd/cmd/testnet.go (7 hunks)
- testutil/network/util.go (1 hunks)
- x/genutil/client/cli/collect.go (3 hunks)
- x/genutil/client/cli/commands.go (1 hunks)
- x/genutil/client/cli/genaccount.go (1 hunks)
- x/genutil/client/cli/genaccount_test.go (3 hunks)
- x/genutil/client/cli/gentx.go (1 hunks)
- x/genutil/collect.go (4 hunks)
- x/genutil/collect_test.go (1 hunks)
- x/genutil/genaccounts.go (4 hunks)
- x/genutil/gentx.go (2 hunks)
- x/genutil/gentx_test.go (7 hunks)
- x/genutil/types/genesis_state_test.go (2 hunks)
Additional Context Used
Path-based Instructions (14)
x/genutil/client/cli/commands.go (1)
Pattern
**/*.go
: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.x/genutil/collect_test.go (2)
Pattern
**/*.go
: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.
Pattern
**/*_test.go
: "Assess the unit test code assessing sufficient code coverage for the changes associated in the pull request"x/genutil/client/cli/collect.go (1)
Pattern
**/*.go
: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.x/genutil/client/cli/genaccount_test.go (2)
Pattern
**/*.go
: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.
Pattern
**/*_test.go
: "Assess the unit test code assessing sufficient code coverage for the changes associated in the pull request"x/genutil/client/cli/genaccount.go (1)
Pattern
**/*.go
: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.x/genutil/gentx.go (1)
Pattern
**/*.go
: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.x/genutil/types/genesis_state_test.go (2)
Pattern
**/*.go
: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.
Pattern
**/*_test.go
: "Assess the unit test code assessing sufficient code coverage for the changes associated in the pull request"x/genutil/genaccounts.go (1)
Pattern
**/*.go
: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.x/genutil/collect.go (1)
Pattern
**/*.go
: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.testutil/network/util.go (1)
Pattern
**/*.go
: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.x/genutil/client/cli/gentx.go (1)
Pattern
**/*.go
: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.x/genutil/gentx_test.go (2)
Pattern
**/*.go
: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.
Pattern
**/*_test.go
: "Assess the unit test code assessing sufficient code coverage for the changes associated in the pull request"simapp/simd/cmd/testnet.go (1)
Pattern
**/*.go
: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.CHANGELOG.md (1)
Pattern
**/*.md
: "Assess the documentation for misspellings, grammatical errors, missing documentation and correctness"
Additional comments not posted (21)
x/genutil/client/cli/commands.go (1)
35-35
: Ensure that the removal of the validator address codec argument fromCollectGenTxsCmd
does not impact its functionality or introduce any regressions.Verification successful
The removal of the validator address codec argument from
CollectGenTxsCmd
is consistent with its updated function definition and usage within the codebase. There's no indication of impact on functionality or introduction of regressions based on the provided context.Scripts Executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Verify if CollectGenTxsCmd is used elsewhere with the removed argument rg "CollectGenTxsCmd" --type goLength of output: 413
x/genutil/collect_test.go (1)
65-65
: Confirm that the addition ofaddresscodec.NewBech32Codec("cosmos")
as an argument togenutil.CollectTxs
is correctly implemented and aligns with the refactor's objectives.x/genutil/client/cli/collect.go (1)
50-50
: Verify that the replacement ofvalAddrCodec
withclientCtx.ValidatorAddressCodec
andclientCtx.AddressCodec
inGenAppStateFromConfig
is correctly implemented and aligns with the refactor's objectives.Verification successful
The replacement of
valAddrCodec
withclientCtx.ValidatorAddressCodec
andclientCtx.AddressCodec
inGenAppStateFromConfig
is correctly implemented and aligns with the refactor's objectives, as evidenced by its consistent application across the codebase.Scripts Executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Verify if GenAppStateFromConfig correctly handles the new arguments ast-grep --lang go --pattern $'genutil.GenAppStateFromConfig($_, $_, $_, $_, $_, $_, $_, $_, $_)'Length of output: 950
x/genutil/client/cli/genaccount_test.go (1)
28-31
: Ensure that the use ofcodectestutil.CodecOptions{}.GetAddressCodec()
to obtain an address codec and its subsequent use in converting addresses to strings is correctly implemented and aligns with the refactor's objectives.Verification successful
The usage of
codectestutil.CodecOptions{}.GetAddressCodec()
to obtain an address codec and its subsequent application in converting addresses to strings is correctly implemented across the test cases, as evidenced by its consistent application in various files, includingx/genutil/client/cli/genaccount_test.go
. This aligns with the refactor's objectives.Scripts Executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Verify if the address codec is correctly utilized across the test cases ast-grep --lang go --pattern $'codectestutil.CodecOptions{}.GetAddressCodec()'Length of output: 6978
x/genutil/client/cli/genaccount.go (1)
77-77
: Confirm that the addition ofclientCtx.AddressCodec
as an argument togenutil.AddGenesisAccount
is correctly implemented and aligns with the refactor's objectives.x/genutil/gentx.go (1)
41-47
: > 📝 NOTEThis review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [44-59]
Ensure that the change of the
addr
parameter type fromsdk.Address
tostring
inValidateAccountInGenesis
and its comparison withaccAddress
are correctly implemented and do not introduce any issues.Verification successful
The change of the
addr
parameter type fromsdk.Address
tostring
inValidateAccountInGenesis
and its comparison withaccAddress
usingstrings.EqualFold
are correctly implemented. The verification of the function calls in the codebase confirms that the new parameter type is being correctly handled. No issues introduced by this change were found.Scripts Executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Verify if ValidateAccountInGenesis correctly handles the new parameter type ast-grep --lang go --pattern $'genutil.ValidateAccountInGenesis($_, $_, $_, $_, $_)'Length of output: 462
x/genutil/types/genesis_state_test.go (1)
44-53
: Verify that the use ofvalAc.BytesToString
to convert validator addresses before creating messages in test functions is correctly implemented and aligns with the refactor's objectives.x/genutil/genaccounts.go (1)
27-38
: Confirm that the addition of theaddressCodec
parameter to theAddGenesisAccount
function and its use in converting account addresses is correctly implemented and aligns with the refactor's objectives.x/genutil/collect.go (1)
28-28
: Ensure the newly addedaddressCodec
parameter is properly documented in the function's comment to explain its purpose and usage.testutil/network/util.go (1)
153-154
: Ensure that the addedcfg.ValidatorAddressCodec
andcfg.AddressCodec
parameters are properly documented in thecollectGenFiles
function's comment to explain their purpose and usage.x/genutil/client/cli/gentx.go (1)
125-128
: Consider adding a comment above the address conversion logic to explain why the conversion is necessary, enhancing code readability and maintainability.x/genutil/gentx_test.go (3)
56-56
: Ensure thevalAc
variable is properly documented in theSetupTest
method to explain its purpose, especially its role in address conversion.
170-174
: Consider adding a comment above the address conversion logic to explain why the conversion is necessary in the context of the test, enhancing code readability.
192-192
: In the test case "account without balance in the genesis state", ensure that the address used (addr2Str
) aligns with the test's intention. Ifaddr1Str
was intended to be used here, correct it accordingly.Verification successful
The analysis of the test case "account without balance in the genesis state" indicates that the use of
addr2Str
is intentional and aligns with the test's purpose. The distinction betweenaddr2Str
andaddr1Str
in different test scenarios suggests deliberate usage catering to specific test intentions. Therefore, the original review comment appears to be based on a misunderstanding of the test case's intention.Scripts Executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Verify if addr2Str is intentionally used in this test case or if it should be addr1Str. echo "Review the test case 'account without balance in the genesis state' to ensure the correct address is used."Length of output: 228
Script:
#!/bin/bash # Search for the test case "account without balance in the genesis state" and extract relevant code to understand the use of addr2Str and addr1Str rg "account without balance in the genesis state" -A 30 x/genutil/gentx_test.goLength of output: 1126
simapp/simd/cmd/testnet.go (3)
13-18
: > 📝 NOTEThis review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [1-41]
Ensure all removed imports, such as the
address
package, are no longer referenced in the file. This aligns with the PR's objective to refactor address handling.
302-302
: Replace direct address handling withclientCtx.ValidatorAddressCodec
for converting addresses, aligning with the PR's objective to improve address representation.- valStr, err := address.ValidatorAddressCodec.BytesToString(sdk.ValAddress(addr)) + valStr, err := clientCtx.ValidatorAddressCodec.BytesToString(sdk.ValAddress(addr))
440-440
: Ensure the use ofclientCtx.ValidatorAddressCodec
andclientCtx.AddressCodec
in address handling is correctly implemented and aligns with the refactor's objectives.CHANGELOG.md (4)
112-115
: The changes described forx/genutil
are clear and accurately reflect the modifications made in the PR. Ensure that all related documentation and examples are updated to reflect these changes.
115-115
: The removal ofservertypes.ModuleInitFlags
and adjustments inserver.AddCommands
are well-documented. Ensure that any related guides or documentation are updated accordingly.
115-115
: The modifications toMsgSimulatorFn
intypes
, including the argument replacement and error handling, are clearly documented. Ensure that all relevant documentation reflects these changes.
115-115
: The removal ofAccounts.String
intypes
is well-documented. Ensure that any impacted areas of the SDK or documentation are updated to reflect this change.
valAccAddr, err := addressCodec.BytesToString(valAddr) | ||
if err != nil { | ||
return appGenTxs, persistentPeers, err | ||
} |
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.
Convert the error message to use fmt.Errorf
with %w
to wrap the original error, enhancing error handling by preserving the original error context.
- return appGenTxs, persistentPeers, err
+ return appGenTxs, persistentPeers, fmt.Errorf("error converting bytes to string: %w", err)
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
valAccAddr, err := addressCodec.BytesToString(valAddr) | |
if err != nil { | |
return appGenTxs, persistentPeers, err | |
} | |
valAccAddr, err := addressCodec.BytesToString(valAddr) | |
if err != nil { | |
return appGenTxs, persistentPeers, fmt.Errorf("error converting bytes to string: %w", err) | |
} |
addr, err := addresscodec.NewBech32Codec("cosmos").BytesToString(addr1) | ||
suite.Require().NoError(err) | ||
|
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.
The conversion of addr1
to a string using addresscodec.NewBech32Codec("cosmos").BytesToString(addr1)
seems redundant since addr1Str
is already available. Consider using addr1Str
directly to avoid unnecessary conversions.
- addr, err := addresscodec.NewBech32Codec("cosmos").BytesToString(addr1)
- suite.Require().NoError(err)
+ addr := addr1Str
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
addr, err := addresscodec.NewBech32Codec("cosmos").BytesToString(addr1) | |
suite.Require().NoError(err) | |
addr := addr1Str |
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.
Actionable comments posted: 2
Review Status
Configuration used: .coderabbit.yml
Files selected for processing (2)
- CHANGELOG.md (1 hunks)
- simapp/simd/cmd/testnet_test.go (2 hunks)
Additional Context Used
Path-based Instructions (2)
simapp/simd/cmd/testnet_test.go (2)
Pattern
**/*.go
: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.
Pattern
**/*_test.go
: "Assess the unit test code assessing sufficient code coverage for the changes associated in the pull request"CHANGELOG.md (1)
Pattern
**/*.md
: "Assess the documentation for misspellings, grammatical errors, missing documentation and correctness"
Additional comments not posted (3)
simapp/simd/cmd/testnet_test.go (3)
50-50
: LGTM! The introduction ofcdcOpts
for codec options is a clean way to manage codec configurations.
51-51
: The modification to includecdcOpts
inMakeTestEncodingConfig
aligns well with the refactor's goals for improved address handling.
63-65
: The updates to theclientCtx
setup, including address and validator codecs, are crucial for aligning the test environment with the new address handling mechanism.
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
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.
nice cleanup!
* main: (45 commits) build(deps): Bump github.com/decred/dcrd/dcrec/secp256k1/v4 from 4.2.0 to 4.3.0 (cosmos#19913) build(deps): Bump google.golang.org/grpc from 1.62.1 to 1.63.0 (cosmos#19929) test(types/address): add additional unit tests for address.LengthPrefix and a… (cosmos#19964) refactor(x/bank)!: remove Address.String() (cosmos#19954) build(deps): Bump github.com/prometheus/common from 0.51.1 to 0.52.2 (cosmos#19930) fix(x/epochs): Fix init genesis (cosmos#19958) feat(core,runtime): transaction service (exec mode) (cosmos#19953) fix(x/authz): non utf-8 characters in logs (cosmos#19923) build(deps): Bump golang.org/x/crypto from 0.21.0 to 0.22.0 (cosmos#19960) chore: fix spelling errors (cosmos#19957) fix(x/tx): don't shadow Amino marshalling error messages (cosmos#19955) refactor(types): loosen module.AppModule interface (cosmos#19951) feat(core): add `TxValidator` interface (cosmos#19950) build(deps): Bump cosmossdk.io/store from 1.0.2 to 1.1.0 in /x/epochs (cosmos#19947) feat(x/epochs): upstream osmosis epoch module (cosmos#19697) build(deps): Bump bufbuild/buf-setup-action from 1.30.0 to 1.30.1 (cosmos#19928) refactor(x/genutil)!: remove Address.String() (cosmos#19926) docs(x/mint): Fix inconsistency in mint docs (cosmos#19915) build(deps): Bump github.com/regen-network/gocuke from 1.1.0 to 1.1.1 in /orm (cosmos#19920) feat: Integrate grpc configuration into client.toml (cosmos#19905) ...
Description
ref:
#13140
#7448
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