-
Notifications
You must be signed in to change notification settings - Fork 14
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(gov): correct queryServer and autocli functionality #725
Conversation
WalkthroughThe pull request introduces several modifications across multiple files, primarily focusing on the restructuring of module management and the governance query server. The Changes
Possibly related PRs
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 using PR comments)
Other keywords and placeholders
CodeRabbit Configuration 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: 3
🧹 Outside diff range and nitpick comments (5)
x/migrate/keeper/gov_test.go (1)
32-32
: LGTM! Consider adding a comment for clarity.The simplification of
govImpl
instantiation is a good change. It directly usesfxgovkeeper.NewMsgServerImpl
, which aligns with the overall modifications mentioned in the PR summary.Consider adding a brief comment explaining the purpose of
govImpl
for better code readability:+// Create a new governance message server implementation govImpl := fxgovkeeper.NewMsgServerImpl(suite.App.GovKeeper)
x/gov/keeper/msg_server.go (1)
27-31
: LGTM: Function signature simplified and implementation improved.The changes to
NewMsgServerImpl
are well-structured and align with the PR objectives. The simplified function signature and use ofgovkeeper.NewMsgServerImpl(k.Keeper)
improve maintainability and consistency with the Cosmos SDK.Consider adding error handling:
func NewMsgServerImpl(k *Keeper) types.MsgServerPro { + if k == nil { + panic("Keeper cannot be nil") + } return &msgServer{ MsgServer: govkeeper.NewMsgServerImpl(k.Keeper), Keeper: k, } }This addition would prevent potential nil pointer dereferences if the function is called with a nil Keeper.
x/gov/keeper/keeper_test.go (1)
Line range hint
307-346
: LGTM: Comprehensive test cases for CheckContractAddressIsDisabledThe new
TestCheckContractAddressIsDisabled
function is a well-structured addition to the test suite. It uses table-driven tests to cover various scenarios, including empty disabled list, disabled address, disabled address and method, and non-disabled cases. This comprehensive approach ensures thorough testing of theCheckContractAddressIsDisabled
function.Consider adding a test case for an invalid hex address or method ID to ensure the function handles malformed input correctly.
x/gov/keeper/grpc_query.go (2)
25-28
: Consider renaming the fieldk
for clarityIn the
QueryServer
struct:type QueryServer struct { v1.QueryServer k *Keeper }The field
k
refers to the keeper instance, but using a single-letter variable can reduce readability. Consider renamingk
tokeeper
for better clarity and consistency.
107-110
: Rename fieldqs
to avoid confusionIn the
legacyQueryServer
struct:type legacyQueryServer struct { v1beta1.QueryServer qs v1.QueryServer }The field
qs
is similar to the receiverq
, which may cause confusion. Consider renamingqs
toqueryServer
for clarity.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (6)
- app/app.go (1 hunks)
- x/gov/keeper/grpc_query.go (5 hunks)
- x/gov/keeper/keeper_test.go (1 hunks)
- x/gov/keeper/msg_server.go (2 hunks)
- x/gov/module.go (2 hunks)
- x/migrate/keeper/gov_test.go (2 hunks)
🧰 Additional context used
🔇 Additional comments (12)
x/migrate/keeper/gov_test.go (2)
77-77
: LGTM! Consistent with previous change.The simplification of
govImpl
instantiation is consistent with the change inTestMigrateGovInactive
. This maintains uniformity across both test functions, which is a good practice.
Line range hint
1-124
: Overall, the changes look good and align with the PR objectives.The modifications in this file simplify the instantiation of the governance message server (
govImpl
) in both test functions. These changes:
- Improve code clarity by directly using
fxgovkeeper.NewMsgServerImpl
.- Maintain consistency across both test functions.
- Do not alter the core functionality of the tests.
The changes align with the PR objectives of correcting queryServer and autocli functionality, specifically in the context of governance-related operations.
x/gov/keeper/msg_server.go (2)
13-13
: LGTM: Import addition is appropriate.The addition of the
govkeeper
import is consistent with the changes made in theNewMsgServerImpl
function. This import allows the use ofgovkeeper.NewMsgServerImpl()
, which is now being utilized in the updated implementation.
Line range hint
1-265
: LGTM: Changes well-integrated with existing code.The modifications to
NewMsgServerImpl
and the addition of thegovkeeper
import are well-integrated with the rest of the file. The existing method implementations and themsgServer
struct remain unchanged and compatible with the new changes. This approach maintains the current functionality while improving the code structure.x/gov/keeper/keeper_test.go (1)
50-53
: LGTM: Simplified initialization of msgServer and queryClientThe changes to the
SetupTest
method streamline the initialization process by directly utilizing thekeeper
implementation from thefx-core
module. This simplification removes the dependency on thegovkeeper
fromcosmos-sdk
and aligns with the overall refactoring of the governance module.app/app.go (1)
Line range hint
446-452
: Approved: Enhanced module iteration in AutoCliOptsThis change improves the
AutoCliOpts
method by iterating overapp.mm.Modules
instead ofapp.ModuleBasics
. This modification ensures that all registered modules, including any additional or custom modules, are properly included in the autocli options. This aligns well with the PR objective of correcting autocli functionality.The new implementation should provide a more comprehensive set of autocli options, potentially including modules that may not have been present in the basic module manager. This change enhances the flexibility and completeness of the autocli feature.
x/gov/keeper/grpc_query.go (2)
119-133
: Ensure compatibility inTallyResult
for legacy queriesIn the
legacyQueryServer.TallyResult
method, you're converting the response to a legacy format. Verify that all fields are correctly converted and that the legacy clients receive the expected data.
Line range hint
69-104
: Ensure proper error handling inTallyResult
In the
TallyResult
method, while handling different proposal statuses, ensure that all potential errors are properly checked and returned.Run the following script to check for unhandled errors:
This script searches for instances where an error is assigned but not immediately checked, which could lead to unhandled errors.
x/gov/module.go (4)
85-88
: EmbeddingAppModuleBasic
and renaming variables for clarityEmbedding
AppModuleBasic
directly intoAppModule
enhances code modularity and leverages Go's embedding capabilities for cleaner interface implementation. Renamingak
andbk
toaccountKeeper
andbankKeeper
improves readability by making the variable names more descriptive.
96-99
: Ensure proper initialization ofAppModuleBasic
In the
NewAppModule
function,AppModuleBasic
is initialized with an empty struct. IfAppModuleBasic
requires specific initialization (e.g., proposal handlers), consider invokingNewAppModuleBasic
to ensure all necessary fields are properly set.Verify if
AppModuleBasic
needs to be initialized with proposal handlers or other parameters. If so, update the initialization accordingly:func NewAppModule(cdc codec.Codec, keeper *keeper.Keeper, ak govtypes.AccountKeeper, bk govtypes.BankKeeper, ss govtypes.ParamSubspace) AppModule { return AppModule{ - AppModuleBasic: AppModuleBasic{}, + AppModuleBasic: NewAppModuleBasic(/* pass necessary parameters */), keeper: keeper, accountKeeper: ak, bankKeeper: bk, cdc: cdc, legacySubspace: ss, } }
105-110
: Confirm empty method implementations for interface complianceThe methods
IsOnePerModuleType
andIsAppModule
have empty bodies to satisfy thedepinject.OnePerModuleType
andappmodule.AppModule
interfaces. Ensure that these methods do not require any additional logic and that empty implementations are acceptable.Confirm that the interfaces are marker interfaces and that no further implementation is necessary.
162-162
: Correct implementation ofConsensusVersion
methodThe
ConsensusVersion
method correctly returns the consensus version from thegov
module. This ensures that the module's consensus version is accurately communicated during upgrades.
Summary by CodeRabbit
New Features
QueryServer
type for improved query handling.legacyQueryServer
type.AppModule
structure with new methods for better organization.Bug Fixes
Chores
msgServer
andgovImpl
in tests.