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

chore: remove duplicate proto files for the same proto file #21648

Merged
merged 10 commits into from
Sep 13, 2024

Conversation

tac0turtle
Copy link
Member

@tac0turtle tac0turtle commented Sep 11, 2024

Description

this pr removes duplicate registration of proto files


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

  • included the correct type prefix in the PR title, you can find examples of the prefixes below:
  • confirmed ! in the type prefix if API or client breaking change
  • targeted the correct branch (see PR Targeting)
  • provided a link to the relevant issue or specification
  • reviewed "Files changed" and left comments if necessary
  • included the necessary unit and integration tests
  • added a changelog entry to CHANGELOG.md
  • updated the relevant documentation or specification, including comments for documenting Go code
  • confirmed all CI checks have passed

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.

Please see Pull Request Reviewer section in the contributing guide for more information on how to review a pull request.

I have...

  • confirmed the correct type prefix in the PR title
  • confirmed all author checklist items have been addressed
  • reviewed state machine logic, API design and naming, documentation is accurate, tests and test coverage

Summary by CodeRabbit

  • New Features

    • Introduced a CometRPC interface for enhanced interaction with the CometBFT blockchain.
    • Added methods for querying blockchain status and retrieving block data.
  • Improvements

    • Streamlined functions for fetching block data and node status, improving performance and clarity.
    • Simplified the query server functionality for better maintainability.
    • Updated dependencies for improved compatibility and functionality.
  • Bug Fixes

    • Enhanced error handling during node retrieval processes.

Copy link
Contributor

coderabbitai bot commented Sep 11, 2024

Walkthrough

Walkthrough

The changes primarily involve a transition from using the Cosmos SDK's client context to a more direct RPC interface for blockchain interactions. Key modifications include the introduction of a new CometRPC interface, which replaces the client.Context parameter in various functions across multiple files. This shift streamlines the code by simplifying function signatures and enhancing direct communication with the blockchain node.

Changes

Files Change Summary
client/grpc/cmtservice/block.go Updated functions to replace client.Context with CometRPC, simplifying block retrieval processes.
client/grpc/cmtservice/service.go Modified queryServer structure to use CometRPC, updating methods to streamline RPC interactions and adding consensusCodec.
client/grpc/cmtservice/status.go Changed GetNodeStatus function to use CometRPC instead of client.Context, simplifying the status retrieval logic.
client/grpc/cmtservice/validator.go Updated getValidators function to replace client.Context with CometRPC, enhancing the direct interaction with the RPC layer.
server/cmt_cmds.go Modified StatusCommand function to retrieve node status through an additional step, improving clarity in the process.
server/v2/cometbft/go.mod Updated dependency management by removing specific dependencies and adding new ones, potentially impacting functionality and compatibility.

Possibly related PRs

Suggested labels

C:x/staking, C:x/accounts, C:x/accounts/multisig


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?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Member

@julienrbrt julienrbrt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK

@julienrbrt julienrbrt added backport/v0.50.x PR scheduled for inclusion in the v0.50's next stable release backport/v0.52.x PR scheduled for inclusion in the v0.52's next stable release and removed backport/v0.50.x PR scheduled for inclusion in the v0.50's next stable release labels Sep 11, 2024
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.

Actionable comments posted: 0

Outside diff range and nitpick comments (1)
server/v2/cometbft/go.mod (1)

Line range hint 4-16: Reminder: Update replace directives before release.

Several replace directives have been added to the file, specifying local package paths for development purposes or to use modified versions of the packages.

Please ensure that these replace directives are removed or updated before releasing the project or when the local changes are merged into the main packages to avoid any conflicts or issues.

Review details

Configuration used: .coderabbit.yml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 04cec5b and d211b09.

Files ignored due to path filters (4)
  • server/v2/cometbft/client/grpc/cmtservice/query.pb.go is excluded by !**/*.pb.go
  • server/v2/cometbft/client/grpc/cmtservice/query.pb.gw.go is excluded by !**/*.pb.gw.go
  • server/v2/cometbft/client/grpc/cmtservice/types.pb.go is excluded by !**/*.pb.go
  • server/v2/cometbft/go.sum is excluded by !**/*.sum
