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
Changes from 1 commit
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)
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…
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
May 14, 2024
0478cb9
import renaming
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
May 14, 2024
55d7bf9
basic unit test for path forwarding
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 …
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)
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
May 23, 2024
2519593
fix lint warning, add extra godocs, and some other small fixes and cl…
May 26, 2024
3bf6c04
Merge branch 'main' into stefano/carlos/ics20-v2-forwarding-poc
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
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
May 31, 2024
7c8f516
retrieve channel capability only if there is a previous packet in store
May 31, 2024
feb7b01
Merge branch 'main' into stefano/carlos/ics20-v2-forwarding-poc
Jun 7, 2024
6fd1773
Merge branch 'main' into stefano/carlos/ics20-v2-forwarding-poc
Jun 9, 2024
efcfa5d
add missing parameter
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
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
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)
Jun 19, 2024
007dee1
nit: make set forwarded packet unexported (#6637)
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
Jun 25, 2024
c2a6bc6
remove unnecessary wrapping of function
Jun 25, 2024
c3ccbfc
Revert "remove unnecessary wrapping of function"
Jun 25, 2024
5345776
fix usage of function
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)
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
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)
Jun 26, 2024
b6d77d7
Merge branch 'main' into feat/ics20-v2-path-forwarding
Jun 27, 2024
4d19be1
add changelog
Jun 27, 2024
2838aef
add test for invalid receiver address
Jun 27, 2024
7afb7f6
Update CHANGELOG.md
Jun 27, 2024
0221c6b
Update CHANGELOG.md
Jun 27, 2024
cc46a63
make getForwardedPacket private
Jun 27, 2024
e67aeaf
remove auxiliary burn coins function
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
Jun 27, 2024
7d2a881
chore: remove unused function
Jun 27, 2024
4ea36c2
perf: allocate slice to length of packet data tokens
Jun 27, 2024
0a28e9b
Merge branch 'main' into feat/ics20-v2-path-forwarding
Jun 27, 2024
7411f2d
chore(transfer/authz): wrapf unauthorized forwarding hops
damiannolan Jun 27, 2024
199c14a
lint
Jun 27, 2024
c7af85a
Update modules/apps/transfer/types/forwarding.go
Jun 27, 2024
25239a2
Merge branch 'main' into feat/ics20-v2-path-forwarding
Jun 27, 2024
90d57db
Preallocate slice but keep len==0 (#6725)
bznein Jun 27, 2024
e310e27
imp: validate allowed forwarding hops
Jun 27, 2024
f28e937
test: unwind fails in Transfer rpc
Jun 27, 2024
50daed0
Merge branch 'main' into feat/ics20-v2-path-forwarding
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
Prev Previous commit
Next Next commit
Merge branch 'main' into stefano/carlos/ics20-v2-forwarding-poc
# Conflicts:
#	modules/apps/transfer/internal/convert/convert.go
#	modules/apps/transfer/keeper/mbt_relay_test.go
#	modules/apps/transfer/keeper/relay.go
#	modules/apps/transfer/keeper/relay_test.go
#	modules/apps/transfer/types/packet.pb.go
#	modules/apps/transfer/types/token_test.go
  • Loading branch information
Carlos Rodriguez committed May 31, 2024
commit 6d87d9574fa0f80a004c52ce8607a1bb5589b9a5
28 changes: 1 addition & 27 deletions modules/apps/transfer/internal/convert/convert.go
Original file line number Diff line number Diff line change
@@ -25,31 +25,5 @@ func PacketDataV1ToV2(packetData types.FungibleTokenPacketData) (types.FungibleT
Receiver: packetData.Receiver,
Memo: packetData.Memo,
ForwardingPath: nil,
}
}

