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] ICS20-V2 Path Forwarding #6693

Merged
merged 162 commits into from
Jun 28, 2024
Merged
Show file tree
Hide file tree
Changes from 136 commits
Commits
Show all changes
162 commits
Select commit Hold shift + click to select a range
c07bca9
Adding proto files for ics20-v2 (#6110)
chatton Apr 8, 2024
e66bd89
update amount -> string (#6120)
charleenfei Apr 9, 2024
034f472
Update MsgTransfer to accept sdk.Coins instead of sdk.Coin (#6113)
chatton Apr 9, 2024
4cc6a85
fix: allow base denom with trailing slash (#6148)
crodriguezvega Apr 15, 2024
71f830c
imp: add CurrentVersion, EscrowVersion (#6160)
charleenfei Apr 16, 2024
28ff9b6
chore: add function for converting packet data from v1 to v3 (#6116)
chatton Apr 16, 2024
4e55137
chore: implement required `FungibleTokenPacketData` v3 interface meth…
charleenfei Apr 22, 2024
ca056cf
imp: `getMultiDenomFungibleTokenPacketData`to be used in packet unmar…
charleenfei Apr 29, 2024
147cf17
chore: implement version checking for channel handshake application c…
charleenfei May 6, 2024
9bbfa1a
imp: update transfer authz implementation to account for multi denom …
charleenfei May 6, 2024
4f57916
ics20-v2: backwards compatibility for transfer rpc and packet callbac…
crodriguezvega May 10, 2024
e04047e
add v3 packet proto
sangier May 10, 2024
c73d5f6
fix protos
sangier May 10, 2024
03cc2e5
fixes
sangier May 10, 2024
65f4476
test fixes
sangier May 10, 2024
db85a29
add forwardPath keys and memo check in sendTransfer
sangier May 13, 2024
999ed80
wip onRecvPacket logic
sangier May 13, 2024
be72180
minor fixes
sangier May 13, 2024
4c333c5
changes to transfer tx CLI to support multiple denoms
crodriguezvega May 14, 2024
0478cb9
import renaming
crodriguezvega May 14, 2024
37f5b5e
onRecv logic completed
sangier May 14, 2024
3fd3345
add revertInFlights function
sangier May 14, 2024
24e2407
add onAck && onTimeout logic
sangier May 14, 2024
7858528
fix interchain accounts test
crodriguezvega May 14, 2024
55d7bf9
basic unit test for path forwarding
crodriguezvega May 14, 2024
1a95262
fix test unsuccessful refund from source
sangier May 15, 2024
44e15cb
wip test fix
sangier May 15, 2024
334d5a9
fix mbt test - need more investigation
sangier May 16, 2024
7466b19
revert test fix
sangier May 16, 2024
5c46d79
add assertions
sangier May 16, 2024
99e6b0a
add support for async ack
sangier May 16, 2024
a114af6
wip test forwarding happy path
sangier May 16, 2024
d800caa
icsv20(path forwarding): use nil as default forwarding path when not …
crodriguezvega May 17, 2024
dd873a1
add forwarding happy path tests
sangier May 17, 2024
a292a3f
Merge branch 'feat/ics20-v2' into stefano/carlos/ics20-v2-forwarding-poc
sangier May 20, 2024
e25ba0c
fix merge
sangier May 20, 2024
f39d173
Use type with V2 suffix for package data (#6330)
chatton May 21, 2024
9b39944
Adding additional comments and changing version variable names (#6345)
chatton May 21, 2024
06ca9a5
Merge branch 'main' into merge-main
chatton May 21, 2024
7897ef3
chore: correctly claim capability
chatton May 21, 2024
786a4f1
lint
colin-axner May 21, 2024
5747756
Merge pull request #6346 from cosmos/merge-main
DimitrisJim May 21, 2024
7e2e6df
Merge branch 'main' into feat/ics20-v2
chatton May 22, 2024
a84b0e7
imp: change ics20 events to emit token set (#6348)
colin-axner May 22, 2024
43877df
imp: check length tokens array against maximum allowed (#6349)
crodriguezvega May 22, 2024
8eae033
Modify UnmarshalPacketData interface to allow additional args (#6341)
DimitrisJim May 22, 2024
dbcff45
Refactor packet data unmarshalling to use specific version (#6354)
chatton May 23, 2024
bb69698
Merge branch 'main' into merge-main-2
chatton May 23, 2024
f19a145
chore: fixing tests
chatton May 23, 2024
8f86dda
Merge pull request #6359 from cosmos/merge-main-2
chatton May 23, 2024
d4b06c8
imp: self review comments for ics20-v2 (#6360)
colin-axner May 23, 2024
a9391a4
imp: self review on ics20-v2 part 2 (#6364)
colin-axner May 23, 2024
575403e
chore: move functions from internal/denom back to trace.go (#6368)
DimitrisJim May 23, 2024
50ccd94
imp: ics20 v2 self review part 3 (#6373)
colin-axner May 23, 2024
87eb32e
chore: remove duplicate test case
colin-axner May 23, 2024
e8b9d5a
chore: address minor nits (#6374)
DimitrisJim May 23, 2024
57aab01
Merge branch 'feat/ics20-v2' into stefano/carlos/ics20-v2-forwarding-poc
crodriguezvega May 23, 2024
2519593
fix lint warning, add extra godocs, and some other small fixes and cl…
crodriguezvega May 26, 2024
3bf6c04
Merge branch 'main' into stefano/carlos/ics20-v2-forwarding-poc
crodriguezvega May 27, 2024
64c2fc4
fix finalReceiver address bug
sangier May 27, 2024
7cd7260
wip - ack test scenario5
sangier May 27, 2024
6673e74
add FungibleTokenPacketDataV2 test for ValidateBasic (#6398)
hastur199 May 28, 2024
550eeef
fix linter complaints
crodriguezvega May 28, 2024
4c54a88
add test - currently faling on middle hop revert
sangier May 28, 2024
debc4cb
add test comments
sangier May 28, 2024
e50fa40
fixes
sangier May 28, 2024
6d87d95
Merge branch 'main' into stefano/carlos/ics20-v2-forwarding-poc
crodriguezvega May 31, 2024
7c8f516
retrieve channel capability only if there is a previous packet in store
crodriguezvega May 31, 2024
feb7b01
Merge branch 'main' into stefano/carlos/ics20-v2-forwarding-poc
crodriguezvega Jun 7, 2024
6fd1773
Merge branch 'main' into stefano/carlos/ics20-v2-forwarding-poc
crodriguezvega Jun 9, 2024
efcfa5d
add missing parameter
crodriguezvega Jun 9, 2024
21dbb37
fix: e2e build failures.
DimitrisJim Jun 10, 2024
70d7a29
Use Transfer instead of sendTransfer when forwarding. (#6564)
DimitrisJim Jun 11, 2024
465b16c
lint: fix linter issues.
DimitrisJim Jun 11, 2024
ec472cf
tests(transfer): move forwarding tests to separate file. (#6568)
DimitrisJim Jun 11, 2024
e483b9a
chore: rename ForwardingInfo to Forwarding
damiannolan Jun 12, 2024
0c9f368
Revert "chore: rename ForwardingInfo to Forwarding"
damiannolan Jun 12, 2024
413b7c1
nit(transfer): Mark hops as non nullable. (#6566)
DimitrisJim Jun 12, 2024
ae2046a
feat(transfer): add forwarding info validation to token packet (#6571)
gjermundgaraba Jun 12, 2024
ba7c4a8
feat(transfer): add validation for forwarding info in msg transfer va…
gjermundgaraba Jun 13, 2024
6b3b5aa
Fix and simplify reverts of forwarding state (#6574)
srdtrk Jun 13, 2024
5070e50
chore: rename ForwardingInfo to Forwarding (#6576)
damiannolan Jun 13, 2024
d874b54
Refactor packet forward functions (#6575)
chatton Jun 13, 2024
a8cd302
Merge branch 'main' into feat/ics20-v2-path-forwarding
crodriguezvega Jun 13, 2024
fbb9cd8
feat(transfer): validate forwarding memo in transfer authorization (#…
gjermundgaraba Jun 13, 2024
c4987a7
Add func convert token to coin ibc (#6584)
duonghb53 Jun 14, 2024
a90b671
transfer: Disallow a forwarding object specified with zero hops and a…
DimitrisJim Jun 14, 2024
c348732
feat(transfer): move async decision and handling to the ibc module on…
gjermundgaraba Jun 14, 2024
789b09b
Merge branch 'main' into feat/ics20-v2-path-forwarding
crodriguezvega Jun 16, 2024
c00ddd9
chore: use NewForwarding instead of direct init (#6605)
gjermundgaraba Jun 17, 2024
fc6c111
Reduce max forwarding to 16 (#6610)
DimitrisJim Jun 17, 2024
72714b3
feat(transfer): use single byte ack for successful forward (#6604)
gjermundgaraba Jun 17, 2024
c546f69
chore(transfer/cli): add forwarding flag to tx cli (#6609)
DimitrisJim Jun 18, 2024
60a6b99
chore(transfer): make Forwarding non-null (#6618)
DimitrisJim Jun 18, 2024
dc47641
chore: restructure functions with logical ordering (#6638)
damiannolan Jun 18, 2024
832b1bd
test: Add tests for OnTimeoutPacket when middle chain times out packe…
bznein Jun 19, 2024
360b2f8
feat(transfer): add ShouldBeForwarded convenience method to msg trans…
gjermundgaraba Jun 19, 2024
84c7c33
disallow timeout height usage when forwarding packets (#6641)
crodriguezvega Jun 19, 2024
007dee1
nit: make set forwarded packet unexported (#6637)
crodriguezvega Jun 19, 2024
14d5486
feat(transfer): use registered error code for error acks in token for…
gjermundgaraba Jun 19, 2024
a28a549
chore(transfer): emit forwarding information in events. (#6647)
DimitrisJim Jun 20, 2024
d6db0c5
Merge branch 'main' into gjermund/merge-main-to-feat-ics20-v2-path-fo…
gjermundgaraba Jun 20, 2024
64bc502
Fix e2e test
gjermundgaraba Jun 20, 2024
1ca1f2f
Merge pull request #6662 from cosmos/gjermund/merge-main-to-feat-ics2…
chatton Jun 20, 2024
87d1f91
Refactor forwarding messages for Transfer and Packet (#6655)
DimitrisJim Jun 20, 2024
ef6d22f
feat: allow authz granters to specify forwarding info for token trans…
bznein Jun 21, 2024
da2f9f6
feat: delete forwarded packet when it is not needed anymore (#6621)
bznein Jun 21, 2024
e68143b
test(transfer): forwarding acknowledgment errors in middle hop (#6659)
gjermundgaraba Jun 21, 2024
6619821
test(transfer): last chain in forwarding packet is ICS20 v1 (#6622)
gjermundgaraba Jun 21, 2024
43eceed
refactor: rename SetupPath to SetupPaths (#6674)
gjermundgaraba Jun 24, 2024
aa860ac
chore: add flag for unwind in transfer cli (#6680)
neitdung Jun 24, 2024
2b4d24b
feat: impl check reject transfer if len(hops) > 0 and ics20-1 (#6675)
duonghb53 Jun 24, 2024
59e3df7
feat(transfer): add unwinding ability (#6656)
DimitrisJim Jun 25, 2024
e3ffcff
Merge branch 'main' into feat/ics20-v2-path-forwarding
chatton Jun 25, 2024
9c5ae03
fix typo
crodriguezvega Jun 25, 2024
c2a6bc6
remove unnecessary wrapping of function
crodriguezvega Jun 25, 2024
c3ccbfc
Revert "remove unnecessary wrapping of function"
crodriguezvega Jun 25, 2024
5345776
fix usage of function
crodriguezvega Jun 25, 2024
74088ba
(chore) replace reflect.DeepEqual with slices.Equal (#6697)
bznein Jun 25, 2024
272c12b
chore: comment hop slicing for clarity (#6702)
gjermundgaraba Jun 25, 2024
4349a1d
chore: cleanup forwarding tests (#6691)
crodriguezvega Jun 26, 2024
24cd07f
chore: pull out hop validation and consolidate for transfer+packet (#…
gjermundgaraba Jun 26, 2024
dca8c42
Merge branch 'main' into feat/ics20-v2-path-forwarding
chatton Jun 26, 2024
37d7335
Remove unwind field in authz (#6701)
chatton Jun 26, 2024
6e1a082
chore: add packet data validation back (#6704)
chatton Jun 26, 2024
8f9691f
(chore) Refactor code around forwarding validation (#6706)
bznein Jun 26, 2024
c505243
use setupForwardingPaths in test
crodriguezvega Jun 26, 2024
d715455
feat(transfer): allow non-cosmos-sdk AccAddress in final receiver for…
gjermundgaraba Jun 26, 2024
4e61ea9
chore: pass only hops to sendTransfer + events rename (#6703)
gjermundgaraba Jun 26, 2024
3e2a5fa
test: forwarding test that verifies forwarded memo (#6707)
gjermundgaraba Jun 26, 2024
5ea9d79
chore: update godoc for relay forwarding tests
gjermundgaraba Jun 26, 2024
100ccc7
chore: use module account instead of custom forward address (#6688)
gjermundgaraba Jun 26, 2024
13d3ac6
chore: replace continue with if/else (#6700)
crodriguezvega Jun 26, 2024
b6d77d7
Merge branch 'main' into feat/ics20-v2-path-forwarding
crodriguezvega Jun 27, 2024
4d19be1
add changelog
crodriguezvega Jun 27, 2024
2838aef
add test for invalid receiver address
crodriguezvega Jun 27, 2024
7afb7f6
Update CHANGELOG.md
crodriguezvega Jun 27, 2024
0221c6b
Update CHANGELOG.md
crodriguezvega Jun 27, 2024
cc46a63
make getForwardedPacket private
crodriguezvega Jun 27, 2024
e67aeaf
remove auxiliary burn coins function
crodriguezvega Jun 27, 2024
966a644
nit: rename func method recv args in types/forwarding.go
damiannolan Jun 27, 2024
e92e086
chore: rename ShouldBeForwarded to HasFowarding
damiannolan Jun 27, 2024
6ea614f
e2e: remove template test for three chain setup.
DimitrisJim Jun 27, 2024
18d0567
nit: no generics silly
DimitrisJim Jun 27, 2024
1b7214d
nit: add clarifying comment to validate basic call on msg.
DimitrisJim Jun 27, 2024
1f5e61f
nit: remove unused key.
DimitrisJim Jun 27, 2024
0a78bde
nit: clean up cli help text.
DimitrisJim Jun 27, 2024
07036a9
nit: don't export is blocked address helper.
DimitrisJim Jun 27, 2024
1442874
nit: docustring for e2e test and helper.
DimitrisJim Jun 27, 2024
25c73c4
nit: improve documentation for transfer's OnRecv callback.
DimitrisJim Jun 27, 2024
baf3fd3
Apply suggestions from code review
crodriguezvega Jun 27, 2024
7d2a881
chore: remove unused function
crodriguezvega Jun 27, 2024
4ea36c2
perf: allocate slice to length of packet data tokens
crodriguezvega Jun 27, 2024
0a28e9b
Merge branch 'main' into feat/ics20-v2-path-forwarding
crodriguezvega Jun 27, 2024
7411f2d
chore(transfer/authz): wrapf unauthorized forwarding hops
damiannolan Jun 27, 2024
199c14a
lint
crodriguezvega Jun 27, 2024
c7af85a
Update modules/apps/transfer/types/forwarding.go
crodriguezvega Jun 27, 2024
25239a2
Merge branch 'main' into feat/ics20-v2-path-forwarding
crodriguezvega Jun 27, 2024
90d57db
Preallocate slice but keep len==0 (#6725)
bznein Jun 27, 2024
e310e27
imp: validate allowed forwarding hops
crodriguezvega Jun 27, 2024
f28e937
test: unwind fails in Transfer rpc
crodriguezvega Jun 27, 2024
50daed0
Merge branch 'main' into feat/ics20-v2-path-forwarding
crodriguezvega Jun 28, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
### Features

* (apps/transfer) [\#6492](https://github.com/cosmos/ibc-go/pull/6492) Added new `Tokens` field to `MsgTransfer` to enable sending of multiple denoms, and deprecated the `Token` field.
* (apps/transfer) [\#6693](https://github.com/cosmos/ibc-go/pull/6693) Added new `Forwarding` field to `MsgTransfer` to enable forwarding tokens through multiple intermediary chains with a signle transaction. This also enables automatic unwinding of tokens to their native chain.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

we should probably also have a changelog entry for authz support.

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we should have a larger entry to highlight the changes to transfer?


### Bug Fixes

Expand Down
2 changes: 1 addition & 1 deletion e2e/tests/core/03-connection/connection_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ type ConnectionTestSuite struct {
}

func (s *ConnectionTestSuite) SetupTest() {
s.SetupPath(ibc.DefaultClientOpts(), s.TransferChannelOptions())
s.SetupPaths(ibc.DefaultClientOpts(), s.TransferChannelOptions())
}

// QueryMaxExpectedTimePerBlockParam queries the on-chain max expected time per block param for 03-connection
Expand Down
6 changes: 5 additions & 1 deletion e2e/tests/transfer/authz_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ type AuthzTransferTestSuite struct {
}

func (suite *AuthzTransferTestSuite) SetupTest() {
suite.SetupPath(ibc.DefaultClientOpts(), suite.TransferChannelOptions())
suite.SetupPaths(ibc.DefaultClientOpts(), suite.TransferChannelOptions())
}

// QueryGranterGrants returns all GrantAuthorizations for the given granterAddress.
Expand Down Expand Up @@ -131,6 +131,7 @@ func (suite *AuthzTransferTestSuite) TestAuthz_MsgTransfer_Succeeds() {
suite.GetTimeoutHeight(ctx, chainB),
0,
"",
transfertypes.Forwarding{},
)

protoAny, err := codectypes.NewAnyWithValue(transferMsg)
Expand Down Expand Up @@ -191,6 +192,7 @@ func (suite *AuthzTransferTestSuite) TestAuthz_MsgTransfer_Succeeds() {
suite.GetTimeoutHeight(ctx, chainB),
0,
"",
transfertypes.Forwarding{},
)

protoAny, err := codectypes.NewAnyWithValue(transferMsg)
Expand Down Expand Up @@ -274,6 +276,7 @@ func (suite *AuthzTransferTestSuite) TestAuthz_InvalidTransferAuthorizations() {
suite.GetTimeoutHeight(ctx, chainB),
0,
"",
transfertypes.Forwarding{},
)

protoAny, err := codectypes.NewAnyWithValue(transferMsg)
Expand Down Expand Up @@ -334,6 +337,7 @@ func (suite *AuthzTransferTestSuite) TestAuthz_InvalidTransferAuthorizations() {
suite.GetTimeoutHeight(ctx, chainB),
0,
"",
transfertypes.Forwarding{},
)

protoAny, err := codectypes.NewAnyWithValue(transferMsg)
Expand Down
2 changes: 1 addition & 1 deletion e2e/tests/transfer/base_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ type TransferTestSuite struct {
}

func (s *TransferTestSuite) SetupTest() {
s.SetupPath(ibc.DefaultClientOpts(), s.TransferChannelOptions())
s.SetupPaths(ibc.DefaultClientOpts(), s.TransferChannelOptions())
}

// QueryTransferParams queries the on-chain send enabled param for the transfer module
Expand Down
70 changes: 70 additions & 0 deletions e2e/tests/transfer/forwarding_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,16 @@ package transfer
import (
"context"
"testing"
"time"

"github.com/strangelove-ventures/interchaintest/v8/ibc"
testifysuite "github.com/stretchr/testify/suite"

"github.com/cosmos/ibc-go/e2e/testsuite"
"github.com/cosmos/ibc-go/e2e/testsuite/query"
"github.com/cosmos/ibc-go/e2e/testvalues"
transfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types"
clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types"
)

func TestTransferForwardingTestSuite(t *testing.T) {
Expand Down Expand Up @@ -98,3 +102,69 @@ func (s *TransferForwardingTestSuite) TestThreeChainSetup() {
s.Require().Equal(expected, actualBalance.Int64())
})
}

DimitrisJim marked this conversation as resolved.
Show resolved Hide resolved
func (s *TransferForwardingTestSuite) TestForwarding_WithLastChainBeingICS20v1_Succeeds() {
DimitrisJim marked this conversation as resolved.
Show resolved Hide resolved
ctx := context.TODO()
t := s.T()

relayer, chains := s.GetRelayer(), s.GetAllChains()

chainA, chainB, chainC := chains[0], chains[1], chains[2]

channelAtoB := s.GetChainAChannel()

// Creating a new path between chain B and chain C with a ICS20-v1 channel
opts := s.TransferChannelOptions()
opts.Version = transfertypes.V1
channelBtoC, _ := s.CreatePath(ctx, chainB, chainC, ibc.DefaultClientOpts(), opts)
s.Require().Equal(transfertypes.V1, channelBtoC.Version, "the channel version is not ics20-1")

chainAWallet := s.CreateUserOnChainA(ctx, testvalues.StartingTokenAmount)
chainAAddress := chainAWallet.FormattedAddress()
chainADenom := chainA.Config().Denom

chainCWallet := s.CreateUserOnChainC(ctx, testvalues.StartingTokenAmount)
chainCAddress := chainCWallet.FormattedAddress()

t.Run("IBC transfer from A to C with forwarding through B", func(t *testing.T) {
inFiveMinutes := time.Now().Add(5 * time.Minute).UnixNano()
forwarding := transfertypes.NewForwarding(false, transfertypes.Hop{
PortId: channelBtoC.PortID,
ChannelId: channelBtoC.ChannelID,
})

msgTransfer := testsuite.GetMsgTransfer(
channelAtoB.PortID,
channelAtoB.ChannelID,
transfertypes.V2,
testvalues.DefaultTransferCoins(chainADenom),
chainAAddress,
chainCAddress,
clienttypes.ZeroHeight(),
uint64(inFiveMinutes),
"",
forwarding)
resp := s.BroadcastMessages(ctx, chainA, chainAWallet, msgTransfer)
s.AssertTxSuccess(resp)
})

Copy link
Contributor Author

Choose a reason for hiding this comment

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

we're omitting the usual escrow checks and stuff here, but I think that's actually fine. We have those in other tests and this test ends up being short and sweet because of it!

t.Run("start relayer", func(t *testing.T) {
s.StartRelayer(relayer)
})

t.Run("packets are relayed from A to B to C", func(t *testing.T) {
chainCDenom := transfertypes.NewDenom(chainADenom,
transfertypes.NewTrace(channelBtoC.Counterparty.PortID, channelBtoC.Counterparty.ChannelID),
transfertypes.NewTrace(channelAtoB.Counterparty.PortID, channelAtoB.Counterparty.ChannelID),
)

s.AssertPacketRelayed(ctx, chainA, channelAtoB.PortID, channelAtoB.ChannelID, 1)
s.AssertPacketRelayed(ctx, chainB, channelBtoC.PortID, channelBtoC.ChannelID, 1)

actualBalance, err := query.Balance(ctx, chainC, chainCAddress, chainCDenom.IBCDenom())
s.Require().NoError(err)

expected := testvalues.IBCTransferAmount
s.Require().Equal(expected, actualBalance.Int64())
})
}
5 changes: 4 additions & 1 deletion e2e/tests/transfer/incentivized_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"github.com/cosmos/ibc-go/e2e/testsuite/query"
"github.com/cosmos/ibc-go/e2e/testvalues"
feetypes "github.com/cosmos/ibc-go/v8/modules/apps/29-fee/types"
transfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types"
channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types"
)

Expand All @@ -38,7 +39,7 @@ func TestIncentivizedTransferTestSuite(t *testing.T) {

// SetupTest explicitly enables fee middleware in the channel options.
func (s *IncentivizedTransferTestSuite) SetupTest() {
s.SetupPath(ibc.DefaultClientOpts(), s.FeeTransferChannelOptions())
s.SetupPaths(ibc.DefaultClientOpts(), s.FeeTransferChannelOptions())
}

func (s *IncentivizedTransferTestSuite) TestMsgPayPacketFee_AsyncSingleSender_Succeeds() {
Expand Down Expand Up @@ -216,6 +217,7 @@ func (s *IncentivizedTransferTestSuite) TestMsgPayPacketFee_InvalidReceiverAccou
s.GetTimeoutHeight(ctx, chainB),
0,
"",
transfertypes.Forwarding{},
)
txResp := s.BroadcastMessages(ctx, chainA, chainAWallet, msgTransfer)
// this message should be successful, as receiver account is not validated on the sending chain.
Expand Down Expand Up @@ -354,6 +356,7 @@ func (s *IncentivizedTransferTestSuite) TestMultiMsg_MsgPayPacketFeeSingleSender
s.GetTimeoutHeight(ctx, chainB),
0,
"",
transfertypes.Forwarding{},
)
resp := s.BroadcastMessages(ctx, chainA, chainAWallet, msgPayPacketFee, msgTransfer)
s.AssertTxSuccess(resp)
Expand Down
3 changes: 2 additions & 1 deletion e2e/tests/transfer/upgradesv1_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ type TransferChannelUpgradesV1TestSuite struct {
func (s *TransferChannelUpgradesV1TestSuite) SetupTest() {
opts := s.TransferChannelOptions()
opts.Version = transfertypes.V1
s.SetupPath(ibc.DefaultClientOpts(), opts)
s.SetupPaths(ibc.DefaultClientOpts(), opts)
}

// TestChannelUpgrade_WithICS20v2_Succeeds tests upgrading a transfer channel to ICS20 v2.
Expand Down Expand Up @@ -306,6 +306,7 @@ func (s *TransferChannelUpgradesV1TestSuite) TestChannelUpgrade_WithFeeMiddlewar
s.GetTimeoutHeight(ctx, chainB),
0,
"",
transfertypes.Forwarding{},
)
resp := s.BroadcastMessages(ctx, chainA, chainAWallet, msgPayPacketFee, msgTransfer)
s.AssertTxSuccess(resp)
Expand Down
3 changes: 2 additions & 1 deletion e2e/tests/transfer/upgradesv2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ type TransferChannelUpgradesTestSuite struct {
}

func (s *TransferChannelUpgradesTestSuite) SetupTest() {
s.SetupPath(ibc.DefaultClientOpts(), s.TransferChannelOptions())
s.SetupPaths(ibc.DefaultClientOpts(), s.TransferChannelOptions())
}

// TestChannelUpgrade_WithFeeMiddleware_Succeeds tests upgrading a transfer channel to wire up fee middleware
Expand Down Expand Up @@ -213,6 +213,7 @@ func (s *TransferChannelUpgradesTestSuite) TestChannelUpgrade_WithFeeMiddleware_
s.GetTimeoutHeight(ctx, chainB),
0,
"",
transfertypes.Forwarding{},
)
resp := s.BroadcastMessages(ctx, chainA, chainAWallet, msgPayPacketFee, msgTransfer)
s.AssertTxSuccess(resp)
Expand Down
4 changes: 3 additions & 1 deletion e2e/tests/upgrades/upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (
"github.com/cosmos/ibc-go/e2e/testsuite/query"
"github.com/cosmos/ibc-go/e2e/testvalues"
feetypes "github.com/cosmos/ibc-go/v8/modules/apps/29-fee/types"
transfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types"
v7migrations "github.com/cosmos/ibc-go/v8/modules/core/02-client/migrations/v7"
clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types"
connectiontypes "github.com/cosmos/ibc-go/v8/modules/core/03-connection/types"
Expand Down Expand Up @@ -62,7 +63,7 @@ func (s *UpgradeTestSuite) SetupTest() {
if strings.HasSuffix(s.T().Name(), "TestV8ToV8_1ChainUpgrade") {
channelOpts = s.FeeTransferChannelOptions()
}
s.SetupPath(ibc.DefaultClientOpts(), channelOpts)
s.SetupPaths(ibc.DefaultClientOpts(), channelOpts)
}

// UpgradeChain upgrades a chain to a specific version using the planName provided.
Expand Down Expand Up @@ -978,6 +979,7 @@ func (s *UpgradeTestSuite) TestV8ToV8_1ChainUpgrade_ChannelUpgrades() {
s.GetTimeoutHeight(ctx, chainB),
0,
"",
transfertypes.Forwarding{},
)
resp := s.BroadcastMessages(ctx, chainA, chainAWallet, msgPayPacketFee, msgTransfer)
s.AssertTxSuccess(resp)
Expand Down
2 changes: 1 addition & 1 deletion e2e/tests/wasm/grandpa_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ func (s *GrandpaTestSuite) SetupTest() {

channelOpts := ibc.DefaultChannelOpts()
channelOpts.Version = transfertypes.V1
s.SetupPath(ibc.DefaultClientOpts(), channelOpts)
s.SetupPaths(ibc.DefaultClientOpts(), channelOpts)
}

// TestMsgTransfer_Succeeds_GrandpaContract features
Expand Down
85 changes: 49 additions & 36 deletions e2e/testsuite/testsuite.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,57 +191,70 @@ func (s *E2ETestSuite) SetupChains(ctx context.Context, channelOptionsModifier C
// SetupTest will by default use the default channel options to create a path between the chains.
// if non default channel options are required, the test suite must override the `SetupTest` function.
func (s *E2ETestSuite) SetupTest() {
s.SetupPath(ibc.DefaultClientOpts(), defaultChannelOpts(s.GetAllChains()))
s.SetupPaths(ibc.DefaultClientOpts(), defaultChannelOpts(s.GetAllChains()))
}

// SetupPath creates a path between the chains using the provided client and channel options.
func (s *E2ETestSuite) SetupPath(clientOpts ibc.CreateClientOptions, channelOpts ibc.CreateChannelOptions) {
// SetupPaths creates paths between the chains using the provided client and channel options.
// The paths are created such that ChainA is connected to ChainB, ChainB is connected to ChainC etc.
func (s *E2ETestSuite) SetupPaths(clientOpts ibc.CreateClientOptions, channelOpts ibc.CreateChannelOptions) {
s.T().Logf("Setting up path for: %s", s.T().Name())
r := s.GetRelayer()

if s.channels[s.T().Name()] == nil {
s.channels[s.T().Name()] = make(map[ibc.Chain][]ibc.ChannelOutput)
}

ctx := context.TODO()
allChains := s.GetAllChains()
for i := 0; i < len(allChains)-1; i++ {
chainA, chainB := allChains[i], allChains[i+1]
pathName := s.generatePathName()
s.T().Logf("establishing path between %s and %s on path %s", chainA.Config().ChainID, chainB.Config().ChainID, pathName)
_, _ = s.CreatePath(ctx, chainA, chainB, clientOpts, channelOpts)
}
}

func (s *E2ETestSuite) CreatePath(
DimitrisJim marked this conversation as resolved.
Show resolved Hide resolved
ctx context.Context,
chainA ibc.Chain,
chainB ibc.Chain,
clientOpts ibc.CreateClientOptions,
channelOpts ibc.CreateChannelOptions,
) (chainAChannel ibc.ChannelOutput, chainBChannel ibc.ChannelOutput) {
r := s.GetRelayer()

err := r.GeneratePath(ctx, s.GetRelayerExecReporter(), chainA.Config().ChainID, chainB.Config().ChainID, pathName)
s.Require().NoError(err)
pathName := s.generatePathName()
s.T().Logf("establishing path between %s and %s on path %s", chainA.Config().ChainID, chainB.Config().ChainID, pathName)

// Create new clients
err = r.CreateClients(ctx, s.GetRelayerExecReporter(), pathName, clientOpts)
s.Require().NoError(err)
err = test.WaitForBlocks(ctx, 1, chainA, chainB)
s.Require().NoError(err)
err := r.GeneratePath(ctx, s.GetRelayerExecReporter(), chainA.Config().ChainID, chainB.Config().ChainID, pathName)
s.Require().NoError(err)

err = r.CreateConnections(ctx, s.GetRelayerExecReporter(), pathName)
s.Require().NoError(err)
err = test.WaitForBlocks(ctx, 1, chainA, chainB)
s.Require().NoError(err)
// Create new clients
err = r.CreateClients(ctx, s.GetRelayerExecReporter(), pathName, clientOpts)
s.Require().NoError(err)
err = test.WaitForBlocks(ctx, 1, chainA, chainB)
s.Require().NoError(err)

err = r.CreateChannel(ctx, s.GetRelayerExecReporter(), pathName, channelOpts)
s.Require().NoError(err)
err = test.WaitForBlocks(ctx, 1, chainA, chainB)
s.Require().NoError(err)
err = r.CreateConnections(ctx, s.GetRelayerExecReporter(), pathName)
s.Require().NoError(err)
err = test.WaitForBlocks(ctx, 1, chainA, chainB)
s.Require().NoError(err)

s.testPaths[s.T().Name()] = append(s.testPaths[s.T().Name()], pathName)
err = r.CreateChannel(ctx, s.GetRelayerExecReporter(), pathName, channelOpts)
s.Require().NoError(err)
err = test.WaitForBlocks(ctx, 1, chainA, chainB)
s.Require().NoError(err)

for _, c := range []ibc.Chain{chainA, chainB} {
channels, err := r.GetChannels(ctx, s.GetRelayerExecReporter(), c.Config().ChainID)
s.Require().NoError(err)
channelsA, err := r.GetChannels(ctx, s.GetRelayerExecReporter(), chainA.Config().ChainID)
s.Require().NoError(err)

// only the most recent channel is relevant.
s.channels[s.T().Name()][c] = []ibc.ChannelOutput{channels[len(channels)-1]}
channelsB, err := r.GetChannels(ctx, s.GetRelayerExecReporter(), chainB.Config().ChainID)
s.Require().NoError(err)

err = relayer.ApplyPacketFilter(ctx, s.T(), r, c.Config().ChainID, channels)
s.Require().NoError(err, "failed to watch port and channel on chain: %s", c.Config().ChainID)
}
if s.channels[s.T().Name()] == nil {
s.channels[s.T().Name()] = make(map[ibc.Chain][]ibc.ChannelOutput)
}

// keep track of channels associated with a given chain for access within the tests.
s.channels[s.T().Name()][chainA] = channelsA
s.channels[s.T().Name()][chainB] = channelsB
Comment on lines +253 to +254
Copy link
Contributor Author

Choose a reason for hiding this comment

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

there was a fix on main that assigns the correct values here, should look something like ibc.ChannelOutput{channelsA[len(channelsA)-1]}

Only the last channel created is relevant for this test. tagging myself to fix! @chatton

Copy link
Contributor Author

Choose a reason for hiding this comment

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

there's actually a small restructure that needs to happen here #6721 I will address this in that PR once it gets synced with main after this is merged


s.testPaths[s.T().Name()] = append(s.testPaths[s.T().Name()], pathName)

return channelsA[len(channelsA)-1], channelsB[len(channelsB)-1]
}

// GetChainAChannel returns the ibc.ChannelOutput for the current test.
Expand Down Expand Up @@ -692,7 +705,7 @@ func getValidatorsAndFullNodes(chainIdx int) (int, int) {
}

// GetMsgTransfer returns a MsgTransfer that is constructed based on the channel version
func GetMsgTransfer(portID, channelID, version string, tokens sdk.Coins, sender, receiver string, timeoutHeight clienttypes.Height, timeoutTimestamp uint64, memo string) *transfertypes.MsgTransfer {
func GetMsgTransfer(portID, channelID, version string, tokens sdk.Coins, sender, receiver string, timeoutHeight clienttypes.Height, timeoutTimestamp uint64, memo string, forwarding transfertypes.Forwarding) *transfertypes.MsgTransfer {
if len(tokens) == 0 {
panic(errors.New("tokens cannot be empty"))
}
Expand All @@ -712,7 +725,7 @@ func GetMsgTransfer(portID, channelID, version string, tokens sdk.Coins, sender,
Tokens: sdk.NewCoins(),
}
case transfertypes.V2:
msg = transfertypes.NewMsgTransfer(portID, channelID, tokens, sender, receiver, timeoutHeight, timeoutTimestamp, memo)
msg = transfertypes.NewMsgTransfer(portID, channelID, tokens, sender, receiver, timeoutHeight, timeoutTimestamp, memo, forwarding)
default:
panic(fmt.Errorf("unsupported transfer version: %s", version))
}
Expand Down
3 changes: 2 additions & 1 deletion e2e/testsuite/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (
"github.com/cosmos/ibc-go/e2e/testsuite/sanitize"
"github.com/cosmos/ibc-go/e2e/testvalues"
feetypes "github.com/cosmos/ibc-go/v8/modules/apps/29-fee/types"
transfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types"
clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types"
channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types"
)
Expand Down Expand Up @@ -299,7 +300,7 @@ func (s *E2ETestSuite) Transfer(ctx context.Context, chain ibc.Chain, user ibc.W
transferVersion = version.AppVersion
}

msg := GetMsgTransfer(portID, channelID, transferVersion, tokens, sender, receiver, timeoutHeight, timeoutTimestamp, memo)
msg := GetMsgTransfer(portID, channelID, transferVersion, tokens, sender, receiver, timeoutHeight, timeoutTimestamp, memo, transfertypes.Forwarding{})

return s.BroadcastMessages(ctx, chain, user, msg)
}
Expand Down
Loading
Loading