Skip to content

test: add test ValidateBasic for FungibleTokenPacketDataV2#6397

Closed
hastur199 wants to merge 62 commits intocosmos:mainfrom
helios-lab:hastur/add-test-validate-basic
Closed

test: add test ValidateBasic for FungibleTokenPacketDataV2#6397
hastur199 wants to merge 62 commits intocosmos:mainfrom
helios-lab:hastur/add-test-validate-basic

Conversation

@hastur199
Copy link
Copy Markdown
Contributor

@hastur199 hastur199 commented May 27, 2024

Description

closes: #6386


Before we can merge this PR, please make sure that all the following items have been
checked off. If any of the checklist items are not applicable, please leave them but
write a little note why.

  • Targeted PR against the correct branch (see CONTRIBUTING.md).
  • Linked to GitHub issue with discussion and accepted design, OR link to spec that describes this work.
  • Code follows the module structure standards and Go style guide.
  • Wrote unit and integration tests.
  • Updated relevant documentation (docs/).
  • Added relevant godoc comments.
  • Provide a conventional commit message to follow the repository standards.
  • Include a descriptive changelog entry when appropriate. This may be left to the discretion of the PR reviewers. (e.g. chores should be omitted from changelog)
  • Re-reviewed Files changed in the GitHub PR explorer.
  • Review SonarCloud Report in the comment section below once CI passes.

Summary by CodeRabbit

  • New Features

    • Introduced support for asynchronous handling of packet acknowledgments.
    • Added forwarding path functionality for multihop transfers, allowing packets to be forwarded to multiple destinations.
    • Enhanced MsgTransfer to include forwarding information.
  • Bug Fixes

    • Improved validation for message transfers and packet data to handle new forwarding path parameters.
  • Tests

    • Updated multiple test cases to include new parameters and validate the new forwarding path functionality.

chatton and others added 30 commits April 8, 2024 13:00
* chore: adding proto files for ics20-v2

* chore: add newline
* add CurrentVersion, EscrowVersion, update tests

* update hardcoded transfer channel version from interchaintest
…6116)

---------

