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(auth): refactor auth/tx to use x/tx #19224

Merged
merged 40 commits into from
Feb 21, 2024
Merged

Conversation

testinginprod
Copy link
Contributor

@testinginprod testinginprod commented Jan 24, 2024

Description

Closes: #XXXX


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
  • 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.

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

  • Refactor
    • Enhanced the transaction building process for improved clarity and extensibility.
  • Chores
    • Updated dependencies to align with the new project structure.
  • Tests
    • Adjusted test cases to reflect changes in transaction handling and signer information.

@testinginprod testinginprod changed the title refactor(auth): refactor auth/x/tx refactor(auth): refactor auth/tx Jan 24, 2024
@testinginprod testinginprod marked this pull request as ready for review January 24, 2024 14:29
@testinginprod testinginprod requested a review from a team as a code owner January 24, 2024 14:29
@testinginprod testinginprod changed the title refactor(auth): refactor auth/tx [DO NOT REVIEW/MERGE] refactor(auth): refactor auth/tx Jan 24, 2024
Copy link
Contributor

coderabbitai bot commented Jan 24, 2024

Walkthrough

Walkthrough

The changes in this set primarily revolve around the migration and restructuring of transaction-related functionality within the codebase. This includes updating module paths, eliminating obsolete dependencies, and extensively refactoring the transaction building process. Moreover, there is a transition from utilizing auth/tx to x/tx for transaction management, alongside the deprecation of specific test cases and adjustments in test utilities to align with the new transaction handling paradigm.

Changes

File(s) Summary
x/auth/go.mod, x/slashing/go.mod, x/tx/go.mod Updated module paths and introduced replace directives for cosmossdk.io/api.
x/auth/go.sum, x/slashing/go.sum, x/tx/go.sum Removed particular versions of cosmossdk.io/api and updated dependencies accordingly.
x/auth/tx/builder.go Restructured the transaction building process with updated protobuf types and handling, encompassing reorganization of imports, package references, introduction of new types and methods, and adjustments in transaction data construction for improved clarity and extensibility.
baseapp/abci_test.go Eliminated a test case related to transactions with unregistered messages.
baseapp/utils_test.go Initialized the Signer field in test utilities to ensure consistent test setup.
x/auth/tx/config/depinject.go Updated imports, replaced a specific return value in ProvideProtoRegistry with gogoproto.HybridResolver, and removed an outdated import, aligning with the modifications in the transaction handling process.

Related issues

  • Migrate CLI commands in x/auth/tx to comet txserver #15888: The migration of CLI commands from x/auth/tx to x/tx aligns with the refactoring and restructuring efforts noted in the changes, especially the focus on enhancing transaction handling.
  • [Epic]: auth/tx migration #18446: The epic for auth/tx migration to x/tx is directly addressed by the refactoring and deprecation efforts in these changes, particularly with the focus on shifting towards x/tx for transaction-related functionality.

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-tests for this file.
  • 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 tests 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 from git and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit tests.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

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

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

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.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

// deprecating (StdTxConfig support)
type intoAny interface {
AsAny() *codectypes.Any
panic("todo")
Copy link
Contributor

Choose a reason for hiding this comment

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

The mkTxResult function has been altered to panic with a "todo" message.

- panic("todo")
+ // TODO: Implement the correct logic for mkTxResult or remove if not needed.

This is a placeholder for future implementation and should be replaced with the correct logic or removed if not needed.


Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
panic("todo")
// TODO: Implement the correct logic for mkTxResult or remove if not needed.

if req.Tx == nil {
return nil, status.Error(codes.InvalidArgument, "invalid empty tx")
}
panic("todo")
Copy link
Contributor

Choose a reason for hiding this comment

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

The TxEncode function has been modified to panic with a "todo" message.

- panic("todo")
+ // TODO: Implement the correct logic for TxEncode or remove if not needed.

This is a placeholder for future implementation and should be replaced with the correct logic or removed if not needed.


Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
panic("todo")
// TODO: Implement the correct logic for TxEncode or remove if not needed.

if req.TxBytes == nil {
return nil, status.Error(codes.InvalidArgument, "invalid empty tx bytes")
}
panic("todo")
Copy link
Contributor

Choose a reason for hiding this comment

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

The TxDecode function has been modified to panic with a "todo" message.

- panic("todo")
+ // TODO: Implement the correct logic for TxDecode or remove if not needed.

This is a placeholder for future implementation and should be replaced with the correct logic or removed if not needed.


Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
panic("todo")
// TODO: Implement the correct logic for TxDecode or remove if not needed.

Comment on lines 166 to 175
func intoV2Fees(fees sdk.Coins) []*basev1beta1.Coin {
coins := make([]*basev1beta1.Coin, len(fees))
for i, c := range fees {
coins[i] = &basev1beta1.Coin{
Denom: c.Denom,
Amount: c.Amount.String(),
}
}
return nil
}
Copy link
Contributor

Choose a reason for hiding this comment

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

The intoV2Fees function is intended to convert sdk.Coins to a slice of *basev1beta1.Coin, but it returns nil instead of the converted slice. This is likely a bug.

func intoV2Fees(fees sdk.Coins) []*basev1beta1.Coin {
	coins := make([]*basev1beta1.Coin, len(fees))
	for i, c := range fees {
		coins[i] = &basev1beta1.Coin{
			Denom:  c.Denom,
			Amount: c.Amount.String(),
		}
	}
-	return nil
+	return coins
}

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
func intoV2Fees(fees sdk.Coins) []*basev1beta1.Coin {
coins := make([]*basev1beta1.Coin, len(fees))
for i, c := range fees {
coins[i] = &basev1beta1.Coin{
Denom: c.Denom,
Amount: c.Amount.String(),
}
}
return nil
}
func intoV2Fees(fees sdk.Coins) []*basev1beta1.Coin {
coins := make([]*basev1beta1.Coin, len(fees))
for i, c := range fees {
coins[i] = &basev1beta1.Coin{
Denom: c.Denom,
Amount: c.Amount.String(),
}
}
return coins
}

x/auth/tx/gogotx.go Fixed Show fixed Hide fixed
Comment on lines 321 to 324
tx := txBuilder.GetTx()
newTxBldr, err := s.TxConfig.WrapTxBuilder(tx)
s.Require().NoError(err)
txBuilder.SetFeePayer(tx.FeePayer()) // NOTE: fee payer will be populated even if empty.
Copy link
Contributor

Choose a reason for hiding this comment

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

The code correctly retrieves the transaction from txBuilder and wraps it using WrapTxBuilder. However, the assertion s.Require().Equal(txBuilder, newTxBldr) is incorrect because txBuilder and newTxBldr are two different instances of TxBuilder. The assertion should compare the relevant fields of both builders to ensure they are equal after wrapping.

- s.Require().Equal(txBuilder, newTxBldr)
+ // Ensure that the relevant fields of txBuilder and newTxBldr are equal
+ s.Require().Equal(txBuilder.GetTx(), newTxBldr.GetTx())

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
tx := txBuilder.GetTx()
newTxBldr, err := s.TxConfig.WrapTxBuilder(tx)
s.Require().NoError(err)
txBuilder.SetFeePayer(tx.FeePayer()) // NOTE: fee payer will be populated even if empty.
tx := txBuilder.GetTx()
newTxBldr, err := s.TxConfig.WrapTxBuilder(tx)
s.Require().NoError(err)
txBuilder.SetFeePayer(tx.FeePayer()) // NOTE: fee payer will be populated even if empty.
// Ensure that the relevant fields of txBuilder and newTxBldr are equal
s.Require().Equal(txBuilder.GetTx(), newTxBldr.GetTx())

x/auth/tx/builder.go Outdated Show resolved Hide resolved
x/auth/tx/builder.go Outdated Show resolved Hide resolved
@testinginprod
Copy link
Contributor Author

image

@github-actions github-actions bot added the C:CLI label Jan 24, 2024
@github-actions github-actions bot added the C:x/genutil genutil module issues label Jan 24, 2024
@facundomedica
Copy link
Member

LGTM, there are some tests to fix

@@ -982,6 +982,7 @@ func (s *CLITestSuite) TestSignWithMultiSignersAminoJSON() {
}

func (s *CLITestSuite) TestAuxSigner() {
s.T().Skip("re-enable this when we bring back sign mode aux client testing")
Copy link
Member

Choose a reason for hiding this comment

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

?

Copy link
Member

Choose a reason for hiding this comment

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

what's rationale for disabling this test?

Copy link
Member

Choose a reason for hiding this comment

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

It was left out of scope for this PR and was removed from the builder. This needs to be added to client/v2, just created an issue: #19433.
cc: @testinginprod

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

Configuration used: .coderabbit.yml

Commits Files that changed from the base of the PR and between e0fda8e and 2227e7d.
Files selected for processing (5)
  • baseapp/abci_test.go (1 hunks)
  • baseapp/utils_test.go (2 hunks)
  • x/auth/go.mod (1 hunks)
  • x/auth/go.sum (1 hunks)
  • x/auth/tx/builder.go (2 hunks)
Files skipped from review due to trivial changes (1)
  • baseapp/abci_test.go
Additional comments: 4
x/auth/go.mod (1)
  • 169-169: Ensure the relative path replacements for cosmossdk.io/api and other cosmossdk.io modules are correctly pointing to the intended local directories. This change impacts how modules are resolved and can affect build and dependency resolution.
baseapp/utils_test.go (2)
  • 355-355: Ensure the hardcoded Signer value in setFailOnHandler function is appropriate for the test scenarios it's used in. Hardcoding addresses in tests can be acceptable but verify it aligns with the test's intent.
  • 371-373: Verify the hardcoded Signer value in wonkyMsg function is intended for the specific test cases. Using hardcoded values in tests is common, but it's important to ensure they match the testing requirements.
x/auth/go.sum (1)
  • 1-5: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [1-1000]

Confirmed the removal of cosmossdk.io/api module version v0.7.3-0.20231113122742-912390d5fc4a and its associated go.mod entry as mentioned in the summary. No other unexpected changes related to this action were found in the go.sum file.

Comment on lines +94 to +97
func (w *builder) GetTx() authsign.Tx {
buildTx, err := w.getTx()
if err != nil {
return err
}

if len(sigs) != len(signers) {
return errorsmod.Wrapf(
sdkerrors.ErrUnauthorized,
"wrong number of signers; expected %d, got %d", len(signers), len(sigs),
)
panic(err)
Copy link
Contributor

Choose a reason for hiding this comment

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

Replace panic with proper error handling in GetTx method to avoid potential runtime crashes.

- panic(err)
+ return nil, err

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
func (w *builder) GetTx() authsign.Tx {
buildTx, err := w.getTx()
if err != nil {
return err
}
if len(sigs) != len(signers) {
return errorsmod.Wrapf(
sdkerrors.ErrUnauthorized,
"wrong number of signers; expected %d, got %d", len(signers), len(sigs),
)
panic(err)
func (w *builder) GetTx() authsign.Tx {
buildTx, err := w.getTx()
if err != nil {
return nil, err

func (w *wrapper) SetSignatures(signatures ...signing.SignatureV2) error {
func (w *builder) SetFeeGranter(feeGranter sdk.AccAddress) { w.granter = feeGranter }

func (w *builder) SetSignatures(signatures ...signing.SignatureV2) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

Review the complexity of SetSignatures method for potential refactoring opportunities to improve readability and maintainability.

func (w *wrapper) setSignatures(sigs [][]byte) {
w.tx.Signatures = sigs
}
func (w *builder) AddAuxSignerData(data tx.AuxSignerData) error { return fmt.Errorf("not supported") }
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider adding a TODO comment for future implementation or decision regarding the AddAuxSignerData method.

+ // TODO: Implement AddAuxSignerData functionality or remove if not planned

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
func (w *builder) AddAuxSignerData(data tx.AuxSignerData) error { return fmt.Errorf("not supported") }
// TODO: Implement AddAuxSignerData functionality or remove if not planned
func (w *builder) AddAuxSignerData(data tx.AuxSignerData) error { return fmt.Errorf("not supported") }

@tac0turtle
Copy link
Member

closes #17530

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.yml

Commits Files that changed from the base of the PR and between 2227e7d and 6bbcdcd.
Files selected for processing (1)
  • x/auth/tx/config/depinject.go (3 hunks)
Additional comments: 2
x/auth/tx/config/depinject.go (2)
  • 7-7: The import of github.com/cosmos/gogoproto/proto has been added. This change aligns with the PR's objective to modernize the authentication and transaction module by utilizing new types and methods introduced in v1beta1. Ensure that this new import is utilized effectively in the codebase, particularly in the context of the changes made to ProvideProtoRegistry.
  • 64-64: The return value in ProvideProtoRegistry has been changed to gogoproto.HybridResolver. This modification is crucial for the refactoring effort, as it indicates a shift towards using a hybrid resolver for proto file resolution, which is likely part of the broader effort to align with v1beta1 standards. It's important to verify that this change integrates well with the rest of the system, especially in terms of how proto files are resolved throughout the application. Given the context of the PR, this change seems appropriate, but it's essential to ensure that all downstream dependencies that rely on ProvideProtoRegistry are compatible with this new return value.

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

Configuration used: .coderabbit.yml

Commits Files that changed from the base of the PR and between 6bbcdcd and 9fed787.
Files selected for processing (6)
  • x/auth/go.mod (1 hunks)
  • x/auth/go.sum (1 hunks)
  • x/slashing/go.mod (1 hunks)
  • x/slashing/go.sum (1 hunks)
  • x/tx/go.mod (1 hunks)
  • x/tx/go.sum (1 hunks)
Files skipped from review due to trivial changes (1)
  • x/tx/go.sum
Files skipped from review as they are similar to previous changes (1)
  • x/auth/go.sum
Additional comments: 1
x/slashing/go.sum (1)
  • 1-1: The removal of the cosmossdk.io/api module version v0.7.3-0.20231113122742-912390d5fc4a from the go.sum file indicates that this specific version is no longer required by the project. It's important to ensure that this change is intentional and that all necessary dependencies are correctly specified in the go.mod file. Running go mod tidy can help verify that the project's dependencies are properly managed and consistent.

@@ -34,3 +34,5 @@ require (
google.golang.org/grpc v1.61.1 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)

replace cosmossdk.io/api => ../../api
Copy link
Contributor

Choose a reason for hiding this comment

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

The addition of the replace directive for cosmossdk.io/api to point to ../../api is a significant change. This directive overrides the module's source location, which can be particularly useful for local development or when working with forked versions of a module. However, it's crucial to ensure that this change aligns with the project's dependency management strategy and that the relative path ../../api correctly points to the intended module location within the project's structure. If this change is meant to be temporary or only for development purposes, consider documenting this context either within the go.mod file itself or in relevant project documentation to avoid confusion.

@@ -167,6 +167,7 @@ replace github.com/cosmos/cosmos-sdk => ../../.

// TODO remove post spinning out all modules
replace (
cosmossdk.io/api => ../../api
Copy link
Contributor

Choose a reason for hiding this comment

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

The replace directives in this go.mod file significantly alter the source locations for various cosmossdk.io modules, pointing them to local paths within the project. This approach is beneficial for local development or when making coordinated changes across multiple modules. However, it's essential to verify that these local paths (../../api, ../../core, ../../depinject, ../accounts, ../bank, ../staking, ../tx) accurately reflect the project's directory structure and that these changes are aligned with the project's overall dependency management strategy. If these directives are intended for temporary or development-specific purposes, documenting their intended use can help maintain clarity and prevent potential issues in dependency resolution for other developers or in production environments.

@@ -168,6 +168,7 @@ replace github.com/cosmos/cosmos-sdk => ../../.

// TODO remove post spinning out all modules
replace (
cosmossdk.io/api => ../../api
Copy link
Contributor

Choose a reason for hiding this comment

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

The replace directives in the x/slashing module's go.mod file, similar to those in the x/tx and x/auth modules, redirect the source locations for various cosmossdk.io modules to local paths. This pattern indicates a structured approach to managing dependencies across these modules, likely to facilitate local development or coordinated updates. As with the other modules, it's critical to ensure that these local paths (../../api, ../../core, ../../depinject, ../accounts, ../auth, ../bank, ../staking, ../tx) are accurate and reflect the intended structure of the project. Additionally, documenting the purpose and scope of these directives can help maintain clarity and prevent confusion during development or when integrating changes into broader environments.

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.yml

Commits Files that changed from the base of the PR and between 9fed787 and d725e5f.
Files selected for processing (2)
  • x/tx/go.mod (2 hunks)
  • x/tx/go.sum (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • x/tx/go.mod
Additional comments: 2
x/tx/go.sum (2)
  • 1-4: The addition of new dependencies from buf.build for cosmos/gogo-proto and tendermint/tendermint protocol buffers is noted. Ensure these versions are compatible with the project's requirements and check for any potential security vulnerabilities in these versions.
  • 1-4: Confirm the removal of cosmossdk.io/api module version v0.7.2 was intentional and assess if it impacts other parts of the project. This change should be aligned with the PR's objectives and not inadvertently affect functionality.

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.yml

Commits Files that changed from the base of the PR and between d725e5f and fb47eac.
Files selected for processing (5)
  • tests/go.mod (1 hunks)
  • x/auth/go.mod (2 hunks)
  • x/auth/go.sum (1 hunks)
  • x/slashing/go.mod (2 hunks)
  • x/slashing/go.sum (1 hunks)
Files skipped from review as they are similar to previous changes (3)
  • x/auth/go.sum
  • x/slashing/go.mod
  • x/slashing/go.sum
Additional comments: 2
x/auth/go.mod (1)
  • 172-172: The replace directives in this go.mod file significantly alter the source locations for various cosmossdk.io modules, pointing them to local paths within the project. This approach is beneficial for local development or when making coordinated changes across multiple modules. However, it's essential to verify that these local paths (../../api, ../../core, ../../depinject, ../accounts, ../bank, ../staking, ../tx) accurately reflect the project's directory structure and that these changes are aligned with the project's overall dependency management strategy. If these directives are intended for temporary or development-specific purposes, documenting their intended use can help maintain clarity and prevent potential issues in dependency resolution for other developers or in production environments.
tests/go.mod (1)
  • 10-10: The addition of cosmossdk.io/errors v1.0.1 // indirect in the tests/go.mod file indicates an update in the dependencies that indirectly affects this module. It's good practice to keep dependencies up-to-date for security and functionality improvements. However, ensure that this update does not introduce breaking changes or incompatibilities with the current test suite. It might be beneficial to verify through additional testing or review of the errors module's changelog for significant changes.

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.yml

Commits Files that changed from the base of the PR and between fb47eac and 4c0d6c7.
Files selected for processing (2)
  • baseapp/abci_utils_test.go (5 hunks)
  • x/tx/signing/textual/e2e_test.go (1 hunks)
Additional comments: 4
baseapp/abci_utils_test.go (4)
  • 472-480: The updated transaction size assertions reflect changes in the transaction encoding or structure. Ensure these new sizes are accurately calculated based on the current transaction encoding scheme to prevent flaky tests.

Consider adding a comment or documentation on how these sizes were determined for future reference and maintenance.

  • 493-493: The MaxTxBytes value in the test case "skip same-sender non-sequential sequence and then add others txs" is set to the sum of the sizes of the first and fourth transactions. Ensure this value aligns with the intended test scenario, especially considering the transaction overhead and the mempool's behavior.
Verification successful

The output from the executed scripts provides insight into the test case "skip same-sender non-sequential sequence and then add others txs" and various settings of MaxTxBytes in different test scenarios within baseapp/abci_utils_test.go. Specifically, for the test case in question, MaxTxBytes is set to the sum of 180 + 181, which matches the description in the review comment. Other test cases show different values for MaxTxBytes, indicating that this parameter is adjusted based on the specific requirements of each test scenario.

However, the output does not explicitly detail the rationale behind the specific sum of 180 + 181 for MaxTxBytes, nor does it provide information on transaction sizes or overhead considerations directly. The values seem to be tailored to the test scenarios, possibly to test the mempool's behavior under different conditions, but without further context or explanation in the output, the intention behind the exact value of MaxTxBytes in the highlighted test case remains inferred from the setup.

Given the information provided, the review comment's concern about ensuring the MaxTxBytes value aligns with the intended test scenario, especially considering transaction overhead and the mempool's behavior, is valid. However, without explicit details on the calculation or considerations behind the specific value, the verification process cannot conclusively determine the correctness of the MaxTxBytes setting beyond its intentional use in the test setup.

Based on the available context, the review comment is upheld as it correctly identifies a point of interest regarding the MaxTxBytes setting in the test scenario. The verification process confirms the setting as described but cannot fully ascertain the rationale without further context.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify the calculation of MaxTxBytes in relation to transaction overhead and mempool behavior.

Length of output: 0



Script:

#!/bin/bash
# Inspect the test case "skip same-sender non-sequential sequence and then add others txs" for details on transaction sizes and overhead considerations
grep -C 5 "skip same-sender non-sequential sequence and then add others txs" baseapp/abci_utils_test.go
# Look for any documentation or comments related to MaxTxBytes calculation in the test file
grep -i "MaxTxBytes" baseapp/abci_utils_test.go -A 3 -B 3

Length of output: 2099

* 501-501: Similar to the previous comment, verify that the `MaxTxBytes` value in the test case "skip multi-signers msg non-sequential sequence" accurately reflects the intended test conditions, taking into account transaction sizes and mempool selection logic.
Verification successful

Given the lack of output from the previous script and the need to verify the MaxTxBytes value in multi-signer scenarios, let's attempt a more targeted approach to gather the necessary information. We'll search the codebase for references to MaxTxBytes in the context of multi-signer transactions, including documentation, comments, or other test cases that might shed light on how MaxTxBytes should be calculated or adjusted for such scenarios.


The search results indicate that MaxTxBytes is consistently used across various test cases and is an important factor in transaction selection logic, including for multi-signer scenarios. The specific value of MaxTxBytes in the test case "skip multi-signers msg non-sequential sequence" (263 + 264) is likely chosen based on the sizes of the transactions involved and the intended test conditions, reflecting a calculated decision to test the mempool's behavior under specific conditions. Without direct evidence to question the justification of this value, it can be concluded that the MaxTxBytes value accurately reflects the intended test conditions, taking into account transaction sizes and mempool selection logic.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Further investigation into the calculation of MaxTxBytes for multi-signer scenarios.

Length of output: 0



Script:

#!/bin/bash
# Search for references to MaxTxBytes in the context of multi-signer transactions.

# Look for comments or documentation related to MaxTxBytes and multi-signer transactions.
rg "MaxTxBytes" -C 5

# Search for test cases involving multi-signer transactions that might reference MaxTxBytes.
rg "multi-signer" -C 5

Length of output: 18825

* 510-510: For the test case "only the first tx is added," ensure that the `MaxTxBytes` value is set with a clear understanding of how it influences the selection of transactions in the mempool, particularly in scenarios with sequential and non-sequential transactions.
Verification successful

Given the lack of output from the initial script and the need to understand how MaxTxBytes influences transaction selection in sequential and non-sequential scenarios, we will generate new shell scripts to search for relevant documentation, comments, and code. This will help us verify the impact of MaxTxBytes on transaction selection.


The output from the shell scripts provides insight into how MaxTxBytes influences transaction selection in the context of the test cases within baseapp/abci_utils_test.go. The test cases demonstrate various scenarios where MaxTxBytes is set to different values, affecting the number of transactions that can be included in a proposal. For example, setting MaxTxBytes to a small value results in fewer or no transactions being added, while larger values allow more transactions to be included. This directly correlates with the original review comment's concern about understanding the impact of MaxTxBytes on transaction selection, especially in scenarios with sequential and non-sequential transactions.

The test case "only the first tx is added" specifically sets MaxTxBytes to 263 + 264, indicating a calculated approach to determining the maximum size of transactions that can be included. This, along with the other test cases, shows a clear understanding of how MaxTxBytes influences the selection of transactions in the mempool, aligning with the intent of the review comment to ensure that MaxTxBytes is set with a clear understanding of its impact.

Given the detailed test cases and the explicit handling of MaxTxBytes in both sequential and non-sequential transaction scenarios, it can be concluded that the code demonstrates a clear understanding of how MaxTxBytes influences transaction selection in the mempool.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Examine the impact of MaxTxBytes on transaction selection in sequential and non-sequential scenarios.

Length of output: 0



Script:

#!/bin/bash
# Search for documentation or comments related to MaxTxBytes and its impact on transaction selection.
rg "MaxTxBytes" -C 3

# Examine the test cases in baseapp/abci_utils_test.go for usage of MaxTxBytes
rg "MaxTxBytes" baseapp/abci_utils_test.go -C 10

# Look into the mempool implementation or related logic that handles MaxTxBytes
rg "mempool" -C 3 | grep "MaxTxBytes" -C 3

Length of output: 14112

Comment on lines +74 to +77
decodeWant, err := hex.DecodeString(tc.Cbor)
require.NoError(t, err)
t.Log("got: " + string(signDoc))
t.Log("want " + string(decodeWant))
Copy link
Contributor

Choose a reason for hiding this comment

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

The addition of decoding tc.Cbor using hex.DecodeString, logging the signDoc and decodeWant, and comparing tc.Cbor with hex.EncodeToString(signDoc) enhances the test's clarity and debuggability. However, consider adding error handling for the hex.EncodeToString(signDoc) call to ensure robustness.

+ encodedSignDoc := hex.EncodeToString(signDoc)
+ require.NoError(t, err)
+ require.Equal(t, tc.Cbor, encodedSignDoc)

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
decodeWant, err := hex.DecodeString(tc.Cbor)
require.NoError(t, err)
t.Log("got: " + string(signDoc))
t.Log("want " + string(decodeWant))
decodeWant, err := hex.DecodeString(tc.Cbor)
require.NoError(t, err)
t.Log("got: " + string(signDoc))
t.Log("want " + string(decodeWant))
encodedSignDoc := hex.EncodeToString(signDoc)
require.NoError(t, err)
require.Equal(t, tc.Cbor, encodedSignDoc)

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.yml

Commits Files that changed from the base of the PR and between 4c0d6c7 and fe91f3a.
Files selected for processing (1)
  • tests/e2e/auth/suite.go (1 hunks)
Files skipped from review due to trivial changes (1)
  • tests/e2e/auth/suite.go

Copy link
Member

@kocubinski kocubinski left a comment

Choose a reason for hiding this comment

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

Nice code clean up and refactor of some ugly parts of x/auth/tx, and migrating more core code paths into x/tx. Great work!

@facundomedica facundomedica added this pull request to the merge queue Feb 21, 2024
Merged via the queue into main with commit e846eca Feb 21, 2024
61 of 63 checks passed
@facundomedica facundomedica deleted the tip/auth/use_x_tx branch February 21, 2024 09:37
julienrbrt added a commit that referenced this pull request Feb 22, 2024
@julienrbrt julienrbrt mentioned this pull request Feb 22, 2024
16 tasks
github-merge-queue bot pushed a commit that referenced this pull request Feb 22, 2024
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.

5 participants