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

feat(tx): port simappv2 changes #20648

Merged
merged 10 commits into from
Jun 17, 2024
Merged

feat(tx): port simappv2 changes #20648

merged 10 commits into from
Jun 17, 2024

Conversation

testinginprod
Copy link
Contributor

@testinginprod testinginprod commented Jun 12, 2024

Description

This PR ports the x/tx changes from simappv2 PR #20412 .


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

    • Introduced new method GetCometInfo in ConsensusKeeper interface for querying Comet information.
  • Bug Fixes

    • Fixed the transaction decoding to support dynamic and gogoproto message formats.
    • Updated MintBankKeeper interface for better module-to-module coin transfer handling.
  • Tests

    • Added tests for the new GetCometInfo method in MockConsensusKeeper.
    • Updated decoding tests to cover new dynamic and gogoproto message handling.

@testinginprod testinginprod requested a review from a team as a code owner June 12, 2024 17:34
Copy link
Contributor

coderabbitai bot commented Jun 12, 2024

Warning

Rate limit exceeded

@testinginprod has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 17 minutes and 13 seconds before requesting another review.

How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

Commits

Files that changed from the base of the PR and between 4a62515 and 285bd3d.

Walkthrough

The recent updates introduce new functionality and refinements to various components related to transaction decoding and handling within the system. Key changes comprise modifications to the DecodedTx struct and the Decoder struct to support dynamic messages, enhancements to the unit tests with mock codecs, adjustments to method signatures, and the addition of a new GetCometInfo method to the ConsensusKeeper interface.

Changes

File Change Summary
x/tx/decode/decode.go Added new imports, updated DecodedTx and Decoder structs, introduced gogoProtoCodec interface, and modified Decode method.
x/tx/decode_test.go, x/tx/fuzz_test.go Added mockCodec type and related message handling for testing.
simapp/mint_fn.go Updated the SendCoinsFromModuleToModule method signature to separate parameters.
x/auth/tx/gogotx.go Updated newWrapperFromDecodedTx function to use DynamicMessages instead of Messages.
x/auth/tx/config.go Enhanced NewTxConfigWithOptions function to include ProtoCodec field in decoder options.
x/auth/tx/testutil/suite.go Modified logic in TestWrapTxBuilder for comparing byte representations of transactions.
x/auth/ante/expected_keepers.go Added GetCometInfo method to ConsensusKeeper interface.
x/auth/ante/testutil/expected_keepers_mocks.go Updated MockConsensusKeeper struct to mock the GetCometInfo method.

Sequence Diagram(s)


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 Configration 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

@testinginprod your pull request is missing a changelog!

})
require.NoError(t, err)

gogoproto.RegisterType(&bankv1beta1.MsgSend{}, string((&bankv1beta1.MsgSend{}).ProtoReflect().Descriptor().FullName()))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is the test fix to make it work.
the alternative was a really hefty refactor

Copy link
Member

Choose a reason for hiding this comment

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

brilliant 🙌

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 abeb7ee and fa13f6b.

Files selected for processing (3)
  • x/tx/decode/decode.go (6 hunks)
  • x/tx/decode/decode_test.go (4 hunks)
  • x/tx/decode/fuzz_test.go (3 hunks)
Additional context used
Path-based instructions (3)
x/tx/decode/fuzz_test.go (2)

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


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

x/tx/decode/decode_test.go (2)

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


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

x/tx/decode/decode.go (1)

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

Additional comments not posted (10)
x/tx/decode/fuzz_test.go (2)

21-25: The implementation of mockCodec.Unmarshal directly delegates to gogoproto.Unmarshal. This is a straightforward wrapper, ensuring that the mockCodec adheres to the gogoProtoCodec interface. This is a good use of interface abstraction to facilitate testing.


117-117: The instantiation of mockCodec within NewDecoder is correctly done, ensuring that the ProtoCodec field is populated for the decoder. This is crucial for the decoder's functionality as it relies on this codec to unmarshal transaction bytes.

x/tx/decode/decode_test.go (3)

25-29: The mockCodec type and its Unmarshal method are correctly implemented to wrap the gogoproto.Unmarshal function. This encapsulation is essential for isolating the unmarshalling logic, which can be swapped out or mocked in unit tests.


56-56: Proper initialization of mockCodec in NewDecoder ensures that the ProtoCodec field is correctly set, which is vital for the decoding process in the tests.


60-61: Registration of message types using gogoproto.RegisterType is crucial for ensuring that these types are recognized during the decoding process. This setup is necessary for the tests to simulate realistic scenarios where these message types are decoded.

x/tx/decode/decode.go (5)

23-24: The DecodedTx struct now includes DynamicMessages and changes Messages to use gogoproto.Message. This modification supports handling both dynamic and statically known protobuf messages, enhancing the flexibility of the transaction decoding process.


38-40: Definition of the gogoProtoCodec interface with an Unmarshal method is a good practice. It abstracts the unmarshalling process, allowing for different implementations that can be injected into the Decoder, facilitating easier testing and modularity.


45-45: The Decoder struct now includes a codec field of type gogoProtoCodec, and the NewDecoder function validates this field. This is a crucial update ensuring that the decoder is properly configured before use, enhancing robustness and error handling in the decoding process.

Also applies to: 51-51, 59-64


Line range hint 122-172: The Decode method has been significantly updated to handle unmarshalling into both dynamic and gogoproto messages. This update is substantial as it enhances the decoder's capability to handle different types of protobuf messages, thus supporting a broader range of transaction types. The method now also handles error propagation and validation more robustly, improving the reliability and maintainability of the code.


200-200: The GetMessages method in DecodedTx now has a simplified return statement, improving readability and maintainability. This change makes the method's behavior more straightforward to understand.

x/tx/decode/decode.go Dismissed Show dismissed Hide dismissed
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 fa13f6b and 5c00c23.

Files selected for processing (2)
  • simapp/mint_fn.go (1 hunks)
  • x/auth/tx/gogotx.go (1 hunks)
Additional context used
Path-based instructions (2)
simapp/mint_fn.go (1)

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

x/auth/tx/gogotx.go (1)

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

Additional comments not posted (3)
simapp/mint_fn.go (2)

20-20: Refactor SendCoinsFromModuleToModule to use separate parameters for sender and recipient modules enhances clarity and reduces potential for misuse.

Ensure the documentation is updated to reflect these parameter changes.


20-20: Integration of the updated SendCoinsFromModuleToModule method in ProvideExampleMintFn is handled correctly.

x/auth/tx/gogotx.go (1)

77-77: Update to iterate over DynamicMessages aligns with the new DecodedTx structure.

Consider adding error handling for ProtoReflect method calls in case of failure.

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 5c00c23 and 5b53145.

Files selected for processing (1)
  • x/auth/tx/config.go (1 hunks)
Additional context used
Path-based instructions (1)
x/auth/tx/config.go (1)

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

Additional comments not posted (1)
x/auth/tx/config.go (1)

193-197: The implementation of the NewDecoder with the new ProtoCodec option is correctly integrated. Ensure that all dependent configurations are updated accordingly.

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 5b53145 and 029e20c.

Files selected for processing (1)
  • x/auth/tx/testutil/suite.go (1 hunks)
Additional context used
Path-based instructions (1)
x/auth/tx/testutil/suite.go (1)

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

Additional comments not posted (1)
x/auth/tx/testutil/suite.go (1)

325-332: Changes in TestWrapTxBuilder correctly ensure that the byte representations of transactions from different TxBuilder instances are equal. This is essential for verifying the functionality of WrapTxBuilder.

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 029e20c and 2393f2d.

Files selected for processing (2)
  • x/auth/ante/expected_keepers.go (1 hunks)
  • x/auth/ante/testutil/expected_keepers_mocks.go (1 hunks)
Additional context used
Path-based instructions (2)
x/auth/ante/expected_keepers.go (1)

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

x/auth/ante/testutil/expected_keepers_mocks.go (1)

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

Additional comments not posted (2)
x/auth/ante/expected_keepers.go (1)

33-33: The addition of GetCometInfo method to the ConsensusKeeper interface is consistent with the existing interface design and uses appropriate Go conventions.

x/auth/ante/testutil/expected_keepers_mocks.go (1)

198-211: The mock implementation of GetCometInfo in MockConsensusKeeper correctly follows the GoMock standards and accurately reflects the method signature in the ConsensusKeeper interface.

@tac0turtle
Copy link
Member

@testinginprod can you merge main and then we can merge this

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 2393f2d and 4a62515.

Files selected for processing (1)
  • x/auth/ante/testutil/expected_keepers_mocks.go (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • x/auth/ante/testutil/expected_keepers_mocks.go

@testinginprod testinginprod added this pull request to the merge queue Jun 17, 2024
Merged via the queue into main with commit 6d2f6ff Jun 17, 2024
67 checks passed
@testinginprod testinginprod deleted the tip/tx/upstream branch June 17, 2024 09:59
alpe added a commit that referenced this pull request Jun 17, 2024
* main:
  feat(tx): port simappv2 changes (#20648)
  build(deps): Bump github.com/spf13/cobra from 1.8.0 to 1.8.1 (#20682)
  chore(proto): fix comments (#20679)
  (serverv2/cometbft) Commands support both json and yaml output (#20670)
  fix(x/staking,x/auth):  regenerate mock to fix test (#20684)
  docs: ADR 074: Msg v2 (#20618)
  fix: nested multisig signatures using CLI (#20438)
  chore: fix spelling errors (#20674)
  fix: align Dockerfile for build-push-action (#20672)
  fix: avoid build fail when make localnet-build-env (#20671)
  build(deps): Bump bufbuild/buf-setup-action from 1.32.2 to 1.33.0 (#20669)
  chore: make function comment match function names (#20666)
  chore(consensus): add cometInfo to consensus  (#20615)
  chore: fix typos (#20662)
  fix: Properly parse json in the wait-tx command. (#20631)
  fix(sims): check before sending RotateConsPubKey (#20659)
  test(types/address): add unit tests for the file types/address.go  (#20237)
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.

4 participants