Co-authored-by: Charly <charly@interchain.berlin>
…shalling/conversion (cosmos#6226)

* chore: adding proto files for ics20-v2

* chore: add newline

* chore: modify MsgTransfer to accept coins instead of coin

* chore: reverted unintentional comment changes

* chore: reverted unintentional comment changes

* chore: adding test for conversion fn

* chore: fix e2e linter

* chore: adding docs

* chore: addressing PR feedback

* chore: remove duplicate import

* chore: addressing PR feedback

* chore: moved extration logic into internal package

* chore: commented out failing test

* chore: adding link to issue

* chore: remove duplicate import

* chore: fix linting errors

* FungibleTokenPacketData interface methods + tests

* linter

* wip: token validation

* update trace identifier validation in Token + tests

* rm Printf

* update with pr review

* add CurrentVersion, EscrowVersion, update tests

* pr review

* fix e2e tests

* pr review

* update e2e test version

* linter

* update hardcoded transfer channel version from interchaintest

* update hardcoded transfer channel version from interchaintest

* wip packet unmarshaller

* wip

* wip testing

* update test

* linter

* rm unnecessary version changes

* rm unnecessary artifacts

* update callbacks test

* update comment

* pr review

* rename getMultiDenomFungibleTokenPacketData to unmarshalPacketDataBytesToICS20V2

---------

Co-authored-by: chatton <github.qpeyb@simplelogin.fr>
Co-authored-by: Carlos Rodriguez <carlos@interchain.io>
…allbacks (cosmos#6175)

* add SupportedVersions array for different ics20 versions, add version checking on channel handshake application callbacks

* add tests

* update pr review

* pr review

* last few pr review nits

* linter

* add version counter proposing

* fix missing app versino

* update code + tests to return our proposed version if counterparty version is invalid

* remove if statement

* address review comments: return ics20-2 if counterparty version is not supported

---------

Co-authored-by: Carlos Rodriguez <carlos@interchain.io>
…transfers (cosmos#6252)

* add transfer authz code + tests

* linter

* address review comments

---------

Co-authored-by: Carlos Rodriguez <carlos@interchain.io>
…ks (cosmos#6189)

* chore: adding proto files for ics20-v2

* chore: add newline

* chore: modify MsgTransfer to accept coins instead of coin

* chore: reverted unintentional comment changes

* chore: reverted unintentional comment changes

* chore: adding test for conversion fn

* chore: fix e2e linter

* chore: adding docs

* chore: addressing PR feedback

* chore: remove duplicate import

* chore: addressing PR feedback

* chore: moved extration logic into internal package

* chore: commented out failing test

* chore: adding link to issue

* chore: remove duplicate import

* chore: fix linting errors

* FungibleTokenPacketData interface methods + tests

* linter

* wip: token validation

* update trace identifier validation in Token + tests

* rm Printf

* update with pr review

* pr review

* linter

* rm unused function: linter

* wip pr feedback

* fix test

* pr review

* lintttttt

* wip: backwards compatibility for transfer rpc

* implement changes for ics20-v2 packet data for onRecvPacket, onAcknowledgePacket and onTimeoutPacket

* fix callbacks tests

* lint

---------

Co-authored-by: chatton <github.qpeyb@simplelogin.fr>
Co-authored-by: Charly <charly@interchain.berlin>
crodriguezvega and others added 18 commits May 22, 2024 11:23
* check length of tokens array against maximum allowed

* chore: add note on arbitrary selection

---------

Co-authored-by: Colin Axnér <25233464+colin-axner@users.noreply.github.com>
…#6341)

* api(port)!: Allow passing of context, port and channel identifier to unmarshal packet data interface as disussed.

This allows us to grab the app version in transfer and unmarshal the packet based on that instead of a hacky unmarshal v2 then v1 and whatever happens.

* lint: as we do

* callbacks: fix signature of UnmarshalPacketData as per changes, make refactors to hopefully simplify signatures.

* chore: lint and remove some todos.

* review: address feedback.
* chore: specifically unmarshal v1 or v2 without brute force

* chore: fix TestPacketDataUnmarshalerInterface test in transfer module

* Pass dest values OnRecv, refactor GetExpectedEvents

* chore: fixing TestGetCallbackData test

* chore: fixed remaining tests in callbacks module

* test: simplify callbacks test, revert back to previous behaviour

* chore: fix test case name

* chore: addressing PR feedback

* chore: added docstring for unmarshalPacketDataBytesToICS20V2

---------

Co-authored-by: DimitrisJim <d.f.hilliard@gmail.com>
Co-authored-by: Colin Axnér <25233464+colin-axner@users.noreply.github.com>
* refactor: address various self review comments

* revert: unnecessary change

* lint
* refactor: apply review suggestions

* imp: additional updates

* refactor: make ValidateIBCDenom private

* Update modules/apps/transfer/types/msgs.go

Co-authored-by: Cian Hatton <cian@interchain.io>

* apply review suggestions

---------

Co-authored-by: Cian Hatton <cian@interchain.io>
* chore: move functions from internal/denom to trace.go

* lint

* lint: the comeback
* imp: self review items

* apply jim's suggestion

* Update modules/apps/transfer/keeper/msg_server_test.go

* Update modules/apps/transfer/ibc_module.go

* Update modules/apps/transfer/ibc_module.go
# Conflicts:
#	modules/apps/transfer/keeper/msg_server.go
#	modules/apps/transfer/keeper/relay.go
#	modules/apps/transfer/keeper/relay_test.go
#	modules/apps/transfer/types/keys.go
#	modules/apps/transfer/types/msgs_test.go
#	modules/apps/transfer/types/v3/packet.go
#	modules/apps/transfer/types/v3/packet.pb.go
#	modules/apps/transfer/types/v3/packet_test.go
#	modules/apps/transfer/types/v3/token_test.go
#	proto/ibc/applications/transfer/v3/packet.proto
# Conflicts:
#	e2e/tests/transfer/authz_test.go
#	e2e/tests/transfer/incentivized_test.go
#	e2e/tests/transfer/upgrades_test.go
#	e2e/tests/upgrades/upgrade_test.go
#	e2e/testsuite/tx.go
#	modules/apps/27-interchain-accounts/host/keeper/relay_test.go
#	modules/apps/29-fee/transfer_test.go
#	modules/apps/callbacks/ibc_middleware_test.go
#	modules/apps/callbacks/types/types_test.go
#	modules/apps/transfer/client/cli/tx.go
#	modules/apps/transfer/internal/convert/convert.go
#	modules/apps/transfer/internal/convert/convert_test.go
#	modules/apps/transfer/keeper/mbt_relay_test.go
#	modules/apps/transfer/keeper/msg_server.go
#	modules/apps/transfer/keeper/msg_server_test.go
#	modules/apps/transfer/keeper/relay.go
#	modules/apps/transfer/keeper/relay_test.go
#	modules/apps/transfer/transfer_test.go
#	modules/apps/transfer/types/keys.go
#	modules/apps/transfer/types/msgs.go
#	modules/apps/transfer/types/msgs_test.go
#	modules/apps/transfer/types/packet.go
#	modules/apps/transfer/types/packet.pb.go
#	modules/apps/transfer/types/packet_test.go
#	modules/apps/transfer/types/token_test.go
#	modules/apps/transfer/types/transfer_authorization_test.go
#	modules/apps/transfer/types/tx.pb.go
#	proto/ibc/applications/transfer/v1/tx.proto
#	proto/ibc/applications/transfer/v2/packet.proto
#	testing/solomachine.go
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented May 27, 2024

Walkthrough

Walkthrough

The changes primarily involve adding a nil parameter to various function calls across multiple test files. This addition aligns with the new parameter requirements of the NewMsgTransfer function. Additionally, new fields and logic for handling packet forwarding paths in interchain transfers have been introduced, including updates to protobuf definitions and validation checks.

Changes

Files/Modules Change Summary
e2e/tests/transfer/authz_test.go, e2e/tests/transfer/incentivized_test.go, e2e/tests/transfer/upgrades_test.go, e2e/tests/upgrades/upgrade_test.go, e2e/testsuite/tx.go, modules/apps/29-fee/keeper/events_test.go, modules/apps/29-fee/transfer_test.go, modules/apps/callbacks/ibc_middleware_test.go, modules/apps/callbacks/replay_test.go, modules/apps/callbacks/transfer_test.go, testing/solomachine.go Added a nil parameter to function calls where NewMsgTransfer is used.
modules/apps/27-interchain-accounts/host/keeper/relay_test.go Added nil in a function call, modified token field to tokens, added memo and forwarding_path fields in a JSON object, and added a comment indicating a test failure.
modules/apps/transfer/client/cli/tx.go Modified NewMsgTransfer function call by adding an additional nil argument.
modules/apps/transfer/ibc_module.go Introduced asynchronous handling of packet acknowledgment based on im.keeper.OnRecvPacket.
modules/apps/transfer/internal/convert/convert.go Added the ForwardingPath field with a nil value in PacketDataV1ToV2 function.
modules/apps/transfer/internal/convert/convert_test.go Added an additional nil argument to function calls in TestConvertPacketV1ToPacketV2.
modules/apps/transfer/keeper/keeper.go Imported channeltypes and added SetForwardedPacket and GetForwardedPacket functions.
modules/apps/transfer/keeper/mbt_relay_test.go Adjusted FungibleTokenPacketFromTla function, added a nil parameter, and introduced a new variable async.
modules/apps/transfer/keeper/msg_server.go Added msg.ForwardingPath parameter to the sendTransfer function call.
modules/apps/transfer/keeper/msg_server_test.go Added a nil parameter in multiple function calls within TestMsgTransfer.
modules/apps/transfer/keeper/relay.go Added imports for errors and time, modified function signatures, added forwarding logic, and updated packet handling.
modules/apps/transfer/keeper/relay_test.go Added an additional parameter nil to types.NewMsgTransfer function calls.
modules/apps/transfer/transfer_test.go Added an additional argument nil to NewMsgTransfer function calls.
modules/apps/transfer/types/keys.go Introduced new key constants and functions for handling forward addresses and packet forwarding keys.
modules/apps/transfer/types/msgs.go Updated NewMsgTransfer to include a new parameter forwardingPath.
modules/apps/transfer/types/msgs_test.go Added an additional parameter nil to NewMsgTransfer function calls.
modules/apps/transfer/types/packet.go Updated NewFungibleTokenPacketDataV2 to include forwardingPath and added validation for conflicts between memo and forwardingPath.
modules/apps/transfer/types/packet_test.go Added a nil argument in various function calls for packet data validation and testing.
modules/apps/transfer/types/token_test.go Added a nil argument in function calls within TestGetFullDenomPath.
modules/apps/transfer/types/transfer_authorization_test.go Added a nil argument in a function call within TestTransferAuthorizationAccept.
proto/ibc/applications/transfer/v1/transfer.proto Introduced ForwardingInfo and Hop message types for packet forwarding.
proto/ibc/applications/transfer/v1/tx.proto Added optional forwarding information field to MsgTransfer and updated MsgUpdateParamsResponse.
proto/ibc/applications/transfer/v2/packet.proto Added forwarding_path field to FungibleTokenPacketDataV2 message.

Sequence Diagram(s) (Beta)

sequenceDiagram
    participant User
    participant CLI
    participant TransferModule
    participant Keeper
    participant Channel

    User->>CLI: Initiate Transfer
    CLI->>TransferModule: Create NewMsgTransfer with forwardingPath
    TransferModule->>Keeper: sendTransfer with forwardingPath
    Keeper->>Channel: OnRecvPacket with forwardingPath
    Channel->>Keeper: Acknowledgment
    Keeper->>TransferModule: Handle Acknowledgment
    TransferModule->>User: Transfer Complete
Loading

Assessment against linked issues

Objective Addressed Explanation
Add test when ValidateBasic of FungibleTokenPacketDataV2 fails if both Memo and ForwardingPath with hops are set (#6386)

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

@mergify
Copy link
Copy Markdown
Contributor

mergify bot commented May 27, 2024

⚠️ The sha of the head commit of this PR conflicts with #6398. Mergify cannot evaluate rules on this PR. ⚠️

Copy link
Copy Markdown
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: 16

Outside diff range and nitpick comments (9)
modules/apps/transfer/types/msgs.go (1)

[!TIP]
Codebase Verification

The script output indicates that several instances of NewMsgTransfer do not include the forwardingPath parameter. This confirms that not all calls to the function have been updated to handle the new parameter.

  • Files with missing forwardingPath parameter:
    • modules/apps/transfer/types/msgs_test.go
    • modules/apps/transfer/keeper/relay_test.go
    • modules/apps/29-fee/transfer_test.go
    • e2e/tests/upgrades/upgrade_test.go
    • e2e/tests/transfer/incentivized_test.go

Please update these instances to include the forwardingPath parameter to ensure consistency with the new function signature.

Analysis chain

Line range hint 52-63: The updated NewMsgTransfer function now accepts a forwardingPath parameter, which is crucial for the new multihop transfer feature. This change is well-implemented and aligns with the modifications in other parts of the codebase. Ensure that all calls to this function across the codebase are updated to handle this new parameter.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify all function calls to `NewMsgTransfer` include the new `forwardingPath` parameter.

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

Length of output: 10850



Script:

#!/bin/bash
# Description: Verify all function calls to `NewMsgTransfer` include the new `forwardingPath` parameter.

# List of files to check
files=(
    "testing/solomachine.go"
    "modules/apps/callbacks/replay_test.go"
    "modules/apps/callbacks/ibc_middleware_test.go"
    "modules/apps/transfer/transfer_test.go"
    "modules/apps/callbacks/transfer_test.go"
    "modules/apps/transfer/types/transfer_authorization_test.go"
    "modules/apps/transfer/types/msgs_test.go"
    "modules/apps/transfer/client/cli/tx.go"
    "modules/apps/transfer/keeper/msg_server_test.go"
    "modules/apps/transfer/keeper/relay_test.go"
    "modules/apps/transfer/keeper/mbt_relay_test.go"
    "modules/apps/transfer/keeper/invariants_test.go"
    "modules/apps/27-interchain-accounts/host/keeper/relay_test.go"
    "modules/apps/29-fee/transfer_test.go"
    "modules/apps/29-fee/keeper/events_test.go"
    "e2e/testsuite/tx.go"
    "e2e/tests/upgrades/upgrade_test.go"
    "e2e/tests/transfer/incentivized_test.go"
    "e2e/tests/transfer/upgrades_test.go"
    "e2e/tests/transfer/authz_test.go"
)

# Check each file for the correct usage of NewMsgTransfer
for file in "${files[@]}"; do
    echo "Checking $file"
    rg 'NewMsgTransfer\([^,]+,[^,]+,[^,]+,[^,]+,[^,]+,[^,]+,[^,]+,[^,]+,[^,]+,[^,]+\)' "$file"
done

Length of output: 8239

e2e/tests/transfer/incentivized_test.go (2)

201-201: Ensure the test case description is updated to reflect the scenario being tested.

Consider adding a more descriptive comment before the test case to explain that it specifically tests the scenario where an invalid receiver address is used, and the expected behavior in such cases.


326-326: Clarify the test scenario in the comment.

It would be beneficial to add a comment here explaining that this test case is simulating a scenario where multiple messages (a transfer and a fee payment) are sent in a single transaction by a single sender. This helps in understanding the purpose and expected outcome of the test.

modules/apps/27-interchain-accounts/host/keeper/relay_test.go (1)

914-914: Clarify the reason for test failure in the comment or improve error handling to provide more specific feedback.

Consider enhancing the comment to explain why the test might fail here, or adjust the test setup to handle errors more gracefully.

modules/apps/transfer/keeper/relay_test.go (5)

Line range hint 132-150: Consider adding a test case for the new ForwardingPath parameter.

It seems that the ForwardingPath parameter is not being tested in the TestSendTransfer function. Would you like me to help by adding a test case to ensure that the forwarding functionality behaves as expected?


Line range hint 392-431: Refactor to simplify the TestOnRecvPacket function.

The TestOnRecvPacket function is quite complex and handles many scenarios. Consider breaking it down into smaller, more focused test functions to improve readability and maintainability.


454-506: Add validation for ForwardingPath in TestPathForwarding.

The TestPathForwarding function could benefit from additional validation checks for the ForwardingPath to ensure that it is set up and utilized correctly throughout the test.


Line range hint 693-1226: Consider using table-driven tests in TestOnAcknowledgementPacket.

The TestOnAcknowledgementPacket function could be refactored to use table-driven tests, which would make it easier to add new test cases and maintain existing ones.


1228-1326: Improve documentation for TestSimplifiedHappyPathForwarding.

The TestSimplifiedHappyPathForwarding function could benefit from more detailed documentation explaining the test setup and expected outcomes, which would help future maintainers understand the test's purpose and design.

Review Details

Configuration used: .coderabbit.yml
Review profile: CHILL

Commits Files that changed from the base of the PR and between bce3e9e and 2ab3430.
Files ignored due to path filters (3)
  • modules/apps/transfer/types/packet.pb.go is excluded by !**/*.pb.go, !**/*.pb.go
  • modules/apps/transfer/types/transfer.pb.go is excluded by !**/*.pb.go, !**/*.pb.go
  • modules/apps/transfer/types/tx.pb.go is excluded by !**/*.pb.go, !**/*.pb.go
Files selected for processing (34)
  • e2e/tests/transfer/authz_test.go (4 hunks)
  • e2e/tests/transfer/incentivized_test.go (2 hunks)
  • e2e/tests/transfer/upgrades_test.go (1 hunks)
  • e2e/tests/upgrades/upgrade_test.go (1 hunks)
  • e2e/testsuite/tx.go (1 hunks)
  • modules/apps/27-interchain-accounts/host/keeper/relay_test.go (4 hunks)
  • modules/apps/29-fee/keeper/events_test.go (1 hunks)
  • modules/apps/29-fee/transfer_test.go (2 hunks)
  • modules/apps/callbacks/ibc_middleware_test.go (6 hunks)
  • modules/apps/callbacks/replay_test.go (1 hunks)
  • modules/apps/callbacks/transfer_test.go (2 hunks)
  • modules/apps/transfer/client/cli/tx.go (1 hunks)
  • modules/apps/transfer/ibc_module.go (1 hunks)
  • modules/apps/transfer/internal/convert/convert.go (1 hunks)
  • modules/apps/transfer/internal/convert/convert_test.go (7 hunks)
  • modules/apps/transfer/keeper/invariants_test.go (1 hunks)
  • modules/apps/transfer/keeper/keeper.go (2 hunks)
  • modules/apps/transfer/keeper/mbt_relay_test.go (3 hunks)
  • modules/apps/transfer/keeper/msg_server.go (1 hunks)
  • modules/apps/transfer/keeper/msg_server_test.go (4 hunks)
  • modules/apps/transfer/keeper/relay.go (10 hunks)
  • modules/apps/transfer/keeper/relay_test.go (16 hunks)
  • modules/apps/transfer/transfer_test.go (3 hunks)
  • modules/apps/transfer/types/keys.go (3 hunks)
  • modules/apps/transfer/types/msgs.go (2 hunks)
  • modules/apps/transfer/types/msgs_test.go (2 hunks)
  • modules/apps/transfer/types/packet.go (2 hunks)
  • modules/apps/transfer/types/packet_test.go (22 hunks)
  • modules/apps/transfer/types/token_test.go (2 hunks)
  • modules/apps/transfer/types/transfer_authorization_test.go (2 hunks)
  • proto/ibc/applications/transfer/v1/transfer.proto (1 hunks)
  • proto/ibc/applications/transfer/v1/tx.proto (2 hunks)
  • proto/ibc/applications/transfer/v2/packet.proto (2 hunks)
  • testing/solomachine.go (1 hunks)
Files skipped from review due to trivial changes (2)
  • modules/apps/29-fee/keeper/events_test.go
  • modules/apps/transfer/types/transfer_authorization_test.go
Additional Context Used
Path-based Instructions (29)
modules/apps/transfer/internal/convert/convert.go (1)

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

modules/apps/transfer/keeper/invariants_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"

modules/apps/transfer/keeper/msg_server.go (1)

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

modules/apps/transfer/internal/convert/convert_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"

modules/apps/transfer/types/keys.go (1)

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

modules/apps/transfer/client/cli/tx.go (1)

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

modules/apps/transfer/types/msgs.go (1)

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

modules/apps/transfer/types/token_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"

modules/apps/transfer/types/packet.go (1)

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

modules/apps/transfer/transfer_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"

modules/apps/29-fee/transfer_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"

modules/apps/callbacks/transfer_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"

modules/apps/transfer/types/msgs_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"

modules/apps/transfer/keeper/msg_server_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"

modules/apps/transfer/keeper/keeper.go (1)

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

e2e/tests/transfer/authz_test.go (3)

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


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


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

modules/apps/transfer/keeper/mbt_relay_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"

modules/apps/callbacks/replay_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"

modules/apps/transfer/ibc_module.go (1)

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

e2e/testsuite/tx.go (2)

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


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

modules/apps/transfer/types/packet_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"

e2e/tests/transfer/upgrades_test.go (3)

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


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


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

modules/apps/transfer/keeper/relay.go (1)

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

testing/solomachine.go (1)

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

e2e/tests/transfer/incentivized_test.go (3)

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


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


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

modules/apps/27-interchain-accounts/host/keeper/relay_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"

modules/apps/callbacks/ibc_middleware_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"

e2e/tests/upgrades/upgrade_test.go (3)

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


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


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

modules/apps/transfer/keeper/relay_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"

Additional comments not posted (60)
proto/ibc/applications/transfer/v1/transfer.proto (1)

30-36: The addition of ForwardingInfo and Hop messages aligns well with the requirements for supporting multihop transfer scenarios. The structure and naming conventions are consistent with existing protobuf definitions.

Also applies to: 38-43

modules/apps/transfer/internal/convert/convert.go (1)

24-27: The handling of the ForwardingPath by setting it to nil during the V1 to V2 conversion is appropriate given the context. This ensures that the new field does not carry over inappropriate data.

proto/ibc/applications/transfer/v2/packet.proto (1)

38-39: The addition of the ForwardingInfo field to the FungibleTokenPacketDataV2 message is well-implemented and supports the new multihop transfer functionality as intended.

modules/apps/transfer/keeper/invariants_test.go (1)

54-54: Correctly passing a nil value for the ForwardingPath in the test message aligns with the expected behavior in scenarios where no forwarding is involved.

modules/apps/transfer/keeper/msg_server.go (1)

51-51: The integration of the ForwardingPath into the sendTransfer function call is correctly implemented, supporting the new forwarding functionality.

proto/ibc/applications/transfer/v1/tx.proto (1)

54-55: The addition of the ForwardingInfo field to the MsgTransfer message is well-implemented and supports the new packet forwarding functionality as intended.

modules/apps/transfer/types/keys.go (1)

32-33: The addition of new keys for handling escrow and forwarding addresses is consistent with the enhancements to support multihop transfers. The implementation of GetForwardAddress follows the established pattern used in GetEscrowAddress, which is good for consistency. However, ensure that the new forwardAddressVersion is well-documented and understood across different modules that might interact with these addresses.

Also applies to: 37-37, 54-54, 84-95

modules/apps/transfer/types/packet.go (1)

Line range hint 105-146: The implementation of NewFungibleTokenPacketDataV2 and its ValidateBasic method in FungibleTokenPacketDataV2 correctly handles the new ForwardingPath field. The validation logic that ensures the Memo and ForwardingPath are not both set is crucial and aligns with the PR objectives. This is a key enhancement for handling packet forwarding in multihop scenarios.

modules/apps/transfer/types/msgs_test.go (2)

99-99: The GetMsgV1Signers function test is well-implemented. It correctly tests the retrieval of signers from a MsgTransfer instance.


59-79: The test cases for MsgTransfer validation are comprehensive and cover a wide range of scenarios. However, it's important to ensure that the ForwardingPath parameter is considered in these tests if it affects the validation logic, given the changes in the function signature.

Verification successful

The ForwardingPath parameter does not affect the validation logic in MsgTransfer as it is not referenced in the ValidateBasic method. Therefore, the current test cases are comprehensive and do not need to include scenarios for ForwardingPath.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify if the `ForwardingPath` parameter affects the validation logic in MsgTransfer.

# Test: Search for validation logic handling `ForwardingPath`. Expect: Handling logic if it affects validation.
rg --type go $'ValidateBasic' -- 'modules/apps/transfer/types/msgs.go'

Length of output: 364



Script:

#!/bin/bash
# Extract the implementation of the ValidateBasic method for MsgTransfer and search for any references to ForwardingPath.

# Extract the ValidateBasic method for MsgTransfer
ast-grep --lang go --pattern $'func (msg MsgTransfer) ValidateBasic() error {
  $$$
}' modules/apps/transfer/types/msgs.go

# Search for references to ForwardingPath within the ValidateBasic method
rg 'ForwardingPath' modules/apps/transfer/types/msgs.go

Length of output: 3462

modules/apps/transfer/keeper/keeper.go (1)

315-326: Good use of error handling for packet retrieval.

e2e/tests/transfer/authz_test.go (4)

190-190: Similar to the previous comment, the forwardingPath is set to nil. This should be verified against the test's requirements to ensure it's appropriate for the scenario being tested.

Verification successful

Setting forwardingPath to nil in the test scenario appears to be intentional and appropriate, as evidenced by multiple instances in the codebase where this is done in similar test contexts.

  • modules/apps/29-fee/transfer_test.go
  • modules/apps/transfer/transfer_test.go
  • modules/apps/transfer/keeper/relay_test.go
  • modules/apps/transfer/types/msgs_test.go
  • e2e/testsuite/tx.go
  • e2e/tests/upgrades/upgrade_test.go
  • e2e/tests/transfer/incentivized_test.go
  • e2e/tests/transfer/upgrades_test.go
Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that the forwardingPath is intentionally set to nil in this context.
# Test: Search for the function usage with nil forwardingPath. Expect: Only occurances where it's intentional.
rg --type go $'NewMsgTransfer.*nil'

Length of output: 8047


333-333: Once more, forwardingPath is set to nil. This repetition across different tests suggests a pattern that should be explicitly justified in the context of the PR's objectives.


130-130: The forwardingPath parameter is set to nil in the NewMsgTransfer call. Ensure this is intentional and aligns with the test's objectives, especially since the PR focuses on testing the ValidateBasic function under conditions where both Memo and ForwardingPath are set.

Verification successful

The forwardingPath parameter being set to nil in the NewMsgTransfer call appears to be intentional and aligns with the test's objectives. This is evidenced by multiple instances in the codebase where NewMsgTransfer is called with nil as the forwardingPath parameter, particularly in test files.

  • modules/apps/29-fee/transfer_test.go
  • modules/apps/transfer/transfer_test.go
  • modules/apps/transfer/keeper/relay_test.go
  • modules/apps/transfer/types/msgs_test.go
  • e2e/testsuite/tx.go
  • e2e/tests/transfer/upgrades_test.go
  • e2e/tests/transfer/incentivized_test.go
  • e2e/tests/upgrades/upgrade_test.go
Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that the forwardingPath is intentionally set to nil in this context.
# Test: Search for the function usage with nil forwardingPath. Expect: Only occurances where it's intentional.
rg --type go $'NewMsgTransfer.*nil'

Length of output: 8047


273-273: Again, forwardingPath is set to nil in the NewMsgTransfer call. Given the focus on forwardingPath in the PR, it's crucial to ensure this is consistent with the intended test scenarios.

Verification successful

The search results show that the NewMsgTransfer function is frequently called with nil as the forwardingPath argument across various test files. This pattern suggests that setting forwardingPath to nil is intentional and consistent with the test scenarios.

  • modules/apps/transfer/transfer_test.go: Multiple instances where NewMsgTransfer is called with nil for forwardingPath.
  • modules/apps/transfer/types/msgs_test.go: Various test cases use nil for forwardingPath.
  • modules/apps/transfer/keeper/relay_test.go: Instances of NewMsgTransfer with nil for forwardingPath.
  • modules/apps/29-fee/transfer_test.go: NewMsgTransfer calls with nil for forwardingPath.
  • e2e/testsuite/tx.go: NewMsgTransfer with nil for forwardingPath.
  • e2e/tests/upgrades/upgrade_test.go: NewMsgTransfer with nil for forwardingPath.
  • e2e/tests/transfer/upgrades_test.go: NewMsgTransfer with nil for forwardingPath.
  • e2e/tests/transfer/incentivized_test.go: NewMsgTransfer with nil for forwardingPath.

Given the consistent use of nil for forwardingPath across these tests, it appears to be an intentional design choice for these scenarios.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that the forwardingPath is intentionally set to nil in this context.
# Test: Search for the function usage with nil forwardingPath. Expect: Only occurances where it's intentional.
rg --type go $'NewMsgTransfer.*nil'

Length of output: 8047



Script:

#!/bin/bash
# Extract lines around the NewMsgTransfer calls to understand the context and check for any comments or documentation.
rg --type go --context 5 'NewMsgTransfer.*nil'

Length of output: 19487

modules/apps/transfer/keeper/mbt_relay_test.go (2)

164-164: The forwardingPath is set to nil here. If this is part of a test setup, ensure it aligns with the test's objectives, especially given the focus on forwardingPath in other parts of the codebase.

Verification successful

The forwardingPath being set to nil in the test setup appears to be intentional and aligns with the test's objectives, as evidenced by multiple instances across various test files where NewMsgTransfer is called with nil for the forwardingPath.

  • modules/apps/transfer/transfer_test.go
  • modules/apps/transfer/keeper/relay_test.go
  • modules/apps/transfer/types/msgs_test.go
  • modules/apps/29-fee/transfer_test.go
  • e2e/tests/transfer/upgrades_test.go
  • e2e/tests/transfer/incentivized_test.go
  • e2e/testsuite/tx.go
  • e2e/tests/upgrades/upgrade_test.go
Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that the forwardingPath is intentionally set to nil in this context.
# Test: Search for the function usage with nil forwardingPath. Expect: Only occurances where it's intentional.
rg --type go $'NewMsgTransfer.*nil'

Length of output: 8047


366-366: Similar to previous comments, forwardingPath is set to nil. Consistency in how forwardingPath is handled across tests is crucial, especially in the context of new features related to packet forwarding.

Verification successful

The search results indicate that setting forwardingPath to nil is a common and intentional practice across various test files and scenarios. This suggests that the usage is consistent and aligns with the intended design.

  • Instances found in modules/apps/transfer/transfer_test.go
  • Instances found in modules/apps/transfer/types/msgs_test.go
  • Instances found in modules/apps/transfer/keeper/relay_test.go
  • Instances found in modules/apps/29-fee/transfer_test.go
  • Instances found in e2e/tests/upgrades/upgrade_test.go
  • Instances found in e2e/tests/transfer/upgrades_test.go
  • Instances found in e2e/tests/transfer/incentivized_test.go
  • Instances found in e2e/testsuite/tx.go
Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that the forwardingPath is intentionally set to nil in this context.
# Test: Search for the function usage with nil forwardingPath. Expect: Only occurances where it's intentional.
rg --type go $'NewMsgTransfer.*nil'

Length of output: 8047

modules/apps/callbacks/replay_test.go (1)

333-333: The forwardingPath parameter is set to nil in the NewMsgTransfer call. This should be checked to ensure it aligns with the intended behavior, especially given the focus on forwarding features in the PR.

Verification successful

The forwardingPath parameter being set to nil in the NewMsgTransfer call is intentional and aligns with the intended behavior. The ForwardingInfo type is used for forwarding-related features, and its usage in test cases with nil indicates that it is optional and not always required.

  • Instances of NewMsgTransfer with nil for forwardingPath are primarily in test scenarios.
  • The ForwardingInfo type is defined with fields Hops and Memo, indicating its role in forwarding features.
Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that the forwardingPath is intentionally set to nil in this context.
# Test: Search for the function usage with nil forwardingPath. Expect: Only occurances where it's intentional.
rg --type go $'NewMsgTransfer.*nil'

Length of output: 8047



Script:

#!/bin/bash
# Description: Gather more context around the NewMsgTransfer function definition and its usage, focusing on the forwardingPath parameter.
# Test: Search for the NewMsgTransfer function definition and its usage in the codebase.
rg --type go 'func NewMsgTransfer' -A 10

Length of output: 779



Script:

#!/bin/bash
# Description: Gather more context around the ForwardingInfo type and its usage in the codebase.
# Test: Search for the ForwardingInfo type definition and its usage in the codebase.
rg --type go 'type ForwardingInfo' -A 10

Length of output: 997

modules/apps/transfer/ibc_module.go (1)

233-245: Consider revising the return of nil in asynchronous handling.

The use of nil here might be intended to indicate a 'no operation' or 'success', but it's unconventional in Go, where typically an explicit error or similar indicator is used to denote success or failure. Could you clarify if this is intended, and ensure it aligns with the overall error handling strategy of the module?

modules/apps/transfer/types/packet_test.go (1)

Line range hint 185-416: Comprehensive test coverage for FungibleTokenPacketDataV2.

The test cases added for FungibleTokenPacketDataV2 are comprehensive and effectively cover both positive and negative scenarios, including the handling of ForwardingInfo. This aligns well with the PR's objectives to ensure robust validation logic.

e2e/tests/transfer/upgrades_test.go (1)

201-201: Ensure the NewMsgTransfer function call includes all required parameters.

Verification successful

The NewMsgTransfer function definition includes the following parameters:

  • sourcePort
  • sourceChannel
  • tokens
  • sender
  • receiver
  • timeoutHeight
  • timeoutTimestamp
  • memo
  • forwardingPath

The usage in e2e/tests/transfer/upgrades_test.go includes all these parameters:

msgTransfer := transfertypes.NewMsgTransfer(
    channelA.PortID, 
    channelA.ChannelID, 
    sdk.NewCoins(transferAmount), 
    chainAWallet.FormattedAddress(), 
    chainBWallet.FormattedAddress(), 
    s.GetTimeoutHeight(ctx, chainB), 
    0, 
    "", 
    nil
)

This confirms that all required parameters are included in the function call.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that the `NewMsgTransfer` function call includes all required parameters.

# Test: Search for the function usage. Expect: All parameters are included.
rg --type go $'NewMsgTransfer'

Length of output: 10850



Script:

#!/bin/bash
# Description: Retrieve the definition of the `NewMsgTransfer` function to verify required parameters.

# Test: Search for the function definition. Expect: Retrieve the function signature.
ast-grep --lang go --pattern 'func NewMsgTransfer($_, $_, $_, $_, $_, $_, $_, $_, $_) $_' 

Length of output: 91



Script:

#!/bin/bash
# Description: Retrieve the definition of the `NewMsgTransfer` function to verify required parameters.

# Test: Search for the function definition with a more flexible pattern. Expect: Retrieve the function signature.
ast-grep --lang go --pattern 'func NewMsgTransfer($$$) $_'

Length of output: 1378

modules/apps/transfer/keeper/relay.go (5)

68-68: Ensure the forwardingPath parameter is properly documented and validated.


394-394: Ensure the OnAcknowledgementPacket function handles packet acknowledgements correctly, especially in multihop scenarios.

Also applies to: 396-396, 399-399, 401-401, 403-403, 406-406, 408-408, 410-410, 412-412, 416-416, 418-418

Verification successful

The OnAcknowledgementPacket function in modules/apps/transfer/keeper/relay.go appears to handle packet acknowledgements correctly, including multihop scenarios. It checks for the existence of a previous packet and processes the acknowledgement accordingly, either writing a success acknowledgement or reverting changes and writing an error acknowledgement.

  • The function retrieves the channel capability and checks if it exists.
  • It then checks if a previous packet was forwarded.
    • If found, it processes the acknowledgement based on its type (result or error).
    • If not found, it processes the current packet's acknowledgement directly.

This logic ensures that the function handles both direct and multihop packet acknowledgements appropriately.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Ensure the `OnAcknowledgementPacket` function handles packet acknowledgements correctly.

# Test: Search for the function usage and logic. Expect: Correct handling of packet acknowledgements.
rg --type go $'OnAcknowledgementPacket'

Length of output: 8727



Script:

#!/bin/bash
# Extract the implementation of the `OnAcknowledgementPacket` function from `modules/apps/transfer/keeper/relay.go` for detailed analysis.
ast-grep --lang go --pattern $'func (k Keeper) OnAcknowledgementPacket(ctx sdk.Context, packet channeltypes.Packet, data types.FungibleTokenPacketDataV2, ack channeltypes.Acknowledgement) error {
  $$$
}' modules/apps/transfer/keeper/relay.go

Length of output: 4311


149-149: Check the creation of FungibleTokenPacketDataV2 for correct data encapsulation.


183-183: Review the logic in OnRecvPacket for handling forwarding paths and token transfers, ensuring it aligns with IBC specifications.

Also applies to: 186-186, 190-190, 201-201, 204-207, 222-222, 251-251, 256-256, 312-312, 319-319, 343-381

Verification successful

The implementation of OnRecvPacket in modules/apps/transfer/keeper/relay.go and the related test cases in modules/apps/transfer/keeper/relay_test.go have been extracted. Here's a summary of the findings:

Implementation of OnRecvPacket

  • The function validates the packet data and checks if receiving is enabled.
  • It handles the receiver address and forwarding path.
  • It processes the received tokens, either unescrowing them or minting new tokens based on the source chain.
  • It includes telemetry and event emission for monitoring.
  • It adds forwarding logic if there is a forwarding path specified.

Test Cases

  • The test cases cover various scenarios, including successful and failure cases for receiving tokens.
  • They validate the correct handling of forwarding paths, receiver addresses, and token amounts.
  • They ensure the total escrow amount is correctly updated.

Alignment with IBC Specifications

  • The function appears to follow the IBC specifications for handling token transfers and forwarding paths.
  • The test cases provide comprehensive coverage to ensure the function behaves as expected under different conditions.

Points of Attention

  • Ensure the forwarding logic correctly handles all edge cases.
  • Verify that the telemetry and event emission provide accurate monitoring data.

Locations in the Codebase

  • modules/apps/transfer/keeper/relay.go (Implementation of OnRecvPacket)
  • modules/apps/transfer/keeper/relay_test.go (Test cases for OnRecvPacket)
Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Review the logic in `OnRecvPacket` for handling forwarding paths and token transfers.

# Test: Search for the function usage and logic. Expect: Alignment with IBC specifications.
rg --type go $'OnRecvPacket'

Length of output: 10781



Script:

#!/bin/bash
# Extract the implementation of OnRecvPacket from relay.go
ast-grep --lang go --pattern $'func (k Keeper) OnRecvPacket(ctx sdk.Context, packet channeltypes.Packet, data types.FungibleTokenPacketDataV2) (bool, error) {
  $$$
}' modules/apps/transfer/keeper/relay.go

# Extract the relevant test cases for OnRecvPacket from relay_test.go
ast-grep --lang go --pattern $'func (suite *KeeperTestSuite) TestOnRecvPacket() {
  $$$
}' modules/apps/transfer/keeper/relay_test.go

ast-grep --lang go --pattern $'func (suite *KeeperTestSuite) TestOnRecvPacketSetsTotalEscrowAmountForSourceIBCToken() {
  $$$
}' modules/apps/transfer/keeper/relay_test.go