Files selected for processing (10)
  • client/grpc/cmtservice/block.go (1 hunks)
  • client/grpc/cmtservice/rpc.go (1 hunks)
  • client/grpc/cmtservice/service.go (13 hunks)
  • client/grpc/cmtservice/status.go (1 hunks)
  • client/grpc/cmtservice/validator.go (1 hunks)
  • server/cmt_cmds.go (1 hunks)
  • server/v2/cometbft/client/grpc/cmtservice/service.go (1 hunks)
  • server/v2/cometbft/go.mod (6 hunks)
  • x/auth/tx/service.go (1 hunks)
  • x/consensus/keeper/keeper.go (1 hunks)
Files skipped from review due to trivial changes (1)
  • x/consensus/keeper/keeper.go
Additional context used
Path-based instructions (8)
client/grpc/cmtservice/status.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

client/grpc/cmtservice/validator.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

client/grpc/cmtservice/block.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

client/grpc/cmtservice/rpc.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

server/v2/cometbft/client/grpc/cmtservice/service.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

client/grpc/cmtservice/service.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

x/auth/tx/service.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

server/cmt_cmds.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

Additional comments not posted (30)
client/grpc/cmtservice/status.go (1)

10-12: LGTM!

The changes to the GetNodeStatus function are approved. The modifications simplify the function's implementation, enhance clarity, and improve efficiency by directly calling the Status method on the rpc parameter.

The changes also conform to the Uber Golang style guide.

client/grpc/cmtservice/validator.go (1)

9-10: LGTM, but verify the function usage.

The changes to the getValidators function enhance clarity and efficiency by streamlining the RPC interactions. The code changes are approved.

However, ensure that this change is thoroughly tested to confirm that it behaves as expected and that all function calls to getValidators have been updated to pass the CometRPC parameter instead of client.Context.

Run the following script to verify the function usage:

Verification successful

All instances of getValidators are updated correctly.

The function getValidators is used only once in the codebase, and it correctly uses the new signature with CometRPC as a parameter. No further updates are necessary.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all function calls to `getValidators` pass the `CometRPC` parameter.

# Test: Search for the function usage. Expect: Only occurrences of the new signature.
rg --type go -A 5 $'getValidators'

Length of output: 662


Script:

#!/bin/bash
# Description: Search for all instances of `getValidators` usage across the codebase.

# Test: Ensure all calls to `getValidators` use the new signature with `CometRPC`.
rg --type go 'getValidators'

Length of output: 280

client/grpc/cmtservice/block.go (3)

10-17: LGTM!

The code changes are approved. The refactoring from client.Context to CometRPC is consistent with the overall goal of streamlining RPC interactions.


19-20: LGTM!

The code changes are approved. The refactoring from client.Context to CometRPC is consistent with the overall goal of streamlining RPC interactions. The direct call to the Block method on the CometRPC type is a cleaner approach.


Line range hint 23-35: LGTM!

The code changes are approved. The refactoring from client.Context to CometRPC is consistent with the overall goal of streamlining RPC interactions. The function correctly handles errors and follows the Uber Golang style guide.

client/grpc/cmtservice/rpc.go (1)

12-36: LGTM!

The CometRPC interface definition looks good:

  1. It consolidates relevant methods in one place, which improves modularity and maintainability.
  2. The methods have clear and descriptive names, making the interface easy to understand.
  3. The methods take a context.Context parameter, which is a good practice for handling timeouts and cancellations.
  4. The methods return appropriate result types from the coretypes package, ensuring type safety.
  5. The Tx and TxSearch methods have parameters for enabling proofs, which is important for security.
  6. The BlockSearch and TxSearch methods have pagination parameters, which is important for performance.
  7. The BlockSearch and TxSearch methods have an orderBy parameter, which provides flexibility in sorting results.