// extractDenomAndTraceFromV1Denom extracts the base denom and remaining trace from a v1 IBC denom.
func ExtractDenomAndTraceFromV1Denom(v1Denom string) (string, []string) {
v1DenomTrace := types.ParseDenomTrace(v1Denom)

// if the path string is empty, then the base denom is the full native denom.
if v1DenomTrace.Path == "" {
return v1DenomTrace.BaseDenom, nil
}

splitPath := strings.Split(v1DenomTrace.Path, "/")

// this condition should never be reached.
if len(splitPath)%2 != 0 {
panic("pathSlice length is not even")
}

// the path slices consists of entries of ports and channel ids separately,
// we need to combine them to form the trace.
var trace []string
for i := 0; i < len(splitPath); i += 2 {
trace = append(trace, strings.Join(splitPath[i:i+2], "/"))
}

return v1DenomTrace.BaseDenom, trace
}, nil
}
1 change: 0 additions & 1 deletion modules/apps/transfer/keeper/mbt_relay_test.go
Original file line number Diff line number Diff line change
@@ -153,7 +153,6 @@ func FungibleTokenPacketFromTla(packet TlaFungibleTokenPacket) FungibleTokenPack
[]types.Token{
{
Denom: denom,
Trace: trace,
Amount: packet.Data.Amount,
},
},
20 changes: 9 additions & 11 deletions modules/apps/transfer/keeper/relay.go
Original file line number Diff line number Diff line change
@@ -224,7 +224,7 @@ func (k Keeper) OnRecvPacket(ctx sdk.Context, packet channeltypes.Packet, data t
}

escrowAddress := types.GetEscrowAddress(packet.GetDestPort(), packet.GetDestChannel())
if err := k.unescrowToken(ctx, escrowAddress, receiver, token); err != nil {
if err := k.unescrowToken(ctx, escrowAddress, receiver, coin); err != nil {
return false, err
}

@@ -248,7 +248,10 @@ func (k Keeper) OnRecvPacket(ctx sdk.Context, packet channeltypes.Packet, data t
}()

// Appending token. The new denom has been computed
receivedTokens = append(receivedTokens, token)
receivedTokens = append(receivedTokens, coin)

// Continue processing rest of tokens in packet data.
continue
}