Length of output: 40874


439-439: Review the OnTimeoutPacket function to ensure it properly handles timeouts and state reversions.

Also applies to: 441-441, 444-444, 446-446, 448-448, 450-450, 452-452

testing/solomachine.go (1)

381-381: The nil parameter in SendTransfer function seems to be a placeholder for future functionality or an oversight. Please clarify its purpose or consider removing it if it's not needed.

Verification successful

The nil parameter in the SendTransfer function is used to indicate that no additional functions are provided to modify the MsgTransfer. This is a valid use case for variadic parameters in Go.

  • testing/solomachine.go: The SendTransfer function definition and its usage in test files confirm that nil is used to indicate the absence of additional functions.
Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the usage of the `nil` parameter in the `SendTransfer` function across the codebase.

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

Length of output: 1302



Script:

#!/bin/bash
# Description: Verify the definition and usage of the `SendTransfer` function to understand the purpose of the `nil` parameter.

# Test: Extract the definition of the `SendTransfer` function.
ast-grep --lang go --pattern $'func (solo *Solomachine) SendTransfer($_, $_, $_ string, fns ...func(*transfertypes.MsgTransfer)) $_' 

# Test: Extract the usage of the `SendTransfer` function in the test files.
rg --type go 'SendTransfer' --context 5

Length of output: 8117

e2e/tests/transfer/incentivized_test.go (1)

Line range hint 1-1: Review the overall test coverage and structure.

The test cases are well-structured and seem to cover the necessary scenarios effectively. Good use of the testify suite to structure tests and assertions.

modules/apps/27-interchain-accounts/host/keeper/relay_test.go (1)

354-354: Ensure that the forwardingPath parameter is tested for non-nil scenarios.

modules/apps/callbacks/ibc_middleware_test.go (10)

Line range hint 14-14: The test cases in TestNewIBCMiddleware are well-structured and cover the necessary edge cases for middleware instantiation.


Line range hint 14-14: The TestWithICS4Wrapper function correctly implements checks for the ICS4 wrapper, ensuring it is properly integrated and typed within the middleware.


Line range hint 14-14: The TestSendPacket function is comprehensive and effectively tests the SendPacket functionality under various conditions, including edge cases and failure scenarios.


Line range hint 14-14: The TestOnAcknowledgementPacket function effectively tests various scenarios of acknowledgement handling, including edge cases and error handling.


Line range hint 14-14: The TestOnTimeoutPacket function is well-structured and thoroughly tests the timeout packet handling, covering necessary scenarios and edge cases.


Line range hint 14-14: The TestOnRecvPacket function provides comprehensive testing for the receive packet functionality, covering a wide range of scenarios and edge cases.


Line range hint 14-14: The TestWriteAcknowledgement function effectively tests the acknowledgement writing functionality, covering various scenarios including error handling and edge cases.


Line range hint 14-14: The TestProcessCallback function is comprehensive and effectively tests the callback processing functionality under various conditions, including error scenarios.


Line range hint 14-14: The TestUnmarshalPacketDataV1 function correctly tests the unmarshalling of packet data from version 1 to version 2, ensuring compatibility and correctness.


Line range hint 14-14: The TestUnmarshalPacketDataV2 function effectively tests the unmarshalling process for version 2 packet data, ensuring data integrity and correctness.

e2e/tests/upgrades/upgrade_test.go (19)

Line range hint 1-1: Ensure the build tag is correctly specified for the e2e tests.


Line range hint 11-11: Ensure all necessary packages are imported and used appropriately.


Line range hint 14-14: Verify the constant values are appropriate and used correctly throughout the tests.


Line range hint 16-16: Ensure the TestUpgradeTestSuite function correctly initializes the test suite and handles configuration errors properly.


Line range hint 18-18: Check the UpgradeTestSuite struct for any missing fields or methods that might be necessary for the tests.


Line range hint 21-21: Review the UpgradeChain method for correct implementation of the upgrade process, error handling, and use of context timeouts.


Line range hint 95-95: Ensure the TestIBCChainUpgrade function correctly sets up the test environment, performs IBC token transfers, and validates the upgrade process.


Line range hint 95-95: Check for proper synchronization and error handling in the TestIBCChainUpgrade function.


Line range hint 95-95: Review the use of relayers and query utilities in the TestIBCChainUpgrade function to ensure they are correctly integrated and functioning.


Line range hint 95-95: Validate the logic for handling different scenarios in the TestIBCChainUpgrade function, such as token escrow and packet relaying.


Line range hint 95-95: Ensure the upgrade process in the TestIBCChainUpgrade function is correctly implemented and tested.


Line range hint 95-95: Check the final assertions in the TestIBCChainUpgrade function to ensure they correctly verify the outcomes of the tests.


Line range hint 95-95: Review the TestChainUpgrade function for correct setup, execution, and validation of chain upgrade tests.


Line range hint 95-95: Ensure the TestV6ToV7ChainUpgrade function correctly tests the upgrade from v6 to v7 of the ibc-go binary, including client and consensus state migrations.


Line range hint 95-95: Review the TestV7ToV7_1ChainUpgrade function for correct implementation of the upgrade process and validation of post-upgrade state.


Line range hint 95-95: Ensure the TestV7ToV8ChainUpgrade function correctly handles the upgrade process, parameter updates, and packet flow validation.


Line range hint 95-95: Review the TestV8ToV8_1ChainUpgrade function for correct implementation of the upgrade process, fee middleware integration, and packet fee handling.


Line range hint 95-95: Ensure the TestV8ToV8_1ChainUpgrade_ChannelUpgrades function correctly tests channel upgrades, relayer interactions, and fee payments.


Line range hint 95-95: Check the ClientState helper function for correct implementation and error handling.

modules/apps/transfer/keeper/relay_test.go (2)

Line range hint 564-599: Check for potential data races in TestOnRecvPacketSetsTotalEscrowAmountForSourceIBCToken.


Line range hint 217-238: Ensure proper handling of ForwardingPath in TestSendTransferSetsTotalEscrowAmountForSourceIBCToken.

Comment on lines +791 to +797
"tokens": [{ "denom": "stake", "amount": "100" }],
"sender": "` + icaAddress + `",
"receiver": "cosmos15ulrf36d4wdtrtqzkgaan9ylwuhs7k7qz753uk",
"timeout_height": { "revision_number": 1, "revision_height": 100 },
"timeout_timestamp": 0
"timeout_timestamp": 0,
"memo": "",
"forwarding_path": { "hops": [], "memo": "" }
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The test case for MsgTransfer should include scenarios where forwardingPath has actual hops to test multi-hop functionality.

- "forwarding_path": { "hops": [], "memo": "" }
+ "forwarding_path": { "hops": ["path1", "path2"], "memo": "Test multi-hop" }

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
"tokens": [{ "denom": "stake", "amount": "100" }],
"sender": "` + icaAddress + `",
"receiver": "cosmos15ulrf36d4wdtrtqzkgaan9ylwuhs7k7qz753uk",
"timeout_height": { "revision_number": 1, "revision_height": 100 },
"timeout_timestamp": 0
"timeout_timestamp": 0,
"memo": "",
"forwarding_path": { "hops": [], "memo": "" }
"tokens": [{ "denom": "stake", "amount": "100" }],
"sender": "` + icaAddress + `",
"receiver": "cosmos15ulrf36d4wdtrtqzkgaan9ylwuhs7k7qz753uk",
"timeout_height": { "revision_number": 1, "revision_height": 100 },
"timeout_timestamp": 0,
"memo": "",
"forwarding_path": { "hops": ["path1", "path2"], "memo": "Test multi-hop" }

Comment on lines +308 to +312
func (k Keeper) SetForwardedPacket(ctx sdk.Context, portID, channelID string, sequence uint64, packet channeltypes.Packet) {
store := ctx.KVStore(k.storeKey)
bz := k.cdc.MustMarshal(&packet)
store.Set(types.PacketForwardKey(portID, channelID, sequence), bz)
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Tip

Codebase Verification

Ensure proper error handling for packet marshaling in SetForwardedPacket. The current implementation in relay.go does not handle potential panics from MustMarshal.

  • modules/apps/transfer/keeper/relay.go: Add error handling around the SetForwardedPacket call to manage potential panics from MustMarshal.
Analysis chain

Ensure proper error handling for packet marshaling.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that marshaling errors are handled properly in the calling code.

# Test: Search for the function usage. Expect: Proper error handling around this function call.
rg --type go $'SetForwardedPacket'

Length of output: 457



Script:

#!/bin/bash
# Extract lines around the usage of SetForwardedPacket in relay.go to inspect error handling.
rg --type go --context 5 'SetForwardedPacket' modules/apps/transfer/keeper/relay.go

Length of output: 351

suite.chainB.GetTimeoutHeight(),
0,
"",
nil,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Tip

Codebase Verification

Consider adding a test case to verify behavior when forwardingPath is non-nil along with an empty receiver.

The search did not reveal any existing test cases that specifically cover the scenario where forwardingPath is non-nil and the receiver is empty. It would be beneficial to add such a test case to ensure this edge case is properly handled.

  • Location to add test case: modules/apps/transfer/keeper/relay_test.go
Analysis chain

Consider adding a test case to verify behavior when forwardingPath is non-nil along with an empty receiver.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that tests for non-nil `forwardingPath` with an empty receiver are present.

# Test: Search for such test cases. Expect: At least one occurrence.
rg --type go 'forwardingPath: &.*receiver: ""'

Length of output: 48



Script:

#!/bin/bash
# Description: Broaden the search for test cases with non-nil `forwardingPath` and empty receiver.

# Test: Search for test cases with non-nil `forwardingPath` and empty receiver, considering variations.
rg --type go 'forwardingPath: &.*receiver: ""' -A 5

Length of output: 53



Script:

#!/bin/bash
# Description: Perform a general search for `forwardingPath` to manually inspect the context.

# Test: Search for occurrences of `forwardingPath` in Go test files.
rg --type go 'forwardingPath' -A 10

Length of output: 15412


// send from chainB to chainC
msg = types.NewMsgTransfer(pathBtoC.EndpointA.ChannelConfig.PortID, pathBtoC.EndpointA.ChannelID, sdk.NewCoins(coinSentFromAToB), suite.chainB.SenderAccount.GetAddress().String(), suite.chainC.SenderAccount.GetAddress().String(), timeoutHeight, 0, "")
msg = types.NewMsgTransfer(pathBtoC.EndpointA.ChannelConfig.PortID, pathBtoC.EndpointA.ChannelID, sdk.NewCoins(coinSentFromAToB), suite.chainB.SenderAccount.GetAddress().String(), suite.chainC.SenderAccount.GetAddress().String(), timeoutHeight, 0, "", nil)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Similar to the previous comment, the NewMsgTransfer function call here also omits the ForwardingPath parameter. This should be included to match the updated function signature and to test the new functionality effectively.


// send from chainC back to chainB
msg = types.NewMsgTransfer(pathBtoC.EndpointB.ChannelConfig.PortID, pathBtoC.EndpointB.ChannelID, sdk.NewCoins(coinSentFromBToC), suite.chainC.SenderAccount.GetAddress().String(), suite.chainB.SenderAccount.GetAddress().String(), timeoutHeight, 0, "")
msg = types.NewMsgTransfer(pathBtoC.EndpointB.ChannelConfig.PortID, pathBtoC.EndpointB.ChannelID, sdk.NewCoins(coinSentFromBToC), suite.chainC.SenderAccount.GetAddress().String(), suite.chainB.SenderAccount.GetAddress().String(), timeoutHeight, 0, "", nil)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Again, the NewMsgTransfer function call is missing the ForwardingPath parameter. Consistency in implementing the updated function signature across all test cases is crucial for proper validation.


msg := types.NewMsgTransfer(
srcPort, srcChannel, coins, sender, receiver, timeoutHeight, timeoutTimestamp, memo,
srcPort, srcChannel, coins, sender, receiver, timeoutHeight, timeoutTimestamp, memo, nil,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The NewMsgTransfer function call in NewTransferTxCmd correctly integrates the new memo parameter. However, it seems that the forwardingPath parameter is still set to nil. If the forwarding functionality is intended to be used from the CLI, this needs to be implemented.

Consider adding CLI flags to specify the forwarding path and integrate it into the NewMsgTransfer call.

portID, channelID string, token sdk.Coin, sender, receiver string, timeoutHeight clienttypes.Height, timeoutTimestamp uint64, memo string,
) sdk.TxResponse {
msg := transfertypes.NewMsgTransfer(portID, channelID, sdk.NewCoins(token), sender, receiver, timeoutHeight, timeoutTimestamp, memo)
msg := transfertypes.NewMsgTransfer(portID, channelID, sdk.NewCoins(token), sender, receiver, timeoutHeight, timeoutTimestamp, memo, nil)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Include ForwardingInfo in MsgTransfer creation.

The MsgTransfer now supports a ForwardingInfo parameter, which is missing in this function call. Consider updating this to include ForwardingInfo as needed to align with the new function signature.

- msg := transfertypes.NewMsgTransfer(portID, channelID, sdk.NewCoins(token), sender, receiver, timeoutHeight, timeoutTimestamp, memo, nil)
+ msg := transfertypes.NewMsgTransfer(portID, channelID, sdk.NewCoins(token), sender, receiver, timeoutHeight, timeoutTimestamp, memo, forwardingInfo)

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
msg := transfertypes.NewMsgTransfer(portID, channelID, sdk.NewCoins(token), sender, receiver, timeoutHeight, timeoutTimestamp, memo, nil)
msg := transfertypes.NewMsgTransfer(portID, channelID, sdk.NewCoins(token), sender, receiver, timeoutHeight, timeoutTimestamp, memo, forwardingInfo)

suite.chainB.SenderAccount.GetAddress().String(),
suite.chainB.GetTimeoutHeight(), 0, // only use timeout height
"memo",
nil,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The NewMsgTransfer function calls in these test cases are missing the ForwardingPath parameter. This parameter should be included in all relevant test cases to ensure the functionality is correctly tested against the updated API.

Also applies to: 135-135, 174-174, 205-205

sender,
receiver,
"",
nil,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The test cases in TestGetFullDenomPath are correctly implemented to check the full denomination path based on the trace. It would be beneficial to add more diverse test cases, especially testing edge cases like malformed traces or extremely long traces to ensure robustness.

Would you like assistance in adding these test cases?

Also applies to: 59-59

Denom: denom,
Amount: packet.Data.Amount,
Trace: trace,
Amount: packet.Data.Amount,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The Amount field is directly set from the packet.Data.Amount, which is a string. This could lead to runtime errors if the string is not a valid integer. Consider parsing the string to an integer with error handling before assigning it to Amount.

- Amount: packet.Data.Amount,
+ amount, err := strconv.ParseInt(packet.Data.Amount, 10, 64)
+ if err != nil {
+     return err
+ }
+ Amount: amount,

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
Amount: packet.Data.Amount,
amount, err := strconv.ParseInt(packet.Data.Amount, 10, 64)
if err != nil {
return err
}
Amount: amount,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add test when ValidateBasic of FungibleTokenPacketDataV2 fails if both Memo and ForwardingPath with hops are set

7 participants