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

fix: used the Timeout instead of two timeoutHeight and timeoutTimestamp #3732

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/controller/keeper"
"github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/controller/types"
icatypes "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/types"
clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types"
channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types"
porttypes "github.com/cosmos/ibc-go/v7/modules/core/05-port/types"
host "github.com/cosmos/ibc-go/v7/modules/core/24-host"
Expand Down Expand Up @@ -231,8 +230,7 @@ func (im IBCMiddleware) SendPacket(
chanCap *capabilitytypes.Capability,
sourcePort string,
sourceChannel string,
timeoutHeight clienttypes.Height,
timeoutTimestamp uint64,
timeout channeltypes.Timeout,
data []byte,
) (uint64, error) {
panic("SendPacket not supported for ICA controller module. Please use SendTx")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func (k Keeper) sendTx(ctx sdk.Context, connectionID, portID string, icaPacketDa
return 0, errorsmod.Wrap(err, "invalid interchain account packet data")
}

sequence, err := k.ics4Wrapper.SendPacket(ctx, chanCap, portID, activeChannelID, clienttypes.ZeroHeight(), timeoutTimestamp, icaPacketData.GetBytes())
sequence, err := k.ics4Wrapper.SendPacket(ctx, chanCap, portID, activeChannelID, channeltypes.Timeout{Height: clienttypes.ZeroHeight(), Timestamp: timeoutTimestamp}, icaPacketData.GetBytes())
if err != nil {
return 0, err
}
Expand Down
6 changes: 2 additions & 4 deletions modules/apps/29-fee/ibc_middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (

"github.com/cosmos/ibc-go/v7/modules/apps/29-fee/keeper"
"github.com/cosmos/ibc-go/v7/modules/apps/29-fee/types"
clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types"
channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types"
porttypes "github.com/cosmos/ibc-go/v7/modules/core/05-port/types"
"github.com/cosmos/ibc-go/v7/modules/core/exported"
Expand Down Expand Up @@ -326,11 +325,10 @@ func (im IBCMiddleware) SendPacket(
chanCap *capabilitytypes.Capability,
sourcePort string,
sourceChannel string,
timeoutHeight clienttypes.Height,
timeoutTimestamp uint64,
timeout channeltypes.Timeout,
data []byte,
) (uint64, error) {
return im.keeper.SendPacket(ctx, chanCap, sourcePort, sourceChannel, timeoutHeight, timeoutTimestamp, data)
return im.keeper.SendPacket(ctx, chanCap, sourcePort, sourceChannel, timeout, data)
}

// WriteAcknowledgement implements the ICS4 Wrapper interface
Expand Down
6 changes: 2 additions & 4 deletions modules/apps/29-fee/keeper/relay.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types"

"github.com/cosmos/ibc-go/v7/modules/apps/29-fee/types"
clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types"
channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types"
ibcexported "github.com/cosmos/ibc-go/v7/modules/core/exported"
)
Expand All @@ -19,11 +18,10 @@ func (k Keeper) SendPacket(
chanCap *capabilitytypes.Capability,
sourcePort string,
sourceChannel string,
timeoutHeight clienttypes.Height,
timeoutTimestamp uint64,
timeout channeltypes.Timeout,
data []byte,
) (uint64, error) {
return k.ics4Wrapper.SendPacket(ctx, chanCap, sourcePort, sourceChannel, timeoutHeight, timeoutTimestamp, data)
return k.ics4Wrapper.SendPacket(ctx, chanCap, sourcePort, sourceChannel, timeout, data)
}

// WriteAcknowledgement wraps IBC ChannelKeeper's WriteAcknowledgement function
Expand Down
2 changes: 1 addition & 1 deletion modules/apps/transfer/keeper/relay.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ func (k Keeper) sendTransfer(
fullDenomPath, token.Amount.String(), sender.String(), receiver, memo,
)

sequence, err := k.ics4Wrapper.SendPacket(ctx, channelCap, sourcePort, sourceChannel, timeoutHeight, timeoutTimestamp, packetData.GetBytes())
sequence, err := k.ics4Wrapper.SendPacket(ctx, channelCap, sourcePort, sourceChannel, channeltypes.Timeout{Height: timeoutHeight, Timestamp: timeoutTimestamp}, packetData.GetBytes())
if err != nil {
return 0, err
}
Expand Down
11 changes: 5 additions & 6 deletions modules/core/04-channel/keeper/packet.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ func (k Keeper) SendPacket(
channelCap *capabilitytypes.Capability,
sourcePort string,
sourceChannel string,
timeoutHeight clienttypes.Height,
timeoutTimestamp uint64,
timeout types.Timeout,
data []byte,
) (uint64, error) {
channel, found := k.GetChannel(ctx, sourcePort, sourceChannel)
Expand Down Expand Up @@ -54,7 +53,7 @@ func (k Keeper) SendPacket(

// construct packet from given fields and channel state
packet := types.NewPacket(data, sequence, sourcePort, sourceChannel,
channel.Counterparty.PortId, channel.Counterparty.ChannelId, timeoutHeight, timeoutTimestamp)
channel.Counterparty.PortId, channel.Counterparty.ChannelId, timeout.Height, timeout.Timestamp)

if err := packet.ValidateBasic(); err != nil {
return 0, errorsmod.Wrap(err, "constructed packet failed basic validation")
Expand All @@ -77,10 +76,10 @@ func (k Keeper) SendPacket(

// check if packet is timed out on the receiving chain
latestHeight := clientState.GetLatestHeight()
if !timeoutHeight.IsZero() && latestHeight.GTE(timeoutHeight) {
if !timeout.Height.IsZero() && latestHeight.GTE(timeout.Height) {
return 0, errorsmod.Wrapf(
types.ErrPacketTimeout,
"receiving chain block height >= packet timeout height (%s >= %s)", latestHeight, timeoutHeight,
"receiving chain block height >= packet timeout height (%s >= %s)", latestHeight, timeout.Height,
)
}

Expand All @@ -101,7 +100,7 @@ func (k Keeper) SendPacket(
k.SetNextSequenceSend(ctx, sourcePort, sourceChannel, sequence+1)
k.SetPacketCommitment(ctx, sourcePort, sourceChannel, packet.GetSequence(), commitment)

emitSendPacketEvent(ctx, packet, channel, timeoutHeight)
emitSendPacketEvent(ctx, packet, channel, timeout.Height)

k.Logger(ctx).Info(
"packet sent",
Expand Down
2 changes: 1 addition & 1 deletion modules/core/04-channel/keeper/packet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ func (suite *KeeperTestSuite) TestSendPacket() {
expectedSequence, ok := suite.chainA.App.GetIBCKeeper().ChannelKeeper.GetNextSequenceSend(suite.chainA.GetContext(), sourcePort, sourceChannel)

sequence, err := suite.chainA.App.GetIBCKeeper().ChannelKeeper.SendPacket(suite.chainA.GetContext(), channelCap,
sourcePort, sourceChannel, timeoutHeight, timeoutTimestamp, packetData)
sourcePort, sourceChannel, types.Timeout{Height: timeoutHeight, Timestamp: timeoutTimestamp}, packetData)

if tc.expPass {
suite.Require().NoError(err)
Expand Down
4 changes: 1 addition & 3 deletions modules/core/05-port/types/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types"

clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types"
channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types"
"github.com/cosmos/ibc-go/v7/modules/core/exported"
)
Expand Down Expand Up @@ -113,8 +112,7 @@ type ICS4Wrapper interface {
chanCap *capabilitytypes.Capability,
sourcePort string,
sourceChannel string,
timeoutHeight clienttypes.Height,
timeoutTimestamp uint64,
timeout channeltypes.Timeout,
data []byte,
) (sequence uint64, err error)

Expand Down
2 changes: 1 addition & 1 deletion testing/endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ func (endpoint *Endpoint) SendPacket(
channelCap := endpoint.Chain.GetChannelCapability(endpoint.ChannelConfig.PortID, endpoint.ChannelID)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you can also update the SendPacket api on this endpoint :)


// no need to send message, acting as a module
sequence, err := endpoint.Chain.App.GetIBCKeeper().ChannelKeeper.SendPacket(endpoint.Chain.GetContext(), channelCap, endpoint.ChannelConfig.PortID, endpoint.ChannelID, timeoutHeight, timeoutTimestamp, data)
sequence, err := endpoint.Chain.App.GetIBCKeeper().ChannelKeeper.SendPacket(endpoint.Chain.GetContext(), channelCap, endpoint.ChannelConfig.PortID, endpoint.ChannelID, channeltypes.Timeout{Height: timeoutHeight, Timestamp: timeoutTimestamp}, data)
if err != nil {
return 0, err
}
Expand Down