// sender chain is the source, mint vouchers
@@ -481,24 +484,19 @@ func (k Keeper) revertInFlightChanges(ctx sdk.Context, sentPacket channeltypes.P

// the token on our chain is the token in the sentPacket
for _, token := range sentPacketData.Tokens {
fullDenomPath := token.GetFullDenomPath()

// parse the denomination from the full denom path
trace := types.ParseDenomTrace(fullDenomPath)

// parse the transfer amount
transferAmount, ok := sdkmath.NewIntFromString(token.Amount)
if !ok {
return errorsmod.Wrapf(types.ErrInvalidAmount, "unable to parse transfer amount (%s) into math.Int", transferAmount)
}
coin := sdk.NewCoin(trace.IBCDenom(), transferAmount)
coin := sdk.NewCoin(token.Denom.IBCDenom(), transferAmount)

// check if the packet we sent out was sending as source or not
// if it is source, then we escrowed the outgoing tokens
if types.SenderChainIsSource(sentPacket.SourcePort, sentPacket.SourceChannel, fullDenomPath) {
if token.Denom.SenderChainIsSource(sentPacket.SourcePort, sentPacket.SourceChannel) {
// check if the packet we received was a source token for our chain
// check if here should be ReceiverChainIsSource
if types.SenderChainIsSource(receivedPacket.DestinationPort, receivedPacket.DestinationChannel, fullDenomPath) {
if token.Denom.SenderChainIsSource(receivedPacket.DestinationPort, receivedPacket.DestinationChannel) {
// receive sent tokens from the received escrow to the forward escrow account
// so we must send the tokens back from the forward escrow to the original received escrow account
return k.unescrowToken(ctx, forwardEscrow, reverseEscrow, coin)
@@ -515,7 +513,7 @@ func (k Keeper) revertInFlightChanges(ctx sdk.Context, sentPacket channeltypes.P
// in this case we burned the vouchers of the outgoing packets
// check if the packet we received was a source token for our chain
// in this case, the tokens were unescrowed from the reverse escrow account
if types.SenderChainIsSource(receivedPacket.DestinationPort, receivedPacket.DestinationChannel, fullDenomPath) {
if token.Denom.SenderChainIsSource(receivedPacket.DestinationPort, receivedPacket.DestinationChannel) {
// in this case we must mint the burned vouchers and send them back to the escrow account
if err := k.bankKeeper.MintCoins(ctx, types.ModuleName, sdk.NewCoins(coin)); err != nil {
return err
54 changes: 12 additions & 42 deletions modules/apps/transfer/keeper/relay_test.go
Original file line number Diff line number Diff line change
@@ -372,31 +372,8 @@
Symbol: strings.ToUpper(denomTraceOnB.GetBaseDenom()),
}

seq := uint64(1)

if tc.recvIsSource {
// send coin from chainB to chainA, receive them, acknowledge them, and send back to chainB
coinFromBToA := sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(100))
transferMsg := types.NewMsgTransfer(path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, sdk.NewCoins(coinFromBToA), suite.chainB.SenderAccount.GetAddress().String(), suite.chainA.SenderAccount.GetAddress().String(), clienttypes.NewHeight(1, 110), 0, memo, nil)
res, err := suite.chainB.SendMsgs(transferMsg)
suite.Require().NoError(err) // message committed

packet, err := ibctesting.ParsePacketFromEvents(res.Events)
suite.Require().NoError(err)

err = path.RelayPacket(packet)
suite.Require().NoError(err) // relay committed

seq++

// NOTE: trace must be explicitly changed in malleate to test invalid cases
denomTrace = types.ParseDenomTrace(types.GetPrefixedDenom(path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, sdk.DefaultBondDenom))
} else {
denomTrace = types.ParseDenomTrace(sdk.DefaultBondDenom)
}

// send coin from chainA to chainB
coin := sdk.NewCoin(denomTrace.IBCDenom(), amount)
coin := sdk.NewCoin(sdk.DefaultBondDenom, amount)
transferMsg := types.NewMsgTransfer(path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, sdk.NewCoins(coin), suite.chainA.SenderAccount.GetAddress().String(), receiver, clienttypes.NewHeight(1, 110), 0, memo, nil)
_, err := suite.chainA.SendMsgs(transferMsg)
suite.Require().NoError(err) // message committed
@@ -536,7 +513,7 @@

// send coin from chainB to chainA, receive them, acknowledge them
coin := sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(100))
transferMsg := types.NewMsgTransfer(path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, sdk.NewCoins(coin), suite.chainB.SenderAccount.GetAddress().String(), suite.chainA.SenderAccount.GetAddress().String(), clienttypes.NewHeight(1, 110), 0, memo)
transferMsg := types.NewMsgTransfer(path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, sdk.NewCoins(coin), suite.chainB.SenderAccount.GetAddress().String(), suite.chainA.SenderAccount.GetAddress().String(), clienttypes.NewHeight(1, 110), 0, memo, nil)
res, err := suite.chainB.SendMsgs(transferMsg)
suite.Require().NoError(err) // message committed

@@ -553,7 +530,7 @@

// send coin back from chainA to chainB
coin = sdk.NewCoin(denomTrace.IBCDenom(), amount)
transferMsg = types.NewMsgTransfer(path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, sdk.NewCoins(coin), suite.chainA.SenderAccount.GetAddress().String(), receiver, clienttypes.NewHeight(1, 110), 0, memo)
transferMsg = types.NewMsgTransfer(path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, sdk.NewCoins(coin), suite.chainA.SenderAccount.GetAddress().String(), receiver, clienttypes.NewHeight(1, 110), 0, memo, nil)
_, err = suite.chainA.SendMsgs(transferMsg)
suite.Require().NoError(err) // message committed

@@ -566,10 +543,10 @@
Denom: denom,
Amount: amount.String(),
},
}, suite.chainA.SenderAccount.GetAddress().String(), receiver, memo)
}, suite.chainA.SenderAccount.GetAddress().String(), receiver, memo, nil)
packet = channeltypes.NewPacket(data.GetBytes(), seq, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, clienttypes.NewHeight(1, 100), 0)

err = suite.chainB.GetSimApp().TransferKeeper.OnRecvPacket(suite.chainB.GetContext(), packet, data)
_, err = suite.chainB.GetSimApp().TransferKeeper.OnRecvPacket(suite.chainB.GetContext(), packet, data)

// check total amount in escrow of received token denom on receiving chain
totalEscrow := suite.chainB.GetSimApp().TransferKeeper.GetTotalEscrowForDenom(suite.chainB.GetContext(), sdk.DefaultBondDenom)
@@ -1309,15 +1286,12 @@
suite.Require().NoError(err)
suite.Require().NotNil(packet)

denomTrace := types.ParseDenomTrace(sdk.DefaultBondDenom)

denom, trace := convertinternal.ExtractDenomAndTraceFromV1Denom(denomTrace.GetFullDenomPath())
denom := types.Denom{Base: sdk.DefaultBondDenom}
data := types.NewFungibleTokenPacketDataV2(
[]types.Token{
{
Denom: denom,
Amount: amount.String(),
Trace: trace,
},
}, sender.GetAddress().String(), receiver.GetAddress().String(), "", &forwardingPath)
packetRecv := channeltypes.NewPacket(data.GetBytes(), 2, path1.EndpointA.ChannelConfig.PortID, path1.EndpointA.ChannelID, path1.EndpointB.ChannelConfig.PortID, path1.EndpointB.ChannelID, clienttypes.NewHeight(1, 100), 0)
@@ -1329,13 +1303,13 @@
suite.Require().Nil(err)

// denomTrace path: transfer/channel-0
denomTrace = types.DenomTrace{
BaseDenom: sdk.DefaultBondDenom,
Path: fmt.Sprintf("%s/%s", path1.EndpointB.ChannelConfig.PortID, path1.EndpointB.ChannelID),
denom = types.Denom{
Base: sdk.DefaultBondDenom,
Trace: []types.Trace{types.NewTrace(path1.EndpointB.ChannelConfig.PortID, path1.EndpointB.ChannelID)},
}

// Check that Escrow B has amount
coin = sdk.NewCoin(denomTrace.IBCDenom(), amount)
coin = sdk.NewCoin(denom.IBCDenom(), amount)
totalEscrowChainB := suite.chainB.GetSimApp().TransferKeeper.GetTotalEscrowForDenom(suite.chainB.GetContext(), coin.GetDenom())
suite.Require().Equal(amount, totalEscrowChainB.Amount, "escrow account on B is different than amount")

@@ -1351,13 +1325,11 @@
suite.Require().NoError(err)
suite.Require().NotNil(packet)

denom, trace = convertinternal.ExtractDenomAndTraceFromV1Denom(denomTrace.GetFullDenomPath())
data = types.NewFungibleTokenPacketDataV2(
[]types.Token{
{
Denom: denom,
Amount: amount.String(),
Trace: trace,
},
}, types.GetForwardAddress(path2.EndpointB.ChannelConfig.PortID, path2.EndpointB.ChannelID).String(), receiver.GetAddress().String(), "", nil)
packetRecv = channeltypes.NewPacket(data.GetBytes(), 3, path2.EndpointB.ChannelConfig.PortID, path2.EndpointB.ChannelID, path2.EndpointA.ChannelConfig.PortID, path2.EndpointA.ChannelID, clienttypes.NewHeight(1, 100), 0)
@@ -1602,7 +1574,7 @@

// Now we want to trigger C -> B -> A
// The coin we want to send out is exactly the one we received on C
//coin = sdk.NewCoin(denomTraceBC.IBCDenom(), amount)

Check failure on line 1577 in modules/apps/transfer/keeper/relay_test.go

GitHub Actions / lint

commentFormatting: put a space between `//` and comment text (gocritic)

sender = suite.chainC.SenderAccounts[0].SenderAccount
receiver = suite.chainA.SenderAccounts[0].SenderAccount // Receiver is the A chain account
@@ -1647,7 +1619,7 @@
suite.Require().NoError(err)
suite.Require().NotNil(result)

// We have succesfully received the packet on B and forwarded it to A.

Check failure on line 1622 in modules/apps/transfer/keeper/relay_test.go

GitHub Actions / lint

`succesfully` is a misspelling of `successfully` (misspell)
// Lets try to retrieve it in order to save it
forwardedPacket, found := suite.chainB.GetSimApp().TransferKeeper.GetForwardedPacket(suite.chainB.GetContext(), path1.EndpointB.ChannelConfig.PortID, path1.EndpointB.ChannelID, packet.Sequence)
suite.Require().True(found)
@@ -1675,7 +1647,7 @@

err = path1.EndpointA.UpdateClient()
suite.Require().NoError(err)
//suite.Require().Equal(packet, forwardedPacket)

Check failure on line 1650 in modules/apps/transfer/keeper/relay_test.go

GitHub Actions / lint

commentFormatting: put a space between `//` and comment text (gocritic)

result, err = path1.EndpointA.RecvPacketWithResult(packet)
suite.Require().Error(err)
@@ -1684,13 +1656,12 @@
// NOW WE HAVE TO SEND ACK TO B, PROPAGTE ACK TO C, CHECK FINAL RESULTS

// Reconstruct packet data
denom, trace := convertinternal.ExtractDenomAndTraceFromV1Denom(denomTraceAB.GetFullDenomPath())
denom := types.ExtractDenomFromFullPath(denomTraceAB.GetFullDenomPath())
data := types.NewFungibleTokenPacketDataV2(
[]types.Token{
{
Denom: denom,
Amount: amount.String(),
Trace: trace,
},
}, types.GetForwardAddress(path1.EndpointB.ChannelConfig.PortID, path1.EndpointB.ChannelID).String(), suite.chainA.SenderAccounts[0].SenderAccount.GetAddress().String(), "", nil)
packetRecv := channeltypes.NewPacket(data.GetBytes(), 3, path1.EndpointB.ChannelConfig.PortID, path1.EndpointB.ChannelID, path1.EndpointA.ChannelConfig.PortID, path1.EndpointA.ChannelID, clienttypes.NewHeight(1, 100), 0)
@@ -1699,7 +1670,7 @@
suite.Require().NoError(err)
ack := channeltypes.NewErrorAcknowledgement(fmt.Errorf("failed packet transfer"))

//err = path1.EndpointA.AcknowledgePacket(packetRecv, ack.Acknowledgement())

Check failure on line 1673 in modules/apps/transfer/keeper/relay_test.go

GitHub Actions / lint

commentFormatting: put a space between `//` and comment text (gocritic)
err = suite.chainB.GetSimApp().TransferKeeper.OnAcknowledgementPacket(suite.chainB.GetContext(), packetRecv, data, ack)
suite.Require().NoError(err)

@@ -1711,16 +1682,15 @@
totalEscrowChainB = suite.chainB.GetSimApp().TransferKeeper.GetTotalEscrowForDenom(suite.chainB.GetContext(), coin.GetDenom())
suite.Require().Equal(sdkmath.NewInt(100), totalEscrowChainB.Amount)

denom, trace = convertinternal.ExtractDenomAndTraceFromV1Denom(denomTraceABC.GetFullDenomPath())
denom = types.ExtractDenomFromFullPath(denomTraceABC.GetFullDenomPath())
data = types.NewFungibleTokenPacketDataV2(
[]types.Token{
{
Denom: denom,
Amount: amount.String(),
Trace: trace,
},
}, suite.chainC.SenderAccounts[0].SenderAccount.GetAddress().String(), suite.chainA.SenderAccounts[0].SenderAccount.GetAddress().String(), "", nil)
//suite.chainC.SenderAccounts[0].SenderAccount.GetAddress().String() This should be forward account of B

Check failure on line 1693 in modules/apps/transfer/keeper/relay_test.go

GitHub Actions / lint

commentFormatting: put a space between `//` and comment text (gocritic)
packet = channeltypes.NewPacket(data.GetBytes(), 3, path2.EndpointB.ChannelConfig.PortID, path2.EndpointB.ChannelID, path2.EndpointA.ChannelConfig.PortID, path2.EndpointA.ChannelID, clienttypes.NewHeight(1, 100), 0)

err = path2.EndpointB.UpdateClient()
@@ -1733,7 +1703,7 @@

// Execute ack
err = suite.chainC.GetSimApp().TransferKeeper.OnAcknowledgementPacket(suite.chainC.GetContext(), packet, data, ack)
//err = path2.EndpointB.AcknowledgePacket(packet, ack.Acknowledgement())

Check failure on line 1706 in modules/apps/transfer/keeper/relay_test.go

GitHub Actions / lint

commentFormatting: put a space between `//` and comment text (gocritic)
suite.Require().NoError(err)

// Check that everythig has been reverted
115 changes: 25 additions & 90 deletions modules/apps/transfer/types/packet.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading
You are viewing a condensed version of this merge commit. You can view the full changes here.