-
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(authz): add go.mod #18265
refactor(authz): add go.mod #18265
Conversation
WalkthroughThe changes primarily involve the migration of the Changes
TipsChat with CodeRabbit Bot (
|
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: 2
Configuration used: CodeRabbit UI
Files ignored due to filter (8)
- go.mod
- go.sum
- simapp/go.mod
- tests/go.mod
- tests/starship/tests/go.mod
- x/authz/go.mod
- x/authz/go.sum
- x/group/go.mod
Files selected for processing (52)
- .github/workflows/test.yml (1} hunks)
- CHANGELOG.md (1} hunks)
- UPGRADING.md (1} hunks)
- go.work.example (2} hunks)
- proto/cosmos/authz/module/v1/module.proto (1} hunks)
- proto/cosmos/authz/v1beta1/authz.proto (1} hunks)
- proto/cosmos/authz/v1beta1/event.proto (1} hunks)
- proto/cosmos/authz/v1beta1/genesis.proto (1} hunks)
- proto/cosmos/authz/v1beta1/query.proto (1} hunks)
- proto/cosmos/authz/v1beta1/tx.proto (1} hunks)
- simapp/app.go (2} hunks)
- simapp/app_config.go (2} hunks)
- simapp/app_test.go (2} hunks)
- simapp/app_v2.go (2} hunks)
- simapp/sim_test.go (2} hunks)
- tests/e2e/authz/grpc.go (1} hunks)
- tests/e2e/authz/tx.go (2} hunks)
- tests/integration/rapidgen/rapidgen.go (2} hunks)
- tests/integration/tx/aminojson/aminojson_test.go (2} hunks)
- tests/integration/tx/decode_test.go (2} hunks)
- x/authz/CHANGELOG.md (1} hunks)
- x/authz/client/cli/tx.go (2} hunks)
- x/authz/client/cli/tx_test.go (2} hunks)
- x/authz/client/testutil/helpers.go (1} hunks)
- x/authz/generic_authorization_test.go (1} hunks)
- x/authz/internal/conv/string.go (1} hunks)
- x/authz/keeper/genesis.go (1} hunks)
- x/authz/keeper/genesis_test.go (2} hunks)
- x/authz/keeper/grpc_query.go (1} hunks)
- x/authz/keeper/grpc_query_test.go (1} hunks)
- x/authz/keeper/keeper.go (1} hunks)
- x/authz/keeper/keeper_test.go (2} hunks)
- x/authz/keeper/keys.go (1} hunks)
- x/authz/keeper/migrations.go (1} hunks)
- x/authz/keeper/msg_server.go (1} hunks)
- x/authz/keeper/msg_server_test.go (1} hunks)
- x/authz/migrations/v2/keys.go (2} hunks)
- x/authz/migrations/v2/store.go (1} hunks)
- x/authz/migrations/v2/store_test.go (2} hunks)
- x/authz/module/abci.go (1} hunks)
- x/authz/module/abci_test.go (2} hunks)
- x/authz/module/module.go (1} hunks)
- x/authz/msgs_test.go (2} hunks)
- x/authz/simulation/decoder.go (1} hunks)
- x/authz/simulation/decoder_test.go (1} hunks)
- x/authz/simulation/genesis.go (1} hunks)
- x/authz/simulation/genesis_test.go (1} hunks)
- x/authz/simulation/operations.go (2} hunks)
- x/authz/simulation/operations_test.go (2} hunks)
- x/authz/sonar-project.properties (1} hunks)
- x/authz/testutil/app_config.go (1} hunks)
- x/group/testutil/app_config.go (1} hunks)
Files skipped from review due to trivial changes (35)
- .github/workflows/test.yml
- CHANGELOG.md
- UPGRADING.md
- go.work.example
- proto/cosmos/authz/module/v1/module.proto
- proto/cosmos/authz/v1beta1/authz.proto
- proto/cosmos/authz/v1beta1/event.proto
- proto/cosmos/authz/v1beta1/genesis.proto
- proto/cosmos/authz/v1beta1/query.proto
- proto/cosmos/authz/v1beta1/tx.proto
- simapp/app.go
- simapp/app_config.go
- simapp/app_test.go
- tests/e2e/authz/grpc.go
- tests/integration/rapidgen/rapidgen.go
- tests/integration/tx/aminojson/aminojson_test.go
- tests/integration/tx/decode_test.go
- x/authz/CHANGELOG.md
- x/authz/client/cli/tx.go
- x/authz/client/cli/tx_test.go
- x/authz/client/testutil/helpers.go
- x/authz/generic_authorization_test.go
- x/authz/keeper/genesis.go
- x/authz/keeper/grpc_query.go
- x/authz/keeper/grpc_query_test.go
- x/authz/keeper/keeper.go
- x/authz/keeper/msg_server.go
- x/authz/migrations/v2/store.go
- x/authz/module/module.go
- x/authz/simulation/decoder_test.go
- x/authz/simulation/genesis.go
- x/authz/simulation/genesis_test.go
- x/authz/sonar-project.properties
- x/authz/testutil/app_config.go
- x/group/testutil/app_config.go
Additional comments: 27
x/authz/module/abci.go (1)
- 6-6: The import path for the
keeper
package has been updated fromgit.luolix.top/cosmos/cosmos-sdk/x/authz/keeper
tocosmossdk.io/x/authz/keeper
. Ensure that the new import path is correct and the package is available at the new location. Also, verify that all references to thekeeper
package in the codebase have been updated to reflect this change.x/authz/keeper/migrations.go (1)
- 4-4: The import path for the
v2
package has been updated fromgit.luolix.top/cosmos/cosmos-sdk/x/authz/migrations/v2
tocosmossdk.io/x/authz/migrations/v2
. Ensure that the new path is correct and the package is available at the new location. Also, verify that all references to thev2
package in the codebase have been updated to use the new import path.x/authz/keeper/keys.go (1)
- 6-11: The import paths have been updated to reflect the new package structure or repository location. Ensure that the new paths are correct and that the necessary packages are available at these locations. Also, verify that all references to these packages in the code have been updated to use the new paths.
x/authz/keeper/msg_server_test.go (1)
- 10-10: The import path for the
authz
package has been updated fromgit.luolix.top/cosmos/cosmos-sdk/x/authz
tocosmossdk.io/x/authz
. Ensure that the new package location is accessible and contains the expected code.x/authz/simulation/decoder.go (1)
- 7-8: The import paths for
authz
andkeeper
have been updated fromgit.luolix.top/cosmos/cosmos-sdk/x/authz
andgit.luolix.top/cosmos/cosmos-sdk/x/authz/keeper
tocosmossdk.io/x/authz
andcosmossdk.io/x/authz/keeper
respectively. This indicates a change in the package structure or repository location. Ensure that the new paths are correct and accessible, and that all references to these packages in the codebase have been updated to the new paths.x/authz/migrations/v2/store_test.go (2)
11-13: The import paths for the
authz
module and its migration package have been updated fromgit.luolix.top/cosmos/cosmos-sdk/x/authz
tocosmossdk.io/x/authz
. This indicates a change in the package structure or repository location. Ensure that the new import paths are correct and that the packages are available at the new locations.19-24: The import paths for the
authz
module and its migration package have been removed. This is consistent with the changes in the previous hunk, where the import paths were updated to the new locations. Ensure that all references to these packages in the code have been updated to use the new import paths.x/authz/keeper/genesis_test.go (2)
14-16: The import paths for the
keeper
,module
, andtestutil
packages have been updated fromgit.luolix.top/cosmos/cosmos-sdk/x/authz
tocosmossdk.io/x/authz
. This indicates a change in the package structure or repository location. Ensure that the new paths are correct and that the packages are available at these locations.22-26: The import paths for the
testutil
,types
,module/testutil
, andx/bank/types
packages remain the same, indicating that these packages have not been moved or restructured. Ensure that these packages are still available at these locations and that they are compatible with the updatedauthz
module.simapp/sim_test.go (2)
22-22: The import path for
authzkeeper
has been updated fromgit.luolix.top/cosmos/cosmos-sdk/x/authz/keeper
tocosmossdk.io/x/authz/keeper
. Ensure that the new path is correct and the package is available at the new location. Also, verify that all references toauthzkeeper
in the code have been updated to use the new import.29-34: The import for
authzkeeper
has been removed from this section. This change is consistent with the addition ofauthzkeeper
in the previous hunk. No other changes have been made to the imports in this section.x/authz/msgs_test.go (2)
15-15: The import path for the
authz
package has been updated fromgit.luolix.top/cosmos/cosmos-sdk/x/authz
tocosmossdk.io/x/authz
. This change indicates a possible restructuring of the package or a change in the repository location. Ensure that the new import path is correct and accessible.21-25: The import paths for the
cdctypes
,sdk
,legacytx
, andbanktypes
packages remain unchanged and still point github.com/cosmos/cosmos-sdk
. If theauthz
package has been moved to a new repository or location (cosmossdk.io
), consider whether these packages should also be moved or if they should remain in thecosmos/cosmos-sdk
repository. If they are moved, their import paths will need to be updated accordingly.x/authz/keeper/keeper_test.go (2)
13-16: The import paths for the
authz
module have been updated fromgit.luolix.top/cosmos/cosmos-sdk/x/authz
tocosmossdk.io/x/authz
. This indicates a change in the package structure or repository location. Please ensure that the new paths are correct and that the package is available at the new location.22-26: The import paths for the
cosmos-sdk
modules have not been changed. This suggests that only theauthz
module has been moved to a different location. Please confirm if this is the intended behavior.simapp/app_v2.go (2)
15-15: The import path for
authzkeeper
has been updated fromgit.luolix.top/cosmos/cosmos-sdk/x/authz/keeper
tocosmossdk.io/x/authz/keeper
. Ensure that the new package atcosmossdk.io/x/authz/keeper
has the same exported functions and types as the old package atgit.luolix.top/cosmos/cosmos-sdk/x/authz/keeper
to avoid breaking changes.41-46: The import statement for
authzkeeper
has been removed from this section. This change is consistent with the addition ofauthzkeeper
in the new hunk at line 15. No action is needed here as long as the new package atcosmossdk.io/x/authz/keeper
is equivalent to the old package atgit.luolix.top/cosmos/cosmos-sdk/x/authz/keeper
.x/authz/simulation/operations.go (2)
7-8: The import paths for the
authz
andkeeper
packages have been updated fromgit.luolix.top/cosmos/cosmos-sdk/x/authz
andgit.luolix.top/cosmos/cosmos-sdk/x/authz/keeper
tocosmossdk.io/x/authz
andcosmossdk.io/x/authz/keeper
respectively. This indicates a change in the package structure or repository location. Ensure that the new paths are correct and that the packages are available at these locations.15-20: The import statements for the
authz
andkeeper
packages have been removed from this section. This is consistent with the addition of these import statements at the beginning of the file with updated paths. No other changes have been made to the import statements in this section.x/authz/module/abci_test.go (2)
13-16: The import paths for the
authz
module have been updated fromgit.luolix.top/cosmos/cosmos-sdk/x/authz
tocosmossdk.io/x/authz
. This indicates a change in the package structure or repository location. Ensure that the new import paths are correct and that theauthz
module is available at the new location. Also, verify that all references to theauthz
module in the codebase have been updated to use the new import paths.23-27: The import paths for the
sdk
,module/testutil
,x/auth/types
, andx/bank/types
modules remain unchanged and still point github.com/cosmos/cosmos-sdk
. This suggests that only theauthz
module has been moved to a new location. Confirm that this is the intended behavior and that the other modules are still located in thegit.luolix.top/cosmos/cosmos-sdk
repository.x/authz/internal/conv/string.go (2)
1-9: The
UnsafeStrToBytes
function uses theunsafe
package to convert a string to a byte slice without allocating new memory. This can be a performance optimization in some cases, but it comes with risks. The returned byte slice shares the same underlying memory as the original string. Therefore, any modification to the returned byte slice will also modify the original string, which can lead to unexpected behavior. This function should be used with caution, and it's important to ensure that the returned byte slice is not modified after this function is called.11-17: The
UnsafeBytesToStr
function also uses theunsafe
package to convert a byte slice to a string without allocating new memory. This function is even riskier thanUnsafeStrToBytes
, because it assumes that the byte slice can be safely reinterpreted as a string. This is not always the case, especially if the byte slice contains data that is not valid UTF-8. This function should be used with extreme caution, and only when it is known for certain that the byte slice contains valid UTF-8 data.- return *(*string)(unsafe.Pointer(&b)) + return *(*string)(unsafe.Pointer(&b[:0]))The above change ensures that the string shares the same underlying array as the byte slice but does not include any of the byte slice's elements. This is safer because it prevents the string from including any non-UTF-8 data that might be in the byte slice.
Committable suggestion (Beta)
func UnsafeBytesToStr(b []byte) string { return *(*string)(unsafe.Pointer(&b[:0])) }
x/authz/simulation/operations_test.go (2)
15-18: The import paths for the
authz
module have been updated fromgit.luolix.top/cosmos/cosmos-sdk/x/authz
tocosmossdk.io/x/authz
. This indicates a change in the package structure or repository location. Ensure that the new paths are correct and that the package is available at the new location. Also, verify that all references to theauthz
module in the codebase have been updated to reflect this change.25-30: The import paths for the
authz
module in the old hunk have been removed, and the new hunk does not include any changes to these paths. This is consistent with the changes in the previous hunk, where theauthz
module was moved to a new location. Ensure that the removal of these import paths does not affect any other parts of the codebase that depend on them.tests/e2e/authz/tx.go (1)
- 13-15: The import paths for
authz
,cli
, andtestutil
have been updated fromgit.luolix.top/cosmos/cosmos-sdk/x/authz
tocosmossdk.io/x/authz
. This indicates a change in the package structure or repository location. Ensure that the new paths are correct and the packages are available at these locations.x/authz/migrations/v2/keys.go (1)
- 5-8: The import path for the
conv
package has been updated fromgit.luolix.top/cosmos/cosmos-sdk/internal/conv
tocosmossdk.io/x/authz/internal/conv
. This change is consistent with the PR summary, which mentions updating import paths due to a change in the package structure or repository location. Please ensure that the new import path is correct and accessible.
"github.com/cosmos/cosmos-sdk/testutil/network" | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
authcli "github.com/cosmos/cosmos-sdk/x/auth/client/cli" | ||
"github.com/cosmos/cosmos-sdk/x/authz" | ||
"github.com/cosmos/cosmos-sdk/x/authz/client/cli" | ||
authzclitestutil "github.com/cosmos/cosmos-sdk/x/authz/client/testutil" | ||
bank "github.com/cosmos/cosmos-sdk/x/bank/types" | ||
) |
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 import paths for network
, types
, cli
, and types
have not been updated to the new cosmossdk.io
domain. If the entire project has been moved to the new domain, these import paths should also be updated to reflect the new location.
- "github.com/cosmos/cosmos-sdk/testutil/network"
- sdk "github.com/cosmos/cosmos-sdk/types"
- authcli "github.com/cosmos/cosmos-sdk/x/auth/client/cli"
- bank "github.com/cosmos/cosmos-sdk/x/bank/types"
+ "cosmossdk.io/testutil/network"
+ sdk "cosmossdk.io/types"
+ authcli "cosmossdk.io/x/auth/client/cli"
+ bank "cosmossdk.io/x/bank/types"
Committable suggestion (Beta)
"github.com/cosmos/cosmos-sdk/testutil/network" | |
sdk "github.com/cosmos/cosmos-sdk/types" | |
authcli "github.com/cosmos/cosmos-sdk/x/auth/client/cli" | |
"github.com/cosmos/cosmos-sdk/x/authz" | |
"github.com/cosmos/cosmos-sdk/x/authz/client/cli" | |
authzclitestutil "github.com/cosmos/cosmos-sdk/x/authz/client/testutil" | |
bank "github.com/cosmos/cosmos-sdk/x/bank/types" | |
) | |
"cosmossdk.io/testutil/network" | |
sdk "cosmossdk.io/types" | |
authcli "cosmossdk.io/x/auth/client/cli" | |
bank "cosmossdk.io/x/bank/types" |
x/authz/migrations/v2/keys.go
Outdated
b := key[2+granterAddrLen+byte(granteeAddrLen):] | ||
return granterAddr, granteeAddr, *(*string)(unsafe.Pointer(&b)) |
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 function conv.UnsafeBytesToStr
has been replaced with an inline unsafe operation to convert a byte slice to a string. While this operation is technically correct, it reduces the readability of the code and may introduce potential risks associated with unsafe operations. It's generally recommended to encapsulate unsafe operations within functions, which can provide additional checks and balances. If the conv.UnsafeBytesToStr
function is still available, consider reverting to using it.
- return granterAddr, granteeAddr, *(*string)(unsafe.Pointer(&b))
+ return granterAddr, granteeAddr, conv.UnsafeBytesToStr(b)
Committable suggestion (Beta)
b := key[2+granterAddrLen+byte(granteeAddrLen):] | |
return granterAddr, granteeAddr, *(*string)(unsafe.Pointer(&b)) | |
kv.AssertKeyAtLeastLength(key, 3+int(granterAddrLen+byte(granteeAddrLen))) | |
granteeAddr = sdk.AccAddress(key[2+granterAddrLen : 2+granterAddrLen+byte(granteeAddrLen)]) | |
b := key[2+granterAddrLen+byte(granteeAddrLen):] | |
return granterAddr, granteeAddr, conv.UnsafeBytesToStr(b) | |
} |
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 UI
Files ignored due to filter (5)
- x/authz/authz.pb.go
- x/authz/event.pb.go
- x/authz/genesis.pb.go
- x/authz/query.pb.go
- x/authz/tx.pb.go
Files selected for processing (1)
- api/cosmos/authz/module/v1/module.pulsar.go (1} hunks)
Additional comments: 1
api/cosmos/authz/module/v1/module.pulsar.go (1)
- 421-422: The import path has been updated from
github.com/cosmos/cosmos-sdk/x/authz
tocosmossdk.io/x/authz
. This change indicates a shift in the package structure or repository location. Ensure that the new import path is correct and accessible, and that all references to the package in the codebase have been updated to reflect this change.
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 UI
Files selected for processing (4)
- UPGRADING.md (2} hunks)
- contrib/images/simd-env/Dockerfile (1} hunks)
- go.work.example (2} hunks)
- x/authz/migrations/v2/keys.go (1} hunks)
Files skipped from review due to trivial changes (4)
- UPGRADING.md
- contrib/images/simd-env/Dockerfile
- go.work.example
- x/authz/migrations/v2/keys.go
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.
lgtm
@@ -0,0 +1,14 @@ | |||
sonar.projectKey=cosmos-sdk-x-authz |
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.
Description
ref #11899
this pr spins out authz into its own go.mod
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...
!
to the type prefix if API or client breaking changeCHANGELOG.md
make lint
andmake test
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...
!
in the type prefix if API or client breaking changeSummary by CodeRabbit
authz
which enhances the software's intuitiveness by providing a separate environment for authorization-related functionalities.group
,gov
,distribution
,slashing
,staking
,authz
) have been spun out into their owngo.mod
files, improving the modularity and maintainability of the codebase.test-x-authz
to the workflow, enhancing the reliability of theauthz
package by running tests and generating a coverage report whenever changes are made.authz
module, ensuring consistency and correctness in the codebase.authz
module, facilitating better tracking of changes and improvements in the future.