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!: turn MsgsV2 into ReflectMessages to make it less confusing #19839

Merged
merged 24 commits into from
May 16, 2024

Conversation

aaronc
Copy link
Member

@aaronc aaronc commented Mar 22, 2024

Description

This is an alternative to #19817 that rather than just removing stuff, names things more clearly removing any mention of V2 and instead distinguishing a "reflected" version of the message from the actual version.

For instance, it's probably confusing when there is GetMsgs and GetMsgsV2 - which one am I supposed to use? Naively, you'd think v2 is better, but that's not really right.

Now, GetMsgsV2 is GetReflectMessages which returns protoreflect.Message not protov2.Message and the documentation clearly states that GetMsgs returns the actual messages and GetReflectMessages is just for performing some dynamic read operations (like get signers) on those messages. Hopefully this is clearer and obviates the need to do some of the less efficient stuff in #19817.


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

  • New Features

    • Introduced GetReflectMessages method for enhanced message handling.
  • Refactor

    • Replaced GetMsgV1Signers and GetMsgV2Signers with GetMsgSigners and GetReflectMsgSigners for improved consistency in message signer retrieval.
  • Chores

    • Updated method signatures and imports to align with new protobuf reflection standards.

Copy link
Contributor

coderabbitai bot commented Mar 22, 2024

Walkthrough

Walkthrough

The changes aim to standardize message signer retrieval methods to GetMsgSigners and GetReflectMsgSigners, updating function signatures and imports for compatibility with protoreflect.Message. These modifications enhance message handling efficiency and support protobuf reflection across various packages.

Changes

File Path Change Summary
x/accounts/keeper.go Added imports for gogoproto and protoreflect; introduced new interfaces and modified method signatures in the Keeper struct.
x/authz/keeper/keeper.go Replaced GetMsgV1Signers with GetMsgSigners in DispatchActions.
x/gov/keeper/proposal.go Updated SubmitProposal to use GetMsgSigners instead of GetMsgV1Signers.
x/group/keeper/proposal_executor.go Changed method call to use GetMsgSigners in ensureMsgAuthZ within doExecuteMsgs.
CHANGELOG.md Noted changes from Tx.GetMsgsV2 to Tx.GetReflectMessages, and GetMsgV1Signers to GetMsgSigners.
baseapp/baseapp.go Adjusted imports and function signatures to use protoreflect.Message instead of protov2.Message.
codec/proto_codec_test.go Replaced GetMsgV1Signers and GetMsgV2Signers with unified methods for message signers.
types/tx_msg.go Replaced GetMsgsV2 with GetReflectMessages in Tx interface, returning []protoreflect.Message.
x/accounts/defaults/multisig/utils_test.go Updated return type and method names in utils_test.go.
x/accounts/utils_test.go Introduced mockSigner type with GetMsgSigners method; removed Balance method in bankQueryServer.

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.

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

@aaronc aaronc marked this pull request as ready for review March 22, 2024 20:00
@aaronc aaronc requested a review from a team as a code owner March 22, 2024 20:00
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 ac61b69 and 79fa103.
Files selected for processing (12)
  • baseapp/baseapp.go (5 hunks)
  • codec/codec.go (2 hunks)
  • codec/proto_codec.go (2 hunks)
  • go.mod (1 hunks)
  • server/mock/tx.go (2 hunks)
  • types/mempool/mempool_test.go (3 hunks)
  • types/mempool/signer_extraction_adapater_test.go (2 hunks)
  • types/tx/types.go (3 hunks)
  • types/tx_msg.go (2 hunks)
  • x/auth/go.mod (1 hunks)
  • x/auth/tx/gogotx.go (2 hunks)
  • x/tx/decode/decode.go (2 hunks)
Additional comments: 20
x/tx/decode/decode.go (2)
  • 18-18: The update to use []protoreflect.Message in the DecodedTx struct aligns with the PR's objectives to transition to protoreflect for message handling. This change is consistent and appropriate.
  • 101-108: The logic for appending protoreflect.Message instances to msgs and extracting signers is correctly implemented. Ensure that all message types used in the application are compatible with this new approach to avoid runtime errors.
server/mock/tx.go (1)
  • 107-108: The implementation of GetReflectMessages in the KVStoreTx struct correctly returns a slice of protoreflect.Message, which is a mock for testing purposes. This aligns with the PR's objectives. Ensure that the comment about this being a hack for tests is addressed or clarified if this is intended to be a permanent solution.

Consider adding a detailed comment explaining why this approach is chosen and if it's intended to be temporary or permanent.

types/tx_msg.go (1)
  • 55-61: The transition from GetMsgsV2 to GetReflectMessages in the Tx interface, returning []protoreflect.Message, is consistent with the PR's objectives. This change enhances clarity and aligns with the use of protoreflect for dynamic read operations.
codec/codec.go (3)
  • 27-30: The update to GetMsgAnySigners to return protoreflect.Message is consistent with the PR's objectives. This change enhances the use of reflection and aligns with the transition to protoreflect.
  • 32-36: The method GetMsgSigners correctly transitions to returning protoreflect.Message, facilitating the use of reflection in context where needed. This change is appropriate and aligns with the refactor's goals.
  • 38-39: The introduction of GetReflectMsgSigners is a clear and direct approach to obtaining signers from a protoreflect.Message. This method simplifies the interface for cases where the message is already in the reflected form.
types/tx/types.go (1)
  • 97-114: > 📝 NOTE

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

The update to the GetSigners function to include protoreflect.Message in its return values aligns with the PR's objectives, facilitating the use of reflection for dynamic operations. Ensure that all message types used are compatible with this approach to avoid runtime issues.

x/auth/go.mod (1)
  • 177-177: The addition of the replace directive for cosmossdk.io/x/tx is appropriate for local development and testing. Ensure that this directive is intended for temporary use and is planned to be removed before merging into a production branch.

Consider documenting the temporary nature of this replace directive to avoid confusion.

x/auth/tx/gogotx.go (2)
  • 9-9: The import of protoreflect is correctly added to support the new GetReflectMessages functionality.
  • 120-120: The implementation of GetReflectMessages correctly aligns with the PR's objectives to utilize protoreflect.Message. Ensure that w.decodedTx.Messages is of the correct type and consider consistent error handling across the codebase.
go.mod (1)
  • 190-190: The addition of the replace directive for cosmossdk.io/x/tx is noted. Please ensure its intention is clear and document its purpose if it's meant to be temporary or for local development.
codec/proto_codec.go (3)
  • 299-305: > 📝 NOTE

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

The update to GetMsgAnySigners to return protoreflect.Message aligns with the refactor's goals. Ensure that the returned types and error handling are consistent across the codebase.

  • 315-316: The implementation of GetReflectMsgSigners correctly utilizes protoreflect.Message, aligning with the refactor's objectives. Ensure that error handling and the use of pc.interfaceRegistry.SigningContext() are consistent with the codebase's standards.
  • 319-322: The update to GetMsgSigners to return protoreflect.Message and handle both proto.Message and gogoproto.Message types aligns with the refactor's goals. Ensure that the handling of different message types and error handling are consistent and clear across the codebase.
baseapp/baseapp.go (5)
  • 18-18: The import of protoreflect aligns with the PR's objective to transition from protov2 to protoreflect for message handling. This change is necessary for the new functionality.
  • 942-944: The introduction of GetReflectMessages method in the transaction processing aligns with the PR's objective. However, it's crucial to ensure that all transactions processed through runTx are compatible with this new method. Additionally, consider adding error handling for scenarios where GetReflectMessages might fail due to the transaction not implementing the required interface.
  • 990-990: The addition of reflectMsgs as a parameter to runMsgs is a significant change that supports the transition to using protoreflect. Ensure that all calls to runMsgs throughout the codebase have been updated to include this new parameter.
  • 1012-1012: Creating events based on protoreflect.Message instances is a key part of the refactor. It's important to ensure that the event creation process correctly handles the dynamic nature of protoreflect.Message and that the events generated are consistent with the application's requirements.
  • 1063-1063: The use of GetReflectMsgSigners to dynamically retrieve signers from messages is a critical part of leveraging protoreflect for dynamic operations. Ensure that this method robustly handles various message types and correctly interprets the signer information.
Verification successful

Given the lack of results from the initial ast-grep command, let's attempt a different approach to verify the implementation of GetReflectMsgSigners. We'll use rg (ripgrep) to search for the function definition and any relevant implementation details that could indicate how it handles various message types.


The search using rg successfully located the GetReflectMsgSigners function within codec/proto_codec.go. The function takes a protoreflect.Message as an argument and returns a slice of byte slices ([][]byte) and an error. It delegates the task of retrieving signers to pc.interfaceRegistry.SigningContext().GetSigners(msg.Interface()), indicating that the actual logic for handling various message types and extracting signers is encapsulated within the GetSigners method of the SigningContext obtained from the interfaceRegistry.

This implementation suggests that GetReflectMsgSigners is designed to work with a variety of message types by leveraging the interfaceRegistry and its SigningContext. However, without further details on the GetSigners method and the SigningContext, it's not possible to fully verify the robust handling of various message types directly from this snippet alone.

Given the information available, the implementation of GetReflectMsgSigners appears to be consistent with the expectation of dynamically retrieving signers from messages using protoreflect. The method's reliance on the interfaceRegistry's SigningContext to abstract the details of signer extraction suggests a design that could accommodate various message types, assuming the SigningContext and GetSigners method are appropriately implemented.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify the implementation of GetReflectMsgSigners to ensure it handles various message types correctly.
ast-grep --lang go --pattern $'func ($_ codec.Codec) GetReflectMsgSigners($_ protoreflect.Message) ([]sdk.AccAddress, error) { $$$ }'

Length of output: 134



Script:

#!/bin/bash
# Use rg to search for the GetReflectMsgSigners function and its implementation details
rg "func .*GetReflectMsgSigners.*protoreflect.Message" -A 10

Length of output: 779

@@ -20,7 +20,7 @@ func (n nonVerifiableTx) GetMsgs() []sdk.Msg {
panic("not implemented")
}

func (n nonVerifiableTx) GetMsgsV2() ([]proto.Message, error) {
func (n nonVerifiableTx) GetReflectMessages() ([]protoreflect.Message, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

The method GetReflectMessages is correctly updated to return []protoreflect.Message, aligning with the PR's objectives. However, it's essential to ensure that the panic statement is only a placeholder and that actual implementation or tests are planned.

Would you like assistance in implementing the actual logic for GetReflectMessages or creating meaningful tests for this method?


func (tx testTx) GetMsgs() []sdk.Msg { return nil }

func (tx testTx) GetMsgsV2() ([]protov2.Message, error) { return nil, nil }
func (tx testTx) GetReflectMsgs() ([]protoreflect.Message, error) { return nil, 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 addition of the GetReflectMsgs method in the testTx struct, returning nil, nil, is a placeholder for tests. Ensure that actual tests for this method are implemented to verify its functionality.

Would you like assistance in creating tests for the GetReflectMsgs method?

@@ -93,7 +94,7 @@

func (sigErrTx) GetMsgs() []sdk.Msg { return nil }

func (sigErrTx) GetMsgsV2() ([]protov2.Message, error) { return nil, nil }
func (sigErrTx) GetReflectMessages() ([]protoreflect.Message, error) { return nil, nil }
Copy link
Contributor

Choose a reason for hiding this comment

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

Similarly, the GetReflectMessages method in the sigErrTx struct returns nil, nil as a placeholder. It's important to implement tests that verify the functionality of this method.

Would you like assistance in creating tests for the GetReflectMessages method?

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 79fa103 and 640032d.
Files selected for processing (1)
  • codec/proto_codec_test.go (2 hunks)
Additional comments: 3
codec/proto_codec_test.go (3)
  • 194-197: The use of protov2.Equal for comparing messages is appropriate here, ensuring that the messages are equal in terms of their serialized content. However, it's important to ensure that msgSendV2Copy is correctly obtained from msgSendV1 through the cdc.GetMsgSigners function, as this involves a type conversion that should be carefully handled to avoid runtime errors.

Ensure that the conversion process in cdc.GetMsgSigners correctly handles different message types and preserves all necessary information for an accurate comparison.

  • 199-199: Renaming GetMsgV2Signers to GetReflectMsgSigners aligns with the PR's objective to make function names more descriptive and intuitive. This change should help clarify the use of reflection in obtaining message signers. Ensure that all references to the old function name are updated across the codebase to prevent any broken dependencies.
  • 208-208: The comparison using protov2.Equal after retrieving signers from a types.Any message is consistent with the earlier comparison. This consistency is good for maintainability. Again, ensure that the conversion and retrieval logic in cdc.GetMsgAnySigners is robust and error-free.

Double-check the implementation of cdc.GetMsgAnySigners to confirm that it correctly handles the conversion and retrieval of message signers, especially when dealing with different message types.

@kocubinski kocubinski self-assigned this Mar 23, 2024
@github-actions github-actions bot removed the C:x/tx label Mar 24, 2024
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 640032d and 52f4031.
Files selected for processing (2)
  • x/auth/tx/builder.go (1 hunks)
  • x/auth/tx/gogotx.go (5 hunks)
Additional comments: 5
x/auth/tx/gogotx.go (4)
  • 9-9: The import of "google.golang.org/protobuf/reflect/protoreflect" is correctly added to support the new GetReflectMessages function. Ensure that all references to protoreflect are used appropriately throughout the file.
  • 34-34: The reference to decodeMsgsV1 suggests that the function GetMsgsV1 might have been replaced or its functionality altered. Since GetMsgsV1 is not directly shown in the provided code, ensure that its replacement or modification aligns with the PR objectives of enhancing clarity and efficiency in message handling.
  • 77-82: The implementation of GetReflectMessages using protoreflect.Message is aligned with the PR objectives. However, ensure that the loop correctly iterates over decodedTx.Messages and that each message's ProtoReflect method is appropriately called without errors.
  • 129-130: The GetReflectMessages function correctly returns the slice of protoreflect.Message. This change is consistent with the PR's goal of improving message handling. Ensure that error handling is considered if any operations within this function could potentially fail in future enhancements.
x/auth/tx/builder.go (1)
  • 59-59: The update to assign decoded.msgs to the msgs field in the newBuilderFromDecodedTx function aligns with the PR objectives of enhancing message handling. Ensure that the decoded.msgs field is correctly populated and represents the intended message format after the refactor.

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 52f4031 and 3aed41a.
Files selected for processing (1)
  • CHANGELOG.md (1 hunks)

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 3aed41a and 75e481d.
Files selected for processing (15)
  • baseapp/baseapp.go (5 hunks)
  • server/mock/tx.go (2 hunks)
  • store/database.go (1 hunks)
  • store/internal/encoding/changeset_test.go (1 hunks)
  • store/storage/pebbledb/batch.go (1 hunks)
  • store/storage/pebbledb/db.go (2 hunks)
  • store/storage/sqlite/batch.go (1 hunks)
  • store/storage/sqlite/db_test.go (1 hunks)
  • types/mempool/mempool_test.go (3 hunks)
  • x/accounts/keeper.go (3 hunks)
  • x/accounts/utils_test.go (2 hunks)
  • x/auth/tx/gogotx.go (5 hunks)
  • x/authz/keeper/keeper.go (1 hunks)
  • x/gov/keeper/proposal.go (1 hunks)
  • x/group/keeper/proposal_executor.go (1 hunks)
Files skipped from review due to trivial changes (2)
  • store/internal/encoding/changeset_test.go
  • store/storage/sqlite/db_test.go
Files skipped from review as they are similar to previous changes (4)
  • baseapp/baseapp.go
  • server/mock/tx.go
  • types/mempool/mempool_test.go
  • x/auth/tx/gogotx.go
Additional comments: 15
store/storage/pebbledb/batch.go (2)
  • 60-60: The change to consolidate storeKey and key into a single storeKey parameter in the Set method simplifies the method signature. Ensure that the b.set method correctly handles the consolidated storeKey.
  • 64-64: The change to consolidate storeKey and key into a single storeKey parameter in the Delete method simplifies the method signature. Ensure that the b.set method correctly handles the consolidated storeKey when marking an entry as deleted.
store/storage/sqlite/batch.go (2)
  • 65-65: The change to accept multiple byte slices in the Set method enhances flexibility. Verify the overall logic and performance implications of this change.
  • 71-71: The change to accept multiple byte slices in the Delete method enhances flexibility. Verify the overall logic and performance implications of this change.
x/group/keeper/proposal_executor.go (1)
  • 59-59: The change from GetMsgV1Signers to GetMsgSigners aligns with the PR's objectives to enhance clarity in message handling. Ensure that the GetMsgSigners method is correctly implemented and used throughout the codebase.
x/accounts/utils_test.go (1)
  • 70-70: The change to use protoreflect.Message in the GetMsgV1Signers function signature aligns with the PR's objectives to transition to protoreflect for message handling. Ensure compatibility of protoreflect.Message with the rest of the codebase.
store/database.go (3)
  • 21-21: The consolidation of storeKey and key into a single parameter in the Get method of the Reader interface simplifies the method signature. Ensure that the implementation of the Get method correctly handles the consolidated parameter.
  • 29-29: The consolidation of storeKey and key into a single parameter in the Set method of the Writer interface simplifies the method signature. Ensure that the implementation of the Set method correctly handles the consolidated parameter.
  • 34-34: The consolidation of storeKey and key into a single parameter in the Delete method of the Writer interface simplifies the method signature. Ensure that the implementation of the Delete method correctly handles the consolidated parameter.
x/gov/keeper/proposal.go (1)
  • 73-73: The change from GetMsgV1Signers to GetMsgSigners aligns with the PR's objectives to enhance clarity in message handling. Ensure that the GetMsgSigners method is correctly implemented and used throughout the codebase.
store/storage/pebbledb/db.go (2)
  • 322-322: The separation of storeKey and key into separate parameters in the prependStoreKey function enhances clarity and maintainability. Ensure compatibility of this change with the rest of the codebase.
  • 365-365: The separation of storeKey and key into separate parameters in the getMVCCSlice function enhances clarity and maintainability. Ensure that the implementation of the getMVCCSlice function correctly handles the separated parameters.
x/authz/keeper/keeper.go (1)
  • 95-95: The change from GetMsgV1Signers to GetMsgSigners aligns with the PR's objectives to enhance clarity in message handling. Ensure that the GetMsgSigners method is correctly implemented and used throughout the codebase.
x/accounts/keeper.go (2)
  • 12-12: The import of protoreflect aligns with the PR's objective to transition from protov2 to protoreflect for message handling. This change is necessary for the new functionality and does not appear to introduce any issues.
  • 366-366: The call to GetMsgSigners within sendModuleMessage correctly handles the updated method signature. This usage demonstrates proper integration of the changes with existing code. However, ensure that the error handling and the logic for checking the sender's authorization are thoroughly tested, especially since the method signature change could affect how messages and signers are processed.
Verification successful

The provided context confirms that the sendModuleMessage function correctly uses GetMsgSigners, including proper error handling and sender authorization checks. This aligns with the expectations set in the original review comment, ensuring that the changes integrate well with the existing code and adhere to best practices.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify thorough testing of GetMsgSigners usage in sendModuleMessage, focusing on error handling and sender authorization.
rg --type go -C 5 'GetMsgSigners' | grep 'sendModuleMessage'

Length of output: 300



Script:

#!/bin/bash
# Inspect the sendModuleMessage function in x/accounts/keeper.go for the usage of GetMsgSigners and its error handling.
rg --type go -C 10 'func \(k Keeper\) sendModuleMessage' x/accounts/keeper.go

Length of output: 1696

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.

LGTM, I find the new API usage more sensible and clear.

Copy link
Member

@julienrbrt julienrbrt left a comment

Choose a reason for hiding this comment

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

lgtm!

@@ -53,7 +53,7 @@ type MsgRouter interface {
// SignerProvider defines an interface used to get the expected sender from a message.
type SignerProvider interface {
// GetMsgV1Signers returns the signers of the message.
Copy link
Member

Choose a reason for hiding this comment

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

nit go doc

@github-actions github-actions bot removed the C:Store label May 9, 2024
@tac0turtle tac0turtle enabled auto-merge May 9, 2024 11:46
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 782d649 and 2390f58.
Files selected for processing (3)
  • CHANGELOG.md (1 hunks)
  • baseapp/baseapp.go (5 hunks)
  • codec/proto_codec_test.go (2 hunks)
Additional Context Used
Path-based Instructions (3)
codec/proto_codec_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"

baseapp/baseapp.go (1)

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

CHANGELOG.md (1)

Pattern **/*.md: "Assess the documentation for misspellings, grammatical errors, missing documentation and correctness"

Additional comments not posted (5)
codec/proto_codec_test.go (1)

Line range hint 194-208: Ensure consistent use of protoreflect in GetReflectMsgSigners.

Verification successful

The review comment's concern about ensuring the consistent use of protoreflect in GetReflectMsgSigners across the codebase has been verified. All instances of GetReflectMsgSigners correctly use protoreflect.Message as per the new expected usage. Here are the relevant files and lines:

  • codec/proto_codec_test.go: Usage with msgSendV2.ProtoReflect()
  • baseapp/baseapp.go: Usage with reflectMsg
  • x/accounts/defaults/multisig/utils_test.go: Mock implementation using protoreflect.Message
  • codec/proto_codec.go: Function definition
  • codec/codec.go: Interface declaration
Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that `GetReflectMsgSigners` is consistently used with `protoreflect` across the codebase.

# Test: Search for the function usage. Expect: Only occurrences of the new signature.
rg --type go $'GetReflectMsgSigners'

Length of output: 624

baseapp/baseapp.go (2)

Line range hint 952-1022: Ensure that runMsgs properly integrates protoreflect for message handling.

Verification successful

The verification process confirms that the runMsgs function in baseapp.go properly integrates protoreflect for message handling. The function signature includes protoreflect.Message, and references across the codebase maintain consistency with this integration. No issues were found regarding the use of an outdated function signature or incorrect integration.

  • File: baseapp/baseapp.go
  • Function: runMsgs
Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that `runMsgs` is properly integrating `protoreflect` for message handling across the codebase.

# Test: Search for the function usage. Expect: Only occurrences of the new signature.
rg --type go $'runMsgs'

Length of output: 1308


1068-1073: Check the implementation of createEvents for correct handling of protoreflect messages.

Verification successful

The implementation of the createEvents function in handling protoreflect messages has been verified across the codebase. The function is consistently used with the correct signature as shown in the provided snippet. There are no discrepancies or multiple versions of the function, ensuring uniformity and correctness in its application.

  • Location Verified: baseapp/baseapp.go
Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that `createEvents` is correctly handling `protoreflect` messages across the codebase.

# Test: Search for the function usage. Expect: Only occurrences of the new signature.
rg --type go $'createEvents'

Length of output: 273

CHANGELOG.md (2)

178-179: Adjust the indentation of the unordered list items to maintain consistency and readability in the document.

-    * Every module has the codec already, passing it created an unneeded dependency.
-    * Additionally, to reflect this change, the module manager does not take a codec either.
+  * Every module has the codec already, passing it created an unneeded dependency.
+  * Additionally, to reflect this change, the module manager does not take a codec either.

181-181: Correct the typographical error in the description to enhance clarity.

- These API changes clear up confusin as to the use and purpose of these methods.
+ These API changes clear up confusion as to the use and purpose of these methods.

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

Review Details

Configuration used: .coderabbit.yml
Review profile: CHILL

Commits Files that changed from the base of the PR and between 2390f58 and 3013237.
Files selected for processing (1)
  • x/accounts/keeper.go (4 hunks)
Additional Context Used
Path-based Instructions (1)
x/accounts/keeper.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/accounts/keeper.go (1)

349-349: Ensure that the codec implementation correctly handles protoreflect.Message in GetMsgSigners calls.

Also applies to: 372-372

// SignerProvider defines an interface used to get the expected sender from a message.
type SignerProvider interface {
// GetMsgSigners returns the signers of the message.
GetMsgSigners(msg gogoproto.Message) ([][]byte, protoreflect.Message, error)
Copy link
Contributor

Choose a reason for hiding this comment

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

Tip

Codebase Verification

The verification process has revealed that there are still occurrences in the codebase where the old gogoproto.Message is being used in the GetMsgSigners method within test files. Specifically, the files x/accounts/utils_test.go and x/accounts/defaults/multisig/utils_test.go have not been updated to use protoreflect.Message. This needs to be addressed to ensure consistency with the changes made in the main codebase.

  • x/accounts/utils_test.go: The GetMsgSigners method in the mockSigner struct still uses gogoproto.Message.
  • x/accounts/defaults/multisig/utils_test.go: The GetMsgSigners method in the mockStateCodec struct also still uses gogoproto.Message.
Analysis chain

The change from gogoproto.Message to protoreflect.Message in GetMsgSigners aligns with the PR's objectives. Ensure all related test files are updated to reflect this change.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that all test files have been updated to use `protoreflect.Message` in `GetMsgSigners`.

# Test: Search for old usage of `gogoproto.Message` in test files. Expect: No occurrences.
rg --type go 'GetMsgSigners' | grep '_test.go' | grep 'gogoproto.Message'

Length of output: 337

@tac0turtle tac0turtle disabled auto-merge May 15, 2024 21:52
@tac0turtle
Copy link
Member

tac0turtle commented May 15, 2024

I'll pick this up tomorrow.

@aaronc
Copy link
Member Author

aaronc commented May 15, 2024

Vini? Sorry I noticed there's a lint error just haven't gotten a chance to fix yet

@tac0turtle
Copy link
Member

Vini? Sorry I noticed there's a lint error just haven't gotten a chance to fix yet

Sorry wasn't meant for here. The lint error has been annoying.

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

Review Details

Configuration used: .coderabbit.yml
Review profile: CHILL

Commits Files that changed from the base of the PR and between 3013237 and 2fbab1c.
Files selected for processing (6)
  • CHANGELOG.md (1 hunks)
  • baseapp/baseapp.go (5 hunks)
  • types/tx_msg.go (2 hunks)
  • x/accounts/defaults/multisig/utils_test.go (1 hunks)
  • x/accounts/utils_test.go (2 hunks)
  • x/authz/keeper/keeper.go (1 hunks)
Files not reviewed due to errors (1)
  • x/authz/keeper/keeper.go (no review received)
Files skipped from review as they are similar to previous changes (1)
  • baseapp/baseapp.go
Additional Context Used
GitHub Check Runs (1)
dependency-review failure (2)

types/tx_msg.go: [failure] 8-8:
"github.com/cosmos/gogoproto/proto" imported and not used

Path-based Instructions (5)
x/accounts/utils_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"

types/tx_msg.go (1)

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

x/accounts/defaults/multisig/utils_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/authz/keeper/keeper.go (1)

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

CHANGELOG.md (1)

Pattern **/*.md: "Assess the documentation for misspellings, grammatical errors, missing documentation and correctness"

Additional comments not posted (6)
x/accounts/utils_test.go (2)

9-9: The import of protoreflect is appropriate for the new mockSigner type.


91-100: The mockSigner type and its GetMsgSigners method are correctly implemented.

types/tx_msg.go (2)

9-9: The import of protoreflect is appropriate for the new GetReflectMessages method.


57-63: The GetReflectMessages method is well-documented and aligns with the purpose of providing dynamic read operations on messages.

x/accounts/defaults/multisig/utils_test.go (2)

Line range hint 9-9: The import of protoreflect is appropriate for the new GetReflectMsgSigners method.


49-49: The GetReflectMsgSigners method is correctly implemented and aligns with the interface requirements.

CHANGELOG.md Outdated Show resolved Hide resolved
types/tx_msg.go Outdated Show resolved Hide resolved
tac0turtle and others added 2 commits May 16, 2024 07:36
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
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 2fbab1c and c0a3b06.
Files selected for processing (1)
  • types/tx_msg.go (2 hunks)
Files skipped from review as they are similar to previous changes (1)
  • types/tx_msg.go

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

Review Details

Configuration used: .coderabbit.yml
Review profile: CHILL

Commits Files that changed from the base of the PR and between c0a3b06 and e31f02a.
Files selected for processing (4)
  • CHANGELOG.md (1 hunks)
  • types/tx_msg.go (2 hunks)
  • x/accounts/keeper.go (2 hunks)
  • x/accounts/utils_test.go (1 hunks)
Files skipped from review as they are similar to previous changes (3)
  • types/tx_msg.go
  • x/accounts/keeper.go
  • x/accounts/utils_test.go
Additional Context Used
Path-based Instructions (1)
CHANGELOG.md (1)

Pattern **/*.md: "Assess the documentation for misspellings, grammatical errors, missing documentation and correctness"

Comment on lines 181 to 182
* Every module has the codec already, passing it created an unneeded dependency.
* Additionally, to reflect this change, the module manager does not take a codec either.
Copy link
Contributor

Choose a reason for hiding this comment

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

Adjust the indentation of the unordered list items to maintain consistency and readability in the document.

-    * Every module has the codec already, passing it created an unneeded dependency.
-    * Additionally, to reflect this change, the module manager does not take a codec either.
+  * Every module has the codec already, passing it created an unneeded dependency.
+  * Additionally, to reflect this change, the module manager does not take a codec either.

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
* Every module has the codec already, passing it created an unneeded dependency.
* Additionally, to reflect this change, the module manager does not take a codec either.
* Every module has the codec already, passing it created an unneeded dependency.
* Additionally, to reflect this change, the module manager does not take a codec either.

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 e31f02a and 1258d41.
Files selected for processing (1)
  • types/tx_msg.go (2 hunks)
Files skipped from review as they are similar to previous changes (1)
  • types/tx_msg.go

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 1258d41 and 6d5bd87.
Files selected for processing (5)
  • x/accounts/keeper.go (2 hunks)
  • x/accounts/utils_test.go (1 hunks)
  • x/authz/keeper/keeper.go (1 hunks)
  • x/gov/keeper/proposal.go (1 hunks)
  • x/group/keeper/proposal_executor.go (1 hunks)
Files skipped from review as they are similar to previous changes (3)
  • x/accounts/keeper.go
  • x/accounts/utils_test.go
  • x/authz/keeper/keeper.go
Additional Context Used
Path-based Instructions (2)
x/group/keeper/proposal_executor.go (1)

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

x/gov/keeper/proposal.go (1)

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

Additional comments not posted (6)
x/group/keeper/proposal_executor.go (2)

Line range hint 1-1: LGTM! The function doExecuteMsgs is correctly implemented with proper error handling and checks.


60-60: LGTM! The function ensureMsgAuthZ is correctly implemented with proper error handling and checks.

x/gov/keeper/proposal.go (4)

Line range hint 1-1: LGTM! The function SubmitProposal is correctly implemented with proper error handling and checks.


Line range hint 1-1: LGTM! The function CancelProposal is correctly implemented with proper error handling and checks.


Line range hint 1-1: LGTM! The function DeleteProposal is correctly implemented with proper error handling and checks.


Line range hint 1-1: LGTM! The function ActivateVotingPeriod is correctly implemented with proper error handling and checks.

@sontrinh16 sontrinh16 added this pull request to the merge queue May 16, 2024
Merged via the queue into main with commit 53925ef May 16, 2024
69 of 70 checks passed
@sontrinh16 sontrinh16 deleted the aaronc/protov2-signers-cleanup branch May 16, 2024 09:59
alpe added a commit that referenced this pull request May 23, 2024
* main: (95 commits)
  fix(x/accounts): check for overflows in multisig weights and votes (#20384)
  docs(x/account/auth): Improve error handling and comments in fee.go (#20426)
  docs: fix some markdown syntax (#20432)
  revert: bank change module to account change (#20427)
  fix: nil pointer panic when store don't exists in historical version (#20425)
  fix(store/v2): Remove should not error on miss (#20423)
  chore: upstream more changes from v2 (#20387)
  docs(x/auth/ante): fixed typo  in TxWithTimeoutHeight interface name (#20418)
  fix: avoid default sendenabled for module accounts (#20419)
  docs(x/auth): fixed typo in command example for multisign transaction (#20417)
  build(deps): Bump bufbuild/buf-setup-action from 1.31.0 to 1.32.0 (#20413)
  build(deps): Bump github.com/hashicorp/go-plugin from 1.6.0 to 1.6.1 in /store (#20414)
  feat(x/accounts): Add schema caching feature and corresponding test case (#20055)
  refactor(runtime/v2): remove dependency on sdk (#20389)
  refactor!: turn MsgsV2 into ReflectMessages to make it less confusing (#19839)
  docs: Enhanced the ParsePagination method documentation (#20385)
  refactor(runtime,core): split router service (#20401)
  chore: fix spelling errors (#20400)
  docs: Documented error handling in OfferSnapshot method (#20380)
  build(deps): Bump google.golang.org/grpc from 1.63.2 to 1.64.0 (#20390)
  ...
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