Skip to content

fix(client/v2): improve message parsing by replacing proto.Merge with cloneMessage #24722

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

Open
wants to merge 17 commits into
base: main
Choose a base branch
from

Conversation

julienrbrt
Copy link
Member

@julienrbrt julienrbrt commented May 8, 2025

Description

Closes: ignite/cli#4623

@Pantani found an issue when using autocli but no pulsar module was present: ignite/cli#4623

  • Pulsar shouldn't be mandatory, but proto.Merge fails when not present in modules (based on this SDK promise, Ignite v29 removed the pulsar file from its default template)
  • The solution was to manually recursively merge the proto, avoiding the checks and assumptions proto.Merge does

We've checked the other usage of proto.Merge but they shouldn't matter.

cc @aaronc


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. Your PR will not be merged unless you satisfy
all of these items.

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

Summary by CodeRabbit

  • Bug Fixes
    • Resolved an issue with message parsing when no pulsar file is present.

Copy link

ironbird-prod bot commented May 8, 2025

Ironbird - launch a network To use Ironbird, you can use the following commands:
  • /ironbird chains - List of chain images that ironbird can use to spin-up testnet
  • /ironbird loadtests - List of load test modes that ironbird can run against testnet
  • /ironbird start OR /ironbird start --load-test-config= - Launch a testnet with the specified chain and load test configuration.
Custom Load Test Configuration You can provide a custom load test configuration using the `--load-test-config=` flag:
/ironbird start cosmos --load-test-config={
  "block_gas_limit_target": 0.75,
  "num_of_blocks": 50,
  "msgs": [
    {"weight": 0.3, "type": "MsgSend"},
    {"weight": 0.3, "type": "MsgMultiSend"},
	{"weight": 0.4, "type": "MsgArr", "ContainedType": "MsgSend", "NumMsgs": 3300}
  ]
}

Use /ironbird loadtests to see more examples.

@github-actions github-actions bot added the C:CLI label May 8, 2025
Copy link
Contributor

coderabbitai bot commented May 8, 2025

📝 Walkthrough

Walkthrough

The changes introduce a new cloneMessage function in place of proto.Merge for copying protobuf messages in the CLI code, implementing a recursive, field-by-field copy using reflection. Additionally, a bug fix entry referencing this change is added to the top of the changelog. No other exported entities are affected.

Changes

File(s) Change Summary
client/v2/autocli/msg.go Replaces all uses of proto.Merge with a new cloneMessage function that recursively copies protobuf messages. Removes the proto import. Adds cloneMessage implementation.
client/v2/CHANGELOG.md Adds a "Bug Fixes" section at the top with an entry referencing PR #24722 about fixing message parsing when no pulsar file is present.

Sequence Diagram(s)

sequenceDiagram
    participant CLI as CLI Command
    participant Msg as Source Message
    participant Clone as cloneMessage
    participant Dst as Destination Message

    CLI->>Clone: cloneMessage(dst, src)
    loop For each field in src
        Clone->>Clone: If field is message, recursively clone
        Clone->>Dst: Set field value
    end
    Clone-->>CLI: Destination message cloned
Loading

Assessment against linked issues

Objective Addressed Explanation
Prevent panic when passing coin type through CLI (field descriptor mismatch) (#4623)
✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

‼️ IMPORTANT
Auto-reply has been disabled for this repository in the CodeRabbit settings. The CodeRabbit bot will not respond to your replies unless it is explicitly tagged.

  • 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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

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

@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

🧹 Nitpick comments (1)
client/v2/CHANGELOG.md (1)

37-39: Fix grammatical error in changelog entry

There's a small grammatical error in the changelog entry.

-* [#24722](https://github.com/cosmos/cosmos-sdk/pull/24722) Fix msg parsing in when no pulsar file is present.
+* [#24722](https://github.com/cosmos/cosmos-sdk/pull/24722) Fix msg parsing when no pulsar file is present.
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 05ac584 and 481baeb.

📒 Files selected for processing (2)
  • client/v2/CHANGELOG.md (1 hunks)
  • client/v2/autocli/msg.go (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: main
  • GitHub Check: Summary
🔇 Additional comments (3)
client/v2/autocli/msg.go (3)

163-163: Appropriate replacement for proto.Merge

The switch from proto.Merge to cloneMessage addresses the root issue with field descriptors from different repositories.


219-219: Consistent application of message cloning approach

Good consistency by applying the same cloning approach in the governance proposal flow.


227-282: Well-implemented manual message cloning function

The custom cloneMessage implementation thoroughly handles all potential field types (primitive fields, nested messages, lists, and maps) through explicit recursive copying.

The panic on line 236 is appropriate as it will help catch development errors early by ensuring field compatibility between messages.

Let's verify that this implementation covers all scenarios by checking other usages of proto.Merge in the codebase:

#!/bin/bash
# Check for other occurrences of proto.Merge in the codebase
rg "proto\.Merge" --type go


// cloneMessage safely copies fields from src message to dst message.
// this avoids the proto.Merge issue with field descriptors from different repositories.
func cloneMessage(dst, src protoreflect.Message) {
Copy link
Contributor

Choose a reason for hiding this comment

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

we need to test this method

Copy link
Member Author

Choose a reason for hiding this comment

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

i'll add a test 👍🏾

Copy link
Member Author

Choose a reason for hiding this comment

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

Added a test: 6bdfb65.
It fails before with that error, passes after the fix.

@julienrbrt julienrbrt requested a review from aljo242 May 15, 2025 01:09
@@ -1,13 +1,13 @@
syntax = "proto3";

package testpb;
package testpbpulsar;
Copy link
Member Author

Choose a reason for hiding this comment

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

Renamed, because test was failing (on ci only) for double registration (https://github.com/cosmos/cosmos-sdk/actions/runs/15034823230/job/42254518136 /

)

@aljo242
Copy link
Contributor

aljo242 commented May 15, 2025

@julienrbrt this is still failing

@julienrbrt
Copy link
Member Author

@julienrbrt this is still failing

fixed, was due because of the test proto renaming..

@aljo242
Copy link
Contributor

aljo242 commented May 15, 2025

@julienrbrt this is still failing

fixed, was due because of the test proto renaming..

https://github.com/cosmos/cosmos-sdk/actions/runs/15051726043/job/42307904781?pr=24722

@julienrbrt
Copy link
Member Author

ffs, there was one more: 7ca9340. it passes now.

@aljo242
Copy link
Contributor

aljo242 commented May 21, 2025

LGTM with @technicallyty approval

@julienrbrt
Copy link
Member Author

LGTM with @technicallyty approval

Awesome, a new client/v2 release with this fix is the last thing needed in order to be able to release Ignite CLI v29.

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.

FIX: pass the coin type through the CLI will panic
3 participants