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

feat(server/v2): introduce cometbft v2 #20483

Merged
merged 15 commits into from
May 31, 2024
Merged

feat(server/v2): introduce cometbft v2 #20483

merged 15 commits into from
May 31, 2024

Conversation

kocubinski
Copy link
Member

@kocubinski kocubinski commented May 29, 2024

Description

Part of server/v2 work and #20412, this PR introduces the server v2 module for CometBFT.


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 new CometBFT server with functionalities for setup, configuration, starting, stopping, and handling CLI commands.
    • Added CLI commands for querying node status, showing node ID, validator info, block information, and resetting state.
  • Enhancements

    • Added a boolean flag IsGenesis to indicate whether a block is a genesis block.
    • Improved consensus mechanisms and transaction handling in the CometBFT system.
    • Enhanced gRPC and RPC functionalities for better node information querying and block retrieval.

Copy link
Contributor

coderabbitai bot commented May 29, 2024

Warning

Rate limit exceeded

@kocubinski has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 6 minutes and 10 seconds before requesting another review.

How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

Commits

Files that changed from the base of the PR and between 76b607b and 6bb592f.

Walkthrough

The recent changes introduce extensive functionalities related to the CometBFT consensus mechanism, including new server setup, configuration, gRPC handling, transaction processing, querying, and mempool management. Additionally, a new IsGenesis boolean field was added to the BlockRequest struct to indicate genesis blocks. These updates enhance the CometBFT system's capabilities for blockchain consensus, node interactions, and transaction handling.

Changes

File(s) Change Summary
core/app/app.go Added IsGenesis boolean field to BlockRequest struct.
server/v2/cometbft/abci.go Introduced Consensus struct implementing abci.Application interface with various consensus-related methods.
server/v2/cometbft/client/grpc/cmtservice/autocli.go Added AutoCLI commands for querying node information and syncing status.
server/v2/cometbft/client/grpc/cmtservice/service.go Implemented gRPC query handling for CometBFT.
server/v2/cometbft/client/grpc/cmtservice/types.go Added functions for converting between gRPC and ABCI query request/response types.
server/v2/cometbft/client/grpc/cmtservice/util.go Provided functions to convert CometBFT headers and blocks to SDK formats.
server/v2/cometbft/client/rpc/block.go Introduced functions for retrieving blockchain information via CometBFT RPC.
server/v2/cometbft/client/rpc/client.go Defined CometRPC interface for querying validators, status, blocks, and transactions.
server/v2/cometbft/client/rpc/utils.go Added functions for formatting block results and creating search block results.
server/v2/cometbft/commands.go Added commands for interacting with a CometBFT server, including querying status and node information.
server/v2/cometbft/config.go Defined configuration settings for the CometBFT application.
server/v2/cometbft/flags/flags.go Defined constants for CLI flag names and a function to add common flags.
server/v2/cometbft/handlers/defaults.go Added default handlers for proposals and transactions in CometBFT.
server/v2/cometbft/handlers/handlers.go Introduced handler functions for transaction processing and verification.
server/v2/cometbft/handlers/tx_selector.go Added TxSelector interface and default implementation for mempool transaction selection.
server/v2/cometbft/log/logger.go Introduced CometLoggerWrapper for wrapping a cosmossdk.io/core/log instance.
server/v2/cometbft/mempool/config.go Defined configurations for SDK built-in app-side mempool implementations.
server/v2/cometbft/mempool/doc.go Documented the mempool package.
server/v2/cometbft/mempool/mempool.go Introduced interfaces and errors for managing a mempool.
server/v2/cometbft/mempool/noop.go Added NoOpMempool type for ignoring transactions.
server/v2/cometbft/query.go Added functions for handling P2P and application queries in CometBFT.
server/v2/cometbft/server.go Introduced server setup, configuration, and CLI commands for CometBFT.
server/v2/cometbft/service.go Added functions for converting data structures between CometBFT and SDK formats.
server/v2/cometbft/snapshots.go Introduced functionality for managing snapshots in a blockchain consensus system.
server/v2/cometbft/streaming.go Added streamDeliverBlockChanges function for streaming changes during block delivery.
server/v2/cometbft/types/errors/errors.go Defined error constants for unknown and invalid requests.
server/v2/cometbft/types/peer.go Introduced PeerFilter type for p2p filtering queries.
server/v2/cometbft/types/store.go Added Store interface for interacting with the store.
server/v2/cometbft/types/vote.go Introduced VoteExtensionsHandler interface for vote extension handlers.
server/v2/cometbft/utils.go Added utility functions for handling ABCI queries and validating block-related parameters.
store/v2/root/factory.go Added SSTypeMemory constant with a value of 3.

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

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • 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/schema.v2.json

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.

@kocubinski kocubinski mentioned this pull request May 29, 2024
12 tasks
@kocubinski kocubinski marked this pull request as ready for review May 29, 2024 18:25
@kocubinski kocubinski requested a review from a team as a code owner May 29, 2024 18:25
Copy link
Contributor

@kocubinski your pull request is missing a changelog!

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: 18

Outside diff range and nitpick comments (14)
server/v2/cometbft/types/errors/errors.go (1)

7-17: The error definitions in errors.go are clear and use the cosmossdk.io/errors module appropriately. Consider adding more detailed documentation for ErrUnknownRequest to explain when this error should be expected.

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

8-50: Ensure consistency in command descriptions.

The command descriptions in CometBFTAutoCLIDescriptor vary significantly in detail and style. For better user experience and consistency, align the verbosity and style of these descriptions. For example, some commands have a Long description while others do not. Consider adding similar detail to all commands or simplifying them uniformly.

store/v2/root/factory.go (1)

30-30: Add a comment explaining the purpose of SSTypeMemory.

It would be beneficial to add a comment explaining the purpose and usage of the SSTypeMemory constant for better code readability and maintainability.

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

34-34: Clarify error message for better user understanding.

The error message "expected second parameter to be 'filter'" could be more descriptive. Consider specifying what the valid 'filter' values are (e.g., 'addr' or 'id') to make the error message more helpful to the user.

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

39-39: Log additional context when the snapshot manager is not configured.

When logging that the snapshot manager is not configured, it might be helpful to include suggestions or actions that can be taken to resolve this issue. This could guide the user on how to proceed and potentially reduce frustration.

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

85-85: Clarify the TODO comment regarding the presence of the Store interface.

The TODO comment on line 85 is vague. It would be beneficial to specify what needs to be determined about the Store interface's presence to make the code easier to maintain and understand.


94-94: Specify how to set options in the NewManager call.

The TODO comment on line 94 suggests that options need to be set somehow. It would be helpful to either implement this or provide more detailed comments on what options are needed and how they might be configured.


Line range hint 267-267: Consider using a more descriptive error message.

The error message on line 267 could be more descriptive. It currently uses a generic message that might not provide enough context for debugging.

- return nil, status.Error(codes.Internal, "ABCI Query handler undefined")
+ return nil, status.Error(codes.Internal, "ABCI Query handler is undefined. Ensure that the query handler is properly initialized before calling.")
server/v2/cometbft/client/grpc/cmtservice/service.go (1)

293-293: Register gRPC services dynamically.

Consider enhancing the flexibility of the RegisterTendermintService function by allowing it to accept additional parameters or configurations that might be needed for different deployments or testing scenarios.

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

28-29: Consider adding documentation for the queryResponse function.

It would be beneficial to add a comment explaining the purpose and usage of this function for better maintainability.


109-127: Review the use of pointers in intoABCITxResults.

Consider whether using pointers here is necessary. If the objects are not large or not modified, using values could reduce the overhead of memory allocation.

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

34-57: Ensure proper documentation for the Consensus struct.

Adding comments to explain the purpose of each field in the Consensus struct would enhance code readability and maintainability.


77-91: Review the setter method for snapshot manager.

Consider if the snapshot manager should be settable post-construction of the Consensus object, as this could lead to runtime issues if changed mid-operation.


117-124: Clarify the purpose of BlockData.

Adding a detailed comment explaining the use of BlockData would be beneficial for future maintainers.

Review Details

Configuration used: .coderabbit.yml
Review profile: CHILL

Commits Files that changed from the base of the PR and between ac49374 and 05180c1.
Files ignored due to path filters (5)
  • 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.mod is excluded by !**/*.mod
  • server/v2/cometbft/go.sum is excluded by !**/*.sum
Files selected for processing (31)
  • core/app/app.go (1 hunks)
  • server/v2/cometbft/abci.go (1 hunks)
  • server/v2/cometbft/client/grpc/cmtservice/autocli.go (1 hunks)
  • server/v2/cometbft/client/grpc/cmtservice/service.go (1 hunks)
  • server/v2/cometbft/client/grpc/cmtservice/types.go (1 hunks)
  • server/v2/cometbft/client/grpc/cmtservice/util.go (1 hunks)
  • server/v2/cometbft/client/rpc/block.go (1 hunks)
  • server/v2/cometbft/client/rpc/client.go (1 hunks)
  • server/v2/cometbft/client/rpc/utils.go (1 hunks)
  • server/v2/cometbft/commands.go (1 hunks)
  • server/v2/cometbft/config.go (1 hunks)
  • server/v2/cometbft/flags/flags.go (1 hunks)
  • server/v2/cometbft/handlers/defaults.go (1 hunks)
  • server/v2/cometbft/handlers/handlers.go (1 hunks)
  • server/v2/cometbft/handlers/tx_selector.go (1 hunks)
  • server/v2/cometbft/log/logger.go (1 hunks)
  • server/v2/cometbft/mempool/config.go (1 hunks)
  • server/v2/cometbft/mempool/doc.go (1 hunks)
  • server/v2/cometbft/mempool/mempool.go (1 hunks)
  • server/v2/cometbft/mempool/noop.go (1 hunks)
  • server/v2/cometbft/query.go (1 hunks)
  • server/v2/cometbft/server.go (1 hunks)
  • server/v2/cometbft/service.go (1 hunks)
  • server/v2/cometbft/snapshots.go (1 hunks)
  • server/v2/cometbft/streaming.go (1 hunks)
  • server/v2/cometbft/types/errors/errors.go (1 hunks)
  • server/v2/cometbft/types/peer.go (1 hunks)
  • server/v2/cometbft/types/store.go (1 hunks)
  • server/v2/cometbft/types/vote.go (1 hunks)
  • server/v2/cometbft/utils.go (1 hunks)
  • store/v2/root/factory.go (1 hunks)
Files skipped from review due to trivial changes (2)
  • server/v2/cometbft/mempool/doc.go
  • server/v2/cometbft/types/peer.go
Additional Context Used
Path-based Instructions (29)
server/v2/cometbft/types/vote.go (1)

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

server/v2/cometbft/mempool/config.go (1)

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

server/v2/cometbft/types/errors/errors.go (1)

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

server/v2/cometbft/log/logger.go (1)

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

server/v2/cometbft/mempool/noop.go (1)

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

server/v2/cometbft/types/store.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/util.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/types.go (1)

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

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

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

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

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

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

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

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

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

core/app/app.go (1)

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

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

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

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/grpc/cmtservice/autocli.go (1)

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

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

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

server/v2/cometbft/handlers/tx_selector.go (1)

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

store/v2/root/factory.go (1)

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

server/v2/cometbft/flags/flags.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/query.go (1)

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

server/v2/cometbft/handlers/defaults.go (1)

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

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

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

server/v2/cometbft/server.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.

server/v2/cometbft/commands.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/abci.go (1)

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

Additional comments not posted (22)
server/v2/cometbft/types/vote.go (1)

9-13: The VoteExtensionsHandler interface is well-defined and adheres to Go best practices.

server/v2/cometbft/mempool/config.go (1)

3-10: The Config struct is clearly documented, explaining the behavior of the MaxTxs field comprehensively.

server/v2/cometbft/log/logger.go (1)

11-23: The CometLoggerWrapper is correctly implemented to adhere to the cmtlog.Logger interface. The With method is properly using variadic parameters for key-value pairs, which is a good practice for logging contexts.

server/v2/cometbft/mempool/noop.go (1)

11-22: The NoOpMempool is well-implemented for its intended use case of discarding transactions. This is particularly useful for testing or scenarios where transaction ordering is handled differently. The generic type T is a good use of Go generics to ensure type safety.

server/v2/cometbft/types/store.go (1)

9-32: The Store interface is comprehensive, covering a wide range of functionalities necessary for state management in blockchain systems. The use of interfaces from cosmossdk.io/core/store and cosmossdk.io/store/v2 ensures modularity and flexibility. Ensure that all methods are implemented correctly in concrete classes to avoid runtime issues.

server/v2/cometbft/client/grpc/cmtservice/util.go (2)

9-27: The convertHeader function is correctly implemented and adheres to the expected data mapping between CometBFT headers and SDK headers.


29-38: The convertBlock function is well-implemented, making effective use of the convertHeader function to ensure consistent header conversion. The straightforward mapping of other block components is clear and maintainable.

server/v2/cometbft/client/grpc/cmtservice/types.go (2)

7-15: The ToABCIRequestQuery function correctly transforms a gRPC ABCIQueryRequest to an ABCI QueryRequest, ensuring all necessary fields are accurately mapped.


18-46: The FromABCIResponseQuery function is implemented correctly, handling the optional ProofOps field safely and ensuring all data is transformed accurately from ABCI to gRPC formats.

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

10-35: The CometRPC interface is comprehensive and well-defined, covering a wide range of functionalities necessary for interacting with a CometBFT node. The use of context and optional parameters in method signatures is consistent and appropriate.

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

15-28: The Mempool interface is well-designed, utilizing generics to enhance type safety and flexibility. The methods are clearly defined, covering essential functionalities for mempool management.


31-41: The Iterator interface is minimalistic and effectively designed for iterating over transactions in the mempool. It adheres to idiomatic Go practices and is easy to understand and implement.

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

10-37: The Config struct is thoroughly and thoughtfully designed, covering a comprehensive range of configuration options for the CometBFT application. The use of struct tags for serialization and the inclusion of custom and external types are correctly implemented.

server/v2/cometbft/handlers/handlers.go (4)

13-16: The PrepareHandler function type is well-defined, allowing for stateful preprocessing of transactions in a flexible and type-safe manner using generics.


18-20: The ProcessHandler function type is appropriately designed for processing transactions, with clear error handling and a straightforward signature.


22-25: The VerifyVoteExtensionhandler function type is correctly designed for verifying vote extensions, using a context and a store reader map to access necessary state data.


27-30: The ExtendVoteHandler function type is effectively designed for extending votes, utilizing a context and a store reader map to handle the request appropriately.

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

12-51: Optimize error handling in streamDeliverBlockChanges.
[REFACTOR_SUGGESTion]
The function streamDeliverBlockChanges logs errors but continues execution, which might lead to inconsistent states or missed errors in a distributed system. Consider modifying the function to return an error immediately when an error is encountered, allowing the caller to handle it appropriately.

- if err := streamingListener.ListenDeliverBlock(ctx, streaming.ListenDeliverBlockRequest{
+ err := streamingListener.ListenDeliverBlock(ctx, streaming.ListenDeliverBlockRequest{
  BlockHeight: height,
  Txs:         txs,
  TxResults:   streamingTxResults,
  Events:      streaming.IntoStreamingEvents(events),
}); 
- if err != nil {
-     c.logger.Error("ListenDeliverBlock listening hook failed", "height", height, "err", err)
+ return err
}
server/v2/cometbft/flags/flags.go (1)

78-78: Ensure FlagChainID is appropriately marked as required where necessary.

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

49-51: Check the error handling in responseExecTxResultWithEvents.

Verification successful

The search results indicate that the errorsmod.ABCIInfo function is used in several places, including baseapp/abci_test.go, types/errors/abci.go, and server/v2/cometbft/utils.go. To verify the consistency of error handling in responseExecTxResultWithEvents, we need to compare the implementation in server/v2/cometbft/utils.go with the other instances.

Let's review the specific lines in server/v2/cometbft/utils.go and compare them with the other instances to ensure consistency.


The error handling in responseExecTxResultWithEvents is consistent with other instances of errorsmod.ABCIInfo usage across the codebase. The pattern of extracting space, code, and log from the error and using them in the response object is uniformly applied.

  • server/v2/cometbft/utils.go: space, code, log := errorsmod.ABCIInfo(err, debug)
  • types/errors/abci.go: space, code, log := errorsmod.ABCIInfo(err, debug)
  • baseapp/abci_test.go: space, code, _ := errorsmod.ABCIInfo(err, false)

These instances show a consistent approach to error handling, ensuring that the error information is correctly parsed and utilized in the response objects.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that the error handling in `responseExecTxResultWithEvents` is consistent across the codebase.

# Test: Search for similar error handling patterns. Expect: Consistent error handling.
rg --type go 'errorsmod.ABCIInfo'

Length of output: 703



Script:

#!/bin/bash
# Extract the relevant lines from the files where `errorsmod.ABCIInfo` is used to compare error handling.

# Extract lines from server/v2/cometbft/utils.go
rg --type go --context 5 'errorsmod.ABCIInfo' server/v2/cometbft/utils.go

# Extract lines from baseapp/abci_test.go
rg --type go --context 5 'errorsmod.ABCIInfo' baseapp/abci_test.go

# Extract lines from types/errors/abci.go
rg --type go --context 5 'errorsmod.ABCIInfo' types/errors/abci.go

Length of output: 3809


77-93: Ensure error handling is robust in finalizeBlockResponse.

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

59-75: Validate the initialization logic in NewConsensus.

Verification successful

The initialization logic in NewConsensus correctly sets all fields and handles the necessary handlers. No issues were found in the usage context.

  • server/v2/cometbft/server.go: The NewConsensus function is used to create a consensus object, and several handlers are set on this object immediately after its creation.
Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that the initialization logic in `NewConsensus` correctly sets all fields and handles any potential errors.

# Test: Search for usage of `NewConsensus` to ensure it is used correctly. Expect: Proper initialization.
rg --type go 'NewConsensus'

Length of output: 571



Script:

#!/bin/bash
# Extract lines around the usage of `NewConsensus` in `server/v2/cometbft/server.go` to review the context and initialization logic.
rg --type go -A 10 -B 10 'NewConsensus' server/v2/cometbft/server.go

Length of output: 804

server/v2/cometbft/server.go Outdated Show resolved Hide resolved
server/v2/cometbft/server.go Show resolved Hide resolved
server/v2/cometbft/commands.go Show resolved Hide resolved
server/v2/cometbft/handlers/tx_selector.go Show resolved Hide resolved
server/v2/cometbft/utils.go Show resolved Hide resolved
server/v2/cometbft/utils.go Show resolved Hide resolved
server/v2/cometbft/abci.go Show resolved Hide resolved
server/v2/cometbft/abci.go Show resolved Hide resolved
FlagOrderBy = "order_by"
)

const (
Copy link
Member

Choose a reason for hiding this comment

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

do we still need all these cc @julienrbrt

Copy link
Member

Choose a reason for hiding this comment

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

We should only have the one we use here for sure. The rest seems duplicated.

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

Review details

Configuration used: .coderabbit.yml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 05180c1 and 76b607b.

Files selected for processing (1)
  • server/v2/cometbft/server.go (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • server/v2/cometbft/server.go

@github-actions github-actions bot added the C:Cosmovisor Issues and PR related to Cosmovisor label May 30, 2024
@github-actions github-actions bot removed the C:Store label May 30, 2024
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.

Some changes will happen later on for the config, but it overall makes sense.

@kocubinski kocubinski added this pull request to the merge queue May 31, 2024
Merged via the queue into main with commit 46d6406 May 31, 2024
62 of 64 checks passed
@kocubinski kocubinski deleted the kocu/cometbft-v2 branch May 31, 2024 00:35
alpe added a commit that referenced this pull request May 31, 2024
* main:
  feat(server/v2): introduce cometbft v2 (#20483)
  refactor(x/upgrade): migrate to appmodule.VersionMap (#20485)
  docs: code guidelines changes (#20482)
  feat(cosmovisor): load cosmovisor configuration from toml file (#19995)
  perf(math): Significantly speedup Dec quo truncate and quo Roundup (#20034)
  fix: Bump CometBFT versions (#20481)
alpe added a commit that referenced this pull request May 31, 2024
* main: (120 commits)
  chore: update protoc-gen-swagger to protoc-gen-openapiv2 (#20448)
  ci: Add GitHub Action for go mod tidy and mocks (#20501)
  chore: Address linter issues (#20486)
  fix: wrap errors in auto CLI service registration (#20493)
  chore: fix comment (#20498)
  chore: fix the note box syntax error (#20499)
  feat(server/v2): introduce cometbft v2 (#20483)
  refactor(x/upgrade): migrate to appmodule.VersionMap (#20485)
  docs: code guidelines changes (#20482)
  feat(cosmovisor): load cosmovisor configuration from toml file (#19995)
  perf(math): Significantly speedup Dec quo truncate and quo Roundup (#20034)
  fix: Bump CometBFT versions (#20481)
  refactor(core): remove redundant ExecMode (#20322)
  feat(store/v2): pruning manager (#20430)
  chore: force reload sonar cloud  (#20480)
  refactor(x/accounts): reuse calculated sum in `func safeAdd` (#20458)
  refactor: remove `defer` in loop (#20223)
  ci: remove livness test (#20474)
  build(deps): Bump bufbuild/buf-setup-action from 1.32.1 to 1.32.2 (#20477)
  chore: migrate a few diagrams to mermaid (#20473)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C:Cosmovisor Issues and PR related to Cosmovisor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants