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

refactor(server/v2/cometbft): use only protov1 and backport #21084 #21681

Merged
merged 2 commits into from
Sep 12, 2024

Conversation

julienrbrt
Copy link
Member

@julienrbrt julienrbrt commented Sep 12, 2024

Description

Simplify cometbft server by using only protov1, instead of going between protov2 <-> protov1
Additionally backports #21084 to cometbft server commands.


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

    • Enhanced block querying command now allows for optional arguments, defaulting to the latest block height if none are provided.
    • Improved serialization performance with the transition to the Gogoproto library.
  • Bug Fixes

    • Adjusted command argument handling to prevent errors when no arguments are supplied.
  • Documentation

    • Updated internal documentation to reflect changes in command functionality and serialization methods.

@julienrbrt julienrbrt added the backport/v0.52.x PR scheduled for inclusion in the v0.52's next stable release label Sep 12, 2024
Copy link
Contributor

coderabbitai bot commented Sep 12, 2024

Walkthrough

Walkthrough

The changes involve updates to the server/v2/cometbft module, focusing on replacing certain package imports and modifying function signatures to use new data types. This includes transitioning from the buf.build package to github.com/cometbft/api and github.com/cosmos/cosmos-sdk/types. Additionally, the serialization method has been updated to utilize gogoproto instead of protojson, and certain dependencies have been adjusted in the go.mod file. The overall functionality remains intact while aligning with a new API structure.

Changes

Files Change Summary
server/v2/cometbft/client/rpc/block.go, server/v2/cometbft/client/rpc/utils.go Updated import statements and function signatures to replace v11 types with cmttypes types. Changes include return types for QueryBlocks, GetBlockByHeight, and GetBlockByHash, as well as updates to utility functions.
server/v2/cometbft/commands.go Changed serialization method from protojson.Marshal to gogoproto.Marshal for the blocks variable and modified argument handling to allow a maximum of one argument.
server/v2/cometbft/go.mod Removed direct dependency on buf.build package and marked it as indirect.
server/v2/cometbft/utils.go Transitioned to using sdk.SimulationResponse and sdk.Result instead of v1beta1 structures, simplifying event handling and response generation.
simapp/gomod2nix.toml Deleted the file containing module dependencies, which may affect dependency management for the application.

Possibly related PRs

  • build(deps): bump rocksdb & core & update ci codeowners #21652: The changes in the server/v2/cometbft/commands.go file regarding the serialization method from protojson.Marshal to gogoproto.Marshal are directly related to the modifications made in the main PR, which also involve similar updates to serialization methods across multiple files.

Suggested labels

C:x/upgrade, C:x/consensus, C:x/protocolpool


Recent review details

Configuration used: .coderabbit.yml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between aac9a4e and ab0b2c7.

Files selected for processing (1)
  • server/v2/cometbft/commands.go (4 hunks)
Additional context used
Path-based instructions (1)
server/v2/cometbft/commands.go (1)

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

Additional comments not posted (2)
server/v2/cometbft/commands.go (2)

204-206: LGTM!

The change in serialization method from protojson.Marshal to gogoproto.Marshal aligns with the PR objective to exclusively utilize protov1. This is a localized change that does not alter the overall functionality of the QueryBlocksCmd function.


Line range hint 226-314: Excellent enhancements to the QueryBlockCmd function!

The changes made to the command's argument handling and block height parsing logic significantly improve the usability and flexibility of the QueryBlockCmd function:

  1. By allowing a maximum of one argument instead of requiring exactly one, the command now defaults to querying the latest block height when no argument is provided. This eliminates the need for users to explicitly specify the latest height, enhancing the command's convenience.

  2. The refined logic for parsing the block height, including the fallback mechanism to retrieve the latest block height if no argument is supplied, ensures a more robust and user-friendly experience. Users can now rely on the command to handle cases where the block height is not explicitly provided.

These enhancements maintain backward compatibility with the previous behavior while introducing valuable improvements to the command's usability.


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.

@github-actions github-actions bot added C:server/v2 Issues related to server/v2 C:server/v2 cometbft labels Sep 12, 2024
Copy link
Contributor

@hieuvubk hieuvubk left a comment

Choose a reason for hiding this comment

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

ack

@julienrbrt julienrbrt changed the title refactor(server/v2/cometbft): use only protov1 refactor(server/v2/cometbft): use only protov1 and backport #21084 Sep 12, 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/utils.go (1)

166-173: Add a TODO comment to track the removal of the hack.

The code segment correctly creates an array of gogoany.Any messages from the transaction result responses using gogoany.NewAnyWithCacheWithValue. While the code itself is fine, the comment about using this approach as a hack to maintain the protov2 API suggests that it may be temporary.

Consider adding a TODO comment to track the removal of this hack and the transition to a more permanent solution in the future. This will help ensure that the code is properly updated and the API is cleaned up when appropriate.

Review details

Configuration used: .coderabbit.yml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 5475903 and aac9a4e.

Files selected for processing (6)
  • server/v2/cometbft/client/rpc/block.go (4 hunks)
  • server/v2/cometbft/client/rpc/utils.go (4 hunks)
  • server/v2/cometbft/commands.go (2 hunks)
  • server/v2/cometbft/go.mod (1 hunks)
  • server/v2/cometbft/utils.go (2 hunks)
  • simapp/gomod2nix.toml (0 hunks)
Files not reviewed due to no reviewable changes (1)
  • simapp/gomod2nix.toml
Files skipped from review due to trivial changes (1)
  • server/v2/cometbft/go.mod
Additional context used
Path-based instructions (4)
server/v2/cometbft/client/rpc/utils.go (1)

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

server/v2/cometbft/client/rpc/block.go (1)

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

server/v2/cometbft/utils.go (1)

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

server/v2/cometbft/commands.go (1)

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

Additional comments not posted (11)
server/v2/cometbft/client/rpc/utils.go (3)

14-17: LGTM!

The function signature update to use cmttypes.Block is consistent with the overall refactor and the function logic remains intact.


32-34: LGTM!

The function signature updates to use cmttypes.Block and sdk.SearchBlocksResult are consistent with the overall refactor and the function logic remains intact.


Line range hint 45-56: LGTM!

The function has been appropriately updated to use the new cmttypes package and gogoproto serialization method, which aligns with the overall refactor goals. The changes are sound and maintain the core functionality.

server/v2/cometbft/client/rpc/block.go (3)

Line range hint 42-55: LGTM!

The function signature update aligns with the PR objective of using only protov1. The change is straightforward and the function logic remains intact.


Line range hint 59-76: LGTM!

The function signature update aligns with the PR objective of using only protov1. The change is straightforward and the function logic remains intact.


Line range hint 80-102: LGTM!

The function signature update aligns with the PR objective of using only protov1. The change is straightforward and the function logic remains intact.

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

24-24: LGTM!

The import statement for the github.com/cosmos/cosmos-sdk/types package is valid and follows the correct syntax. The sdk alias is a conventional shorthand for the package.


149-163: Looks good!

The code segment correctly converts the transaction result events to ABCI events and maps the event attributes to ABCI event attributes. The indexAll flag is used appropriately to control the indexing behavior. The code follows the expected logic and does not introduce any issues.


176-189: LGTM!

The code segment correctly creates an sdk.SimulationResponse object with the relevant fields populated from the transaction result. The GasInfo field is properly set, and the Result field contains an sdk.Result object with the events, message responses, and error log. The use of gogoproto.Marshal to marshal the response is appropriate. The code follows the expected logic and does not introduce any issues.

server/v2/cometbft/commands.go (2)

10-12: LGTM!

The imported packages are relevant and necessary.


204-204: Verify compatibility of serialization change.

The change to use gogoproto.Marshal for serialization instead of protojson.Marshal looks good as it aligns with the goal of enhancing performance and compatibility with CometBFT specific data structures.

However, please verify that this serialization change doesn't break any existing functionality or cause issues in other parts of the codebase that may be relying on the previous serialization format.

@julienrbrt julienrbrt added this pull request to the merge queue Sep 12, 2024
Merged via the queue into main with commit 766117c Sep 12, 2024
77 of 78 checks passed
@julienrbrt julienrbrt deleted the julien/cometbft branch September 12, 2024 10:45
mergify bot pushed a commit that referenced this pull request Sep 12, 2024
…21681)

(cherry picked from commit 766117c)

# Conflicts:
#	server/v2/cometbft/go.mod
#	simapp/gomod2nix.toml
julienrbrt added a commit that referenced this pull request Sep 12, 2024
…ackport #21681) (#21684)

Co-authored-by: Julien Robert <julien@rbrt.fr>
alpe added a commit that referenced this pull request Sep 12, 2024
* main:
  refactor(server/v2/cometbft): use only protov1 and backport #21084 (#21681)
  chore(x/staking): revert proto breakage (#21666)
  build(deps): bump rocksdb & core & update ci codeowners (#21652)
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:server/v2 cometbft C:server/v2 Issues related to server/v2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants