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(simapp): textual wiring #18242

Merged
merged 5 commits into from
Oct 24, 2023
Merged

fix(simapp): textual wiring #18242

merged 5 commits into from
Oct 24, 2023

Conversation

julienrbrt
Copy link
Member

@julienrbrt julienrbrt commented Oct 24, 2023

Description

Closes: #17822

Verifies that textual works and --node flags works as well.


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
  • added ! to 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
  • followed the guidelines for building modules
  • included the necessary unit and integration tests
  • added a changelog entry to CHANGELOG.md
  • included comments for documenting Go code
  • updated the relevant documentation or specification
  • reviewed "Files changed" and left comments if necessary
  • run make lint and make test
  • 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.

I have...

  • confirmed the correct type prefix in the PR title
  • confirmed ! in the type prefix if API or client breaking change
  • confirmed all author checklist items have been addressed
  • reviewed state machine logic
  • reviewed API design and naming
  • reviewed documentation is accurate
  • reviewed tests and test coverage
  • manually tested (if applicable)

Summary by CodeRabbit

  • Refactor: Simplified code by removing unnecessary variables and assignments, enhancing the software's maintainability.
  • New Feature: Enabled sign mode textual and improved transaction configuration options, providing users with more flexibility and control over transactions.
  • Documentation: Updated module import instructions and introduced a new x/protocolpool module in the UPGRADING.md file, helping developers to understand the changes and adapt their code accordingly.
  • Style: Fixed a typo in a parameter name, improving code readability.
  • Chore: Updated default values for certain fields and removed deprecated functions, ensuring the software stays up-to-date and efficient.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 24, 2023

Walkthrough

This pull request introduces significant changes to improve code simplicity, maintainability, and performance. It includes updates to the client context, transaction configuration, and sign modes. It also refactors the code to remove unnecessary variables and functions, and corrects typos. The changes are spread across several files, including cmd.go, factory.go, msg.go, root_v2.go, and config.go.

Changes

File(s) Summary
client/cmd.go, client/v2/autocli/msg.go Simplified slice operations and updated default values for fields in the clientCtx struct.
client/tx/factory.go, client/tx/tx.go Removed unnecessary variable assignments and simplified error handling.
simapp/simd/cmd/root_v2.go, x/auth/tx/config/config.go Updated import statements, removed deprecated functions, and corrected typos.
UPGRADING.md Documented changes related to module imports and the introduction of new modules.

"In the land of code, where the shadows lie,

A rabbit hopped, with a twinkle in its eye. 🐇✨

With every hop, a change was made,

Simplifying code, improving the grade. 📝🎓

Now the code is clean, the rabbit's task is done,

It's time to hop away, under the setting sun. 🌅🐇"


Tips

Chat with CodeRabbit Bot (@coderabbitai)

  • If you reply to a review comment from CodeRabbit, the bot will automatically respond.
  • To engage with CodeRabbit bot directly around the specific lines of code in the PR, mention @coderabbitai in your review comment
  • Note: Review comments are made on code diffs or files, not on the PR overview.
  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

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 a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai help to get help.

Note: For conversation with the bot, please use the review comments on code diffs or files.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • 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/coderabbit-overrides.json

@github-actions github-actions bot added the C:CLI label Oct 24, 2023
@julienrbrt julienrbrt added the backport/v0.50.x PR scheduled for inclusion in the v0.50's next stable release label Oct 24, 2023
@julienrbrt julienrbrt marked this pull request as ready for review October 24, 2023 19:16
@julienrbrt julienrbrt requested a review from a team as a code owner October 24, 2023 19:16
@github-actions
Copy link
Contributor

@julienrbrt your pull request is missing a changelog!

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.

Review Status

Actionable comments generated: 1

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 2f23e8a and eb28327.
Files selected for processing (5)
  • client/cmd.go (3 hunks)
  • client/tx/factory.go (1 hunks)
  • client/v2/autocli/msg.go (1 hunks)
  • simapp/simd/cmd/root_v2.go (5 hunks)
  • x/auth/tx/config/config.go (2 hunks)
Files skipped from review due to trivial changes (2)
  • client/tx/factory.go
  • x/auth/tx/config/config.go
Additional comments: 9
client/v2/autocli/msg.go (2)
  • 118-119: The client context is now updated with the command context and output. This is a good practice as it ensures that the client context is always in sync with the command context and output.

  • 121-135: The creation of txConfig and its assignment to clientCtx is now inside the condition that checks if the application is not offline and if the sign mode textual is not enabled. This change is logical as it prevents unnecessary operations when the application is offline or the sign mode textual is already enabled. However, ensure that this change does not affect other parts of the code that rely on clientCtx having a txConfig even when the application is offline or the sign mode textual is already enabled.

client/cmd.go (2)
  • 11-11: The import golang.org/x/exp/slices is added to use the slices.Contains function. Ensure that this package is maintained and compatible with the current codebase.

  • 287-287: The loop checking for the presence of SignMode_SIGN_MODE_TEXTUAL in SupportedModes() has been replaced with a call to slices.Contains. This is a good optimization as it simplifies the code and potentially improves performance.

simapp/simd/cmd/root_v2.go (5)
  • 27-33: The import of authtxconfig has been added and the variable txConfigOpts has been removed from the NewRootCmd function. This change seems to be part of a larger refactoring to move the creation of txConfig from NewRootCmd to ProvideClientContext. Ensure that this change does not affect the functionality of the NewRootCmd function.

  • 47-52: The txConfigOpts variable has been removed from the NewRootCmd function. This change is part of the refactoring to move the creation of txConfig from NewRootCmd to ProvideClientContext. Ensure that this change does not affect the functionality of the NewRootCmd function.

  • 101-101: The ProvideClientContext function now takes txConfigOpts as an argument instead of txConfig. This change is part of the refactoring to move the creation of txConfig from NewRootCmd to ProvideClientContext. Ensure that all calls to ProvideClientContext have been updated to match the new signature.

  • 109-114: The WithTxConfig method call has been removed from the clientCtx initialization. This change is part of the refactoring to move the creation of txConfig from NewRootCmd to ProvideClientContext. Ensure that this change does not affect the functionality of the clientCtx.

  • 128-134: The txConfig is now created in the ProvideClientContext function using txConfigOpts and the NewTxConfigWithOptions function. The txConfig is then set in the clientCtx using the WithTxConfig method. This change is part of the refactoring to move the creation of txConfig from NewRootCmd to ProvideClientContext. Ensure that this change does not affect the functionality of the clientCtx and txConfig.

client/cmd.go Show resolved Hide resolved
@julienrbrt julienrbrt marked this pull request as draft October 24, 2023 19:19
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.

tested on v1 and v2. LGTM

@julienrbrt julienrbrt marked this pull request as ready for review October 24, 2023 20:24
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.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between eb28327 and 57d05ee.
Files ignored due to filter (1)
  • client/v2/go.mod
Files selected for processing (2)
  • client/tx/tx.go (2 hunks)
  • client/v2/autocli/msg.go (2 hunks)
Files skipped from review due to trivial changes (1)
  • client/tx/tx.go
Additional comments: 3
client/v2/autocli/msg.go (3)
  • 6-11: The import "golang.org/x/exp/slices" has been removed. Ensure that this package is not used elsewhere in the code. If it is, you may need to replace its usage with an equivalent function or method.

  • 117-118: The client context is now updated with the command context and output. This is a good practice as it ensures that the client context is always in sync with the command context and output.

  • 121-136: The check for !clientCtx.Offline has been moved to encompass more code, including the creation of txConfig. This change could potentially improve performance by avoiding unnecessary operations when clientCtx.Offline is true. However, ensure that this change does not affect the expected behavior of the code.

-		if !clientCtx.Offline && !slices.Contains(b.TxConfigOpts.EnabledSignModes, signing.SignMode_SIGN_MODE_TEXTUAL) {
+		if !clientCtx.Offline {
Committable suggestion (Beta)
		if !clientCtx.Offline {
			clientCtx = clientCtx.WithCmdContext(cmd.Context())
			clientCtx = clientCtx.WithOutput(cmd.OutOrStdout())

			b.TxConfigOpts.EnabledSignModes = append(b.TxConfigOpts.EnabledSignModes, signing.SignMode_SIGN_MODE_TEXTUAL)
			b.TxConfigOpts.TextualCoinMetadataQueryFn = authtxconfig.NewGRPCCoinMetadataQueryFn(clientCtx)

			txConfig, err := authtx.NewTxConfigWithOptions(
				codec.NewProtoCodec(clientCtx.InterfaceRegistry),
				b.TxConfigOpts,
			)
			if err != nil {
				return err
			}

			clientCtx = clientCtx.WithTxConfig(txConfig)
		}

@julienrbrt julienrbrt added this pull request to the merge queue Oct 24, 2023
@julienrbrt julienrbrt removed this pull request from the merge queue due to a manual request Oct 24, 2023
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.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 57d05ee and a461239.
Files selected for processing (1)
  • UPGRADING.md (5 hunks)
Files skipped from review due to trivial changes (1)
  • UPGRADING.md

@julienrbrt julienrbrt added this pull request to the merge queue Oct 24, 2023
Merged via the queue into main with commit fd93ee7 Oct 24, 2023
55 of 56 checks passed
@julienrbrt julienrbrt deleted the julien/textual branch October 24, 2023 21:20
mergify bot pushed a commit that referenced this pull request Oct 24, 2023
(cherry picked from commit fd93ee7)

# Conflicts:
#	UPGRADING.md
#	client/tx/factory.go
#	client/tx/tx.go
#	client/v2/go.mod
julienrbrt added a commit that referenced this pull request Oct 24, 2023
@@ -115,21 +114,26 @@ func (b *Builder) BuildMsgMethodCommand(descriptor protoreflect.MethodDescriptor
return err
}

// enable sign mode textual and config tx options
if !clientCtx.Offline && !slices.Contains(b.TxConfigOpts.EnabledSignModes, signing.SignMode_SIGN_MODE_TEXTUAL) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

We removed this check here that !slices.Contains(b.TxConfigOpts.EnabledSignModes, signing.SignMode_SIGN_MODE_TEXTUAL), was that intentional?

Copy link
Member Author

@julienrbrt julienrbrt Oct 25, 2023

Choose a reason for hiding this comment

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

Yes, it was intentional.
In the client (autocli or root.go), we always need to overwrite the TxConfigOpts.TextualCoinMetadataQueryFn to use NewGRPCCoinMetadataQueryFn. If an app is using depinject, that value will using the bank keeper, which is only correct for the server (app.go)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Got it and thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport/v0.50.x PR scheduled for inclusion in the v0.50's next stable release C:CLI C:x/auth
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: Sign mode textual error if not upper case
3 participants