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

fix(stf): fixes to make init genesis pass #21088

Merged
merged 3 commits into from
Jul 27, 2024
Merged

fix(stf): fixes to make init genesis pass #21088

merged 3 commits into from
Jul 27, 2024

Conversation

alpe
Copy link
Contributor

@alpe alpe commented Jul 26, 2024

Description

Some minor fixes while working on v2 sims integration.


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 error handling across various functionalities for improved stability and debugging.
    • Standardized JSON marshalling process for event handling, improving compatibility and performance.
  • Bug Fixes

    • Improved robustness by preventing potential nil pointer dereferences in configuration unmarshalling.
  • Chores

    • Updated import statements for better package management.

@alpe alpe requested a review from a team as a code owner July 26, 2024 11:00
Copy link
Contributor

coderabbitai bot commented Jul 26, 2024

Walkthrough

Walkthrough

The changes primarily enhance error handling and serialization practices across the application. Key updates include improved checks for nil pointers before unmarshalling configurations, more informative error reporting, and a transition to standardized JSON marshalling methods. These modifications aim to strengthen the application's robustness, maintainability, and overall reliability.

Changes

File Change Summary
runtime/v2/builder.go Improved error handling in the Build method by checking for nil before unmarshalling store options, enhancing robustness.
runtime/v2/manager.go Enhanced error reporting in the InitGenesisJSON function by wrapping errors with additional context for better debugging.
runtime/v2/store/commands.go Updated condition in createRootStore to check for nil before unmarshalling store options, refining error handling.
server/v2/stf/core_event_service.go Modified TypedEventToEvent to use jsonpb.Marshaler for marshalling events, improving compatibility and memory management.
simapp/v2/app_di.go Adjusted import statements for better dependency management, including the addition of github.com/cosmos/cosmos-sdk/x/genutil.
schema/module_schema_test.go Enhanced test functions for readability and debugging by adding t.Helper() to clarify test failure locations.
schema/appdata/mux_test.go Marked the checkExpectedCallOrder function as a helper to improve clarity in test error reporting.

Sequence Diagram(s)

sequenceDiagram
    participant Builder
    participant Manager
    participant EventService
    participant Store

    Builder->>Store: Check for store options
    alt options exist
        Store->>Builder: Unmarshal options
    else options do not exist
        Store-->>Builder: Skip unmarshalling
    end

    Manager->>Manager: Initialize Genesis
    alt error occurs
        Manager-->>Manager: Wrap error with context
    end

    EventService->>EventService: Marshal typed event
    EventService->>EventService: Use jsonpb.Marshaler
Loading

Possibly related issues


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.

Copy link
Contributor

@alpe your pull request is missing a changelog!

@julienrbrt julienrbrt added the backport/v0.52.x PR scheduled for inclusion in the v0.52's next stable release label Jul 26, 2024
@@ -31,6 +29,8 @@ import (
slashingkeeper "cosmossdk.io/x/slashing/keeper"
stakingkeeper "cosmossdk.io/x/staking/keeper"
upgradekeeper "cosmossdk.io/x/upgrade/keeper"
_ "github.com/cosmos/cosmos-sdk/x/genutil"
"github.com/spf13/viper"
Copy link
Member

Choose a reason for hiding this comment

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

linter won't be happy of this

@@ -5,6 +5,7 @@ import (
"encoding/json"
"slices"

"github.com/cosmos/cosmos-sdk/codec"
Copy link
Member

Choose a reason for hiding this comment

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

we shouldn't bring in a cosmos-sdk dependency, can we use directly gogoproto jsonpb?

@julienrbrt julienrbrt changed the title Fix: fixes to make init genesis pass fix(stf): fixes to make init genesis pass Jul 26, 2024
@julienrbrt
Copy link
Member

Adding the backport label as simapp/v2 and comet server imports the SDK and we have replaces everywhere still in release/v052.x

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 fe8474e and d741d2e.

Files selected for processing (5)
  • runtime/v2/builder.go (1 hunks)
  • runtime/v2/manager.go (1 hunks)
  • server/v2/stf/core_event_service.go (2 hunks)
  • server/v2/store/commands.go (1 hunks)
  • simapp/v2/app_di.go (2 hunks)
Files skipped from review due to trivial changes (1)
  • simapp/v2/app_di.go
Additional context used
Path-based instructions (4)
server/v2/stf/core_event_service.go (1)

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

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

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

runtime/v2/builder.go (1)

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

runtime/v2/manager.go (1)

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

Learnings (1)
Common learnings
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 (5)
server/v2/stf/core_event_service.go (2)

8-8: Import statement added for codec package

The import statement for the Cosmos SDK's codec package has been added to support the new marshalling method.


59-61: Change to JSON marshalling method

The function now uses codec.ProtoMarshalJSON instead of gogoproto.Marshal for marshalling the event. This change aligns with standardized JSON marshalling practices in the Cosmos SDK, which can improve maintainability and compatibility.

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

132-134: Enhanced nil check for sub-configuration

The condition now ensures that v.Sub("store.options") is not nil before attempting to unmarshal the store options. This change prevents potential nil pointer dereferences, improving the robustness of the code.

runtime/v2/builder.go (1)

131-134: Enhanced nil check for sub-configuration

The condition now ensures that v.Sub("store.options") is not nil before attempting to unmarshal the store options. This change prevents potential nil pointer dereferences, improving the robustness of the code.

runtime/v2/manager.go (1)

169-169: Enhanced error reporting approved.

The change improves error reporting by wrapping the error with the module name, which enhances the clarity of error logs and aids in debugging.

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 d741d2e and da16f20a87bef4088560696393438aad7b41cf79.

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

evtJSON, err := gogoproto.Marshal(tev)
if err != nil {
buf := new(bytes.Buffer)
jm := &jsonpb.Marshaler{OrigName: true, EmitDefaults: true, AnyResolver: nil}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am using jsonpb now but without the types.UnpackInterfaces to not add codec types.

@alpe alpe force-pushed the alex/v2_init_fixes branch from da16f20 to b458062 Compare July 26, 2024 13:08
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 da16f20a87bef4088560696393438aad7b41cf79 and b458062.

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

@tac0turtle
Copy link
Member

Lint is failing. Once fixed should be good to merge

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 b458062 and 26cddef.

Files selected for processing (6)
  • schema/appdata/async.go (1 hunks)
  • schema/appdata/mux_test.go (1 hunks)
  • schema/module_schema_test.go (2 hunks)
  • server/v2/cometbft/client/grpc/cmtservice/service.go (2 hunks)
  • server/v2/stf/core_event_service.go (2 hunks)
  • simapp/v2/app_di.go (1 hunks)
Files skipped from review due to trivial changes (5)
  • schema/appdata/async.go
  • schema/appdata/mux_test.go
  • schema/module_schema_test.go
  • server/v2/cometbft/client/grpc/cmtservice/service.go
  • simapp/v2/app_di.go
Files skipped from review as they are similar to previous changes (1)
  • server/v2/stf/core_event_service.go

@tac0turtle tac0turtle added this pull request to the merge queue Jul 27, 2024
Merged via the queue into main with commit b05bb26 Jul 27, 2024
72 checks passed
@tac0turtle tac0turtle deleted the alex/v2_init_fixes branch July 27, 2024 18:15
mergify bot pushed a commit that referenced this pull request Jul 27, 2024
Co-authored-by: marbar3778 <[email protected]>
(cherry picked from commit b05bb26)

# Conflicts:
#	runtime/v2/builder.go
#	schema/appdata/async.go
#	schema/appdata/mux_test.go
#	schema/module_schema_test.go
#	server/v2/store/commands.go
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:schema C:server/v2 cometbft C:server/v2 stf
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants