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

test(systemtest): Fix QueryBySig #23102

Merged
merged 2 commits into from
Dec 27, 2024
Merged

test(systemtest): Fix QueryBySig #23102

merged 2 commits into from
Dec 27, 2024

Conversation

hieuvubk
Copy link
Contributor

@hieuvubk hieuvubk commented Dec 27, 2024

Description

Closes: #XXXX

  • Add TxConfig to comet clientCtx for authtx.formatTxResults

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 transaction handling capabilities with the addition of a new transaction configuration variable.
  • Bug Fixes

    • Improved error messaging in transaction decoding tests for better clarity on invalid transaction input.

Copy link
Contributor

coderabbitai bot commented Dec 27, 2024

📝 Walkthrough

Walkthrough

The pull request introduces a new variable txConfig in the maybeHandleExternalServices function within the server/v2/cometbft/grpc.go file. This variable is of type authtx.TxConfig and is initialized using codecs from the application's signing context. The clientCtx is updated to include this new txConfig, enhancing the transaction context configuration without modifying the existing functionality or control flow. Additionally, the error messages in specific test functions are updated for clarity regarding transaction decoding failures.

Changes

File Change Summary
server/v2/cometbft/grpc.go Added txConfig variable to maybeHandleExternalServices function, initialized with application codecs and integrated into clientCtx.
tests/systemtests/tx_test.go Updated error message in TestTxDecodeAmino_GRPC and TestTxDecodeAmino_GRPCGateway for invalid transaction bytes from "invalid request" to "unmarshal to legacytx.StdTx failed".

Possibly related PRs

Suggested labels

C:x/auth, backport/v0.52.x

Suggested reviewers

  • kocubinski
  • facundomedica
  • testinginprod

Tip

CodeRabbit's docstrings feature is now available as part of our Early Access Program! Simply use the command @coderabbitai generate docstrings to have CodeRabbit automatically generate docstrings for your pull request. We would love to hear your feedback on Discord.


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>, please review it.
    • 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 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.

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. (Beta)
  • @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.

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

529-535: Consider verifying and customizing sign modes if needed.
By default, authtx.NewTxConfig uses DefaultSignModes. If the chain requires additional or restricted sign modes, consider specifying them directly instead of the defaults.

📜 Review details

Configuration used: .coderabbit.yml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between aabd4b1 and d3ec004.

📒 Files selected for processing (1)
  • server/v2/cometbft/grpc.go (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
server/v2/cometbft/grpc.go (1)

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

🔇 Additional comments (1)
server/v2/cometbft/grpc.go (1)

541-542: Great use of method chaining for context setup.
Chaining .WithClient(rpcClient) and .WithTxConfig(txConfig) is clear and aligns with idiomatic Go in the Cosmos SDK.

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

🧹 Nitpick comments (1)
server/v2/cometbft/grpc.go (1)

529-535: Validate the usage of authtx.NewTxConfig and consider sign modes manageability.

The current usage of authtx.NewTxConfig is valid for establishing TxConfig with default sign modes. However, if your application requires more flexible or specialized sign modes, consider making sign modes configurable instead of relying on defaults alone.

📜 Review details

Configuration used: .coderabbit.yml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between aabd4b1 and d3ec004.

📒 Files selected for processing (1)
  • server/v2/cometbft/grpc.go (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
server/v2/cometbft/grpc.go (1)

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

Comment on lines +541 to +542
WithClient(rpcClient).
WithTxConfig(txConfig)
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Handle potential errors from RPC client creation.

You’re calling rpchttp.New(...) above without checking its error. This could lead to runtime issues if the RPC client fails to initialize. It’s recommended to validate and handle this error path rather than ignoring it.

- rpcClient, _ := rpchttp.New(c.cfg.AppTomlConfig.RPC.ListenAddress)
+ rpcClient, err := rpchttp.New(c.cfg.AppTomlConfig.RPC.ListenAddress)
+ if err != nil {
+     return nil, fmt.Errorf("failed to create RPC client: %w", err)
+ }

Committable suggestion skipped: line range outside the PR's diff.

@hieuvubk hieuvubk marked this pull request as draft December 27, 2024 08:46
@hieuvubk hieuvubk marked this pull request as ready for review December 27, 2024 09:07
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)
tests/systemtests/tx_test.go (1)

950-950: Enhance error message phrasing for consistency

In Go, error messages typically follow the convention of starting with a lowercase verb and avoiding phrases like "failed" at the end. Consider using something like "failed to unmarshal legacytx.StdTx" or "could not unmarshal legacytx.StdTx" for improved readability.

- {"invalid tx bytes", &tx.TxDecodeAminoRequest{AminoBinary: invalidTxBytes}, true, "unmarshal to legacytx.StdTx failed"},
+ {"invalid tx bytes", &tx.TxDecodeAminoRequest{AminoBinary: invalidTxBytes}, true, "failed to unmarshal legacytx.StdTx"},
📜 Review details

Configuration used: .coderabbit.yml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d3ec004 and 4916cbf.

📒 Files selected for processing (1)
  • tests/systemtests/tx_test.go (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
tests/systemtests/tx_test.go (3)

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


Pattern tests/**/*: "Assess the integration and e2e test code assessing sufficient code coverage for the changes associated in the pull request"


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

@tac0turtle tac0turtle added this pull request to the merge queue Dec 27, 2024
@tac0turtle tac0turtle removed this pull request from the merge queue due to a manual request Dec 27, 2024
@tac0turtle tac0turtle added this pull request to the merge queue Dec 27, 2024
Merged via the queue into main with commit 784d1c8 Dec 27, 2024
73 of 74 checks passed
@tac0turtle tac0turtle deleted the hieu/tx_config branch December 27, 2024 12:59
@julienrbrt
Copy link
Member

@Mergifyio backport release/v0.52.x

Copy link
Contributor

mergify bot commented Dec 28, 2024

backport release/v0.52.x

✅ Backports have been created

mergify bot pushed a commit that referenced this pull request Dec 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C:server/v2 cometbft C:server/v2 Issues related to server/v2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants