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

ICS 20 Cleanup and Tests #5577

Merged
merged 23 commits into from
Feb 20, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
d3ee967
Add comments, remove unused code and attempt to point to places where…
jackzampolin Jan 27, 2020
6adb6ed
Merge branch 'ibc-alpha' of https://github.com/cosmos/cosmos-sdk into…
fedekunze Jan 31, 2020
c6e2321
close channel when transfer fails
fedekunze Jan 31, 2020
965440f
rename packer data transfer to align to spec; refactor table tests
fedekunze Feb 3, 2020
05fee3f
ICS 20 implementation cleanup work (#5602)
cwgoes Feb 3, 2020
4ddaf28
Merge branch 'ibc-alpha' into jack/ics-20
cwgoes Feb 3, 2020
f068bf8
merge ibc-alpha
fedekunze Feb 18, 2020
61b7eee
Merge branch 'ibc-alpha' of https://github.com/cosmos/cosmos-sdk into…
fedekunze Feb 18, 2020
7dfd6b9
Merge PR #5603: Remove acknowledgement interface in favour of []byte
cwgoes Feb 18, 2020
6f5ad5c
fixes and cleanup
fedekunze Feb 19, 2020
f9fcce8
ibc alpha changes
fedekunze Feb 19, 2020
f56fd31
spec compliance
fedekunze Feb 19, 2020
1068bb5
refactor relay prefixes and tests
fedekunze Feb 19, 2020
37436b1
Fix test compilation
jackzampolin Feb 19, 2020
dac12e8
Merge branch 'ibc-alpha' of https://github.com/cosmos/cosmos-sdk into…
fedekunze Feb 20, 2020
05b3e48
cleanup; add notes and additional test case
fedekunze Feb 20, 2020
4f9763e
Receive transfer test
fedekunze Feb 20, 2020
4db79ba
Apply suggestions from code review
cwgoes Feb 20, 2020
e8cca15
Fix autolinter application
cwgoes Feb 20, 2020
4d14d36
Add testcase with incorrect prefix
cwgoes Feb 20, 2020
b31d01b
golangcibot fixes
fedekunze Feb 20, 2020
06fa17c
timeout test
fedekunze Feb 20, 2020
74815b6
delete extra comment
fedekunze Feb 20, 2020
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
2 changes: 1 addition & 1 deletion x/ibc/04-channel/types/msgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ func (msg MsgPacket) GetSigners() []sdk.AccAddress {

var _ sdk.Msg = MsgTimeout{}

// MsgTimeout receives timeouted packet
// MsgTimeout receives timed-out packet
type MsgTimeout struct {
Packet `json:"packet" yaml:"packet"`
NextSequenceRecv uint64 `json:"next_sequence_recv" yaml:"next_sequence_recv"`
Expand Down
1 change: 0 additions & 1 deletion x/ibc/20-transfer/alias.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,5 @@ type (
ConnectionKeeper = types.ConnectionKeeper
SupplyKeeper = types.SupplyKeeper
MsgTransfer = types.MsgTransfer
MsgRecvPacket = types.MsgRecvPacket
PacketDataTransfer = types.PacketDataTransfer
)
1 change: 0 additions & 1 deletion x/ibc/20-transfer/client/cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ func GetTxCmd(cdc *codec.Codec) *cobra.Command {

ics20TransferTxCmd.AddCommand(flags.PostCommands(
GetTransferTxCmd(cdc),
// GetMsgRecvPacketCmd(cdc),
)...)

return ics20TransferTxCmd
Expand Down
7 changes: 0 additions & 7 deletions x/ibc/20-transfer/client/rest/swagger.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,4 @@ type (
Signatures []auth.StdSignature `json:"signatures" yaml:"signatures"`
Memo string `json:"memo" yaml:"memo"`
}

PostRecvPacket struct {
Msgs []types.MsgRecvPacket `json:"msg" yaml:"msg"`
Fee auth.StdFee `json:"fee" yaml:"fee"`
Signatures []auth.StdSignature `json:"signatures" yaml:"signatures"`
Memo string `json:"memo" yaml:"memo"`
}
)
1 change: 1 addition & 0 deletions x/ibc/20-transfer/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
// InitGenesis sets distribution information for genesis
func InitGenesis(ctx sdk.Context, keeper Keeper) {
// check if the module account exists
// TODO: should we create the module account if it doesn't exist?
Copy link
Collaborator

Choose a reason for hiding this comment

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

the desired logic is to panic the application if the module account is not initialized on app.go

moduleAcc := keeper.GetTransferAccount(ctx)
if moduleAcc == nil {
panic(fmt.Sprintf("%s module account has not been set", types.GetModuleAccountName()))
Expand Down
4 changes: 4 additions & 0 deletions x/ibc/20-transfer/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
)

// NewHandler returns sdk.Handler for IBC token transfer module messages
// See NewHandler function in ADR15: https://github.com/cosmos/ics/tree/master/spec/ics-020-fungible-token-transfer#packet-relay
fedekunze marked this conversation as resolved.
Show resolved Hide resolved
func NewHandler(k Keeper) sdk.Handler {
return func(ctx sdk.Context, msg sdk.Msg) (*sdk.Result, error) {
switch msg := msg.(type) {
Expand All @@ -34,6 +35,7 @@ func NewHandler(k Keeper) sdk.Handler {
}
}

// See createOutgoingPacket in spec:https://github.com/cosmos/ics/tree/master/spec/ics-020-fungible-token-transfer#packet-relay
fedekunze marked this conversation as resolved.
Show resolved Hide resolved
func handleMsgTransfer(ctx sdk.Context, k Keeper, msg MsgTransfer) (*sdk.Result, error) {
err := k.SendTransfer(ctx, msg.SourcePort, msg.SourceChannel, msg.Amount, msg.Sender, msg.Receiver, msg.Source)
if err != nil {
Expand All @@ -54,6 +56,7 @@ func handleMsgTransfer(ctx sdk.Context, k Keeper, msg MsgTransfer) (*sdk.Result,
}, nil
}

// See onRecvPacket in spec: https://github.com/cosmos/ics/tree/master/spec/ics-020-fungible-token-transfer#packet-relay
func handlePacketDataTransfer(ctx sdk.Context, k Keeper, msg channeltypes.MsgPacket, data types.PacketDataTransfer) (*sdk.Result, error) {
packet := msg.Packet
err := k.ReceiveTransfer(ctx, packet.SourcePort, packet.SourceChannel, packet.DestinationPort, packet.DestinationChannel, data)
Expand Down Expand Up @@ -83,6 +86,7 @@ func handlePacketDataTransfer(ctx sdk.Context, k Keeper, msg channeltypes.MsgPac
}, nil
}

// See onTimeoutPacket in spec: https://github.com/cosmos/ics/tree/master/spec/ics-020-fungible-token-transfer#packet-relay
func handleTimeoutDataTransfer(ctx sdk.Context, k Keeper, msg channeltypes.MsgTimeout, data types.PacketDataTransfer) (*sdk.Result, error) {
packet := msg.Packet
err := k.TimeoutTransfer(ctx, packet.SourcePort, packet.SourceChannel, packet.DestinationPort, packet.DestinationChannel, data)
Expand Down
172 changes: 0 additions & 172 deletions x/ibc/20-transfer/keeper/callbacks.go

This file was deleted.

51 changes: 0 additions & 51 deletions x/ibc/20-transfer/keeper/callbacks_test.go

This file was deleted.

4 changes: 4 additions & 0 deletions x/ibc/20-transfer/keeper/relay.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ func (k Keeper) TimeoutTransfer(
return k.supplyKeeper.SendCoinsFromModuleToAccount(ctx, types.GetModuleAccountName(), data.Sender, data.Amount)
}

// See spec for this function: https://github.com/cosmos/ics/tree/master/spec/ics-020-fungible-token-transfer#packet-relay
func (k Keeper) createOutgoingPacket(
ctx sdk.Context,
seq uint64,
Expand All @@ -149,6 +150,7 @@ func (k Keeper) createOutgoingPacket(
// escrow tokens if the destination chain is the same as the sender's
escrowAddress := types.GetEscrowAddress(sourcePort, sourceChannel)

// construct receiving denominations, check correctness
prefix := types.GetDenomPrefix(destinationPort, destinationChannel)
coins := make(sdk.Coins, len(amount))
for i, coin := range amount {
Expand All @@ -161,13 +163,15 @@ func (k Keeper) createOutgoingPacket(
coins[i] = sdk.NewCoin(coin.Denom[len(prefix):], coin.Amount)
}

// escrow source tokens (assumed to fail if balance insufficient)
fedekunze marked this conversation as resolved.
Show resolved Hide resolved
err := k.bankKeeper.SendCoins(ctx, sender, escrowAddress, coins)
if err != nil {
return err
}

} else {
// burn vouchers from the sender's balance if the source is from another chain
// construct receiving denomination, check correctness
prefix := types.GetDenomPrefix(sourcePort, sourceChannel)
for _, coin := range amount {
if !strings.HasPrefix(coin.Denom, prefix) {
Expand Down
Loading