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: remove consensus messages #21248

Merged
merged 14 commits into from
Aug 12, 2024
Merged

Conversation

tac0turtle
Copy link
Member

@tac0turtle tac0turtle commented Aug 11, 2024

Description

this pr proposes an alternative to consensus messages. This keeps inline with all the other usage of context key

closes #20996


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

ref: #21176

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 context key for initialization data in the consensus module.
    • Added enhanced methods for managing the genesis state in various modules.
  • Improvements

    • Improved documentation for context keys and initialization methods for better clarity.
    • Enhanced error handling with additional logging in consensus parameter methods.
    • Simplified handling of consensus messages within the application.
  • Bug Fixes

    • Updated application version handling for more accurate responses.
  • Maintenance

    • Upgraded Go version and various dependencies for improved performance and compatibility.
    • Removed unnecessary comments to streamline code readability.

Copy link
Contributor

coderabbitai bot commented Aug 11, 2024

Warning

Rate limit exceeded

@tac0turtle has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 0 minutes and 31 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 429d184 and 82ef194.

Walkthrough

Walkthrough

The changes across the codebase introduce several enhancements focused on improving code readability, documentation, and the initialization of consensus parameters. Key modifications include refined struct formatting, new context keys for better management of initialization data, and updates to the handling of consensus parameters in various methods. These adjustments aim to enhance clarity and maintainability while also addressing the retrieval of consensus parameters in the CometBFT ABCI Info call.

Changes

Files Change Summary
core/app/app.go, core/context/context.go Improved struct formatting for readability; added comments; introduced a new context key for setting consensus parameters.
server/v2/appmanager/appmanager.go, server/v2/appmanager/go.mod Added documentation for InitGenesis method; renamed variable for clarity; updated Go version and dependencies.
server/v2/cometbft/abci.go, server/v2/cometbft/utils.go Enhanced handling of consensus parameters; added error logging for type assertions.
server/v2/stf/stf.go, simapp/v2/app_config.go Removed runConsensusMessages function; adjusted DeliverBlock logic; added consensus module to the initialization sequence.
x/consensus/keeper/keeper.go, x/consensus/module.go Introduced InitGenesis and other genesis management methods; improved parameter update logic for consistency.
x/consensus/proto/cosmos/consensus/v1/query.proto, x/consensus/proto/cosmos/consensus/v1/tx.proto Removed unnecessary import statements to enhance modularity.

Assessment against linked issues

Objective Addressed Explanation
Get consensus params in CometBFT ABCI Info call (#20996)

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 mentioned this pull request Aug 12, 2024
15 tasks
@tac0turtle tac0turtle marked this pull request as ready for review August 12, 2024 11:29
@tac0turtle tac0turtle requested a review from a team as a code owner August 12, 2024 11:29
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: 2

Outside diff range, codebase verification and nitpick comments (6)
x/consensus/module.go (1)

52-55: Implement the DefaultGenesis method.

The DefaultGenesis method in x/consensus/module.go currently returns nil, while other modules implement it to provide a meaningful default genesis state. Implementing this method will ensure consistency and potentially avoid issues during application initialization. Consider what default state should be returned for the consensus module.

Analysis chain

Implement DefaultGenesis method.

The DefaultGenesis method currently returns nil. Consider implementing a default state if necessary.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage and necessity of `DefaultGenesis`.

# Test: Search for `DefaultGenesis` usage in the codebase.
rg 'DefaultGenesis' --type go

Length of output: 16644

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

47-47: Replace fmt.Println with structured logging.

Using fmt.Println for logging is not recommended in production code. Consider using a structured logger to provide better context and control over log output.

k.Logger(ctx).Info("Initializing genesis state for consensus")

99-101: Enhance error messages for better debugging.

Consider providing more context in error messages to aid in debugging. For example, include the parameter values being set when an error occurs.

if err := k.ParamsStore.Set(ctx, nextParams.ToProto()); err != nil {
    return nil, fmt.Errorf("failed to set consensus parameters: %w", err)
}
server/v2/cometbft/utils.go (1)

306-306: Improve logging message clarity.

The log message "err2" is not descriptive and does not provide context about the error. Consider using a more informative message.

- fmt.Println("err2")
+ fmt.Println("failed to assert type for consensus params response")
server/v2/stf/stf.go (2)

331-333: Add context to the preBlock comment.

The comment for preBlock could be enhanced by explaining what "pre block logic" entails.

- // preBlock executes the pre block logic.
+ // preBlock executes logic that prepares the state before the block is processed, such as initializing state variables.

351-353: Add context to the beginBlock comment.

The comment for beginBlock could be more descriptive about what the "begin block logic" involves.

- // beginBlock executes the begin block logic.
+ // beginBlock executes logic at the start of block processing, such as updating timestamps or setting initial conditions.
Review details

Configuration used: .coderabbit.yml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 367d94a and 5f33a78.

Files ignored due to path filters (2)
  • server/v2/appmanager/go.sum is excluded by !**/*.sum
  • server/v2/go.sum is excluded by !**/*.sum
Files selected for processing (13)
  • core/app/app.go (1 hunks)
  • core/context/context.go (1 hunks)
  • server/v2/appmanager/appmanager.go (3 hunks)
  • server/v2/appmanager/go.mod (1 hunks)
  • server/v2/cometbft/abci.go (5 hunks)
  • server/v2/cometbft/config.go (1 hunks)
  • server/v2/cometbft/utils.go (1 hunks)
  • server/v2/go.mod (7 hunks)
  • server/v2/stf/stf.go (5 hunks)
  • simapp/v2/app_config.go (1 hunks)
  • x/consensus/keeper/keeper.go (4 hunks)
  • x/consensus/module.go (4 hunks)
  • x/consensus/proto/cosmos/consensus/v1/query.proto (1 hunks)
Files skipped from review due to trivial changes (4)
  • core/app/app.go
  • server/v2/appmanager/appmanager.go
  • server/v2/cometbft/config.go
  • x/consensus/proto/cosmos/consensus/v1/query.proto
Additional context used
Path-based instructions (7)
core/context/context.go (1)

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

x/consensus/module.go (1)

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

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

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

simapp/v2/app_config.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/stf/stf.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.

Learnings (1)
x/consensus/keeper/keeper.go (1)
Learnt from: likhita-809
PR: cosmos/cosmos-sdk#18471
File: x/protocolpool/keeper/genesis.go:12-51
Timestamp: 2023-11-22T12:32:39.368Z
Learning: - The user `likhita-809` has confirmed the changes suggested in the previous interaction.
- The file in question is `x/protocolpool/keeper/genesis.go` from a Cosmos SDK module.
- The changes involve optimizing the `InitGenesis` function by removing redundant code and ensuring proper handling of start times for budget proposals.
Additional comments not posted (16)
server/v2/appmanager/go.mod (3)

3-3: Update Go version to 1.22.2.

The Go version has been updated from 1.21 to 1.22.2. Ensure that your environment supports this version and check for any compatibility issues with existing code.


12-12: Update golang.org/x/exp dependency.

The golang.org/x/exp dependency has been updated to a newer commit. Ensure that any experimental features used are stable and compatible.


7-7: Update cosmossdk.io/core dependency.

The cosmossdk.io/core dependency has been updated to a newer version. Verify that this update does not introduce breaking changes.

core/context/context.go (2)

6-6: Add initInfoKey for consensus params.

The initInfoKey struct has been added for initialization-related data. Ensure this key is used correctly throughout the codebase.


11-16: Enhance documentation for context keys.

The comments for ExecModeKey, CometInfoKey, and InitInfoKey improve code readability and maintainability by clarifying their purposes.

x/consensus/module.go (5)

5-5: Add encoding/json import.

The addition of encoding/json is necessary for handling JSON data in the new genesis methods.


29-29: Implement HasGenesis interface.

The AppModule now implements the HasGenesis interface, enabling genesis state operations. Ensure all methods are correctly implemented.


47-50: Implement InitGenesis method.

The InitGenesis method initializes the module's state. Ensure it correctly interacts with the keeper.


57-60: Implement ValidateGenesis method.

The ValidateGenesis method is a noop. Ensure validation logic is added if needed.

Verification successful

Consider implementing validation logic in ValidateGenesis if necessary.

The ValidateGenesis method in x/consensus/module.go is currently a no-op and does not seem to impact other parts of the codebase. However, implementing validation logic might be beneficial if the consensus module has specific requirements for its genesis state. Review the module's requirements to determine if validation is needed.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the necessity of validation logic in `ValidateGenesis`.

# Test: Search for references to `ValidateGenesis`.
rg 'ValidateGenesis' --type go

Length of output: 15197


62-65: Implement ExportGenesis method.

The ExportGenesis method currently returns nil. Review if exporting logic is required.

server/v2/go.mod (1)

Line range hint 3-109: LGTM! Dependency updates are appropriate.

The updates to the Go version and dependencies are appropriate and align with routine maintenance practices.

simapp/v2/app_config.go (1)

142-142: LGTM! Consensus module initialization is correctly added.

Adding consensustypes.ModuleName to the InitGenesis list ensures proper initialization of the consensus module.

server/v2/stf/stf.go (1)

159-164: Verify removal of consensus message handling.

The DeliverBlock function no longer handles consensus messages. Ensure that this logic is appropriately managed elsewhere in the codebase to maintain functionality.

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

264-269: Review changes in BlockRequest construction.

The BlockRequest struct construction in InitChain has been simplified. Ensure that the removal of ConsensusMessages does not impact other functionalities.

Verification successful

No impact from removal of ConsensusMessages in BlockRequest construction.

The search results did not show any dependencies on the ConsensusMessages field within the BlockRequest struct, indicating that its removal does not affect other functionalities.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the impact of changes to `BlockRequest` construction.

# Test: Search for all usages of `BlockRequest` to ensure no dependencies on the removed `ConsensusMessages` field.
rg --type go 'BlockRequest'

Length of output: 76139


156-164: Ensure dynamic app version handling is correct.

The dynamic setting of AppVersion based on consensus parameters is a significant change. Verify that all scenarios where version > 0 are correctly handled and that the consensus parameters are always available when needed.

Verification successful

Dynamic App Version Handling is Correct

The dynamic setting of AppVersion based on consensus parameters is correctly implemented. All usages of GetConsensusParams in server/v2/cometbft/abci.go include proper error handling, ensuring that consensus parameters are available when needed. No further issues were found.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify scenarios where `version > 0` and consensus parameters are accessed.

# Test: Search for all usages of `GetConsensusParams` to ensure proper error handling and availability.
rg --type go 'GetConsensusParams'

Length of output: 2278


Script:

#!/bin/bash
# Extract more context around the usages of `GetConsensusParams` in `server/v2/cometbft/abci.go`
rg --type go --context 5 'GetConsensusParams' server/v2/cometbft/abci.go

Length of output: 1752


244-251: Clarify context value setting in InitChain.

The use of context.WithValue in InitChain is crucial for setting consensus parameters. Ensure that all necessary parameters are included and correctly utilized in the context.

Verification successful

Context Value Setting in InitChain is Correct

The MsgUpdateParams struct used in both setting and retrieving the context value is consistent across the codebase, ensuring proper handling and usage. No issues were found with the current implementation.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the correct setting and usage of context values in `InitChain`.

# Test: Search for all usages of `corecontext.InitInfoKey` to ensure proper handling and retrieval.
rg --type go 'corecontext.InitInfoKey'

Length of output: 253


Script:

#!/bin/bash
# Check the definition of `consensustypes.MsgUpdateParams`
ast-grep --lang go --pattern 'type MsgUpdateParams struct { $$$ }' --json

# Check the definition of `types.MsgUpdateParams`
ast-grep --lang go --pattern 'type MsgUpdateParams struct { $$$ }' --json

Length of output: 47683

fmt.Println("InitGenesis consensus")
value := ctx.Value(corecontext.InitInfoKey).(*types.MsgUpdateParams)
Copy link
Contributor

Choose a reason for hiding this comment

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

Use type assertion with check to prevent panics.

The direct type assertion ctx.Value(corecontext.InitInfoKey).(*types.MsgUpdateParams) can cause a panic if the value is not of the expected type. Consider using a type assertion with a check to handle this safely.

value, ok := ctx.Value(corecontext.InitInfoKey).(*types.MsgUpdateParams)
if !ok {
    return fmt.Errorf("unexpected type for InitInfoKey")
}

Comment on lines +370 to 372
// endBlock executes the end block logic.
func (s STF[T]) endBlock(
ctx *executionContext,
Copy link
Contributor

Choose a reason for hiding this comment

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

Correct the mode attribute in endBlock events.

The mode attribute in endBlock events is incorrectly set to "BeginBlock". It should reflect the end block context.

- event.Attribute{Key: "mode", Value: "BeginBlock"},
+ event.Attribute{Key: "mode", Value: "EndBlock"},

Committable suggestion was skipped due to low confidence.

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.

lgtm! Just some reverts needed.

server/v2/cometbft/utils.go Outdated Show resolved Hide resolved
server/v2/appmanager/go.mod Outdated Show resolved Hide resolved
server/v2/go.mod Outdated Show resolved Hide resolved
x/consensus/keeper/keeper.go Outdated Show resolved Hide resolved
Copy link
Member

@facundomedica facundomedica left a comment

Choose a reason for hiding this comment

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

utACK

ExecModeKey = execModeKey{}
// ExecModeKey is the context key for setting the execution mode.
ExecModeKey = execModeKey{}
// CometInfoKey is the context key for allowing modules to get CometInfo.
Copy link
Member

Choose a reason for hiding this comment

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

nit: maybe we want to use something more generic than CometInfoKey? Maybe something like ConsensusInfoKey? It's a tiny nit, no need to block merge because of this

Copy link
Member Author

Choose a reason for hiding this comment

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

Since the info is called comet I would opt to keep it for consistency.

@@ -41,6 +42,27 @@ func (k *Keeper) GetAuthority() string {
return k.authority
}

// InitGenesis initializes the initial state of the module
func (k *Keeper) InitGenesis(ctx context.Context) error {
value := ctx.Value(corecontext.InitInfoKey).(*types.MsgUpdateParams)
Copy link
Member

Choose a reason for hiding this comment

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

value, ok := to fix the tests

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 5f33a78 and 429d184.

Files ignored due to path filters (1)
  • server/v2/go.sum is excluded by !**/*.sum
Files selected for processing (6)
  • server/v2/cometbft/abci.go (5 hunks)
  • server/v2/go.mod (6 hunks)
  • simapp/app.go (2 hunks)
  • simapp/app_config.go (1 hunks)
  • x/consensus/keeper/keeper.go (4 hunks)
  • x/consensus/proto/cosmos/consensus/v1/tx.proto (1 hunks)
Files skipped from review due to trivial changes (1)
  • x/consensus/proto/cosmos/consensus/v1/tx.proto
Files skipped from review as they are similar to previous changes (1)
  • server/v2/go.mod
Additional context used
Path-based instructions (4)
x/consensus/keeper/keeper.go (1)

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

simapp/app_config.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.

simapp/app.go (1)

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

Learnings (1)
x/consensus/keeper/keeper.go (1)
Learnt from: likhita-809
PR: cosmos/cosmos-sdk#18471
File: x/protocolpool/keeper/genesis.go:12-51
Timestamp: 2023-11-22T12:32:39.368Z
Learning: - The user `likhita-809` has confirmed the changes suggested in the previous interaction.
- The file in question is `x/protocolpool/keeper/genesis.go` from a Cosmos SDK module.
- The changes involve optimizing the `InitGenesis` function by removing redundant code and ensuring proper handling of start times for budget proposals.
Additional comments not posted (7)
x/consensus/keeper/keeper.go (2)

45-68: LGTM!

The InitGenesis method properly initializes the module's state using context values and handles errors effectively. The use of type assertion with a check is a good practice.


98-114: Streamlined parameter update process is effective.

The UpdateParams method efficiently updates consensus parameters and handles errors appropriately. The consolidation of parameter setting and event emission improves clarity.

simapp/app_config.go (1)

152-152: Inclusion of consensustypes.ModuleName is appropriate.

Adding consensustypes.ModuleName to the InitGenesis sequence ensures that consensus parameters are initialized correctly, enhancing the application's configuration.

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

Line range hint 156-174: Dynamic AppVersion retrieval enhances accuracy.

The Info method's use of consensus parameters to set AppVersion improves the accuracy of the information returned, aligning with best practices.


244-251: Effective integration of consensus parameters in context.

The InitChain method's modification of the context with consensus parameters allows for streamlined access and manipulation, enhancing the initialization process.

simapp/app.go (2)

54-54: Import statement added for consensustypes.

The addition of the consensustypes import is appropriate and aligns with the changes in the module initialization order.


505-524: Consensus module prioritized in initialization.

The inclusion of consensustypes.ModuleName at the beginning of genesisModuleOrder ensures that the consensus module is initialized first. This aligns with the goal of enhancing consistency and maintainability.

Verify if this change affects the initialization dependencies of other modules.

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 5f33a78 and 429d184.

Files ignored due to path filters (1)
  • server/v2/go.sum is excluded by !**/*.sum
Files selected for processing (6)
  • server/v2/cometbft/abci.go (5 hunks)
  • server/v2/go.mod (6 hunks)
  • simapp/app.go (2 hunks)
  • simapp/app_config.go (1 hunks)
  • x/consensus/keeper/keeper.go (4 hunks)
  • x/consensus/proto/cosmos/consensus/v1/tx.proto (1 hunks)
Files skipped from review due to trivial changes (2)
  • server/v2/go.mod
  • x/consensus/proto/cosmos/consensus/v1/tx.proto
Additional context used
Path-based instructions (4)
x/consensus/keeper/keeper.go (1)

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

simapp/app_config.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.

simapp/app.go (1)

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

Learnings (1)
x/consensus/keeper/keeper.go (1)
Learnt from: likhita-809
PR: cosmos/cosmos-sdk#18471
File: x/protocolpool/keeper/genesis.go:12-51
Timestamp: 2023-11-22T12:32:39.368Z
Learning: - The user `likhita-809` has confirmed the changes suggested in the previous interaction.
- The file in question is `x/protocolpool/keeper/genesis.go` from a Cosmos SDK module.
- The changes involve optimizing the `InitGenesis` function by removing redundant code and ensuring proper handling of start times for budget proposals.
Additional comments not posted (8)
x/consensus/keeper/keeper.go (3)

Line range hint 117-142:
Validation logic approved!

The paramCheck function effectively validates consensus parameters with appropriate error handling.


45-68: LGTM! Verify the function usage in the codebase.

The InitGenesis function is well-implemented with proper type assertion checks and validation logic.

Ensure that the function is correctly integrated and used across the codebase.


98-114: Refactoring approved! Verify the function usage in the codebase.

The UpdateParams function has been refactored for improved readability and maintainability.

Ensure that the function is correctly integrated and used across the codebase.

simapp/app_config.go (1)

152-152: Initialization logic enhancement approved!

Adding consensustypes.ModuleName to InitGenesis ensures proper setup of consensus parameters during initialization.

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

Line range hint 156-174:
Application versioning logic approved!

The Info method's enhancement to conditionally assign appVersion based on consensus parameters improves the accuracy of application version reflection.


244-251: Chain initialization logic approved!

The InitChain method's inclusion of additional parameters from req.ConsensusParams in the context enhances the interaction with consensus parameters.

simapp/app.go (2)

54-54: Import Statement Approved.

The import of consensustypes from cosmossdk.io/x/consensus/types is appropriate for the changes made in the genesisModuleOrder.


505-524: Initialization Order Update Approved.

Adding consensustypes.ModuleName to the beginning of the genesisModuleOrder ensures that consensus-related types are initialized first, which aligns with the PR objectives.

However, verify that this change does not affect the initialization of other modules adversely.

Verification successful

Initialization Order Change Verified.

The addition of consensustypes.ModuleName at the beginning of genesisModuleOrder is correctly reflected in the initialization and export order of modules. This change aligns with the intended functionality to prioritize consensus-related modules without adversely affecting other modules.

  • The genesisModuleOrder is used in SetOrderInitGenesis and SetOrderExportGenesis, ensuring consistent initialization and export order.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the initialization order of modules in the genesisModuleOrder.

# Test: Check the usage of genesisModuleOrder in the codebase. Expect: Proper initialization order.
rg --type go $'genesisModuleOrder'

Length of output: 234

@tac0turtle tac0turtle added this pull request to the merge queue Aug 12, 2024
Merged via the queue into main with commit 3e41324 Aug 12, 2024
73 of 75 checks passed
@tac0turtle tac0turtle deleted the marko/consensusmsg_cleanup branch August 12, 2024 14:24
@julienrbrt
Copy link
Member

This touches cometbft and simapp/v2 so we should partially backport

@julienrbrt
Copy link
Member

@Mergifyio backport release/v0.52.x

Copy link
Contributor

mergify bot commented Aug 12, 2024

backport release/v0.52.x

✅ Backports have been created

mergify bot pushed a commit that referenced this pull request Aug 12, 2024
(cherry picked from commit 3e41324)

# Conflicts:
#	core/app/app.go
#	core/context/context.go
#	server/v2/appmanager/appmanager.go
#	server/v2/go.mod
#	server/v2/go.sum
#	server/v2/stf/stf.go
julienrbrt added a commit that referenced this pull request Aug 12, 2024
Co-authored-by: Marko <marko@baricevic.me>
Co-authored-by: Julien Robert <julien@rbrt.fr>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Get consensus params in comet server
5 participants