Skip to content
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

Merged
merged 5 commits into from
Dec 11, 2023
Merged

[CORE-827] Scaffolding code for x/ibcratelimit #870

merged 5 commits into from
Dec 11, 2023

Conversation

teddyding
Copy link
Contributor

Changelist

  • Scaffolding code
  • Also add api options to query.proto

Test Plan

[Describe how this PR was tested (if applicable)]

Author/Reviewer Checklist

  • If this PR has changes that result in a different app state given the same prior state and transaction list, manually add the state-breaking label.
  • If the PR has breaking postgres changes to the indexer add the indexer-postgres-breaking label.
  • If this PR isn't state-breaking but has changes that modify behavior in PrepareProposal or ProcessProposal, manually add the label proposal-breaking.
  • If this PR is one of many that implement a specific feature, manually label them all feature:[feature-name].
  • If you wish to for mergify-bot to automatically create a PR to backport your change to a release branch, manually add the label backport/[branch-name].
  • Manually add any of the following labels: refactor, chore, bug.

Copy link

linear bot commented Dec 9, 2023

Copy link
Contributor

coderabbitai bot commented Dec 9, 2023

Walkthrough

The changes involve the introduction of a new ibcratelimit module within the dydxprotocol ecosystem, affecting various aspects such as types, keeper logic, gRPC query handlers, CLI commands, and genesis state handling. The module appears to be related to rate limiting functionality, possibly for inter-blockchain communication (IBC). The updates include new error handling, message types, parameter validation, and module initialization, with many placeholders for future implementation.

Changes

File(s) Change Summary
.../v4-protos/src/codegen/dydxprotocol/bundle.ts Import reordering and namespace dydxprotocol structure modifications.
.../v4-protos/src/codegen/dydxprotocol/ibcratelimit/query.lcd.ts New LCDQueryClient class with methods listLimitParams and capacityByDenom.
.../v4-protos/src/codegen/dydxprotocol/lcd.ts Addition of ibcratelimit property to an object.
proto/dydxprotocol/ibcratelimit/query.proto Added HTTP annotations for gRPC service definition.
.../ibcratelimit/client/cli/query.go New GetQueryCmd function in cli package.
.../ibcratelimit/client/cli/query_params.go New CmdQueryParams function in cli package.
.../ibcratelimit/client/cli/query_params_test.go New test setup and TestQueryParams function.
.../ibcratelimit/client/cli/tx.go New cli package with GetTxCmd function and global variable.
.../ibcratelimit/genesis.go New ibcratelimit package with InitGenesis and ExportGenesis functions.
.../ibcratelimit/genesis_test.go New TestGenesis function in ibcratelimit_test package.
.../ibcratelimit/keeper/grpc_query.go New ListLimitParams and CapacityByDenom methods in keeper package.
.../ibcratelimit/keeper/grpc_query_test.go New TestQueryParams function in keeper_test package.
.../ibcratelimit/keeper/keeper.go New keeper package with Keeper struct and methods.
.../ibcratelimit/keeper/keeper_test.go Package declaration for keeper_test.
.../ibcratelimit/keeper/msg_server.go New msgServer type with methods in keeper package.
.../ibcratelimit/keeper/msg_server_test.go Package declaration and TODO comment in keeper_test.
.../ibcratelimit/module.go New ibcratelimit package with AppModuleBasic and AppModule structs.
.../ibcratelimit/module_simulation.go Additions and modifications to simulation functions in ibcratelimit package.
.../ibcratelimit/module_test.go New package ibcratelimit_test with placeholder comment.
.../ibcratelimit/simulation/helpers.go New FindAccount function in simulation package.
.../ibcratelimit/types/codec.go New types package with codec registration functions and variables.
.../ibcratelimit/types/errors.go New error declaration ErrInvalidAuthority in types package.
.../ibcratelimit/types/expected_keepers.go Package declaration for types.
.../ibcratelimit/types/genesis.go New DefaultGenesis and Validate functions in types package.
.../ibcratelimit/types/genesis_test.go Package declaration for types_test.
.../ibcratelimit/types/keys.go New types package with constants for ModuleName and StoreKey.
.../ibcratelimit/types/keys_test.go New test functions TestModuleKeys and TestStateKeys in types_test package.
.../ibcratelimit/types/params.go New Validate function for LimitParams struct in types package.
.../ibcratelimit/types/tx.go New types package with MsgSetLimitParams struct and methods.
.../ibcratelimit/types/types.go Package declaration for types.

Tips

Chat with CodeRabbit Bot (@coderabbitai)

  • If you reply to a review comment from CodeRabbit, the bot will automatically respond.
  • To engage with CodeRabbit bot directly around the specific lines of code in the PR, mention @coderabbitai in your review comment
  • Note: Review comments are made on code diffs or files, not on the PR overview.
  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Note: For conversation with the bot, please use the review comments on code diffs or files.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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

Commits Files that changed from the base of the PR and between eb7c575 and ce32ee5.
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 the dydxprotocol 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 corresponding LCDQueryClient instantiation is consistent with the PR's objective to scaffold code for the x/ibcratelimit module.
proto/dydxprotocol/ibcratelimit/query.proto (1)
  • 2-23: The changes to the query.proto file correctly introduce HTTP annotations for the ListLimitParams and CapacityByDenom 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 returns nil. 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 and CapacityByDenom are placeholders with Unimplemented 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 the Keeper 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 the authorities map.

  • 44-45: The Logger function correctly creates a namespaced logger for the x/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 in GetQueryCmd is consistent with the module's store key definition.


The verification of types.StoreKey confirms that it is defined within the types 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 in GetQueryCmd 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 the InterfaceRegistry 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 the x/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 of LimitParams to ensure that MsgSetLimitParams is well-formed before being processed.

Comment on lines +3 to +7
// Validate validates the set of params
func (p *LimitParams) Validate() error {
// TODO(CORE-824): implement keepers
return nil
}
Copy link
Contributor

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`
Copy link
Contributor

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.

Comment on lines +15 to +17
func TestStateKeys(t *testing.T) {
// TODO(CORE-824): test state keys
}
Copy link
Contributor

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.

Comment on lines +3 to +7
// DefaultGenesis returns the default genesis state
func DefaultGenesis() *GenesisState {
// TODO(CORE-824): Implement keepers
return nil
}
Copy link
Contributor

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.

Comment on lines +9 to +14
// Validate performs basic genesis state validation returning an error upon any
// failure.
func (gs GenesisState) Validate() error {
// TODO(CORE-824): Implement keepers
return nil
}
Copy link
Contributor

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.

Comment on lines +46 to +47
func (am AppModule) ProposalMsgs(simState module.SimulationState) []simtypes.WeightedProposalMsg {
return []simtypes.WeightedProposalMsg{}
Copy link
Contributor

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.

Comment on lines +42 to +44
func TestQueryParams(t *testing.T) {
// TODO(CORE-823): implement query for `x/ibcratelimit`
}
Copy link
Contributor

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.

Comment on lines +12 to +14
func (msg *MsgSetLimitParams) GetSigners() []sdk.AccAddress {
addr, _ := sdk.AccAddressFromBech32(msg.Authority)
return []sdk.AccAddress{addr}
Copy link
Contributor

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.

Comment on lines +17 to +27
// 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
Copy link
Contributor

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.

Comment on lines +32 to +36
// AppModuleBasic implements the AppModuleBasic interface that defines the independent methodsa Cosmos SDK module
// needs to implement.
type AppModuleBasic struct {
cdc codec.BinaryCodec
}
Copy link
Contributor

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".

@teddyding teddyding merged commit dd168a0 into main Dec 11, 2023
30 of 31 checks passed
@teddyding teddyding deleted the td/CORE-827 branch December 11, 2023 02:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

2 participants