-
Notifications
You must be signed in to change notification settings - Fork 124
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
[CORE-827] Scaffolding code for x/ibcratelimit
#870
Conversation
WalkthroughThe changes involve the introduction of a new 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: 20
Configuration used: CodeRabbit UI
Files ignored due to filter (2)
- protocol/x/ibcratelimit/types/query.pb.go
- protocol/x/ibcratelimit/types/query.pb.gw.go
Files selected for processing (30)
- indexer/packages/v4-protos/src/codegen/dydxprotocol/bundle.ts (5 hunks)
- indexer/packages/v4-protos/src/codegen/dydxprotocol/ibcratelimit/query.lcd.ts (1 hunks)
- indexer/packages/v4-protos/src/codegen/dydxprotocol/lcd.ts (1 hunks)
- proto/dydxprotocol/ibcratelimit/query.proto (1 hunks)
- protocol/x/ibcratelimit/client/cli/query.go (1 hunks)
- protocol/x/ibcratelimit/client/cli/query_params.go (1 hunks)
- protocol/x/ibcratelimit/client/cli/query_params_test.go (1 hunks)
- protocol/x/ibcratelimit/client/cli/tx.go (1 hunks)
- protocol/x/ibcratelimit/genesis.go (1 hunks)
- protocol/x/ibcratelimit/genesis_test.go (1 hunks)
- protocol/x/ibcratelimit/keeper/grpc_query.go (1 hunks)
- protocol/x/ibcratelimit/keeper/grpc_query_test.go (1 hunks)
- protocol/x/ibcratelimit/keeper/keeper.go (1 hunks)
- protocol/x/ibcratelimit/keeper/keeper_test.go (1 hunks)
- protocol/x/ibcratelimit/keeper/msg_server.go (1 hunks)
- protocol/x/ibcratelimit/keeper/msg_server_test.go (1 hunks)
- protocol/x/ibcratelimit/module.go (1 hunks)
- protocol/x/ibcratelimit/module_simulation.go (1 hunks)
- protocol/x/ibcratelimit/module_test.go (1 hunks)
- protocol/x/ibcratelimit/simulation/helpers.go (1 hunks)
- protocol/x/ibcratelimit/types/codec.go (1 hunks)
- protocol/x/ibcratelimit/types/errors.go (1 hunks)
- protocol/x/ibcratelimit/types/expected_keepers.go (1 hunks)
- protocol/x/ibcratelimit/types/genesis.go (1 hunks)
- protocol/x/ibcratelimit/types/genesis_test.go (1 hunks)
- protocol/x/ibcratelimit/types/keys.go (1 hunks)
- protocol/x/ibcratelimit/types/keys_test.go (1 hunks)
- protocol/x/ibcratelimit/types/params.go (1 hunks)
- protocol/x/ibcratelimit/types/tx.go (1 hunks)
- protocol/x/ibcratelimit/types/types.go (1 hunks)
Files skipped from review due to trivial changes (6)
- protocol/x/ibcratelimit/keeper/keeper_test.go
- protocol/x/ibcratelimit/keeper/msg_server_test.go
- protocol/x/ibcratelimit/module_test.go
- protocol/x/ibcratelimit/types/expected_keepers.go
- protocol/x/ibcratelimit/types/genesis_test.go
- protocol/x/ibcratelimit/types/types.go
Additional comments: 23
indexer/packages/v4-protos/src/codegen/dydxprotocol/bundle.ts (2)
95-98: The addition of
ibcratelimit
related imports and the reordering of existing imports align with the PR objectives and the summary provided.211-218: The addition of
ibcratelimit
properties to thedydxprotocol
namespace is consistent with the PR objectives and the summary provided.indexer/packages/v4-protos/src/codegen/dydxprotocol/lcd.ts (1)
- 33-35: The addition of the
ibcratelimit
property with its correspondingLCDQueryClient
instantiation is consistent with the PR's objective to scaffold code for thex/ibcratelimit
module.proto/dydxprotocol/ibcratelimit/query.proto (1)
- 2-23: The changes to the
query.proto
file correctly introduce HTTP annotations for theListLimitParams
andCapacityByDenom
RPC methods, enabling HTTP GET requests for these gRPC services. The import of "google/api/annotations.proto" is necessary for these annotations and is correctly added. The protobuf service definition is well-structured and follows the standard conventions for defining gRPC services with HTTP mappings.protocol/x/ibcratelimit/client/cli/query_params.go (1)
- 7-10: The
CmdQueryParams
function is a placeholder and currently returnsnil
. Ensure that the implementation of this function is tracked and prioritized as per the module's development plan.protocol/x/ibcratelimit/client/cli/tx.go (1)
- 13-14: The
DefaultRelativePacketTimeoutTimestamp
variable is defined but not used within this file. Ensure that it is used elsewhere in the codebase or consider removing it if it is not needed.
The
DefaultRelativePacketTimeoutTimestamp
variable is appropriately defined and used across various modules within the codebase. No further action is needed regarding this variable.protocol/x/ibcratelimit/genesis_test.go (1)
- 7-9: Placeholder for future test implementation is present as expected.
protocol/x/ibcratelimit/keeper/grpc_query.go (1)
- 13-19: The methods
ListLimitParams
andCapacityByDenom
are placeholders withUnimplemented
status errors. Ensure that the implementation of these methods is tracked and prioritized according to the project's roadmap, as indicated by the TODO comments referencing CORE-823.protocol/x/ibcratelimit/keeper/grpc_query_test.go (1)
- 7-9: Placeholder for future test implementation is noted. Ensure that the test for
TestQueryParams
is implemented to maintain code quality and test coverage.protocol/x/ibcratelimit/keeper/keeper.go (4)
27-36: The
NewKeeper
function correctly initializes theKeeper
struct, including the conversion of a slice of authorities to a unique set to prevent duplicates.39-41: The
HasAuthority
function is implemented correctly to check for the presence of an authority in theauthorities
map.44-45: The
Logger
function correctly creates a namespaced logger for thex/ibcratelimit
module.48-49: The
InitializeForGenesis
function is currently a placeholder and should be implemented as part of the module's genesis state initialization.protocol/x/ibcratelimit/keeper/msg_server.go (2)
24-38: The
SetLimitParams
function correctly checks for authority and returns an appropriate error if the authority is invalid. However, the actual business logic is marked as a TODO and needs to be implemented.41-55: Similarly, the
DeleteLimitParams
function also checks for authority and returns an error if the authority is invalid. The business logic is also marked as a TODO and needs to be implemented.protocol/x/ibcratelimit/module.go (2)
142-145: The initial
ConsensusVersion
is correctly set to 1, which is a good practice for versioning in Cosmos SDK modules.90-90: Verify that
types.StoreKey
used inGetQueryCmd
is consistent with the module's store key definition.
The verification of
types.StoreKey
confirms that it is defined within thetypes
package and is consistent with the module's store key definition, as it is set to the module name "ibcratelimit". This aligns with the standard practice in Cosmos SDK modules where the store key typically matches the module name.Final review comment:
The usage of
types.StoreKey
inGetQueryCmd
is consistent with the module's store key definition as verified.protocol/x/ibcratelimit/types/codec.go (2)
10-14: The
RegisterInterfaces
function registers the gRPC service description but does not show any registration of the message types with the interface registry. Ensure that all message types are properly registered with theInterfaceRegistry
to enable correct serialization and deserialization of messages.16-18: The
Amino
codec is declared but not used within the provided code. If it's intended for future use or backward compatibility, consider documenting its purpose to avoid confusion.protocol/x/ibcratelimit/types/errors.go (1)
- 9-13: The addition of
ErrInvalidAuthority
error type is consistent with the PR's objective to scaffold thex/ibcratelimit
module and introduce new types and error handling mechanisms.protocol/x/ibcratelimit/types/keys.go (1)
- 4-10: The constants for the module name and store key are correctly defined and follow Go naming conventions.
protocol/x/ibcratelimit/types/keys_test.go (1)
- 10-13: The tests for module and store keys are correctly checking the constants from the
types
package.protocol/x/ibcratelimit/types/tx.go (1)
- 28-28: Assuming
LimitParams.Validate()
is implemented elsewhere, verify that it properly validates all fields ofLimitParams
to ensure thatMsgSetLimitParams
is well-formed before being processed.
// Validate validates the set of params | ||
func (p *LimitParams) Validate() error { | ||
// TODO(CORE-824): implement keepers | ||
return nil | ||
} |
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 Validate
method currently does not perform any validation and contains a TODO comment. It is important to implement validation logic for LimitParams
to ensure that the parameters meet the expected criteria. If the implementation is pending due to other dependencies, consider adding more descriptive TODO comments to specify what needs to be done or what is being waited on.
RunE: client.ValidateCmd, | ||
} | ||
|
||
// TODO(CORE-823): implement query for `x/ibcratelimit` |
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 TODO
comment indicates that the query command implementation for x/ibcratelimit
is pending. Ensure that this is tracked in the project's issue tracking system to avoid missing this implementation in future updates.
func TestStateKeys(t *testing.T) { | ||
// TODO(CORE-824): test state keys | ||
} |
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 TestStateKeys
function is currently a placeholder with a TODO comment. Ensure that the tests for state keys are implemented before the final merge to maintain good test coverage.
// DefaultGenesis returns the default genesis state | ||
func DefaultGenesis() *GenesisState { | ||
// TODO(CORE-824): Implement keepers | ||
return nil | ||
} |
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 DefaultGenesis
function is currently returning nil
and contains a TODO
comment, indicating that the implementation is pending. Ensure that there is a tracking issue or item for this TODO
to prevent it from being overlooked.
// Validate performs basic genesis state validation returning an error upon any | ||
// failure. | ||
func (gs GenesisState) Validate() error { | ||
// TODO(CORE-824): Implement keepers | ||
return nil | ||
} |
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 Validate
function is also a placeholder with a TODO
comment. Similar to DefaultGenesis
, ensure that there is a tracking issue or item for this TODO
.
func (am AppModule) ProposalMsgs(simState module.SimulationState) []simtypes.WeightedProposalMsg { | ||
return []simtypes.WeightedProposalMsg{} |
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 ProposalMsgs
function returns an empty slice. For simulations to be effective, this should return a set of weighted governance proposal messages that are relevant to the ibcratelimit
module.
func TestQueryParams(t *testing.T) { | ||
// TODO(CORE-823): implement query for `x/ibcratelimit` | ||
} |
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 TestQueryParams
function is currently a placeholder. It's important to implement the actual test cases to ensure the x/ibcratelimit
module's query functionality works as expected. This should be prioritized to maintain high code quality and to catch any potential issues early.
func (msg *MsgSetLimitParams) GetSigners() []sdk.AccAddress { | ||
addr, _ := sdk.AccAddressFromBech32(msg.Authority) | ||
return []sdk.AccAddress{addr} |
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.
Ensure that the GetSigners
method correctly handles the case where sdk.AccAddressFromBech32(msg.Authority)
returns an error. Currently, the error is ignored, which could lead to unexpected behavior if Authority
is not a valid Bech32 address.
// GetTxCmd returns the transaction commands for this module | ||
func GetTxCmd() *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: types.ModuleName, | ||
Short: fmt.Sprintf("%s transactions subcommands", types.ModuleName), | ||
DisableFlagParsing: true, | ||
SuggestionsMinimumDistance: 2, | ||
RunE: client.ValidateCmd, | ||
} | ||
|
||
return cmd |
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 GetTxCmd
function returns a cobra.Command
without any subcommands. If this is intentional scaffolding for future commands to be added, it may be helpful to include a comment explaining this. Otherwise, consider adding the relevant subcommands to this function.
// AppModuleBasic implements the AppModuleBasic interface that defines the independent methodsa Cosmos SDK module | ||
// needs to implement. | ||
type AppModuleBasic struct { | ||
cdc codec.BinaryCodec | ||
} |
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 comment on line 32 contains a typo: "methodsa" should be "methods a".
Changelist
query.proto
Test Plan
[Describe how this PR was tested (if applicable)]
Author/Reviewer Checklist
state-breaking
label.indexer-postgres-breaking
label.PrepareProposal
orProcessProposal
, manually add the labelproposal-breaking
.feature:[feature-name]
.backport/[branch-name]
.refactor
,chore
,bug
.