server/v2/cometbft/client/grpc/cmtservice/service.go (5)

12-15: LGTM!

The changes to the import statements are approved. The addition of the address and cmtservice packages is necessary to support the refactored code.


18-18: LGTM!

The type assertion is approved. It ensures that the GetLatestValidatorSetResponse type correctly implements the UnpackInterfacesMessage interface, enhancing the handling of validator set responses.


26-26: LGTM!

The abciQueryFn type definition is approved. It provides a clean abstraction for the ABCI query functionality, enhancing code readability and maintainability.


28-36: LGTM!

The changes to the RegisterTendermintService function are approved. The inclusion of the consensusCodec parameter and the use of cmtservice.NewQueryServer align with the overall refactoring effort to leverage the cmtservice package's functionalities, promoting a more modular and extensible design.


38-42: LGTM!

The changes to the RegisterGRPCGatewayRoutes function are approved. The use of cmtservice.RegisterServiceHandlerClient and cmtservice.NewServiceClient aligns with the overall refactoring effort to leverage the cmtservice package, ensuring proper registration and handling of the GRPC-gateway routes.

client/grpc/cmtservice/service.go (14)

6-6: LGTM!

The import of cosmossdk.io/core/address package is approved.


32-32: LGTM!

The replacement of clientCtx field with rpc field of type CometRPC is approved.


33-33: LGTM!

The renaming of queryFn field is approved.


34-34: LGTM!

The addition of consensusCodec field of type address.Codec is approved.


40-42: LGTM!

The updates to the NewQueryServer function parameters are approved. They reflect the shift towards using the new CometRPC type for RPC interactions and handling consensus address encoding.


45-46: LGTM!

The updates to the NewQueryServer function to use the new rpc field are approved. They promote a more cohesive and modular approach to handling RPC interactions.


52-52: LGTM!

The update to the GetSyncing method to use the new rpc field is approved. It aligns with the overall refactoring to use the new RPC structure.


Line range hint 64-75: LGTM!

The updates to the GetLatestBlock method to use the new rpc field and consensusCodec are approved. They align with the overall refactoring to use the new RPC structure and handle consensus address encoding.


Line range hint 89-98: LGTM!

The updates to the GetBlockByHeight method to use the new rpc field and consensusCodec are approved. They align with the overall refactoring to use the new RPC structure and handle consensus address encoding.

Also applies to: 103-103


122-122: LGTM!

The update to the GetLatestValidatorSet method to pass the new rpc and consensusCodec fields to the ValidatorsOutput function is approved. It aligns with the overall refactoring to use the new RPC structure and handle consensus address encoding.


Line range hint 144-153: LGTM!

The updates to the GetValidatorSetByHeight method to use the new rpc field and pass the new rpc and consensusCodec fields to the ValidatorsOutput function are approved. They align with the overall refactoring to use the new RPC structure and handle consensus address encoding.


Line range hint 165-189: LGTM!

The updates to the ValidatorsOutput function signature and implementation to use the new rpc and consCodec parameters are approved. They align with the overall refactoring to use the new RPC structure and handle consensus address encoding.


Line range hint 207-291: LGTM!

The update to the GetNodeInfo method to use the new rpc field is approved. It aligns with the overall refactoring to use the new RPC structure. The rest of the changes in this section are just code movements without any functional impact.


292-292: LGTM!

The update to the RegisterTendermintService function to pass the new node and clientCtx.ConsensusAddressCodec to the NewQueryServer function is approved. It aligns with the overall refactoring to use the new RPC structure and handle consensus address encoding.

server/v2/cometbft/go.mod (3)

59-61: Verify the necessity and compatibility of the added dependencies.

Several new dependencies have been added to the require block, including github.com/DataDog/datadog-go, github.com/Microsoft/go-winio, github.com/felixge/httpsnoop, github.com/gogo/googleapis, github.com/gorilla/handlers, github.com/gorilla/mux, github.com/grpc-ecosystem/go-grpc-middleware, and github.com/huandu/skiplist.

Please ensure that these dependencies are necessary for the project and align with its goals and architecture. Also, verify that they are compatible with the existing dependencies and the project's license.

Also applies to: 91-91, 98-98, 109-112, 123-123


75-75: Verify the impact of removing dependencies from the require block.

github.com/cosmos/cosmos-proto and github.com/golang/protobuf have been removed from the require block but reintroduced in the indirect dependencies section.

Please ensure that removing these dependencies from the require block does not have any unintended consequences on the project's functionality and that their versions in the indirect dependencies section are compatible with the project's requirements.

Also applies to: 102-102


175-175: Verify the compatibility and security of the added indirect dependencies.

Several new indirect dependencies have been added, including golang.org/x/mod, golang.org/x/tools, google.golang.org/genproto/googleapis/api, and google.golang.org/grpc.

Please ensure that these indirect dependencies are compatible with the project and do not introduce any security vulnerabilities or licensing issues. Also, verify that their versions are appropriate for the project's requirements.

Also applies to: 181-181, 183-183, 185-185

x/auth/tx/service.go (1)

152-157: LGTM!

The changes to retrieve the node using s.clientCtx.GetNode() and handle potential errors before calling GetProtoBlock are approved. This enhances the function's robustness and improves error handling.

server/cmt_cmds.go (1)

44-48: Approved: The change improves the control flow by separating node retrieval from status retrieval.

Retrieving the node object using clientCtx.GetNode() before passing it to cmtservice.GetNodeStatus enhances clarity and could potentially improve error handling related to node retrieval.

@julienrbrt
Copy link
Member

Adding the backport v0.52 labels due to change in the SDK and in cometbft server.

@tac0turtle tac0turtle added this pull request to the merge queue Sep 13, 2024
Merged via the queue into main with commit c0e84af Sep 13, 2024
71 checks passed
@tac0turtle tac0turtle deleted the marko/drop-duplicate-regs branch September 13, 2024 10:19
mergify bot pushed a commit that referenced this pull request Sep 13, 2024
(cherry picked from commit c0e84af)

# Conflicts:
#	server/v2/cometbft/go.mod
tac0turtle added a commit that referenced this pull request Sep 13, 2024
…21648) (#21709)

Co-authored-by: Marko <marko@baricevic.me>
Co-authored-by: marbar3778 <marbar3778@yahoo.com>
alpe added a commit that referenced this pull request Sep 16, 2024
* main:
  test: fix sims (#21735)
  build: bump proto-builder (#21730)
  refactor(schema)!: rename IntegerStringKind and DecimalStringKind (#21694)
  feat(types/collections): add `LegacyDec` collection value (#21693)
  refactor(server): alias AppOptions to coreserver.DynamicConfig (#21711)
  refactor(simapp): simplify simapp di (#21718)
  feat: replace the cosmos-db usecases in the tests with `core/testing` (#21525)
  feat(runtime/v2): store loader on simappv2 (#21704)
  docs(x/auth): vesting (#21715)
  build(deps): Bump google.golang.org/grpc from 1.66.1 to 1.66.2 (#21670)
  refactor(systemtest): Add cli.RunAndWait for common operations (#21689)
  fix(runtime/v2): provide default factory options if unset in app builder (#21690)
  chore: remove duplicate proto files for the same proto file (#21648)
  feat(x/genutil): add better error messages for genesis validation (#21701)
  build(deps): Bump cosmossdk.io/core from 1.0.0-alpha.1 to 1.0.0-alpha.2 (#21698)
  test: migrate e2e/bank to system tests (#21607)
  chore: fix the gci lint issue in testutil (#21695)
  docs(x/authz): update grant docs (#21677)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport/v0.52.x PR scheduled for inclusion in the v0.52's next stable release C:CLI C:server/v2 cometbft C:server/v2 Issues related to server/v2 C:x/auth
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants