Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: delete forwarded packet when it is not needed anymore #6621

Merged
merged 40 commits into from
Jun 21, 2024

Conversation

bznein
Copy link
Contributor

@bznein bznein commented Jun 17, 2024

Description

closes: #6546


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.

bznein and others added 24 commits June 13, 2024 11:25
@bznein bznein added the priority PRs that need prompt reviews label Jun 17, 2024
Copy link
Contributor

@colin-axner colin-axner left a comment

Choose a reason for hiding this comment

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

Looking good! I left a few comments. I believe the incorrect port/channel pair is being referenced. It's possible tests don't catch the issue since we tend to reuse the same starting channelid across testing chains ref #4062

modules/apps/transfer/keeper/keeper.go Outdated Show resolved Hide resolved
return err
}

return k.deleteForwardedPacket(ctx, packet.SourcePort, packet.SourceChannel, packet.Sequence)
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we add checks in our testing for deletion of the right packet?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done for the OnAcknowledgment, for the timeout case I have #6596 in review and I'll ad it to that test once we merge this.

modules/apps/transfer/keeper/forwarding.go Outdated Show resolved Hide resolved
modules/apps/transfer/keeper/forwarding.go Outdated Show resolved Hide resolved
modules/apps/transfer/keeper/forwarding.go Outdated Show resolved Hide resolved
modules/apps/transfer/keeper/forwarding.go Outdated Show resolved Hide resolved
modules/apps/transfer/keeper/relay_forwarding_test.go Outdated Show resolved Hide resolved
modules/apps/transfer/keeper/relay_forwarding_test.go Outdated Show resolved Hide resolved
@bznein bznein requested a review from colin-axner June 20, 2024 10:14
Copy link
Contributor

@crodriguezvega crodriguezvega left a comment

Choose a reason for hiding this comment

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

Looks good to me, @bznein!

@@ -561,6 +561,10 @@ func (suite *KeeperTestSuite) TestAcknowledgementFailureScenario5Forwarding() {
err = path1.EndpointB.AcknowledgePacket(packetFromBtoA, errorAckOnA.Acknowledgement())
suite.Require().NoError(err)

// Check that B deleted the forwarded packet.
Copy link
Contributor

Choose a reason for hiding this comment

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

We can probably add this check to some other tests as well (like the happy path).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good idea, done!

@@ -328,3 +328,11 @@ func (k Keeper) GetForwardedPacket(ctx sdk.Context, portID, channelID string, se

return storedPacket, true
}

// deleteForwardedPacket deletes the forwarded packet from the store.
func (k Keeper) deleteForwardedPacket(ctx sdk.Context, portID, channelID string, sequence uint64) {
Copy link
Contributor

Choose a reason for hiding this comment

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

There is some improvement we can do with the naming since "forwarded packet" here in the name of the function refers to the packet that was received by the middle chain, but in the places where this function is called "forwarded packet" refers to the packet that was sent from the middle chain. Anyway, no need to change it for now, we can make a proposal for other naming in a separate PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah I agree. I chose a name which is consistent with what we use in the rest of the file (which in my understanding refer to the same concept), but I'm happy to find a better name.

Copy link

sonarcloud bot commented Jun 21, 2024

@bznein bznein merged commit da2f9f6 into feat/ics20-v2-path-forwarding Jun 21, 2024
76 of 77 checks passed
@bznein bznein deleted the bznein/6546/deletepacket branch June 21, 2024 09:58
github-merge-queue bot pushed a commit that referenced this pull request Jun 28, 2024
* Adding proto files for ics20-v2 (#6110)

* chore: adding proto files for ics20-v2

* chore: add newline

* update amount -> string (#6120)

* Update MsgTransfer to accept sdk.Coins instead of sdk.Coin (#6113)

* fix: allow base denom with trailing slash (#6148)

* imp: add CurrentVersion, EscrowVersion (#6160)

* add CurrentVersion, EscrowVersion, update tests

* update hardcoded transfer channel version from interchaintest

* chore: add function for converting packet data from v1 to v3 (#6116)

---------

Co-authored-by: Charly <[email protected]>

* chore: implement required `FungibleTokenPacketData` v3 interface methods (#6126)

* imp: `getMultiDenomFungibleTokenPacketData`to be used in packet unmarshalling/conversion (#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 <[email protected]>
Co-authored-by: Carlos Rodriguez <[email protected]>

* chore: implement version checking for channel handshake application callbacks (#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 <[email protected]>

* imp: update transfer authz implementation to account for multi denom transfers (#6252)

* add transfer authz code + tests

* linter

* address review comments

---------

Co-authored-by: Carlos Rodriguez <[email protected]>

* ics20-v2: backwards compatibility for transfer rpc and packet callbacks (#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 <[email protected]>
Co-authored-by: Charly <[email protected]>

* add v3 packet proto

* fix protos

* fixes

* test fixes

* add forwardPath keys and memo check in sendTransfer

* wip onRecvPacket logic

* minor fixes

* changes to transfer tx CLI to support multiple denoms

* import renaming

* onRecv logic completed

* add revertInFlights function

* add onAck && onTimeout logic

* fix interchain accounts test

* basic unit test for path forwarding

* fix test unsuccessful refund from source

* wip test fix

* fix mbt test - need more investigation

* revert test fix

* add assertions

* add support for async ack

* wip test forwarding happy path

* icsv20(path forwarding): use nil as default forwarding path when not set, use sequence in key to store forwarded packet (#6325)

* use nil forwarding path as default when not set, use sequence in key to store forwarded packet

* lint

* add forwarding happy path tests

* fix merge

* Use type with V2 suffix for package data (#6330)

* Adding additional comments and changing version variable names (#6345)

* chore: correctly claim capability

* lint

* imp: change ics20 events to emit token set (#6348)

* refactor: quick change to tokens event attribute

* fix: various tests

* lint

* lint:fixeroni

* imp: remove events variable in favour of direct event emission

---------

Co-authored-by: DimitrisJim <[email protected]>

* imp: check length tokens array against maximum allowed (#6349)

* check length of tokens array against maximum allowed

* chore: add note on arbitrary selection

---------

Co-authored-by: Colin Axnér <[email protected]>

* Modify UnmarshalPacketData interface to allow additional args (#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.

* Refactor packet data unmarshalling to use specific version (#6354)

* 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 <[email protected]>
Co-authored-by: Colin Axnér <[email protected]>

* chore: fixing tests

* imp: self review comments for ics20-v2 (#6360)

* refactor: address various self review comments

* revert: unnecessary change

* lint

* imp: self review on ics20-v2 part 2 (#6364)

* refactor: apply review suggestions

* imp: additional updates

* refactor: make ValidateIBCDenom private

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

Co-authored-by: Cian Hatton <[email protected]>

* apply review suggestions

---------

Co-authored-by: Cian Hatton <[email protected]>

* chore: move functions from internal/denom back to trace.go (#6368)

* chore: move functions from internal/denom to trace.go

* lint

* lint: the comeback

* imp: ics20 v2 self review part 3 (#6373)

* 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

* chore: remove duplicate test case

* chore: address minor nits (#6374)

* fix lint warning, add extra godocs, and some other small fixes and cleanup

* fix finalReceiver address bug

* wip - ack test scenario5

* add FungibleTokenPacketDataV2 test for ValidateBasic (#6398)

* fix linter complaints

* add test - currently faling on middle hop revert

* add test comments

* fixes

* retrieve channel capability only if there is a previous packet in store

* add missing parameter

* fix: e2e build failures.

* Use Transfer instead of sendTransfer when forwarding. (#6564)

Pass nil as the next forwarding path if at final hop.
Use consistent timeout for all hops.

* lint: fix linter issues.

* tests(transfer): move forwarding tests to separate file. (#6568)

* chore: rename ForwardingInfo to Forwarding

* Revert "chore: rename ForwardingInfo to Forwarding"

This reverts commit e483b9a.

* nit(transfer): Mark hops as non nullable. (#6566)

* nit(transfer): Mark hops as non nullable.

* lint: fix additional linting issues

* feat(transfer): add forwarding info validation to token packet (#6571)

* feat(transfer): add forwarding info validation to token packet

* Added NewForwardingInfo constructor

* Removed redundant check

* Clean up tests per cr comments

* Back to Validate and use NewDenom

* feat(transfer): add validation for forwarding info in msg transfer validate basic (#6583)

* Fix and simplify reverts of forwarding state (#6574)

* refactor: initial simplification attempt

* refactor: further organize

* fix: all tests fixed

* docs: improved godocs

* fix: logic and testing error

* style: self suggestion

* docs: suggestion

* docs: spellcheck

* style: suggestions

* style: renamed to revertForwardedPacket

* style: suggestion

* docs: remove docs

* docs: godoc suggestion

* style: suggestion

* docs: colin suggestions

* chore: rename ForwardingInfo to Forwarding (#6576)

* chore: rename ForwardingInfo to Forwarding

* chore: rename forwarding_path field to forwarding

* chore: make lint-fix

* chore: rename forwarding info -> forwarding

* chore: renaming fixes before merge

* Refactor packet forward functions (#6575)

* feat(transfer): validate forwarding memo in transfer authorization (#6591)

* Add func convert token to coin ibc (#6584)

* add func convert token to coin ibc

* fix command: change func to ToCoin and add godoc

* add unit test

* Revert using ToCoin on Recv where trace manipulation occurs.
Use ToCoin while forwarding.
Update tests as per Carlos's review.

* rename variable

---------

Co-authored-by: Carlos Rodriguez <[email protected]>
Co-authored-by: DimitrisJim <[email protected]>

* transfer: Disallow a forwarding object specified with zero hops and a memo (#6599)

* transfer: Disallow a forwarding object specified with zero hops and a memo.

* Apply suggestions from code review

Co-authored-by: Carlos Rodriguez <[email protected]>

---------

Co-authored-by: Carlos Rodriguez <[email protected]>
Co-authored-by: Gjermund Garaba <[email protected]>

* feat(transfer): move async decision and handling to the ibc module onrecv callback (#6592)

* refactor: initial simplification attempt

* refactor: further organize

* fix: all tests fixed

* chore: refactor packet forward functions

* chore: use receiver address directly in msg transfer

* feat(transfer): move async to ibc_module for onrecv

* chore: fix linter

* fix: logic and testing error

* style: self suggestion

* docs: suggestion

* docs: spellcheck

* style: suggestions

* style: renamed to revertForwardedPacket

* style: suggestion

* docs: remove docs

* Added tests for transfer OnRecv

* Use new names and methods from feature branch

* Apply suggestions from code review

Co-authored-by: colin axnér <[email protected]>

* Clean up test from cr feedback

* move vars to beginning of function

* lint

* Update modules/apps/transfer/ibc_module.go

Co-authored-by: Carlos Rodriguez <[email protected]>

* lint

---------

Co-authored-by: srdtrk <[email protected]>
Co-authored-by: chatton <[email protected]>
Co-authored-by: colin axnér <[email protected]>
Co-authored-by: Carlos Rodriguez <[email protected]>
Co-authored-by: DimitrisJim <[email protected]>

* chore: use NewForwarding instead of direct init (#6605)

* Reduce max forwarding to 16 (#6610)

* feat(transfer): use single byte ack for successful forward (#6604)

Co-authored-by: Nikolas De Giorgis <[email protected]>

* chore(transfer/cli): add forwarding flag to tx cli (#6609)

Co-authored-by: Carlos Rodriguez <[email protected]>

* chore(transfer): make Forwarding non-null (#6618)

* chore(transfer): make Forwarding non-null

* chore(transfer): always validate forwarding.

* chore: restructure functions with logical ordering (#6638)

* test: Add tests for OnTimeoutPacket when middle chain times out packet  (#6596)

* Create ontimeoutpacket test for forwarding

---------

Co-authored-by: Carlos Rodriguez <[email protected]>

* feat(transfer): add ShouldBeForwarded convenience method to msg transfer (#6595)

* feat(transfer): add should-be-forwarded convenience method to msg transfer

* Clean up packet and transfer msg validation for forwarding logic

---------

Co-authored-by: Carlos Rodriguez <[email protected]>

* disallow timeout height usage when forwarding packets (#6641)

* disallow non-zero timeout height when forwarding tokens

* typo

* move constant

* use time to create default timeout timestamp delta

* Apply suggestions from code review

* refactor: add GetTimeoutTimestamp helper fn to the testing pkg

* lint

---------

Co-authored-by: colin axnér <[email protected]>

* nit: make set forwarded packet unexported (#6637)

Co-authored-by: Gjermund Garaba <[email protected]>
Co-authored-by: colin axnér <[email protected]>

* feat(transfer): use registered error code for error acks in token forwarding (#6648)

* Add typed errors to packet forwarding

* Use forward errors in tests

* Make ack construction consistent

* chore(transfer): emit forwarding information in events. (#6647)

* chore(transfer): emit forwarding information in events.

* nit: rename as per Carlos's suggestion

* Fix e2e test

* Refactor forwarding messages for Transfer and Packet (#6655)

* feat(transfer): add unwind, refactor proto structure. gen-all

* tests(transfer/types): fix test failures in types tests.

* tests(transfer/keeper): fix test failures in keeper tests.

* cli(transfer): fix cli usage. pending flag for unwind.

* tests(callbacks): fix failing tests in callbacks.

* tests(transfer/internal): fix failures in internal package.

* tests(transfer): fix test failures in top level tranfer package.

* tests(ica/host/keeper): fix repr of msg transfer in ica host msg execution.

* lint(all): lint this bad boy

* chore(transfer/types): amend validation for MsgTransfer's ShouldBeForwarded, add tests for ForwardedPacketData, minor nits.

* nit(self): only pass relevant fields to create packet data; minor comment improvement.

* Apply suggestions from code review

Co-authored-by: Carlos Rodriguez <[email protected]>

* chore(merge): fix merge issues.

* chore(proto): mention optional nature of fields.

* memo: do not drop it

* validation: drop requirement on memo being empty on msg transfer.

---------

Co-authored-by: Carlos Rodriguez <[email protected]>

* feat: allow authz granters to specify forwarding info for token transfer (#6661)

* First attempt to modify proto and validation.

* Fmt

* Make it compile

* Proto

* Add basic validation

* Added tests

* Fix nil check and remove redundant code.

* Move "forwarding" to non-pointer

* Added one test case.

* Moved error and changed method name.

* PR Feedback.

* Add nullable=false

* Added test and fixed test names

* Run make proto-all

* Change pointer to non-pointer

* Change Yet Another Pointer

* More pointers

* Comments and naming

* Reintroduce brace removed while merging

* Remove accidentally reintroduced tests

* feat: delete forwarded packet when it is not needed anymore  (#6621)

* Create ontimeoutpacket test for forwarding

* Propagate ack on A

* Refactoring

* Minor changes

* Added comments

* Fix type name.

* Gofumpt

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

Co-authored-by: Carlos Rodriguez <[email protected]>

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

Co-authored-by: Carlos Rodriguez <[email protected]>

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

Co-authored-by: Carlos Rodriguez <[email protected]>

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

Co-authored-by: Carlos Rodriguez <[email protected]>

* Add godoc to test.

* Changed trace construction

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

Co-authored-by: Carlos Rodriguez <[email protected]>

* remove error msg parameter from helper function

* Add test for forwarded packet

* Delete packet when not needed anymore.

* Move deletion of packet in a single place.

* Reintroduce newline

* Do not ignore error.

* PR feedback.

* Construct packet for B ack check.

* PR feedback

* Pass packet to acknowledgeforwardedpacket

* revert unwanted change

* Another unwanted change

* Better signature and fix source/dest

* Added one more test.

---------

Co-authored-by: Carlos Rodriguez <[email protected]>
Co-authored-by: Gjermund Garaba <[email protected]>

* test(transfer): forwarding acknowledgment errors in middle hop (#6659)

* test(transfer): forwarding where middle chaind is source for receive and send

* Fix errors after merge

* Finish up the test

* Update some out-of-date comments

* test(transfer): multi-hop ack failure with middle chain NOT being source

* Fix tests after height change

* Fix tests after height change

* Fix test after #6586

* Rename tests to not use scenario numbers

* Rename test

* address self-review comments

* use boolean in NewForwarding parameter

* some more review comments

---------

Co-authored-by: Carlos Rodriguez <[email protected]>

* test(transfer): last chain in forwarding packet is ICS20 v1 (#6622)

* test(transfer): last chain in forwarding being ICS20 v1

* Finish TestForwarding_WithLastChainBeingICS20v1_Succeeds

* Update CreateNewPath signature

Co-authored-by: Nikolas De Giorgis <[email protected]>

* Fix PR review comments

---------

Co-authored-by: Nikolas De Giorgis <[email protected]>

* refactor: rename SetupPath to SetupPaths (#6674)

* chore: add flag for unwind in transfer cli (#6680)

* add flag for unwind in transfer cli

* update long description of cli

---------

Co-authored-by: Carlos Rodriguez <[email protected]>

* feat: impl check reject transfer if len(hops) > 0 and ics20-1 (#6675)

* impl check reject transfer if len(hops) > 0 and ics20-1

* add test case hops is not empty with ics20-2

* address review comments

* reorder variable declaration

---------

Co-authored-by: Carlos Rodriguez <[email protected]>
Co-authored-by: Gjermund Garaba <[email protected]>

* feat(transfer): add unwinding ability (#6656)

* Create ontimeoutpacket test for forwarding

* Propagate ack on A

* Refactoring

* Minor changes

* Added comments

* Fix type name.

* Gofumpt

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

Co-authored-by: Carlos Rodriguez <[email protected]>

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

Co-authored-by: Carlos Rodriguez <[email protected]>

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

Co-authored-by: Carlos Rodriguez <[email protected]>

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

Co-authored-by: Carlos Rodriguez <[email protected]>

* Add godoc to test.

* Changed trace construction

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

Co-authored-by: Carlos Rodriguez <[email protected]>

* remove error msg parameter from helper function

* Add test for forwarded packet

* Construct packet for B ack check.

* PR feedback

* feat(transfer): add unwind, refactor proto structure. gen-all

* tests(transfer/types): fix test failures in types tests.

* tests(transfer/keeper): fix test failures in keeper tests.

* cli(transfer): fix cli usage. pending flag for unwind.

* tests(callbacks): fix failing tests in callbacks.

* tests(transfer/internal): fix failures in internal package.

* tests(transfer): fix test failures in top level tranfer package.

* tests(ica/host/keeper): fix repr of msg transfer in ica host msg execution.

* lint(all): lint this bad boy

* chore(transfer/types): amend validation for MsgTransfer's ShouldBeForwarded, add tests for ForwardedPacketData, minor nits.

* nit(self): only pass relevant fields to create packet data; minor comment improvement.

* Apply suggestions from code review

Co-authored-by: Carlos Rodriguez <[email protected]>

* chore(merge): fix merge issues.

* chore(proto): mention optional nature of fields.

* memo: do not drop it

* validation: drop requirement on memo being empty on msg transfer.

* feat(transfer): add unwinding ability, wip.

* Added unwind to allocation forwarding.

* Add tests and move some validation

* Missing import

* Fixed validation and added test

* PR Feedback

* Return nil when returning an error.

* Cleaner comment

* Add test case for multiple hos

---------

Co-authored-by: bznein <[email protected]>
Co-authored-by: Nikolas De Giorgis <[email protected]>
Co-authored-by: Carlos Rodriguez <[email protected]>

* fix typo

* remove unnecessary wrapping of function

* Revert "remove unnecessary wrapping of function"

This reverts commit c2a6bc6.

* fix usage of function

* (chore) replace reflect.DeepEqual with slices.Equal (#6697)

* Replace reflect.DeepEqual with slices.Equal

* Nit formatting

* chore: comment hop slicing for clarity (#6702)

Co-authored-by: Carlos Rodriguez <[email protected]>

* chore: cleanup forwarding tests (#6691)

* chore: cleanup forwarding tests

* lint

* fix

---------

Co-authored-by: Nikolas De Giorgis <[email protected]>
Co-authored-by: Gjermund Garaba <[email protected]>

* chore: pull out hop validation and consolidate for transfer+packet (#6695)

* chore: pull out hop validation and consolidate transfer+packet

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

Co-authored-by: Carlos Rodriguez <[email protected]>

* cr fixes

---------

Co-authored-by: Carlos Rodriguez <[email protected]>

* Remove unwind field in authz (#6701)

* chore: remove unwind field in authz

* chore: remove duplicate test

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

Co-authored-by: Carlos Rodriguez <[email protected]>

---------

Co-authored-by: Carlos Rodriguez <[email protected]>

* chore: add packet data validation back (#6704)

* (chore) Refactor code around forwarding validation (#6706)

* Refactor validation

* Fixed verification logic, added two tests

* Fix check for unwind

* removed unneeded indirection

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

Co-authored-by: DimitrisJim <[email protected]>

* Add docstring.

---------

Co-authored-by: Gjermund Garaba <[email protected]>
Co-authored-by: DimitrisJim <[email protected]>

* use setupForwardingPaths in test

* feat(transfer): allow non-cosmos-sdk AccAddress in final receiver for forwarded packets (#6709)

* allow non-cosmos-sdk AccAddress for forwarded packets

* cr fixes

* chore: pass only hops to sendTransfer + events rename (#6703)

Co-authored-by: Carlos Rodriguez <[email protected]>

* test: forwarding test that verifies forwarded memo (#6707)

* test: forwarding with memo

* fix test

* cr fixes

* chore: update godoc for relay forwarding tests

* chore: use module account instead of custom forward address (#6688)

* chore: use module account instead of custom forward address

* pull blocked addr checker into keeper method

* lint

* clean up IsBlockedAddr

* chore: replace continue with if/else (#6700)

Co-authored-by: Nikolas De Giorgis <[email protected]>

* add changelog

* add test for invalid receiver address

* Update CHANGELOG.md

* Update CHANGELOG.md

* make getForwardedPacket private

* remove auxiliary burn coins function

* nit: rename func method recv args in types/forwarding.go

* chore: rename ShouldBeForwarded to HasFowarding

* e2e: remove template test for three chain setup.

* nit: no generics silly

* nit: add clarifying comment to validate basic call on msg.

* nit: remove unused key.

* nit: clean up cli help text.

* nit: don't export is blocked address helper.

* nit: docustring for e2e test and helper.

* nit: improve documentation for transfer's OnRecv callback.

Co-authored-by: Damian Nolan <[email protected]>

* Apply suggestions from code review

Co-authored-by: Aditya <[email protected]>

* chore: remove unused function

* perf: allocate slice to length of packet data tokens

* chore(transfer/authz): wrapf unauthorized forwarding hops

* lint

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

Co-authored-by: DimitrisJim <[email protected]>

* Preallocate slice but keep len==0 (#6725)

* imp: validate allowed forwarding hops

* test: unwind fails in Transfer rpc

---------

Co-authored-by: Charly <[email protected]>
Co-authored-by: Carlos Rodriguez <[email protected]>
Co-authored-by: Charly <[email protected]>
Co-authored-by: Stefano Angieri <[email protected]>
Co-authored-by: sangier <[email protected]>
Co-authored-by: Colin Axnér <[email protected]>
Co-authored-by: DimitrisJim <[email protected]>
Co-authored-by: Hastur <[email protected]>
Co-authored-by: Damian Nolan <[email protected]>
Co-authored-by: Gjermund Garaba <[email protected]>
Co-authored-by: srdtrk <[email protected]>
Co-authored-by: Maintain <[email protected]>
Co-authored-by: srdtrk <[email protected]>
Co-authored-by: Nikolas De Giorgis <[email protected]>
Co-authored-by: Gjermund Garaba <[email protected]>
Co-authored-by: Dzung Do | Decentrio <[email protected]>
Co-authored-by: bznein <[email protected]>
Co-authored-by: Aditya <[email protected]>
github-merge-queue bot pushed a commit that referenced this pull request Jun 28, 2024
* Adding proto files for ics20-v2 (#6110)

* chore: adding proto files for ics20-v2

* chore: add newline

* update amount -> string (#6120)

* Update MsgTransfer to accept sdk.Coins instead of sdk.Coin (#6113)

* fix: allow base denom with trailing slash (#6148)

* imp: add CurrentVersion, EscrowVersion (#6160)

* add CurrentVersion, EscrowVersion, update tests

* update hardcoded transfer channel version from interchaintest

* chore: add function for converting packet data from v1 to v3 (#6116)

---------

Co-authored-by: Charly <[email protected]>

* chore: implement required `FungibleTokenPacketData` v3 interface methods (#6126)

* imp: `getMultiDenomFungibleTokenPacketData`to be used in packet unmarshalling/conversion (#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 <[email protected]>
Co-authored-by: Carlos Rodriguez <[email protected]>

* chore: implement version checking for channel handshake application callbacks (#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 <[email protected]>

* imp: update transfer authz implementation to account for multi denom transfers (#6252)

* add transfer authz code + tests

* linter

* address review comments

---------

Co-authored-by: Carlos Rodriguez <[email protected]>

* ics20-v2: backwards compatibility for transfer rpc and packet callbacks (#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 <[email protected]>
Co-authored-by: Charly <[email protected]>

* add v3 packet proto

* fix protos

* fixes

* test fixes

* add forwardPath keys and memo check in sendTransfer

* wip onRecvPacket logic

* minor fixes

* changes to transfer tx CLI to support multiple denoms

* import renaming

* onRecv logic completed

* add revertInFlights function

* add onAck && onTimeout logic

* fix interchain accounts test

* basic unit test for path forwarding

* fix test unsuccessful refund from source

* wip test fix

* fix mbt test - need more investigation

* revert test fix

* add assertions

* add support for async ack

* wip test forwarding happy path

* icsv20(path forwarding): use nil as default forwarding path when not set, use sequence in key to store forwarded packet (#6325)

* use nil forwarding path as default when not set, use sequence in key to store forwarded packet

* lint

* add forwarding happy path tests

* fix merge

* Use type with V2 suffix for package data (#6330)

* Adding additional comments and changing version variable names (#6345)

* chore: correctly claim capability

* lint

* imp: change ics20 events to emit token set (#6348)

* refactor: quick change to tokens event attribute

* fix: various tests

* lint

* lint:fixeroni

* imp: remove events variable in favour of direct event emission

---------

Co-authored-by: DimitrisJim <[email protected]>

* imp: check length tokens array against maximum allowed (#6349)

* check length of tokens array against maximum allowed

* chore: add note on arbitrary selection

---------

Co-authored-by: Colin Axnér <[email protected]>

* Modify UnmarshalPacketData interface to allow additional args (#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.

* Refactor packet data unmarshalling to use specific version (#6354)

* 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 <[email protected]>
Co-authored-by: Colin Axnér <[email protected]>

* chore: fixing tests

* imp: self review comments for ics20-v2 (#6360)

* refactor: address various self review comments

* revert: unnecessary change

* lint

* imp: self review on ics20-v2 part 2 (#6364)

* refactor: apply review suggestions

* imp: additional updates

* refactor: make ValidateIBCDenom private

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

Co-authored-by: Cian Hatton <[email protected]>

* apply review suggestions

---------

Co-authored-by: Cian Hatton <[email protected]>

* chore: move functions from internal/denom back to trace.go (#6368)

* chore: move functions from internal/denom to trace.go

* lint

* lint: the comeback

* imp: ics20 v2 self review part 3 (#6373)

* 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

* chore: remove duplicate test case

* chore: address minor nits (#6374)

* fix lint warning, add extra godocs, and some other small fixes and cleanup

* fix finalReceiver address bug

* wip - ack test scenario5

* add FungibleTokenPacketDataV2 test for ValidateBasic (#6398)

* fix linter complaints

* add test - currently faling on middle hop revert

* add test comments

* fixes

* retrieve channel capability only if there is a previous packet in store

* add missing parameter

* fix: e2e build failures.

* Use Transfer instead of sendTransfer when forwarding. (#6564)

Pass nil as the next forwarding path if at final hop.
Use consistent timeout for all hops.

* lint: fix linter issues.

* tests(transfer): move forwarding tests to separate file. (#6568)

* chore: rename ForwardingInfo to Forwarding

* Revert "chore: rename ForwardingInfo to Forwarding"

This reverts commit e483b9a.

* nit(transfer): Mark hops as non nullable. (#6566)

* nit(transfer): Mark hops as non nullable.

* lint: fix additional linting issues

* feat(transfer): add forwarding info validation to token packet (#6571)

* feat(transfer): add forwarding info validation to token packet

* Added NewForwardingInfo constructor

* Removed redundant check

* Clean up tests per cr comments

* Back to Validate and use NewDenom

* feat(transfer): add validation for forwarding info in msg transfer validate basic (#6583)

* Fix and simplify reverts of forwarding state (#6574)

* refactor: initial simplification attempt

* refactor: further organize

* fix: all tests fixed

* docs: improved godocs

* fix: logic and testing error

* style: self suggestion

* docs: suggestion

* docs: spellcheck

* style: suggestions

* style: renamed to revertForwardedPacket

* style: suggestion

* docs: remove docs

* docs: godoc suggestion

* style: suggestion

* docs: colin suggestions

* chore: rename ForwardingInfo to Forwarding (#6576)

* chore: rename ForwardingInfo to Forwarding

* chore: rename forwarding_path field to forwarding

* chore: make lint-fix

* chore: rename forwarding info -> forwarding

* chore: renaming fixes before merge

* Refactor packet forward functions (#6575)

* feat(transfer): validate forwarding memo in transfer authorization (#6591)

* Add func convert token to coin ibc (#6584)

* add func convert token to coin ibc

* fix command: change func to ToCoin and add godoc

* add unit test

* Revert using ToCoin on Recv where trace manipulation occurs.
Use ToCoin while forwarding.
Update tests as per Carlos's review.

* rename variable

---------

Co-authored-by: Carlos Rodriguez <[email protected]>
Co-authored-by: DimitrisJim <[email protected]>

* transfer: Disallow a forwarding object specified with zero hops and a memo (#6599)

* transfer: Disallow a forwarding object specified with zero hops and a memo.

* Apply suggestions from code review

Co-authored-by: Carlos Rodriguez <[email protected]>

---------

Co-authored-by: Carlos Rodriguez <[email protected]>
Co-authored-by: Gjermund Garaba <[email protected]>

* feat(transfer): move async decision and handling to the ibc module onrecv callback (#6592)

* refactor: initial simplification attempt

* refactor: further organize

* fix: all tests fixed

* chore: refactor packet forward functions

* chore: use receiver address directly in msg transfer

* feat(transfer): move async to ibc_module for onrecv

* chore: fix linter

* fix: logic and testing error

* style: self suggestion

* docs: suggestion

* docs: spellcheck

* style: suggestions

* style: renamed to revertForwardedPacket

* style: suggestion

* docs: remove docs

* Added tests for transfer OnRecv

* Use new names and methods from feature branch

* Apply suggestions from code review

Co-authored-by: colin axnér <[email protected]>

* Clean up test from cr feedback

* move vars to beginning of function

* lint

* Update modules/apps/transfer/ibc_module.go

Co-authored-by: Carlos Rodriguez <[email protected]>

* lint

---------

Co-authored-by: srdtrk <[email protected]>
Co-authored-by: chatton <[email protected]>
Co-authored-by: colin axnér <[email protected]>
Co-authored-by: Carlos Rodriguez <[email protected]>
Co-authored-by: DimitrisJim <[email protected]>

* chore: use NewForwarding instead of direct init (#6605)

* Reduce max forwarding to 16 (#6610)

* feat(transfer): use single byte ack for successful forward (#6604)

Co-authored-by: Nikolas De Giorgis <[email protected]>

* chore(transfer/cli): add forwarding flag to tx cli (#6609)

Co-authored-by: Carlos Rodriguez <[email protected]>

* chore(transfer): make Forwarding non-null (#6618)

* chore(transfer): make Forwarding non-null

* chore(transfer): always validate forwarding.

* chore: restructure functions with logical ordering (#6638)

* test: Add tests for OnTimeoutPacket when middle chain times out packet  (#6596)

* Create ontimeoutpacket test for forwarding

---------

Co-authored-by: Carlos Rodriguez <[email protected]>

* feat(transfer): add ShouldBeForwarded convenience method to msg transfer (#6595)

* feat(transfer): add should-be-forwarded convenience method to msg transfer

* Clean up packet and transfer msg validation for forwarding logic

---------

Co-authored-by: Carlos Rodriguez <[email protected]>

* disallow timeout height usage when forwarding packets (#6641)

* disallow non-zero timeout height when forwarding tokens

* typo

* move constant

* use time to create default timeout timestamp delta

* Apply suggestions from code review

* refactor: add GetTimeoutTimestamp helper fn to the testing pkg

* lint

---------

Co-authored-by: colin axnér <[email protected]>

* nit: make set forwarded packet unexported (#6637)

Co-authored-by: Gjermund Garaba <[email protected]>
Co-authored-by: colin axnér <[email protected]>

* feat(transfer): use registered error code for error acks in token forwarding (#6648)

* Add typed errors to packet forwarding

* Use forward errors in tests

* Make ack construction consistent

* chore(transfer): emit forwarding information in events. (#6647)

* chore(transfer): emit forwarding information in events.

* nit: rename as per Carlos's suggestion

* Fix e2e test

* Refactor forwarding messages for Transfer and Packet (#6655)

* feat(transfer): add unwind, refactor proto structure. gen-all

* tests(transfer/types): fix test failures in types tests.

* tests(transfer/keeper): fix test failures in keeper tests.

* cli(transfer): fix cli usage. pending flag for unwind.

* tests(callbacks): fix failing tests in callbacks.

* tests(transfer/internal): fix failures in internal package.

* tests(transfer): fix test failures in top level tranfer package.

* tests(ica/host/keeper): fix repr of msg transfer in ica host msg execution.

* lint(all): lint this bad boy

* chore(transfer/types): amend validation for MsgTransfer's ShouldBeForwarded, add tests for ForwardedPacketData, minor nits.

* nit(self): only pass relevant fields to create packet data; minor comment improvement.

* Apply suggestions from code review

Co-authored-by: Carlos Rodriguez <[email protected]>

* chore(merge): fix merge issues.

* chore(proto): mention optional nature of fields.

* memo: do not drop it

* validation: drop requirement on memo being empty on msg transfer.

---------

Co-authored-by: Carlos Rodriguez <[email protected]>

* feat: allow authz granters to specify forwarding info for token transfer (#6661)

* First attempt to modify proto and validation.

* Fmt

* Make it compile

* Proto

* Add basic validation

* Added tests

* Fix nil check and remove redundant code.

* Move "forwarding" to non-pointer

* Added one test case.

* Moved error and changed method name.

* PR Feedback.

* Add nullable=false

* Added test and fixed test names

* Run make proto-all

* Change pointer to non-pointer

* Change Yet Another Pointer

* More pointers

* Comments and naming

* Reintroduce brace removed while merging

* Remove accidentally reintroduced tests

* feat: delete forwarded packet when it is not needed anymore  (#6621)

* Create ontimeoutpacket test for forwarding

* Propagate ack on A

* Refactoring

* Minor changes

* Added comments

* Fix type name.

* Gofumpt

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

Co-authored-by: Carlos Rodriguez <[email protected]>

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

Co-authored-by: Carlos Rodriguez <[email protected]>

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

Co-authored-by: Carlos Rodriguez <[email protected]>

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

Co-authored-by: Carlos Rodriguez <[email protected]>

* Add godoc to test.

* Changed trace construction

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

Co-authored-by: Carlos Rodriguez <[email protected]>

* remove error msg parameter from helper function

* Add test for forwarded packet

* Delete packet when not needed anymore.

* Move deletion of packet in a single place.

* Reintroduce newline

* Do not ignore error.

* PR feedback.

* Construct packet for B ack check.

* PR feedback

* Pass packet to acknowledgeforwardedpacket

* revert unwanted change

* Another unwanted change

* Better signature and fix source/dest

* Added one more test.

---------

Co-authored-by: Carlos Rodriguez <[email protected]>
Co-authored-by: Gjermund Garaba <[email protected]>

* test(transfer): forwarding acknowledgment errors in middle hop (#6659)

* test(transfer): forwarding where middle chaind is source for receive and send

* Fix errors after merge

* Finish up the test

* Update some out-of-date comments

* test(transfer): multi-hop ack failure with middle chain NOT being source

* Fix tests after height change

* Fix tests after height change

* Fix test after #6586

* Rename tests to not use scenario numbers

* Rename test

* address self-review comments

* use boolean in NewForwarding parameter

* some more review comments

---------

Co-authored-by: Carlos Rodriguez <[email protected]>

* test(transfer): last chain in forwarding packet is ICS20 v1 (#6622)

* test(transfer): last chain in forwarding being ICS20 v1

* Finish TestForwarding_WithLastChainBeingICS20v1_Succeeds

* Update CreateNewPath signature

Co-authored-by: Nikolas De Giorgis <[email protected]>

* Fix PR review comments

---------

Co-authored-by: Nikolas De Giorgis <[email protected]>

* refactor: rename SetupPath to SetupPaths (#6674)

* chore: add flag for unwind in transfer cli (#6680)

* add flag for unwind in transfer cli

* update long description of cli

---------

Co-authored-by: Carlos Rodriguez <[email protected]>

* feat: impl check reject transfer if len(hops) > 0 and ics20-1 (#6675)

* impl check reject transfer if len(hops) > 0 and ics20-1

* add test case hops is not empty with ics20-2

* address review comments

* reorder variable declaration

---------

Co-authored-by: Carlos Rodriguez <[email protected]>
Co-authored-by: Gjermund Garaba <[email protected]>

* feat(transfer): add unwinding ability (#6656)

* Create ontimeoutpacket test for forwarding

* Propagate ack on A

* Refactoring

* Minor changes

* Added comments

* Fix type name.

* Gofumpt

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

Co-authored-by: Carlos Rodriguez <[email protected]>

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

Co-authored-by: Carlos Rodriguez <[email protected]>

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

Co-authored-by: Carlos Rodriguez <[email protected]>

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

Co-authored-by: Carlos Rodriguez <[email protected]>

* Add godoc to test.

* Changed trace construction

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

Co-authored-by: Carlos Rodriguez <[email protected]>

* remove error msg parameter from helper function

* Add test for forwarded packet

* Construct packet for B ack check.

* PR feedback

* feat(transfer): add unwind, refactor proto structure. gen-all

* tests(transfer/types): fix test failures in types tests.

* tests(transfer/keeper): fix test failures in keeper tests.

* cli(transfer): fix cli usage. pending flag for unwind.

* tests(callbacks): fix failing tests in callbacks.

* tests(transfer/internal): fix failures in internal package.

* tests(transfer): fix test failures in top level tranfer package.

* tests(ica/host/keeper): fix repr of msg transfer in ica host msg execution.

* lint(all): lint this bad boy

* chore(transfer/types): amend validation for MsgTransfer's ShouldBeForwarded, add tests for ForwardedPacketData, minor nits.

* nit(self): only pass relevant fields to create packet data; minor comment improvement.

* Apply suggestions from code review

Co-authored-by: Carlos Rodriguez <[email protected]>

* chore(merge): fix merge issues.

* chore(proto): mention optional nature of fields.

* memo: do not drop it

* validation: drop requirement on memo being empty on msg transfer.

* feat(transfer): add unwinding ability, wip.

* Added unwind to allocation forwarding.

* Add tests and move some validation

* Missing import

* Fixed validation and added test

* PR Feedback

* Return nil when returning an error.

* Cleaner comment

* Add test case for multiple hos

---------

Co-authored-by: bznein <[email protected]>
Co-authored-by: Nikolas De Giorgis <[email protected]>
Co-authored-by: Carlos Rodriguez <[email protected]>

* fix typo

* remove unnecessary wrapping of function

* Revert "remove unnecessary wrapping of function"

This reverts commit c2a6bc6.

* fix usage of function

* (chore) replace reflect.DeepEqual with slices.Equal (#6697)

* Replace reflect.DeepEqual with slices.Equal

* Nit formatting

* chore: comment hop slicing for clarity (#6702)

Co-authored-by: Carlos Rodriguez <[email protected]>

* chore: cleanup forwarding tests (#6691)

* chore: cleanup forwarding tests

* lint

* fix

---------

Co-authored-by: Nikolas De Giorgis <[email protected]>
Co-authored-by: Gjermund Garaba <[email protected]>

* chore: pull out hop validation and consolidate for transfer+packet (#6695)

* chore: pull out hop validation and consolidate transfer+packet

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

Co-authored-by: Carlos Rodriguez <[email protected]>

* cr fixes

---------

Co-authored-by: Carlos Rodriguez <[email protected]>

* Remove unwind field in authz (#6701)

* chore: remove unwind field in authz

* chore: remove duplicate test

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

Co-authored-by: Carlos Rodriguez <[email protected]>

---------

Co-authored-by: Carlos Rodriguez <[email protected]>

* chore: add packet data validation back (#6704)

* (chore) Refactor code around forwarding validation (#6706)

* Refactor validation

* Fixed verification logic, added two tests

* Fix check for unwind

* removed unneeded indirection

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

Co-authored-by: DimitrisJim <[email protected]>

* Add docstring.

---------

Co-authored-by: Gjermund Garaba <[email protected]>
Co-authored-by: DimitrisJim <[email protected]>

* use setupForwardingPaths in test

* feat(transfer): allow non-cosmos-sdk AccAddress in final receiver for forwarded packets (#6709)

* allow non-cosmos-sdk AccAddress for forwarded packets

* cr fixes

* chore: pass only hops to sendTransfer + events rename (#6703)

Co-authored-by: Carlos Rodriguez <[email protected]>

* test: forwarding test that verifies forwarded memo (#6707)

* test: forwarding with memo

* fix test

* cr fixes

* chore: update godoc for relay forwarding tests

* chore: use module account instead of custom forward address (#6688)

* chore: use module account instead of custom forward address

* pull blocked addr checker into keeper method

* lint

* clean up IsBlockedAddr

* Test for four chains!

* chore: replace continue with if/else (#6700)

Co-authored-by: Nikolas De Giorgis <[email protected]>

* add changelog

* Propagate ack.

* Check error

* Removed helper

* add test for invalid receiver address

* Update CHANGELOG.md

* Update CHANGELOG.md

* Update CHANGELOG.md

* Update CHANGELOG.md

* make getForwardedPacket private

* remove auxiliary burn coins function

* nit: rename func method recv args in types/forwarding.go

* chore: rename ShouldBeForwarded to HasFowarding

* e2e: remove template test for three chain setup.

* nit: no generics silly

* nit: add clarifying comment to validate basic call on msg.

* nit: remove unused key.

* nit: clean up cli help text.

* nit: don't export is blocked address helper.

* nit: docustring for e2e test and helper.

* nit: improve documentation for transfer's OnRecv callback.

Co-authored-by: Damian Nolan <[email protected]>

* Apply suggestions from code review

Co-authored-by: Aditya <[email protected]>

* chore: remove unused function

* perf: allocate slice to length of packet data tokens

* chore(transfer/authz): wrapf unauthorized forwarding hops

* lint

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

Co-authored-by: DimitrisJim <[email protected]>

* Preallocate slice but keep len==0 (#6725)

* imp: validate allowed forwarding hops

* test: unwind fails in Transfer rpc

---------

Co-authored-by: Cian Hatton <[email protected]>
Co-authored-by: Charly <[email protected]>
Co-authored-by: Carlos Rodriguez <[email protected]>
Co-authored-by: Charly <[email protected]>
Co-authored-by: chatton <[email protected]>
Co-authored-by: Stefano Angieri <[email protected]>
Co-authored-by: sangier <[email protected]>
Co-authored-by: Colin Axnér <[email protected]>
Co-authored-by: DimitrisJim <[email protected]>
Co-authored-by: Hastur <[email protected]>
Co-authored-by: Damian Nolan <[email protected]>
Co-authored-by: Gjermund Garaba <[email protected]>
Co-authored-by: srdtrk <[email protected]>
Co-authored-by: Maintain <[email protected]>
Co-authored-by: srdtrk <[email protected]>
Co-authored-by: Gjermund Garaba <[email protected]>
Co-authored-by: Dzung Do | Decentrio <[email protected]>
Co-authored-by: Aditya <[email protected]>
crodriguezvega added a commit that referenced this pull request Jun 28, 2024
* Adding proto files for ics20-v2 (#6110)

* chore: adding proto files for ics20-v2

* chore: add newline

* update amount -> string (#6120)

* Update MsgTransfer to accept sdk.Coins instead of sdk.Coin (#6113)

* fix: allow base denom with trailing slash (#6148)

* imp: add CurrentVersion, EscrowVersion (#6160)

* add CurrentVersion, EscrowVersion, update tests

* update hardcoded transfer channel version from interchaintest

* chore: add function for converting packet data from v1 to v3 (#6116)

---------

Co-authored-by: Charly <[email protected]>

* chore: implement required `FungibleTokenPacketData` v3 interface methods (#6126)

* imp: `getMultiDenomFungibleTokenPacketData`to be used in packet unmarshalling/conversion (#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 <[email protected]>
Co-authored-by: Carlos Rodriguez <[email protected]>

* chore: implement version checking for channel handshake application callbacks (#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 <[email protected]>

* imp: update transfer authz implementation to account for multi denom transfers (#6252)

* add transfer authz code + tests

* linter

* address review comments

---------

Co-authored-by: Carlos Rodriguez <[email protected]>

* ics20-v2: backwards compatibility for transfer rpc and packet callbacks (#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 <[email protected]>
Co-authored-by: Charly <[email protected]>

* add v3 packet proto

* fix protos

* fixes

* test fixes

* add forwardPath keys and memo check in sendTransfer

* wip onRecvPacket logic

* minor fixes

* changes to transfer tx CLI to support multiple denoms

* import renaming

* onRecv logic completed

* add revertInFlights function

* add onAck && onTimeout logic

* fix interchain accounts test

* basic unit test for path forwarding

* fix test unsuccessful refund from source

* wip test fix

* fix mbt test - need more investigation

* revert test fix

* add assertions

* add support for async ack

* wip test forwarding happy path

* icsv20(path forwarding): use nil as default forwarding path when not set, use sequence in key to store forwarded packet (#6325)

* use nil forwarding path as default when not set, use sequence in key to store forwarded packet

* lint

* add forwarding happy path tests

* fix merge

* Use type with V2 suffix for package data (#6330)

* Adding additional comments and changing version variable names (#6345)

* chore: correctly claim capability

* lint

* imp: change ics20 events to emit token set (#6348)

* refactor: quick change to tokens event attribute

* fix: various tests

* lint

* lint:fixeroni

* imp: remove events variable in favour of direct event emission

---------

Co-authored-by: DimitrisJim <[email protected]>

* imp: check length tokens array against maximum allowed (#6349)

* check length of tokens array against maximum allowed

* chore: add note on arbitrary selection

---------

Co-authored-by: Colin Axnér <[email protected]>

* Modify UnmarshalPacketData interface to allow additional args (#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.

* Refactor packet data unmarshalling to use specific version (#6354)

* 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 <[email protected]>
Co-authored-by: Colin Axnér <[email protected]>

* chore: fixing tests

* imp: self review comments for ics20-v2 (#6360)

* refactor: address various self review comments

* revert: unnecessary change

* lint

* imp: self review on ics20-v2 part 2 (#6364)

* refactor: apply review suggestions

* imp: additional updates

* refactor: make ValidateIBCDenom private

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

Co-authored-by: Cian Hatton <[email protected]>

* apply review suggestions

---------

Co-authored-by: Cian Hatton <[email protected]>

* chore: move functions from internal/denom back to trace.go (#6368)

* chore: move functions from internal/denom to trace.go

* lint

* lint: the comeback

* imp: ics20 v2 self review part 3 (#6373)

* 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

* chore: remove duplicate test case

* chore: address minor nits (#6374)

* fix lint warning, add extra godocs, and some other small fixes and cleanup

* fix finalReceiver address bug

* wip - ack test scenario5

* add FungibleTokenPacketDataV2 test for ValidateBasic (#6398)

* fix linter complaints

* add test - currently faling on middle hop revert

* add test comments

* fixes

* retrieve channel capability only if there is a previous packet in store

* add missing parameter

* fix: e2e build failures.

* Use Transfer instead of sendTransfer when forwarding. (#6564)

Pass nil as the next forwarding path if at final hop.
Use consistent timeout for all hops.

* lint: fix linter issues.

* tests(transfer): move forwarding tests to separate file. (#6568)

* chore: rename ForwardingInfo to Forwarding

* Revert "chore: rename ForwardingInfo to Forwarding"

This reverts commit e483b9a.

* nit(transfer): Mark hops as non nullable. (#6566)

* nit(transfer): Mark hops as non nullable.

* lint: fix additional linting issues

* feat(transfer): add forwarding info validation to token packet (#6571)

* feat(transfer): add forwarding info validation to token packet

* Added NewForwardingInfo constructor

* Removed redundant check

* Clean up tests per cr comments

* Back to Validate and use NewDenom

* feat(transfer): add validation for forwarding info in msg transfer validate basic (#6583)

* Fix and simplify reverts of forwarding state (#6574)

* refactor: initial simplification attempt

* refactor: further organize

* fix: all tests fixed

* docs: improved godocs

* fix: logic and testing error

* style: self suggestion

* docs: suggestion

* docs: spellcheck

* style: suggestions

* style: renamed to revertForwardedPacket

* style: suggestion

* docs: remove docs

* docs: godoc suggestion

* style: suggestion

* docs: colin suggestions

* chore: rename ForwardingInfo to Forwarding (#6576)

* chore: rename ForwardingInfo to Forwarding

* chore: rename forwarding_path field to forwarding

* chore: make lint-fix

* chore: rename forwarding info -> forwarding

* chore: renaming fixes before merge

* Refactor packet forward functions (#6575)

* feat(transfer): validate forwarding memo in transfer authorization (#6591)

* Add func convert token to coin ibc (#6584)

* add func convert token to coin ibc

* fix command: change func to ToCoin and add godoc

* add unit test

* Revert using ToCoin on Recv where trace manipulation occurs.
Use ToCoin while forwarding.
Update tests as per Carlos's review.

* rename variable

---------

Co-authored-by: Carlos Rodriguez <[email protected]>
Co-authored-by: DimitrisJim <[email protected]>

* transfer: Disallow a forwarding object specified with zero hops and a memo (#6599)

* transfer: Disallow a forwarding object specified with zero hops and a memo.

* Apply suggestions from code review

Co-authored-by: Carlos Rodriguez <[email protected]>

---------

Co-authored-by: Carlos Rodriguez <[email protected]>
Co-authored-by: Gjermund Garaba <[email protected]>

* feat(transfer): move async decision and handling to the ibc module onrecv callback (#6592)

* refactor: initial simplification attempt

* refactor: further organize

* fix: all tests fixed

* chore: refactor packet forward functions

* chore: use receiver address directly in msg transfer

* feat(transfer): move async to ibc_module for onrecv

* chore: fix linter

* fix: logic and testing error

* style: self suggestion

* docs: suggestion

* docs: spellcheck

* style: suggestions

* style: renamed to revertForwardedPacket

* style: suggestion

* docs: remove docs

* Added tests for transfer OnRecv

* Use new names and methods from feature branch

* Apply suggestions from code review

Co-authored-by: colin axnér <[email protected]>

* Clean up test from cr feedback

* move vars to beginning of function

* lint

* Update modules/apps/transfer/ibc_module.go

Co-authored-by: Carlos Rodriguez <[email protected]>

* lint

---------

Co-authored-by: srdtrk <[email protected]>
Co-authored-by: chatton <[email protected]>
Co-authored-by: colin axnér <[email protected]>
Co-authored-by: Carlos Rodriguez <[email protected]>
Co-authored-by: DimitrisJim <[email protected]>

* chore: use NewForwarding instead of direct init (#6605)

* Reduce max forwarding to 16 (#6610)

* feat(transfer): use single byte ack for successful forward (#6604)

Co-authored-by: Nikolas De Giorgis <[email protected]>

* chore(transfer/cli): add forwarding flag to tx cli (#6609)

Co-authored-by: Carlos Rodriguez <[email protected]>

* chore(transfer): make Forwarding non-null (#6618)

* chore(transfer): make Forwarding non-null

* chore(transfer): always validate forwarding.

* chore: restructure functions with logical ordering (#6638)

* test: Add tests for OnTimeoutPacket when middle chain times out packet  (#6596)

* Create ontimeoutpacket test for forwarding

---------

Co-authored-by: Carlos Rodriguez <[email protected]>

* feat(transfer): add ShouldBeForwarded convenience method to msg transfer (#6595)

* feat(transfer): add should-be-forwarded convenience method to msg transfer

* Clean up packet and transfer msg validation for forwarding logic

---------

Co-authored-by: Carlos Rodriguez <[email protected]>

* disallow timeout height usage when forwarding packets (#6641)

* disallow non-zero timeout height when forwarding tokens

* typo

* move constant

* use time to create default timeout timestamp delta

* Apply suggestions from code review

* refactor: add GetTimeoutTimestamp helper fn to the testing pkg

* lint

---------

Co-authored-by: colin axnér <[email protected]>

* nit: make set forwarded packet unexported (#6637)

Co-authored-by: Gjermund Garaba <[email protected]>
Co-authored-by: colin axnér <[email protected]>

* feat(transfer): use registered error code for error acks in token forwarding (#6648)

* Add typed errors to packet forwarding

* Use forward errors in tests

* Make ack construction consistent

* chore(transfer): emit forwarding information in events. (#6647)

* chore(transfer): emit forwarding information in events.

* nit: rename as per Carlos's suggestion

* Fix e2e test

* Refactor forwarding messages for Transfer and Packet (#6655)

* feat(transfer): add unwind, refactor proto structure. gen-all

* tests(transfer/types): fix test failures in types tests.

* tests(transfer/keeper): fix test failures in keeper tests.

* cli(transfer): fix cli usage. pending flag for unwind.

* tests(callbacks): fix failing tests in callbacks.

* tests(transfer/internal): fix failures in internal package.

* tests(transfer): fix test failures in top level tranfer package.

* tests(ica/host/keeper): fix repr of msg transfer in ica host msg execution.

* lint(all): lint this bad boy

* chore(transfer/types): amend validation for MsgTransfer's ShouldBeForwarded, add tests for ForwardedPacketData, minor nits.

* nit(self): only pass relevant fields to create packet data; minor comment improvement.

* Apply suggestions from code review

Co-authored-by: Carlos Rodriguez <[email protected]>

* chore(merge): fix merge issues.

* chore(proto): mention optional nature of fields.

* memo: do not drop it

* validation: drop requirement on memo being empty on msg transfer.

---------

Co-authored-by: Carlos Rodriguez <[email protected]>

* feat: allow authz granters to specify forwarding info for token transfer (#6661)

* First attempt to modify proto and validation.

* Fmt

* Make it compile

* Proto

* Add basic validation

* Added tests

* Fix nil check and remove redundant code.

* Move "forwarding" to non-pointer

* Added one test case.

* Moved error and changed method name.

* PR Feedback.

* Add nullable=false

* Added test and fixed test names

* Run make proto-all

* Change pointer to non-pointer

* Change Yet Another Pointer

* More pointers

* Comments and naming

* Reintroduce brace removed while merging

* Remove accidentally reintroduced tests

* feat: delete forwarded packet when it is not needed anymore  (#6621)

* Create ontimeoutpacket test for forwarding

* Propagate ack on A

* Refactoring

* Minor changes

* Added comments

* Fix type name.

* Gofumpt

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

Co-authored-by: Carlos Rodriguez <[email protected]>

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

Co-authored-by: Carlos Rodriguez <[email protected]>

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

Co-authored-by: Carlos Rodriguez <[email protected]>

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

Co-authored-by: Carlos Rodriguez <[email protected]>

* Add godoc to test.

* Changed trace construction

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

Co-authored-by: Carlos Rodriguez <[email protected]>

* remove error msg parameter from helper function

* Add test for forwarded packet

* Delete packet when not needed anymore.

* Move deletion of packet in a single place.

* Reintroduce newline

* Do not ignore error.

* PR feedback.

* Construct packet for B ack check.

* PR feedback

* Pass packet to acknowledgeforwardedpacket

* revert unwanted change

* Another unwanted change

* Better signature and fix source/dest

* Added one more test.

---------

Co-authored-by: Carlos Rodriguez <[email protected]>
Co-authored-by: Gjermund Garaba <[email protected]>

* test(transfer): forwarding acknowledgment errors in middle hop (#6659)

* test(transfer): forwarding where middle chaind is source for receive and send

* Fix errors after merge

* Finish up the test

* Update some out-of-date comments

* test(transfer): multi-hop ack failure with middle chain NOT being source

* Fix tests after height change

* Fix tests after height change

* Fix test after #6586

* Rename tests to not use scenario numbers

* Rename test

* address self-review comments

* use boolean in NewForwarding parameter

* some more review comments

---------

Co-authored-by: Carlos Rodriguez <[email protected]>

* test(transfer): last chain in forwarding packet is ICS20 v1 (#6622)

* test(transfer): last chain in forwarding being ICS20 v1

* Finish TestForwarding_WithLastChainBeingICS20v1_Succeeds

* Update CreateNewPath signature

Co-authored-by: Nikolas De Giorgis <[email protected]>

* Fix PR review comments

---------

Co-authored-by: Nikolas De Giorgis <[email protected]>

* refactor: rename SetupPath to SetupPaths (#6674)

* chore: add flag for unwind in transfer cli (#6680)

* add flag for unwind in transfer cli

* update long description of cli

---------

Co-authored-by: Carlos Rodriguez <[email protected]>

* feat: impl check reject transfer if len(hops) > 0 and ics20-1 (#6675)

* impl check reject transfer if len(hops) > 0 and ics20-1

* add test case hops is not empty with ics20-2

* address review comments

* reorder variable declaration

---------

Co-authored-by: Carlos Rodriguez <[email protected]>
Co-authored-by: Gjermund Garaba <[email protected]>

* feat(transfer): add unwinding ability (#6656)

* Create ontimeoutpacket test for forwarding

* Propagate ack on A

* Refactoring

* Minor changes

* Added comments

* Fix type name.

* Gofumpt

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

Co-authored-by: Carlos Rodriguez <[email protected]>

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

Co-authored-by: Carlos Rodriguez <[email protected]>

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

Co-authored-by: Carlos Rodriguez <[email protected]>

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

Co-authored-by: Carlos Rodriguez <[email protected]>

* Add godoc to test.

* Changed trace construction

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

Co-authored-by: Carlos Rodriguez <[email protected]>

* remove error msg parameter from helper function

* Add test for forwarded packet

* Construct packet for B ack check.

* PR feedback

* feat(transfer): add unwind, refactor proto structure. gen-all

* tests(transfer/types): fix test failures in types tests.

* tests(transfer/keeper): fix test failures in keeper tests.

* cli(transfer): fix cli usage. pending flag for unwind.

* tests(callbacks): fix failing tests in callbacks.

* tests(transfer/internal): fix failures in internal package.

* tests(transfer): fix test failures in top level tranfer package.

* tests(ica/host/keeper): fix repr of msg transfer in ica host msg execution.

* lint(all): lint this bad boy

* chore(transfer/types): amend validation for MsgTransfer's ShouldBeForwarded, add tests for ForwardedPacketData, minor nits.

* nit(self): only pass relevant fields to create packet data; minor comment improvement.

* Apply suggestions from code review

Co-authored-by: Carlos Rodriguez <[email protected]>

* chore(merge): fix merge issues.

* chore(proto): mention optional nature of fields.

* memo: do not drop it

* validation: drop requirement on memo being empty on msg transfer.

* feat(transfer): add unwinding ability, wip.

* Added unwind to allocation forwarding.

* Add tests and move some validation

* Missing import

* Fixed validation and added test

* PR Feedback

* Return nil when returning an error.

* Cleaner comment

* Add test case for multiple hos

---------

Co-authored-by: bznein <[email protected]>
Co-authored-by: Nikolas De Giorgis <[email protected]>
Co-authored-by: Carlos Rodriguez <[email protected]>

* fix typo

* remove unnecessary wrapping of function

* Revert "remove unnecessary wrapping of function"

This reverts commit c2a6bc6.

* fix usage of function

* imp: replace sender/receiver chain is source with has prefix

* (chore) replace reflect.DeepEqual with slices.Equal (#6697)

* Replace reflect.DeepEqual with slices.Equal

* Nit formatting

* chore: comment hop slicing for clarity (#6702)

Co-authored-by: Carlos Rodriguez <[email protected]>

* chore: cleanup forwarding tests (#6691)

* chore: cleanup forwarding tests

* lint

* fix

---------

Co-authored-by: Nikolas De Giorgis <[email protected]>
Co-authored-by: Gjermund Garaba <[email protected]>

* chore: pull out hop validation and consolidate for transfer+packet (#6695)

* chore: pull out hop validation and consolidate transfer+packet

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

Co-authored-by: Carlos Rodriguez <[email protected]>

* cr fixes

---------

Co-authored-by: Carlos Rodriguez <[email protected]>

* lint

* Remove unwind field in authz (#6701)

* chore: remove unwind field in authz

* chore: remove duplicate test

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

Co-authored-by: Carlos Rodriguez <[email protected]>

---------

Co-authored-by: Carlos Rodriguez <[email protected]>

* chore: add packet data validation back (#6704)

* (chore) Refactor code around forwarding validation (#6706)

* Refactor validation

* Fixed verification logic, added two tests

* Fix check for unwind

* removed unneeded indirection

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

Co-authored-by: DimitrisJim <[email protected]>

* Add docstring.

---------

Co-authored-by: Gjermund Garaba <[email protected]>
Co-authored-by: DimitrisJim <[email protected]>

* use setupForwardingPaths in test

* address review comments

* feat(transfer): allow non-cosmos-sdk AccAddress in final receiver for forwarded packets (#6709)

* allow non-cosmos-sdk AccAddress for forwarded packets

* cr fixes

* chore: pass only hops to sendTransfer + events rename (#6703)

Co-authored-by: Carlos Rodriguez <[email protected]>

* test: forwarding test that verifies forwarded memo (#6707)

* test: forwarding with memo

* fix test

* cr fixes

* chore: update godoc for relay forwarding tests

* chore: use module account instead of custom forward address (#6688)

* chore: use module account instead of custom forward address

* pull blocked addr checker into keeper method

* lint

* clean up IsBlockedAddr

* chore: replace continue with if/else (#6700)

Co-authored-by: Nikolas De Giorgis <[email protected]>

* add migration docs

* add changelog

* add test for invalid receiver address

* Update CHANGELOG.md

* Update CHANGELOG.md

* make getForwardedPacket private

* remove auxiliary burn coins function

* nit: rename func method recv args in types/forwarding.go

* chore: rename ShouldBeForwarded to HasFowarding

* e2e: remove template test for three chain setup.

* nit: no generics silly

* nit: add clarifying comment to validate basic call on msg.

* nit: remove unused key.

* nit: clean up cli help text.

* nit: don't export is blocked address helper.

* nit: docustring for e2e test and helper.

* nit: improve documentation for transfer's OnRecv callback.

Co-authored-by: Damian Nolan <[email protected]>

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

Co-authored-by: colin axnér <[email protected]>

* delete unused file

---------

Co-authored-by: Cian Hatton <[email protected]>
Co-authored-by: Charly <[email protected]>
Co-authored-by: Charly <[email protected]>
Co-authored-by: chatton <[email protected]>
Co-authored-by: Stefano Angieri <[email protected]>
Co-authored-by: sangier <[email protected]>
Co-authored-by: Colin Axnér <[email protected]>
Co-authored-by: DimitrisJim <[email protected]>
Co-authored-by: Hastur <[email protected]>
Co-authored-by: Damian Nolan <[email protected]>
Co-authored-by: Gjermund Garaba <[email protected]>
Co-authored-by: srdtrk <[email protected]>
Co-authored-by: Maintain <[email protected]>
Co-authored-by: srdtrk <[email protected]>
Co-authored-by: Nikolas De Giorgis <[email protected]>
Co-authored-by: Gjermund Garaba <[email protected]>
Co-authored-by: Dzung Do | Decentrio <[email protected]>
Co-authored-by: bznein <[email protected]>
github-merge-queue bot pushed a commit that referenced this pull request Jul 9, 2024
* Adding proto files for ics20-v2 (#6110)

* chore: adding proto files for ics20-v2

* chore: add newline

* update amount -> string (#6120)

* Update MsgTransfer to accept sdk.Coins instead of sdk.Coin (#6113)

* fix: allow base denom with trailing slash (#6148)

* imp: add CurrentVersion, EscrowVersion (#6160)

* add CurrentVersion, EscrowVersion, update tests

* update hardcoded transfer channel version from interchaintest

* chore: add function for converting packet data from v1 to v3 (#6116)

---------

Co-authored-by: Charly <[email protected]>

* chore: implement required `FungibleTokenPacketData` v3 interface methods (#6126)

* imp: `getMultiDenomFungibleTokenPacketData`to be used in packet unmarshalling/conversion (#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 <[email protected]>
Co-authored-by: Carlos Rodriguez <[email protected]>

* chore: implement version checking for channel handshake application callbacks (#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 <[email protected]>

* imp: update transfer authz implementation to account for multi denom transfers (#6252)

* add transfer authz code + tests

* linter

* address review comments

---------

Co-authored-by: Carlos Rodriguez <[email protected]>

* ics20-v2: backwards compatibility for transfer rpc and packet callbacks (#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 <[email protected]>
Co-authored-by: Charly <[email protected]>

* add v3 packet proto

* fix protos

* fixes

* test fixes

* add forwardPath keys and memo check in sendTransfer

* wip onRecvPacket logic

* minor fixes

* changes to transfer tx CLI to support multiple denoms

* import renaming

* onRecv logic completed

* add revertInFlights function

* add onAck && onTimeout logic

* fix interchain accounts test

* basic unit test for path forwarding

* fix test unsuccessful refund from source

* wip test fix

* fix mbt test - need more investigation

* revert test fix

* add assertions

* add support for async ack

* wip test forwarding happy path

* icsv20(path forwarding): use nil as default forwarding path when not set, use sequence in key to store forwarded packet (#6325)

* use nil forwarding path as default when not set, use sequence in key to store forwarded packet

* lint

* add forwarding happy path tests

* fix merge

* Use type with V2 suffix for package data (#6330)

* Adding additional comments and changing version variable names (#6345)

* chore: correctly claim capability

* lint

* imp: change ics20 events to emit token set (#6348)

* refactor: quick change to tokens event attribute

* fix: various tests

* lint

* lint:fixeroni

* imp: remove events variable in favour of direct event emission

---------

Co-authored-by: DimitrisJim <[email protected]>

* imp: check length tokens array against maximum allowed (#6349)

* check length of tokens array against maximum allowed

* chore: add note on arbitrary selection

---------

Co-authored-by: Colin Axnér <[email protected]>

* Modify UnmarshalPacketData interface to allow additional args (#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.

* Refactor packet data unmarshalling to use specific version (#6354)

* 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 <[email protected]>
Co-authored-by: Colin Axnér <[email protected]>

* chore: fixing tests

* imp: self review comments for ics20-v2 (#6360)

* refactor: address various self review comments

* revert: unnecessary change

* lint

* imp: self review on ics20-v2 part 2 (#6364)

* refactor: apply review suggestions

* imp: additional updates

* refactor: make ValidateIBCDenom private

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

Co-authored-by: Cian Hatton <[email protected]>

* apply review suggestions

---------

Co-authored-by: Cian Hatton <[email protected]>

* chore: move functions from internal/denom back to trace.go (#6368)

* chore: move functions from internal/denom to trace.go

* lint

* lint: the comeback

* imp: ics20 v2 self review part 3 (#6373)

* 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

* chore: remove duplicate test case

* chore: address minor nits (#6374)

* fix lint warning, add extra godocs, and some other small fixes and cleanup

* fix finalReceiver address bug

* wip - ack test scenario5

* add FungibleTokenPacketDataV2 test for ValidateBasic (#6398)

* fix linter complaints

* add test - currently faling on middle hop revert

* add test comments

* fixes

* retrieve channel capability only if there is a previous packet in store

* add missing parameter

* fix: e2e build failures.

* Use Transfer instead of sendTransfer when forwarding. (#6564)

Pass nil as the next forwarding path if at final hop.
Use consistent timeout for all hops.

* lint: fix linter issues.

* tests(transfer): move forwarding tests to separate file. (#6568)

* chore: rename ForwardingInfo to Forwarding

* Revert "chore: rename ForwardingInfo to Forwarding"

This reverts commit e483b9a.

* nit(transfer): Mark hops as non nullable. (#6566)

* nit(transfer): Mark hops as non nullable.

* lint: fix additional linting issues

* feat(transfer): add forwarding info validation to token packet (#6571)

* feat(transfer): add forwarding info validation to token packet

* Added NewForwardingInfo constructor

* Removed redundant check

* Clean up tests per cr comments

* Back to Validate and use NewDenom

* feat(transfer): add validation for forwarding info in msg transfer validate basic (#6583)

* Fix and simplify reverts of forwarding state (#6574)

* refactor: initial simplification attempt

* refactor: further organize

* fix: all tests fixed

* docs: improved godocs

* fix: logic and testing error

* style: self suggestion

* docs: suggestion

* docs: spellcheck

* style: suggestions

* style: renamed to revertForwardedPacket

* style: suggestion

* docs: remove docs

* docs: godoc suggestion

* style: suggestion

* docs: colin suggestions

* chore: rename ForwardingInfo to Forwarding (#6576)

* chore: rename ForwardingInfo to Forwarding

* chore: rename forwarding_path field to forwarding

* chore: make lint-fix

* chore: rename forwarding info -> forwarding

* chore: renaming fixes before merge

* Refactor packet forward functions (#6575)

* feat(transfer): validate forwarding memo in transfer authorization (#6591)

* Add func convert token to coin ibc (#6584)

* add func convert token to coin ibc

* fix command: change func to ToCoin and add godoc

* add unit test

* Revert using ToCoin on Recv where trace manipulation occurs.
Use ToCoin while forwarding.
Update tests as per Carlos's review.

* rename variable

---------

Co-authored-by: Carlos Rodriguez <[email protected]>
Co-authored-by: DimitrisJim <[email protected]>

* transfer: Disallow a forwarding object specified with zero hops and a memo (#6599)

* transfer: Disallow a forwarding object specified with zero hops and a memo.

* Apply suggestions from code review

Co-authored-by: Carlos Rodriguez <[email protected]>

---------

Co-authored-by: Carlos Rodriguez <[email protected]>
Co-authored-by: Gjermund Garaba <[email protected]>

* feat(transfer): move async decision and handling to the ibc module onrecv callback (#6592)

* refactor: initial simplification attempt

* refactor: further organize

* fix: all tests fixed

* chore: refactor packet forward functions

* chore: use receiver address directly in msg transfer

* feat(transfer): move async to ibc_module for onrecv

* chore: fix linter

* fix: logic and testing error

* style: self suggestion

* docs: suggestion

* docs: spellcheck

* style: suggestions

* style: renamed to revertForwardedPacket

* style: suggestion

* docs: remove docs

* Added tests for transfer OnRecv

* Use new names and methods from feature branch

* Apply suggestions from code review

Co-authored-by: colin axnér <[email protected]>

* Clean up test from cr feedback

* move vars to beginning of function

* lint

* Update modules/apps/transfer/ibc_module.go

Co-authored-by: Carlos Rodriguez <[email protected]>

* lint

---------

Co-authored-by: srdtrk <[email protected]>
Co-authored-by: chatton <[email protected]>
Co-authored-by: colin axnér <[email protected]>
Co-authored-by: Carlos Rodriguez <[email protected]>
Co-authored-by: DimitrisJim <[email protected]>

* chore: use NewForwarding instead of direct init (#6605)

* Reduce max forwarding to 16 (#6610)

* feat(transfer): use single byte ack for successful forward (#6604)

Co-authored-by: Nikolas De Giorgis <[email protected]>

* chore(transfer/cli): add forwarding flag to tx cli (#6609)

Co-authored-by: Carlos Rodriguez <[email protected]>

* chore(transfer): make Forwarding non-null (#6618)

* chore(transfer): make Forwarding non-null

* chore(transfer): always validate forwarding.

* chore: restructure functions with logical ordering (#6638)

* test: Add tests for OnTimeoutPacket when middle chain times out packet  (#6596)

* Create ontimeoutpacket test for forwarding

---------

Co-authored-by: Carlos Rodriguez <[email protected]>

* feat(transfer): add ShouldBeForwarded convenience method to msg transfer (#6595)

* feat(transfer): add should-be-forwarded convenience method to msg transfer

* Clean up packet and transfer msg validation for forwarding logic

---------

Co-authored-by: Carlos Rodriguez <[email protected]>

* wip: relayer configuration experimentation

* disallow timeout height usage when forwarding packets (#6641)

* disallow non-zero timeout height when forwarding tokens

* typo

* move constant

* use time to create default timeout timestamp delta

* Apply suggestions from code review

* refactor: add GetTimeoutTimestamp helper fn to the testing pkg

* lint

---------

Co-authored-by: colin axnér <[email protected]>

* nit: make set forwarded packet unexported (#6637)

Co-authored-by: Gjermund Garaba <[email protected]>
Co-authored-by: colin axnér <[email protected]>

* feat(transfer): use registered error code for error acks in token forwarding (#6648)

* Add typed errors to packet forwarding

* Use forward errors in tests

* Make ack construction consistent

* chore(transfer): emit forwarding information in events. (#6647)

* chore(transfer): emit forwarding information in events.

* nit: rename as per Carlos's suggestion

* Fix e2e test

* chore: test passing using relayer packet filter

* Refactor forwarding messages for Transfer and Packet (#6655)

* feat(transfer): add unwind, refactor proto structure. gen-all

* tests(transfer/types): fix test failures in types tests.

* tests(transfer/keeper): fix test failures in keeper tests.

* cli(transfer): fix cli usage. pending flag for unwind.

* tests(callbacks): fix failing tests in callbacks.

* tests(transfer/internal): fix failures in internal package.

* tests(transfer): fix test failures in top level tranfer package.

* tests(ica/host/keeper): fix repr of msg transfer in ica host msg execution.

* lint(all): lint this bad boy

* chore(transfer/types): amend validation for MsgTransfer's ShouldBeForwarded, add tests for ForwardedPacketData, minor nits.

* nit(self): only pass relevant fields to create packet data; minor comment improvement.

* Apply suggestions from code review

Co-authored-by: Carlos Rodriguez <[email protected]>

* chore(merge): fix merge issues.

* chore(proto): mention optional nature of fields.

* memo: do not drop it

* validation: drop requirement on memo being empty on msg transfer.

---------

Co-authored-by: Carlos Rodriguez <[email protected]>

* feat: allow authz granters to specify forwarding info for token transfer (#6661)

* First attempt to modify proto and validation.

* Fmt

* Make it compile

* Proto

* Add basic validation

* Added tests

* Fix nil check and remove redundant code.

* Move "forwarding" to non-pointer

* Added one test case.

* Moved error and changed method name.

* PR Feedback.

* Add nullable=false

* Added test and fixed test names

* Run make proto-all

* Change pointer to non-pointer

* Change Yet Another Pointer

* More pointers

* Comments and naming

* Reintroduce brace removed while merging

* Remove accidentally reintroduced tests

* feat: delete forwarded packet when it is not needed anymore  (#6621)

* Create ontimeoutpacket test for forwarding

* Propagate ack on A

* Refactoring

* Minor changes

* Added comments

* Fix type name.

* Gofumpt

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

Co-authored-by: Carlos Rodriguez <[email protected]>

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

Co-authored-by: Carlos Rodriguez <[email protected]>

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

Co-authored-by: Carlos Rodriguez <[email protected]>

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

Co-authored-by: Carlos Rodriguez <[email protected]>

* Add godoc to test.

* Changed trace construction

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

Co-authored-by: Carlos Rodriguez <[email protected]>

* remove error msg parameter from helper function

* Add test for forwarded packet

* Delete packet when not needed anymore.

* Move deletion of packet in a single place.

* Reintroduce newline

* Do not ignore error.

* PR feedback.

* Construct packet for B ack check.

* PR feedback

* Pass packet to acknowledgeforwardedpacket

* revert unwanted change

* Another unwanted change

* Better signature and fix source/dest

* Added one more test.

---------

Co-authored-by: Carlos Rodriguez <[email protected]>
Co-authored-by: Gjermund Garaba <[email protected]>

* test(transfer): forwarding acknowledgment errors in middle hop (#6659)

* test(transfer): forwarding where middle chaind is source for receive and send

* Fix errors after merge

* Finish up the test

* Update some out-of-date comments

* test(transfer): multi-hop ack failure with middle chain NOT being source

* Fix tests after height change

* Fix tests after height change

* Fix test after #6586

* Rename tests to not use scenario numbers

* Rename test

* address self-review comments

* use boolean in NewForwarding parameter

* some more review comments

---------

Co-authored-by: Carlos Rodriguez <[email protected]>

* test(transfer): last chain in forwarding packet is ICS20 v1 (#6622)

* test(transfer): last chain in forwarding being ICS20 v1

* Finish TestForwarding_WithLastChainBeingICS20v1_Succeeds

* Update CreateNewPath signature

Co-authored-by: Nikolas De Giorgis <[email protected]>

* Fix PR review comments

---------

Co-authored-by: Nikolas De Giorgis <[email protected]>

* refactor: rename SetupPath to SetupPaths (#6674)

* chore: configure the hermes config to watch a specific port and channel ID

* chore: add flag for unwind in transfer cli (#6680)

* add flag for unwind in transfer cli

* update long description of cli

---------

Co-authored-by: Carlos Rodriguez <[email protected]>

* chore: small refactor for SetupPath

* chore: adding link to interchaintest issue and doing some cleanup

* chore: adding interchaintest issue link in comment

* chore: merge main

* chore: fix linter

* chore: sync main

* feat: impl check reject transfer if len(hops) > 0 and ics20-1 (#6675)

* impl check reject transfer if len(hops) > 0 and ics20-1

* add test case hops is not empty with ics20-2

* address review comments

* reorder variable declaration

---------

Co-authored-by: Carlos Rodriguez <[email protected]>
Co-authored-by: Gjermund Garaba <[email protected]>

* chore: fix go mod

* feat(transfer): add unwinding ability (#6656)

* Create ontimeoutpacket test for forwarding

* Propagate ack on A

* Refactoring

* Minor changes

* Added comments

* Fix type name.

* Gofumpt

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

Co-authored-by: Carlos Rodriguez <[email protected]>

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

Co-authored-by: Carlos Rodriguez <[email protected]>

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

Co-authored-by: Carlos Rodriguez <[email protected]>

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

Co-authored-by: Carlos Rodriguez <[email protected]>

* Add godoc to test.

* Changed trace construction

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

Co-authored-by: Carlos Rodriguez <[email protected]>

* remove error msg parameter from helper function

* Add test for forwarded packet

* Construct packet for B ack check.

* PR feedback

* feat(transfer): add unwind, refactor proto structure. gen-all

* tests(transfer/types): fix test failures in types tests.

* tests(transfer/keeper): fix test failures in keeper tests.

* cli(transfer): fix cli usage. pending flag for unwind.

* tests(callbacks): fix failing tests in callbacks.

* tests(transfer/internal): fix failures in internal package.

* tests(transfer): fix test failures in top level tranfer package.

* tests(ica/host/keeper): fix repr of msg transfer in ica host msg execution.

* lint(all): lint this bad boy

* chore(transfer/types): amend validation for MsgTransfer's ShouldBeForwarded, add tests for ForwardedPacketData, minor nits.

* nit(self): only pass relevant fields to create packet data; minor comment improvement.

* Apply suggestions from code review

Co-authored-by: Carlos Rodriguez <[email protected]>

* chore(merge): fix merge issues.

* chore(proto): mention optional nature of fields.

* memo: do not drop it

* validation: drop requirement on memo being empty on msg transfer.

* feat(transfer): add unwinding ability, wip.

* Added unwind to allocation forwarding.

* Add tests and move some validation

* Missing import

* Fixed validation and added test

* PR Feedback

* Return nil when returning an error.

* Cleaner comment

* Add test case for multiple hos

---------

Co-authored-by: bznein <[email protected]>
Co-authored-by: Nikolas De Giorgis <[email protected]>
Co-authored-by: Carlos Rodriguez <[email protected]>

* chore: add support to run full test suite in run-e2e.sh

* chore: only store last channel for each test

* fix typo

* remove unnecessary wrapping of function

* Revert "remove unnecessary wrapping of function"

This reverts commit c2a6bc6.

* fix usage of function

* (chore) replace reflect.DeepEqual with slices.Equal (#6697)

* Replace reflect.DeepEqual with slices.Equal

* Nit formatting

* chore: comment hop slicing for clarity (#6702)

Co-authored-by: Carlos Rodriguez <[email protected]>

* chore: cleanup forwarding tests (#6691)

* chore: cleanup forwarding tests

* lint

* fix

---------

Co-authored-by: Nikolas De Giorgis <[email protected]>
Co-authored-by: Gjermund Garaba <[email protected]>

* chore: pull out hop validation and consolidate for transfer+packet (#6695)

* chore: pull out hop validation and consolidate transfer+packet

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

Co-authored-by: Carlos Rodriguez <[email protected]>

* cr fixes

---------

Co-authored-by: Carlos Rodriguez <[email protected]>

* Remove unwind field in authz (#6701)

* chore: remove unwind field in authz

* chore: remove duplicate test

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

Co-authored-by: Carlos Rodriguez <[email protected]>

---------

Co-authored-by: Carlos Rodriguez <[email protected]>

* chore: add packet data validation back (#6704)

* (chore) Refactor code around forwarding validation (#6706)

* Refactor validation

* Fixed verification logic, added two tests

* Fix check for unwind

* removed unneeded indirection

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

Co-authored-by: DimitrisJim <[email protected]>

* Add docstring.

---------

Co-authored-by: Gjermund Garaba <[email protected]>
Co-authored-by: DimitrisJim <[email protected]>

* use setupForwardingPaths in test

* feat(transfer): allow non-cosmos-sdk AccAddress in final receiver for forwarded packets (#6709)

* allow non-cosmos-sdk AccAddress for forwarded packets

* cr fixes

* chore: pass only hops to sendTransfer + events rename (#6703)

Co-authored-by: Carlos Rodriguez <[email protected]>

* test: forwarding test that verifies forwarded memo (#6707)

* test: forwarding with memo

* fix test

* cr fixes

* chore: update godoc for relay forwarding tests

* chore: use module account instead of custom forward address (#6688)

* chore: use module account instead of custom forward address

* pull blocked addr checker into keeper method

* lint

* clean up IsBlockedAddr

* chore: replace continue with if/else (#6700)

Co-authored-by: Nikolas De Giorgis <[email protected]>

* add changelog

* add test for invalid receiver address

* Update CHANGELOG.md

* Update CHANGELOG.md

* make getForwardedPacket private

* remove auxiliary burn coins function

* nit: rename func method recv args in types/forwarding.go

* chore: rename ShouldBeForwarded to HasFowarding

* e2e: remove template test for three chain setup.

* nit: no generics silly

* nit: add clarifying comment to validate basic call on msg.

* nit: remove unused key.

* nit: clean up cli help text.

* nit: don't export is blocked address helper.

* nit: docustring for e2e test and helper.

* nit: improve documentation for transfer's OnRecv callback.

Co-authored-by: Damian Nolan <[email protected]>

* chore: move setup code into individual tests

* chore: use custom setup functions in tests that need them

* chore: remove unused function

* Apply suggestions from code review

Co-authored-by: Aditya <[email protected]>

* chore: remove unused function

* perf: allocate slice to length of packet data tokens

* chore(transfer/authz): wrapf unauthorized forwarding hops

* lint

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

Co-authored-by: DimitrisJim <[email protected]>

* Preallocate slice but keep len==0 (#6725)

* imp: validate allowed forwarding hops

* test: unwind fails in Transfer rpc

* wip: tests failing after merge conflict

* chore: test passing with new config

* wip: working on ensuring existing tests pass

* wip: working on ensuring existing tests pass

* chore: revert changes to ibc genesis test

* wip: transfer tests passing in parallel

* chore: add comments and max function

* chore: fix e2e linting

* chore: move param tests into their own files

* chore: run transfer test in CI in parallel

* chore: tweak run-e2e.sh to not check for fzf

* chore: reference correct env var

* chore: separate out transfer utility logic from test suite

* chore: unexporting transfer tester type

* chore: temporarily disable regular E2Es

* chore: explicitly run a single test suite

* chore: re-enable regular E2Es and remove redundant  start relayer fn

* chore: adding flag to workflow

* chore: correctly store all channels created

* chore: renaming based on PR feedback

---------

Co-authored-by: Charly <[email protected]>
Co-authored-by: Carlos Rodriguez <[email protected]>
Co-authored-by: Charly <[email protected]>
Co-authored-by: Stefano Angieri <[email protected]>
Co-authored-by: sangier <[email protected]>
Co-authored-by: Colin Axnér <[email protected]>
Co-authored-by: DimitrisJim <[email protected]>
Co-authored-by: Hastur <[email protected]>
Co-authored-by: Damian Nolan <[email protected]>
Co-authored-by: Gjermund Garaba <[email protected]>
Co-authored-by: srdtrk <[email protected]>
Co-authored-by: Maintain <[email protected]>
Co-authored-by: srdtrk <[email protected]>
Co-authored-by: Nikolas De Giorgis <[email protected]>
Co-authored-by: Gjermund Garaba <[email protected]>
Co-authored-by: Dzung Do | Decentrio <[email protected]>
Co-authored-by: bznein <[email protected]>
Co-authored-by: Aditya <[email protected]>
bznein added a commit that referenced this pull request Jul 9, 2024
* Adding proto files for ics20-v2 (#6110)

* chore: adding proto files for ics20-v2

* chore: add newline

* update amount -> string (#6120)

* Update MsgTransfer to accept sdk.Coins instead of sdk.Coin (#6113)

* fix: allow base denom with trailing slash (#6148)

* imp: add CurrentVersion, EscrowVersion (#6160)

* add CurrentVersion, EscrowVersion, update tests

* update hardcoded transfer channel version from interchaintest

* chore: add function for converting packet data from v1 to v3 (#6116)

---------

Co-authored-by: Charly <[email protected]>

* chore: implement required `FungibleTokenPacketData` v3 interface methods (#6126)

* imp: `getMultiDenomFungibleTokenPacketData`to be used in packet unmarshalling/conversion (#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 <[email protected]>
Co-authored-by: Carlos Rodriguez <[email protected]>

* chore: implement version checking for channel handshake application callbacks (#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 <[email protected]>

* imp: update transfer authz implementation to account for multi denom transfers (#6252)

* add transfer authz code + tests

* linter

* address review comments

---------

Co-authored-by: Carlos Rodriguez <[email protected]>

* ics20-v2: backwards compatibility for transfer rpc and packet callbacks (#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 <[email protected]>
Co-authored-by: Charly <[email protected]>

* add v3 packet proto

* fix protos

* fixes

* test fixes

* add forwardPath keys and memo check in sendTransfer

* wip onRecvPacket logic

* minor fixes

* changes to transfer tx CLI to support multiple denoms

* import renaming

* onRecv logic completed

* add revertInFlights function

* add onAck && onTimeout logic

* fix interchain accounts test

* basic unit test for path forwarding

* fix test unsuccessful refund from source

* wip test fix

* fix mbt test - need more investigation

* revert test fix

* add assertions

* add support for async ack

* wip test forwarding happy path

* icsv20(path forwarding): use nil as default forwarding path when not set, use sequence in key to store forwarded packet (#6325)

* use nil forwarding path as default when not set, use sequence in key to store forwarded packet

* lint

* add forwarding happy path tests

* fix merge

* Use type with V2 suffix for package data (#6330)

* Adding additional comments and changing version variable names (#6345)

* chore: correctly claim capability

* lint

* imp: change ics20 events to emit token set (#6348)

* refactor: quick change to tokens event attribute

* fix: various tests

* lint

* lint:fixeroni

* imp: remove events variable in favour of direct event emission

---------

Co-authored-by: DimitrisJim <[email protected]>

* imp: check length tokens array against maximum allowed (#6349)

* check length of tokens array against maximum allowed

* chore: add note on arbitrary selection

---------

Co-authored-by: Colin Axnér <[email protected]>

* Modify UnmarshalPacketData interface to allow additional args (#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.

* Refactor packet data unmarshalling to use specific version (#6354)

* 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 <[email protected]>
Co-authored-by: Colin Axnér <[email protected]>

* chore: fixing tests

* imp: self review comments for ics20-v2 (#6360)

* refactor: address various self review comments

* revert: unnecessary change

* lint

* imp: self review on ics20-v2 part 2 (#6364)

* refactor: apply review suggestions

* imp: additional updates

* refactor: make ValidateIBCDenom private

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

Co-authored-by: Cian Hatton <[email protected]>

* apply review suggestions

---------

Co-authored-by: Cian Hatton <[email protected]>

* chore: move functions from internal/denom back to trace.go (#6368)

* chore: move functions from internal/denom to trace.go

* lint

* lint: the comeback

* imp: ics20 v2 self review part 3 (#6373)

* 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

* chore: remove duplicate test case

* chore: address minor nits (#6374)

* fix lint warning, add extra godocs, and some other small fixes and cleanup

* fix finalReceiver address bug

* wip - ack test scenario5

* add FungibleTokenPacketDataV2 test for ValidateBasic (#6398)

* fix linter complaints

* add test - currently faling on middle hop revert

* add test comments

* fixes

* retrieve channel capability only if there is a previous packet in store

* add missing parameter

* fix: e2e build failures.

* Use Transfer instead of sendTransfer when forwarding. (#6564)

Pass nil as the next forwarding path if at final hop.
Use consistent timeout for all hops.

* lint: fix linter issues.

* tests(transfer): move forwarding tests to separate file. (#6568)

* chore: rename ForwardingInfo to Forwarding

* Revert "chore: rename ForwardingInfo to Forwarding"

This reverts commit e483b9a.

* nit(transfer): Mark hops as non nullable. (#6566)

* nit(transfer): Mark hops as non nullable.

* lint: fix additional linting issues

* feat(transfer): add forwarding info validation to token packet (#6571)

* feat(transfer): add forwarding info validation to token packet

* Added NewForwardingInfo constructor

* Removed redundant check

* Clean up tests per cr comments

* Back to Validate and use NewDenom

* feat(transfer): add validation for forwarding info in msg transfer validate basic (#6583)

* Fix and simplify reverts of forwarding state (#6574)

* refactor: initial simplification attempt

* refactor: further organize

* fix: all tests fixed

* docs: improved godocs

* fix: logic and testing error

* style: self suggestion

* docs: suggestion

* docs: spellcheck

* style: suggestions

* style: renamed to revertForwardedPacket

* style: suggestion

* docs: remove docs

* docs: godoc suggestion

* style: suggestion

* docs: colin suggestions

* chore: rename ForwardingInfo to Forwarding (#6576)

* chore: rename ForwardingInfo to Forwarding

* chore: rename forwarding_path field to forwarding

* chore: make lint-fix

* chore: rename forwarding info -> forwarding

* chore: renaming fixes before merge

* Refactor packet forward functions (#6575)

* feat(transfer): validate forwarding memo in transfer authorization (#6591)

* Add func convert token to coin ibc (#6584)

* add func convert token to coin ibc

* fix command: change func to ToCoin and add godoc

* add unit test

* Revert using ToCoin on Recv where trace manipulation occurs.
Use ToCoin while forwarding.
Update tests as per Carlos's review.

* rename variable

---------

Co-authored-by: Carlos Rodriguez <[email protected]>
Co-authored-by: DimitrisJim <[email protected]>

* transfer: Disallow a forwarding object specified with zero hops and a memo (#6599)

* transfer: Disallow a forwarding object specified with zero hops and a memo.

* Apply suggestions from code review

Co-authored-by: Carlos Rodriguez <[email protected]>

---------

Co-authored-by: Carlos Rodriguez <[email protected]>
Co-authored-by: Gjermund Garaba <[email protected]>

* feat(transfer): move async decision and handling to the ibc module onrecv callback (#6592)

* refactor: initial simplification attempt

* refactor: further organize

* fix: all tests fixed

* chore: refactor packet forward functions

* chore: use receiver address directly in msg transfer

* feat(transfer): move async to ibc_module for onrecv

* chore: fix linter

* fix: logic and testing error

* style: self suggestion

* docs: suggestion

* docs: spellcheck

* style: suggestions

* style: renamed to revertForwardedPacket

* style: suggestion

* docs: remove docs

* Added tests for transfer OnRecv

* Use new names and methods from feature branch

* Apply suggestions from code review

Co-authored-by: colin axnér <[email protected]>

* Clean up test from cr feedback

* move vars to beginning of function

* lint

* Update modules/apps/transfer/ibc_module.go

Co-authored-by: Carlos Rodriguez <[email protected]>

* lint

---------

Co-authored-by: srdtrk <[email protected]>
Co-authored-by: chatton <[email protected]>
Co-authored-by: colin axnér <[email protected]>
Co-authored-by: Carlos Rodriguez <[email protected]>
Co-authored-by: DimitrisJim <[email protected]>

* chore: use NewForwarding instead of direct init (#6605)

* Reduce max forwarding to 16 (#6610)

* feat(transfer): use single byte ack for successful forward (#6604)

Co-authored-by: Nikolas De Giorgis <[email protected]>

* chore(transfer/cli): add forwarding flag to tx cli (#6609)

Co-authored-by: Carlos Rodriguez <[email protected]>

* chore(transfer): make Forwarding non-null (#6618)

* chore(transfer): make Forwarding non-null

* chore(transfer): always validate forwarding.

* chore: restructure functions with logical ordering (#6638)

* test: Add tests for OnTimeoutPacket when middle chain times out packet  (#6596)

* Create ontimeoutpacket test for forwarding

---------

Co-authored-by: Carlos Rodriguez <[email protected]>

* feat(transfer): add ShouldBeForwarded convenience method to msg transfer (#6595)

* feat(transfer): add should-be-forwarded convenience method to msg transfer

* Clean up packet and transfer msg validation for forwarding logic

---------

Co-authored-by: Carlos Rodriguez <[email protected]>

* wip: relayer configuration experimentation

* disallow timeout height usage when forwarding packets (#6641)

* disallow non-zero timeout height when forwarding tokens

* typo

* move constant

* use time to create default timeout timestamp delta

* Apply suggestions from code review

* refactor: add GetTimeoutTimestamp helper fn to the testing pkg

* lint

---------

Co-authored-by: colin axnér <[email protected]>

* nit: make set forwarded packet unexported (#6637)

Co-authored-by: Gjermund Garaba <[email protected]>
Co-authored-by: colin axnér <[email protected]>

* feat(transfer): use registered error code for error acks in token forwarding (#6648)

* Add typed errors to packet forwarding

* Use forward errors in tests

* Make ack construction consistent

* chore(transfer): emit forwarding information in events. (#6647)

* chore(transfer): emit forwarding information in events.

* nit: rename as per Carlos's suggestion

* Fix e2e test

* chore: test passing using relayer packet filter

* Refactor forwarding messages for Transfer and Packet (#6655)

* feat(transfer): add unwind, refactor proto structure. gen-all

* tests(transfer/types): fix test failures in types tests.

* tests(transfer/keeper): fix test failures in keeper tests.

* cli(transfer): fix cli usage. pending flag for unwind.

* tests(callbacks): fix failing tests in callbacks.

* tests(transfer/internal): fix failures in internal package.

* tests(transfer): fix test failures in top level tranfer package.

* tests(ica/host/keeper): fix repr of msg transfer in ica host msg execution.

* lint(all): lint this bad boy

* chore(transfer/types): amend validation for MsgTransfer's ShouldBeForwarded, add tests for ForwardedPacketData, minor nits.

* nit(self): only pass relevant fields to create packet data; minor comment improvement.

* Apply suggestions from code review

Co-authored-by: Carlos Rodriguez <[email protected]>

* chore(merge): fix merge issues.

* chore(proto): mention optional nature of fields.

* memo: do not drop it

* validation: drop requirement on memo being empty on msg transfer.

---------

Co-authored-by: Carlos Rodriguez <[email protected]>

* feat: allow authz granters to specify forwarding info for token transfer (#6661)

* First attempt to modify proto and validation.

* Fmt

* Make it compile

* Proto

* Add basic validation

* Added tests

* Fix nil check and remove redundant code.

* Move "forwarding" to non-pointer

* Added one test case.

* Moved error and changed method name.

* PR Feedback.

* Add nullable=false

* Added test and fixed test names

* Run make proto-all

* Change pointer to non-pointer

* Change Yet Another Pointer

* More pointers

* Comments and naming

* Reintroduce brace removed while merging

* Remove accidentally reintroduced tests

* feat: delete forwarded packet when it is not needed anymore  (#6621)

* Create ontimeoutpacket test for forwarding

* Propagate ack on A

* Refactoring

* Minor changes

* Added comments

* Fix type name.

* Gofumpt

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

Co-authored-by: Carlos Rodriguez <[email protected]>

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

Co-authored-by: Carlos Rodriguez <[email protected]>

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

Co-authored-by: Carlos Rodriguez <[email protected]>

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

Co-authored-by: Carlos Rodriguez <[email protected]>

* Add godoc to test.

* Changed trace construction

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

Co-authored-by: Carlos Rodriguez <[email protected]>

* remove error msg parameter from helper function

* Add test for forwarded packet

* Delete packet when not needed anymore.

* Move deletion of packet in a single place.

* Reintroduce newline

* Do not ignore error.

* PR feedback.

* Construct packet for B ack check.

* PR feedback

* Pass packet to acknowledgeforwardedpacket

* revert unwanted change

* Another unwanted change

* Better signature and fix source/dest

* Added one more test.

---------

Co-authored-by: Carlos Rodriguez <[email protected]>
Co-authored-by: Gjermund Garaba <[email protected]>

* test(transfer): forwarding acknowledgment errors in middle hop (#6659)

* test(transfer): forwarding where middle chaind is source for receive and send

* Fix errors after merge

* Finish up the test

* Update some out-of-date comments

* test(transfer): multi-hop ack failure with middle chain NOT being source

* Fix tests after height change

* Fix tests after height change

* Fix test after #6586

* Rename tests to not use scenario numbers

* Rename test

* address self-review comments

* use boolean in NewForwarding parameter

* some more review comments

---------

Co-authored-by: Carlos Rodriguez <[email protected]>

* test(transfer): last chain in forwarding packet is ICS20 v1 (#6622)

* test(transfer): last chain in forwarding being ICS20 v1

* Finish TestForwarding_WithLastChainBeingICS20v1_Succeeds

* Update CreateNewPath signature

Co-authored-by: Nikolas De Giorgis <[email protected]>

* Fix PR review comments

---------

Co-authored-by: Nikolas De Giorgis <[email protected]>

* refactor: rename SetupPath to SetupPaths (#6674)

* chore: configure the hermes config to watch a specific port and channel ID

* chore: add flag for unwind in transfer cli (#6680)

* add flag for unwind in transfer cli

* update long description of cli

---------

Co-authored-by: Carlos Rodriguez <[email protected]>

* chore: small refactor for SetupPath

* chore: adding link to interchaintest issue and doing some cleanup

* chore: adding interchaintest issue link in comment

* chore: merge main

* chore: fix linter

* chore: sync main

* feat: impl check reject transfer if len(hops) > 0 and ics20-1 (#6675)

* impl check reject transfer if len(hops) > 0 and ics20-1

* add test case hops is not empty with ics20-2

* address review comments

* reorder variable declaration

---------

Co-authored-by: Carlos Rodriguez <[email protected]>
Co-authored-by: Gjermund Garaba <[email protected]>

* chore: fix go mod

* feat(transfer): add unwinding ability (#6656)

* Create ontimeoutpacket test for forwarding

* Propagate ack on A

* Refactoring

* Minor changes

* Added comments

* Fix type name.

* Gofumpt

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

Co-authored-by: Carlos Rodriguez <[email protected]>

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

Co-authored-by: Carlos Rodriguez <[email protected]>

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

Co-authored-by: Carlos Rodriguez <[email protected]>

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

Co-authored-by: Carlos Rodriguez <[email protected]>

* Add godoc to test.

* Changed trace construction

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

Co-authored-by: Carlos Rodriguez <[email protected]>

* remove error msg parameter from helper function

* Add test for forwarded packet

* Construct packet for B ack check.

* PR feedback

* feat(transfer): add unwind, refactor proto structure. gen-all

* tests(transfer/types): fix test failures in types tests.

* tests(transfer/keeper): fix test failures in keeper tests.

* cli(transfer): fix cli usage. pending flag for unwind.

* tests(callbacks): fix failing tests in callbacks.

* tests(transfer/internal): fix failures in internal package.

* tests(transfer): fix test failures in top level tranfer package.

* tests(ica/host/keeper): fix repr of msg transfer in ica host msg execution.

* lint(all): lint this bad boy

* chore(transfer/types): amend validation for MsgTransfer's ShouldBeForwarded, add tests for ForwardedPacketData, minor nits.

* nit(self): only pass relevant fields to create packet data; minor comment improvement.

* Apply suggestions from code review

Co-authored-by: Carlos Rodriguez <[email protected]>

* chore(merge): fix merge issues.

* chore(proto): mention optional nature of fields.

* memo: do not drop it

* validation: drop requirement on memo being empty on msg transfer.

* feat(transfer): add unwinding ability, wip.

* Added unwind to allocation forwarding.

* Add tests and move some validation

* Missing import

* Fixed validation and added test

* PR Feedback

* Return nil when returning an error.

* Cleaner comment

* Add test case for multiple hos

---------

Co-authored-by: bznein <[email protected]>
Co-authored-by: Nikolas De Giorgis <[email protected]>
Co-authored-by: Carlos Rodriguez <[email protected]>

* chore: add support to run full test suite in run-e2e.sh

* chore: only store last channel for each test

* fix typo

* remove unnecessary wrapping of function

* Revert "remove unnecessary wrapping of function"

This reverts commit c2a6bc6.

* fix usage of function

* (chore) replace reflect.DeepEqual with slices.Equal (#6697)

* Replace reflect.DeepEqual with slices.Equal

* Nit formatting

* chore: comment hop slicing for clarity (#6702)

Co-authored-by: Carlos Rodriguez <[email protected]>

* chore: cleanup forwarding tests (#6691)

* chore: cleanup forwarding tests

* lint

* fix

---------

Co-authored-by: Nikolas De Giorgis <[email protected]>
Co-authored-by: Gjermund Garaba <[email protected]>

* chore: pull out hop validation and consolidate for transfer+packet (#6695)

* chore: pull out hop validation and consolidate transfer+packet

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

Co-authored-by: Carlos Rodriguez <[email protected]>

* cr fixes

---------

Co-authored-by: Carlos Rodriguez <[email protected]>

* Remove unwind field in authz (#6701)

* chore: remove unwind field in authz

* chore: remove duplicate test

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

Co-authored-by: Carlos Rodriguez <[email protected]>

---------

Co-authored-by: Carlos Rodriguez <[email protected]>

* chore: add packet data validation back (#6704)

* (chore) Refactor code around forwarding validation (#6706)

* Refactor validation

* Fixed verification logic, added two tests

* Fix check for unwind

* removed unneeded indirection

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

Co-authored-by: DimitrisJim <[email protected]>

* Add docstring.

---------

Co-authored-by: Gjermund Garaba <[email protected]>
Co-authored-by: DimitrisJim <[email protected]>

* use setupForwardingPaths in test

* feat(transfer): allow non-cosmos-sdk AccAddress in final receiver for forwarded packets (#6709)

* allow non-cosmos-sdk AccAddress for forwarded packets

* cr fixes

* chore: pass only hops to sendTransfer + events rename (#6703)

Co-authored-by: Carlos Rodriguez <[email protected]>

* test: forwarding test that verifies forwarded memo (#6707)

* test: forwarding with memo

* fix test

* cr fixes

* chore: update godoc for relay forwarding tests

* chore: use module account instead of custom forward address (#6688)

* chore: use module account instead of custom forward address

* pull blocked addr checker into keeper method

* lint

* clean up IsBlockedAddr

* chore: replace continue with if/else (#6700)

Co-authored-by: Nikolas De Giorgis <[email protected]>

* add changelog

* add test for invalid receiver address

* Update CHANGELOG.md

* Update CHANGELOG.md

* make getForwardedPacket private

* remove auxiliary burn coins function

* nit: rename func method recv args in types/forwarding.go

* chore: rename ShouldBeForwarded to HasFowarding

* e2e: remove template test for three chain setup.

* nit: no generics silly

* nit: add clarifying comment to validate basic call on msg.

* nit: remove unused key.

* nit: clean up cli help text.

* nit: don't export is blocked address helper.

* nit: docustring for e2e test and helper.

* nit: improve documentation for transfer's OnRecv callback.

Co-authored-by: Damian Nolan <[email protected]>

* chore: move setup code into individual tests

* chore: use custom setup functions in tests that need them

* chore: remove unused function

* Apply suggestions from code review

Co-authored-by: Aditya <[email protected]>

* chore: remove unused function

* perf: allocate slice to length of packet data tokens

* chore(transfer/authz): wrapf unauthorized forwarding hops

* lint

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

Co-authored-by: DimitrisJim <[email protected]>

* Preallocate slice but keep len==0 (#6725)

* imp: validate allowed forwarding hops

* test: unwind fails in Transfer rpc

* wip: tests failing after merge conflict

* chore: test passing with new config

* wip: working on ensuring existing tests pass

* wip: working on ensuring existing tests pass

* chore: revert changes to ibc genesis test

* wip: transfer tests passing in parallel

* chore: add comments and max function

* chore: fix e2e linting

* chore: move param tests into their own files

* chore: run transfer test in CI in parallel

* chore: tweak run-e2e.sh to not check for fzf

* chore: reference correct env var

* chore: separate out transfer utility logic from test suite

* chore: unexporting transfer tester type

* chore: temporarily disable regular E2Es

* chore: explicitly run a single test suite

* chore: re-enable regular E2Es and remove redundant  start relayer fn

* chore: adding flag to workflow

* chore: correctly store all channels created

* chore: renaming based on PR feedback

---------

Co-authored-by: Charly <[email protected]>
Co-authored-by: Carlos Rodriguez <[email protected]>
Co-authored-by: Charly <[email protected]>
Co-authored-by: Stefano Angieri <[email protected]>
Co-authored-by: sangier <[email protected]>
Co-authored-by: Colin Axnér <[email protected]>
Co-authored-by: DimitrisJim <[email protected]>
Co-authored-by: Hastur <[email protected]>
Co-authored-by: Damian Nolan <[email protected]>
Co-authored-by: Gjermund Garaba <[email protected]>
Co-authored-by: srdtrk <[email protected]>
Co-authored-by: Maintain <[email protected]>
Co-authored-by: srdtrk <[email protected]>
Co-authored-by: Nikolas De Giorgis <[email protected]>
Co-authored-by: Gjermund Garaba <[email protected]>
Co-authored-by: Dzung Do | Decentrio <[email protected]>
Co-authored-by: bznein <[email protected]>
Co-authored-by: Aditya <[email protected]>
github-merge-queue bot pushed a commit that referenced this pull request Jul 10, 2024
* Adding proto files for ics20-v2 (#6110)

* chore: adding proto files for ics20-v2

* chore: add newline

* update amount -> string (#6120)

* Update MsgTransfer to accept sdk.Coins instead of sdk.Coin (#6113)

* fix: allow base denom with trailing slash (#6148)

* imp: add CurrentVersion, EscrowVersion (#6160)

* add CurrentVersion, EscrowVersion, update tests

* update hardcoded transfer channel version from interchaintest

* chore: add function for converting packet data from v1 to v3 (#6116)

---------

Co-authored-by: Charly <[email protected]>

* chore: implement required `FungibleTokenPacketData` v3 interface methods (#6126)

* imp: `getMultiDenomFungibleTokenPacketData`to be used in packet unmarshalling/conversion (#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 <[email protected]>
Co-authored-by: Carlos Rodriguez <[email protected]>

* chore: implement version checking for channel handshake application callbacks (#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 <[email protected]>

* imp: update transfer authz implementation to account for multi denom transfers (#6252)

* add transfer authz code + tests

* linter

* address review comments

---------

Co-authored-by: Carlos Rodriguez <[email protected]>

* ics20-v2: backwards compatibility for transfer rpc and packet callbacks (#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 <[email protected]>
Co-authored-by: Charly <[email protected]>

* add v3 packet proto

* fix protos

* fixes

* test fixes

* add forwardPath keys and memo check in sendTransfer

* wip onRecvPacket logic

* minor fixes

* changes to transfer tx CLI to support multiple denoms

* import renaming

* onRecv logic completed

* add revertInFlights function

* add onAck && onTimeout logic

* fix interchain accounts test

* basic unit test for path forwarding

* fix test unsuccessful refund from source

* wip test fix

* fix mbt test - need more investigation

* revert test fix

* add assertions

* add support for async ack

* wip test forwarding happy path

* icsv20(path forwarding): use nil as default forwarding path when not set, use sequence in key to store forwarded packet (#6325)

* use nil forwarding path as default when not set, use sequence in key to store forwarded packet

* lint

* add forwarding happy path tests

* fix merge

* Use type with V2 suffix for package data (#6330)

* Adding additional comments and changing version variable names (#6345)

* chore: correctly claim capability

* lint

* imp: change ics20 events to emit token set (#6348)

* refactor: quick change to tokens event attribute

* fix: various tests

* lint

* lint:fixeroni

* imp: remove events variable in favour of direct event emission

---------

Co-authored-by: DimitrisJim <[email protected]>

* imp: check length tokens array against maximum allowed (#6349)

* check length of tokens array against maximum allowed

* chore: add note on arbitrary selection

---------

Co-authored-by: Colin Axnér <[email protected]>

* Modify UnmarshalPacketData interface to allow additional args (#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.

* Refactor packet data unmarshalling to use specific version (#6354)

* 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 <[email protected]>
Co-authored-by: Colin Axnér <[email protected]>

* chore: fixing tests

* imp: self review comments for ics20-v2 (#6360)

* refactor: address various self review comments

* revert: unnecessary change

* lint

* imp: self review on ics20-v2 part 2 (#6364)

* refactor: apply review suggestions

* imp: additional updates

* refactor: make ValidateIBCDenom private

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

Co-authored-by: Cian Hatton <[email protected]>

* apply review suggestions

---------

Co-authored-by: Cian Hatton <[email protected]>

* chore: move functions from internal/denom back to trace.go (#6368)

* chore: move functions from internal/denom to trace.go

* lint

* lint: the comeback

* imp: ics20 v2 self review part 3 (#6373)

* 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

* chore: remove duplicate test case

* chore: address minor nits (#6374)

* fix lint warning, add extra godocs, and some other small fixes and cleanup

* fix finalReceiver address bug

* wip - ack test scenario5

* add FungibleTokenPacketDataV2 test for ValidateBasic (#6398)

* fix linter complaints

* add test - currently faling on middle hop revert

* add test comments

* fixes

* retrieve channel capability only if there is a previous packet in store

* add missing parameter

* fix: e2e build failures.

* Use Transfer instead of sendTransfer when forwarding. (#6564)

Pass nil as the next forwarding path if at final hop.
Use consistent timeout for all hops.

* lint: fix linter issues.

* tests(transfer): move forwarding tests to separate file. (#6568)

* chore: rename ForwardingInfo to Forwarding

* Revert "chore: rename ForwardingInfo to Forwarding"

This reverts commit e483b9a.

* nit(transfer): Mark hops as non nullable. (#6566)

* nit(transfer): Mark hops as non nullable.

* lint: fix additional linting issues

* feat(transfer): add forwarding info validation to token packet (#6571)

* feat(transfer): add forwarding info validation to token packet

* Added NewForwardingInfo constructor

* Removed redundant check

* Clean up tests per cr comments

* Back to Validate and use NewDenom

* feat(transfer): add validation for forwarding info in msg transfer validate basic (#6583)

* Fix and simplify reverts of forwarding state (#6574)

* refactor: initial simplification attempt

* refactor: further organize

* fix: all tests fixed

* docs: improved godocs

* fix: logic and testing error

* style: self suggestion

* docs: suggestion

* docs: spellcheck

* style: suggestions

* style: renamed to revertForwardedPacket

* style: suggestion

* docs: remove docs

* docs: godoc suggestion

* style: suggestion

* docs: colin suggestions

* chore: rename ForwardingInfo to Forwarding (#6576)

* chore: rename ForwardingInfo to Forwarding

* chore: rename forwarding_path field to forwarding

* chore: make lint-fix

* chore: rename forwarding info -> forwarding

* chore: renaming fixes before merge

* Refactor packet forward functions (#6575)

* feat(transfer): validate forwarding memo in transfer authorization (#6591)

* Add func convert token to coin ibc (#6584)

* add func convert token to coin ibc

* fix command: change func to ToCoin and add godoc

* add unit test

* Revert using ToCoin on Recv where trace manipulation occurs.
Use ToCoin while forwarding.
Update tests as per Carlos's review.

* rename variable

---------

Co-authored-by: Carlos Rodriguez <[email protected]>
Co-authored-by: DimitrisJim <[email protected]>

* transfer: Disallow a forwarding object specified with zero hops and a memo (#6599)

* transfer: Disallow a forwarding object specified with zero hops and a memo.

* Apply suggestions from code review

Co-authored-by: Carlos Rodriguez <[email protected]>

---------

Co-authored-by: Carlos Rodriguez <[email protected]>
Co-authored-by: Gjermund Garaba <[email protected]>

* feat(transfer): move async decision and handling to the ibc module onrecv callback (#6592)

* refactor: initial simplification attempt

* refactor: further organize

* fix: all tests fixed

* chore: refactor packet forward functions

* chore: use receiver address directly in msg transfer

* feat(transfer): move async to ibc_module for onrecv

* chore: fix linter

* fix: logic and testing error

* style: self suggestion

* docs: suggestion

* docs: spellcheck

* style: suggestions

* style: renamed to revertForwardedPacket

* style: suggestion

* docs: remove docs

* Added tests for transfer OnRecv

* Use new names and methods from feature branch

* Apply suggestions from code review

Co-authored-by: colin axnér <[email protected]>

* Clean up test from cr feedback

* move vars to beginning of function

* lint

* Update modules/apps/transfer/ibc_module.go

Co-authored-by: Carlos Rodriguez <[email protected]>

* lint

---------

Co-authored-by: srdtrk <[email protected]>
Co-authored-by: chatton <[email protected]>
Co-authored-by: colin axnér <[email protected]>
Co-authored-by: Carlos Rodriguez <[email protected]>
Co-authored-by: DimitrisJim <[email protected]>

* chore: use NewForwarding instead of direct init (#6605)

* Reduce max forwarding to 16 (#6610)

* feat(transfer): use single byte ack for successful forward (#6604)

Co-authored-by: Nikolas De Giorgis <[email protected]>

* chore(transfer/cli): add forwarding flag to tx cli (#6609)

Co-authored-by: Carlos Rodriguez <[email protected]>

* chore(transfer): make Forwarding non-null (#6618)

* chore(transfer): make Forwarding non-null

* chore(transfer): always validate forwarding.

* chore: restructure functions with logical ordering (#6638)

* test: Add tests for OnTimeoutPacket when middle chain times out packet  (#6596)

* Create ontimeoutpacket test for forwarding

---------

Co-authored-by: Carlos Rodriguez <[email protected]>

* feat(transfer): add ShouldBeForwarded convenience method to msg transfer (#6595)

* feat(transfer): add should-be-forwarded convenience method to msg transfer

* Clean up packet and transfer msg validation for forwarding logic

---------

Co-authored-by: Carlos Rodriguez <[email protected]>

* wip: relayer configuration experimentation

* disallow timeout height usage when forwarding packets (#6641)

* disallow non-zero timeout height when forwarding tokens

* typo

* move constant

* use time to create default timeout timestamp delta

* Apply suggestions from code review

* refactor: add GetTimeoutTimestamp helper fn to the testing pkg

* lint

---------

Co-authored-by: colin axnér <[email protected]>

* nit: make set forwarded packet unexported (#6637)

Co-authored-by: Gjermund Garaba <[email protected]>
Co-authored-by: colin axnér <[email protected]>

* feat(transfer): use registered error code for error acks in token forwarding (#6648)

* Add typed errors to packet forwarding

* Use forward errors in tests

* Make ack construction consistent

* chore(transfer): emit forwarding information in events. (#6647)

* chore(transfer): emit forwarding information in events.

* nit: rename as per Carlos's suggestion

* Fix e2e test

* chore: test passing using relayer packet filter

* Refactor forwarding messages for Transfer and Packet (#6655)

* feat(transfer): add unwind, refactor proto structure. gen-all

* tests(transfer/types): fix test failures in types tests.

* tests(transfer/keeper): fix test failures in keeper tests.

* cli(transfer): fix cli usage. pending flag for unwind.

* tests(callbacks): fix failing tests in callbacks.

* tests(transfer/internal): fix failures in internal package.

* tests(transfer): fix test failures in top level tranfer package.

* tests(ica/host/keeper): fix repr of msg transfer in ica host msg execution.

* lint(all): lint this bad boy

* chore(transfer/types): amend validation for MsgTransfer's ShouldBeForwarded, add tests for ForwardedPacketData, minor nits.

* nit(self): only pass relevant fields to create packet data; minor comment improvement.

* Apply suggestions from code review

Co-authored-by: Carlos Rodriguez <[email protected]>

* chore(merge): fix merge issues.

* chore(proto): mention optional nature of fields.

* memo: do not drop it

* validation: drop requirement on memo being empty on msg transfer.

---------

Co-authored-by: Carlos Rodriguez <[email protected]>

* feat: allow authz granters to specify forwarding info for token transfer (#6661)

* First attempt to modify proto and validation.

* Fmt

* Make it compile

* Proto

* Add basic validation

* Added tests

* Fix nil check and remove redundant code.

* Move "forwarding" to non-pointer

* Added one test case.

* Moved error and changed method name.

* PR Feedback.

* Add nullable=false

* Added test and fixed test names

* Run make proto-all

* Change pointer to non-pointer

* Change Yet Another Pointer

* More pointers

* Comments and naming

* Reintroduce brace removed while merging

* Remove accidentally reintroduced tests

* feat: delete forwarded packet when it is not needed anymore  (#6621)

* Create ontimeoutpacket test for forwarding

* Propagate ack on A

* Refactoring

* Minor changes

* Added comments

* Fix type name.

* Gofumpt

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

Co-authored-by: Carlos Rodriguez <[email protected]>

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

Co-authored-by: Carlos Rodriguez <[email protected]>

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

Co-authored-by: Carlos Rodriguez <[email protected]>

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

Co-authored-by: Carlos Rodriguez <[email protected]>

* Add godoc to test.

* Changed trace construction

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

Co-authored-by: Carlos Rodriguez <[email protected]>

* remove error msg parameter from helper function

* Add test for forwarded packet

* Delete packet when not needed anymore.

* Move deletion of packet in a single place.

* Reintroduce newline

* Do not ignore error.

* PR feedback.

* Construct packet for B ack check.

* PR feedback

* Pass packet to acknowledgeforwardedpacket

* revert unwanted change

* Another unwanted change

* Better signature and fix source/dest

* Added one more test.

---------

Co-authored-by: Carlos Rodriguez <[email protected]>
Co-authored-by: Gjermund Garaba <[email protected]>

* test(transfer): forwarding acknowledgment errors in middle hop (#6659)

* test(transfer): forwarding where middle chaind is source for receive and send

* Fix errors after merge

* Finish up the test

* Update some out-of-date comments

* test(transfer): multi-hop ack failure with middle chain NOT being source

* Fix tests after height change

* Fix tests after height change

* Fix test after #6586

* Rename tests to not use scenario numbers

* Rename test

* address self-review comments

* use boolean in NewForwarding parameter

* some more review comments

---------

Co-authored-by: Carlos Rodriguez <[email protected]>

* test(transfer): last chain in forwarding packet is ICS20 v1 (#6622)

* test(transfer): last chain in forwarding being ICS20 v1

* Finish TestForwarding_WithLastChainBeingICS20v1_Succeeds

* Update CreateNewPath signature

Co-authored-by: Nikolas De Giorgis <[email protected]>

* Fix PR review comments

---------

Co-authored-by: Nikolas De Giorgis <[email protected]>

* refactor: rename SetupPath to SetupPaths (#6674)

* chore: configure the hermes config to watch a specific port and channel ID

* chore: add flag for unwind in transfer cli (#6680)

* add flag for unwind in transfer cli

* update long description of cli

---------

Co-authored-by: Carlos Rodriguez <[email protected]>

* chore: small refactor for SetupPath

* chore: adding link to interchaintest issue and doing some cleanup

* chore: adding interchaintest issue link in comment

* chore: merge main

* chore: fix linter

* chore: sync main

* feat: impl check reject transfer if len(hops) > 0 and ics20-1 (#6675)

* impl check reject transfer if len(hops) > 0 and ics20-1

* add test case hops is not empty with ics20-2

* address review comments

* reorder variable declaration

---------

Co-authored-by: Carlos Rodriguez <[email protected]>
Co-authored-by: Gjermund Garaba <[email protected]>

* chore: fix go mod

* feat(transfer): add unwinding ability (#6656)

* Create ontimeoutpacket test for forwarding

* Propagate ack on A

* Refactoring

* Minor changes

* Added comments

* Fix type name.

* Gofumpt

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

Co-authored-by: Carlos Rodriguez <[email protected]>

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

Co-authored-by: Carlos Rodriguez <[email protected]>

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

Co-authored-by: Carlos Rodriguez <[email protected]>

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

Co-authored-by: Carlos Rodriguez <[email protected]>

* Add godoc to test.

* Changed trace construction

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

Co-authored-by: Carlos Rodriguez <[email protected]>

* remove error msg parameter from helper function

* Add test for forwarded packet

* Construct packet for B ack check.

* PR feedback

* feat(transfer): add unwind, refactor proto structure. gen-all

* tests(transfer/types): fix test failures in types tests.

* tests(transfer/keeper): fix test failures in keeper tests.

* cli(transfer): fix cli usage. pending flag for unwind.

* tests(callbacks): fix failing tests in callbacks.

* tests(transfer/internal): fix failures in internal package.

* tests(transfer): fix test failures in top level tranfer package.

* tests(ica/host/keeper): fix repr of msg transfer in ica host msg execution.

* lint(all): lint this bad boy

* chore(transfer/types): amend validation for MsgTransfer's ShouldBeForwarded, add tests for ForwardedPacketData, minor nits.

* nit(self): only pass relevant fields to create packet data; minor comment improvement.

* Apply suggestions from code review

Co-authored-by: Carlos Rodriguez <[email protected]>

* chore(merge): fix merge issues.

* chore(proto): mention optional nature of fields.

* memo: do not drop it

* validation: drop requirement on memo being empty on msg transfer.

* feat(transfer): add unwinding ability, wip.

* Added unwind to allocation forwarding.

* Add tests and move some validation

* Missing import

* Fixed validation and added test

* PR Feedback

* Return nil when returning an error.

* Cleaner comment

* Add test case for multiple hos

---------

Co-authored-by: bznein <[email protected]>
Co-authored-by: Nikolas De Giorgis <[email protected]>
Co-authored-by: Carlos Rodriguez <[email protected]>

* chore: add support to run full test suite in run-e2e.sh

* chore: only store last channel for each test

* fix typo

* remove unnecessary wrapping of function

* Revert "remove unnecessary wrapping of function"

This reverts commit c2a6bc6.

* fix usage of function

* (chore) replace reflect.DeepEqual with slices.Equal (#6697)

* Replace reflect.DeepEqual with slices.Equal

* Nit formatting

* chore: comment hop slicing for clarity (#6702)

Co-authored-by: Carlos Rodriguez <[email protected]>

* chore: cleanup forwarding tests (#6691)

* chore: cleanup forwarding tests

* lint

* fix

---------

Co-authored-by: Nikolas De Giorgis <[email protected]>
Co-authored-by: Gjermund Garaba <[email protected]>

* chore: pull out hop validation and consolidate for transfer+packet (#6695)

* chore: pull out hop validation and consolidate transfer+packet

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

Co-authored-by: Carlos Rodriguez <[email protected]>

* cr fixes

---------

Co-authored-by: Carlos Rodriguez <[email protected]>

* Remove unwind field in authz (#6701)

* chore: remove unwind field in authz

* chore: remove duplicate test

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

Co-authored-by: Carlos Rodriguez <[email protected]>

---------

Co-authored-by: Carlos Rodriguez <[email protected]>

* chore: add packet data validation back (#6704)

* (chore) Refactor code around forwarding validation (#6706)

* Refactor validation

* Fixed verification logic, added two tests

* Fix check for unwind

* removed unneeded indirection

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

Co-authored-by: DimitrisJim <[email protected]>

* Add docstring.

---------

Co-authored-by: Gjermund Garaba <[email protected]>
Co-authored-by: DimitrisJim <[email protected]>

* use setupForwardingPaths in test

* feat(transfer): allow non-cosmos-sdk AccAddress in final receiver for forwarded packets (#6709)

* allow non-cosmos-sdk AccAddress for forwarded packets

* cr fixes

* chore: pass only hops to sendTransfer + events rename (#6703)

Co-authored-by: Carlos Rodriguez <[email protected]>

* test: forwarding test that verifies forwarded memo (#6707)

* test: forwarding with memo

* fix test

* cr fixes

* chore: update godoc for relay forwarding tests

* chore: use module account instead of custom forward address (#6688)

* chore: use module account instead of custom forward address

* pull blocked addr checker into keeper method

* lint

* clean up IsBlockedAddr

* chore: replace continue with if/else (#6700)

Co-authored-by: Nikolas De Giorgis <[email protected]>

* add changelog

* add test for invalid receiver address

* Update CHANGELOG.md

* Update CHANGELOG.md

* make getForwardedPacket private

* remove auxiliary burn coins function

* nit: rename func method recv args in types/forwarding.go

* chore: rename ShouldBeForwarded to HasFowarding

* e2e: remove template test for three chain setup.

* nit: no generics silly

* nit: add clarifying comment to validate basic call on msg.

* nit: remove unused key.

* nit: clean up cli help text.

* nit: don't export is blocked address helper.

* nit: docustring for e2e test and helper.

* nit: improve documentation for transfer's OnRecv callback.

Co-authored-by: Damian Nolan <[email protected]>

* chore: move setup code into individual tests

* chore: use custom setup functions in tests that need them

* chore: remove unused function

* Apply suggestions from code review

Co-authored-by: Aditya <[email protected]>

* chore: remove unused function

* perf: allocate slice to length of packet data tokens

* chore(transfer/authz): wrapf unauthorized forwarding hops

* lint

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

Co-authored-by: DimitrisJim <[email protected]>

* Preallocate slice but keep len==0 (#6725)

* imp: validate allowed forwarding hops

* test: unwind fails in Transfer rpc

* wip: tests failing after merge conflict

* chore: test passing with new config

* wip: working on ensuring existing tests pass

* wip: working on ensuring existing tests pass

* chore: revert changes to ibc genesis test

* wip: transfer tests passing in parallel

* chore: add comments and max function

* chore: fix e2e linting

* chore: move param tests into their own files

* chore: run transfer test in CI in parallel

* chore: tweak run-e2e.sh to not check for fzf

* chore: reference correct env var

* chore: separate out transfer utility logic from test suite

* chore: unexporting transfer tester type

* chore: temporarily disable regular E2Es

* chore: explicitly run a single test suite

* chore: re-enable regular E2Es and remove redundant  start relayer fn

* chore: adding flag to workflow

* chore: correctly store all channels created

* chore: enable parallel execution for TestAuthzTransferTestSuite

* chore: adding TestTransferLocalhostTestSuite to e2e-test-suites workflow

* chore: replace . with , in string

* chore: adding TestConnectionTestSuite to e2e-suite workflow

* chore: adding TestInterchainAccountsGovTestSuite to e2e-suites

* chore: incentivized tests passing in parallel

* chore: rename relayers to relayer wallets

* chore: fix build issues

* chore: move incentivize test to e2e-suites

* chore: run forwarding tests as full suite

---------

Co-authored-by: Charly <[email protected]>
Co-authored-by: Carlos Rodriguez <[email protected]>
Co-authored-by: Charly <[email protected]>
Co-authored-by: Stefano Angieri <[email protected]>
Co-authored-by: sangier <[email protected]>
Co-authored-by: Colin Axnér <[email protected]>
Co-authored-by: DimitrisJim <[email protected]>
Co-authored-by: Hastur <[email protected]>
Co-authored-by: Damian Nolan <[email protected]>
Co-authored-by: Gjermund Garaba <[email protected]>
Co-authored-by: srdtrk <[email protected]>
Co-authored-by: Maintain <[email protected]>
Co-authored-by: srdtrk <[email protected]>
Co-authored-by: Nikolas De Giorgis <[email protected]>
Co-authored-by: Gjermund Garaba <[email protected]>
Co-authored-by: Dzung Do | Decentrio <[email protected]>
Co-authored-by: bznein <[email protected]>
Co-authored-by: Aditya <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority PRs that need prompt reviews
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants