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(x/consensus): audit QA #21151

Merged
merged 8 commits into from
Aug 9, 2024
Merged

refactor(x/consensus): audit QA #21151

merged 8 commits into from
Aug 9, 2024

Conversation

facundomedica
Copy link
Member

@facundomedica facundomedica commented Aug 1, 2024

Description

Closes: #XXXX


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 query command wait-tx for enhanced command interface.
    • Enhanced registration of consensus messages within the consensus module.
  • Modifications

    • Simplified consensus module instantiation to use appmodule.Environment.
    • Updated handling of consensus parameters for improved efficiency and clarity.
  • Bug Fixes

    • Adjusted field annotations for synchrony in message structure to reflect correct versioning.
  • Chores

    • Removed deprecated comments and refined protocol buffer descriptor for better data handling.

Copy link
Contributor

coderabbitai bot commented Aug 1, 2024

Walkthrough

Walkthrough

The updates to the Cosmos SDK reflect a significant architectural enhancement, emphasizing improved modularity and streamlined module management. Key changes include the consolidation of services within the consensus module, the introduction of new command interfaces in the client section, and adjustments in parameter handling across various modules. These modifications aim to simplify interactions, enhance functionality, and facilitate better dependency management across the SDK.

Changes

File Path Change Summary
CHANGELOG.md, x/consensus/CHANGELOG.md Introduced new features and API breaking changes in the consensus module, including message registration and integration of cometinfo.
api/cosmos/consensus/v1/tx.pulsar.go Updated MsgUpdateParams struct by removing deprecated comments; altered byte value in protocol buffer descriptor.
x/consensus/keeper/keeper.go Removed StoreKey variable, simplifying store key management in the consensus module.
x/consensus/keeper/keeper_test.go Adjusted key assignment in SetupTest method to utilize types.StoreKey instead of consensusparamkeeper.StoreKey.
x/consensus/proto/cosmos/consensus/v1/tx.proto Updated synchrony field version annotation to reflect the latest SDK version; maintained deprecated status of abci.
x/consensus/types/msgs.go Enhanced ToProtoConsensusParams method to directly link parameters from the message object, improving code efficiency.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant ConsensusModule
    participant Storage

    Client->>ConsensusModule: Send MsgUpdateParams
    ConsensusModule->>Storage: Store new consensus parameters
    Storage-->>ConsensusModule: Acknowledge storage
    ConsensusModule-->>Client: Confirm parameters updated
Loading

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

@julienrbrt julienrbrt added the backport/v0.52.x PR scheduled for inclusion in the v0.52's next stable release label Aug 1, 2024
// Since: cosmos-sdk 0.51
cometbft.types.v1.ABCIParams abci = 5 [deprecated = true, (cosmos_proto.field_added_in) = "cosmos-sdk 0.50"];
cometbft.types.v1.SynchronyParams synchrony = 6 [(cosmos_proto.field_added_in) = "cosmos-sdk 0.51"];
// Since: cosmos-sdk 0.50
Copy link
Member

Choose a reason for hiding this comment

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

we can kill all those Since comments btw

@github-actions github-actions bot removed the C:Store label Aug 7, 2024
@facundomedica facundomedica marked this pull request as ready for review August 7, 2024 16:39
@facundomedica facundomedica requested a review from a team as a code owner August 7, 2024 16:39
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, codebase verification and nitpick comments (2)
x/consensus/CHANGELOG.md (2)

36-36: Add missing article "the".

The sentence "Add consensus messages registration to consensus module" is missing the article "the".

- Add consensus messages registration to consensus module.
+ Add the consensus messages registration to the consensus module.
Tools
LanguageTool

[uncategorized] ~36-~36: You might be missing the article “the” here.
Context: ... Add consensus messages registration to consensus module. * [#20615](https://github.com/c...

(AI_EN_LECTOR_MISSING_DETERMINER_THE)


41-42: Clarify API breaking change for ToProtoConsensusParams().

The change log entry for ToProtoConsensusParams() should clarify that it now returns an error, which requires error handling in dependent code.

- `ToProtoConsensusParams()` returns an error
+ `ToProtoConsensusParams()` now returns an error, requiring error handling in dependent code.
Review details

Configuration used: .coderabbit.yml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 4dc9469 and 502df91.

Files ignored due to path filters (1)
  • x/consensus/types/tx.pb.go is excluded by !**/*.pb.go
Files selected for processing (7)
  • CHANGELOG.md (3 hunks)
  • api/cosmos/consensus/v1/tx.pulsar.go (2 hunks)
  • x/consensus/CHANGELOG.md (1 hunks)
  • x/consensus/keeper/keeper.go (1 hunks)
  • x/consensus/keeper/keeper_test.go (1 hunks)
  • x/consensus/proto/cosmos/consensus/v1/tx.proto (1 hunks)
  • x/consensus/types/msgs.go (1 hunks)
Files skipped from review due to trivial changes (1)
  • x/consensus/keeper/keeper.go
Additional context used
Path-based instructions (5)
x/consensus/types/msgs.go (1)

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

x/consensus/CHANGELOG.md (1)

Pattern **/*.md: "Assess the documentation for misspellings, grammatical errors, missing documentation and correctness"

x/consensus/keeper/keeper_test.go (2)

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


Pattern **/*_test.go: "Assess the unit test code assessing sufficient code coverage for the changes associated in the pull request"

api/cosmos/consensus/v1/tx.pulsar.go (1)

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

CHANGELOG.md (1)

Pattern **/*.md: "Assess the documentation for misspellings, grammatical errors, missing documentation and correctness"

LanguageTool
x/consensus/CHANGELOG.md

[uncategorized] ~36-~36: You might be missing the article “the” here.
Context: ... Add consensus messages registration to consensus module. * [#20615](https://github.com/c...

(AI_EN_LECTOR_MISSING_DETERMINER_THE)

Additional comments not posted (9)
x/consensus/types/msgs.go (2)

34-35: Direct assignment of Feature and Synchrony fields.

The direct assignment of Feature and Synchrony fields from the msg object simplifies the code and improves readability. Ensure that msg.Feature and msg.Synchrony are properly validated before this method is called.


39-44: Streamlined conditional check for msg.Abci.

The conditional check for msg.Abci and the subsequent initialization of cp.Feature if nil, followed by the assignment of VoteExtensionsEnableHeight, improves code clarity and reduces nested conditions. Ensure that msg.Abci.VoteExtensionsEnableHeight is always valid when msg.Abci is not nil.

x/consensus/proto/cosmos/consensus/v1/tx.proto (1)

41-43: Update version annotation for synchrony field.

The version annotation for the synchrony field has been updated from "cosmos-sdk 0.51" to "cosmos-sdk 0.52". This change correctly reflects the new version in which the synchrony parameter is recognized.

x/consensus/keeper/keeper_test.go (1)

41-41: Verify the impact of key initialization change.

The key initialization has been changed from consensusparamkeeper.StoreKey to types.StoreKey. Ensure that this change aligns with the broader refactor or correction and does not introduce any issues.

Verification successful

Verified the impact of key initialization change.

The change from consensusparamkeeper.StoreKey to types.StoreKey aligns with a broader refactor and is consistently used across the codebase. There are no issues introduced by this change.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of `types.StoreKey` in the codebase.

# Test: Search for the usage of `types.StoreKey`. Expect: Consistent usage across the codebase.
rg --type go 'types.StoreKey'

Length of output: 30309

api/cosmos/consensus/v1/tx.pulsar.go (2)

1445-1445: Verify the usage and status of the Abci field.

The deprecation comment for the Abci field has been removed. Ensure that this field is still in use or confirm the intention to phase out its visibility in the code documentation.

Verification successful

Verified the usage and status of the Abci field.

The Abci field is still actively used across various files in the codebase. The removal of the deprecation comment is appropriate as there is no indication that the field is being phased out.

  • x/consensus/types/msgs.go
  • x/consensus/types/tx.pb.go
  • x/consensus/keeper/keeper_test.go
  • types/abci.pb.go
  • server/v2/cometbft/abci.go
  • baseapp/abci.go
  • api/cosmos/consensus/v1/tx.pulsar.go
  • baseapp/abci_utils.go
  • baseapp/abci_test.go
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of `Abci` field in the codebase.

# Test: Search for the usage of `Abci` field. Expect: Consistent usage or clear intention to phase out.
rg --type go 'Abci'

Length of output: 16983


1445-1445: Verify the impact of byte value change in file_cosmos_consensus_v1_tx_proto_rawDesc.

The byte value in the file_cosmos_consensus_v1_tx_proto_rawDesc variable has been modified from 0x51 to 0x32. Ensure that this change aligns with the intended update and does not introduce any issues in serialization or deserialization processes.

CHANGELOG.md (3)

Line range hint 1-6:
LGTM! Enhancements and backward compatibility.

The changes in this hunk add new functionalities and ensure backward compatibility, which is a good practice.


Line range hint 7-12:
LGTM! Improved module management and AutoCLI migration.

The changes in this hunk improve module management and reflect ongoing migrations towards AutoCLI, which enhances the overall architecture.


Line range hint 13-18:
LGTM! Better modularity and dependency management.

The changes in this hunk improve modularity and dependency management. However, ensure that the change in NewValidatorSigningInfo to accept strings instead of sdk.AccAddress does not introduce any issues.

Verification successful

Verification successful: The change in NewValidatorSigningInfo to accept strings instead of sdk.AccAddress has been consistently applied across the codebase. No issues were found.

  • x/slashing/types/signing_info.go
  • x/slashing/keeper/signing_info_test.go
  • x/slashing/keeper/msg_server_test.go
  • x/slashing/keeper/hooks.go
  • x/slashing/keeper/grpc_query_test.go
  • x/slashing/keeper/genesis_test.go
  • x/slashing/simulation/decoder_test.go
  • tests/sims/slashing/operations_test.go
  • tests/integration/slashing/keeper/keeper_test.go
  • tests/integration/evidence/keeper/infraction_test.go
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the impact of the change in `NewValidatorSigningInfo` to accept strings instead of `sdk.AccAddress`.

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

Length of output: 11128

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.

ACK

@tac0turtle tac0turtle added this pull request to the merge queue Aug 9, 2024
Merged via the queue into main with commit a9a687c Aug 9, 2024
76 checks passed
@tac0turtle tac0turtle deleted the facu/consensus-audit branch August 9, 2024 15:25
mergify bot pushed a commit that referenced this pull request Aug 9, 2024
(cherry picked from commit a9a687c)

# Conflicts:
#	api/cosmos/consensus/v1/tx.pulsar.go
tac0turtle added a commit that referenced this pull request Aug 9, 2024
Co-authored-by: Facundo Medica <[email protected]>
Co-authored-by: marbar3778 <[email protected]>
@julienrbrt julienrbrt mentioned this pull request Aug 12, 2024
28 tasks
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:x/consensus
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants