Skip to content

Commit

Permalink
04-channel: skip the timeout validation for the proxy
Browse files Browse the repository at this point in the history
Signed-off-by: Jun Kimura <jun.kimura@datachain.jp>
  • Loading branch information
bluele committed Jan 20, 2022
1 parent 6582d8c commit a627cf5
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 13 deletions.
17 changes: 10 additions & 7 deletions modules/core/04-channel/keeper/packet.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,21 +77,24 @@ func (k Keeper) SendPacket(
// check if packet is timed out on the receiving chain
latestHeight := clientState.GetLatestHeight()
timeoutHeight := packet.GetTimeoutHeight()
if !timeoutHeight.IsZero() && latestHeight.GTE(timeoutHeight) {
return sdkerrors.Wrapf(
types.ErrPacketTimeout,
"receiving chain block height >= packet timeout height (%s >= %s)", latestHeight, timeoutHeight,
)
}

clientType, _, err := clienttypes.ParseClientIdentifier(connectionEnd.GetClientID())
if err != nil {
return err
}

if clientType != exported.Proxy {
if !timeoutHeight.IsZero() && latestHeight.GTE(timeoutHeight) {
return sdkerrors.Wrapf(
types.ErrPacketTimeout,
"receiving chain block height >= packet timeout height (%s >= %s)", latestHeight, timeoutHeight,
)
}
}

// NOTE: this is a temporary fix. Solo machine does not support usage of 'GetTimestampAtHeight'
// A future change should move this function to be a ClientState callback.
if clientType != exported.Solomachine {
if clientType != exported.Solomachine && clientType != exported.Proxy {
latestTimestamp, err := k.connectionKeeper.GetTimestampAtHeight(ctx, connectionEnd, latestHeight)
if err != nil {
return err
Expand Down
19 changes: 13 additions & 6 deletions modules/core/04-channel/keeper/timeout.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types"
clienttypes "github.com/cosmos/ibc-go/modules/core/02-client/types"
connectiontypes "github.com/cosmos/ibc-go/modules/core/03-connection/types"
"github.com/cosmos/ibc-go/modules/core/04-channel/types"
host "github.com/cosmos/ibc-go/modules/core/24-host"
Expand Down Expand Up @@ -66,16 +67,22 @@ func (k Keeper) TimeoutPacket(
)
}

// check that timeout height or timeout timestamp has passed on the other end
proofTimestamp, err := k.connectionKeeper.GetTimestampAtHeight(ctx, connectionEnd, proofHeight)
clientType, _, err := clienttypes.ParseClientIdentifier(connectionEnd.GetClientID())
if err != nil {
return err
}

timeoutHeight := packet.GetTimeoutHeight()
if (timeoutHeight.IsZero() || proofHeight.LT(timeoutHeight)) &&
(packet.GetTimeoutTimestamp() == 0 || proofTimestamp < packet.GetTimeoutTimestamp()) {
return sdkerrors.Wrap(types.ErrPacketTimeout, "packet timeout has not been reached for height or timestamp")
if clientType != exported.Proxy {
// check that timeout height or timeout timestamp has passed on the other end
proofTimestamp, err := k.connectionKeeper.GetTimestampAtHeight(ctx, connectionEnd, proofHeight)
if err != nil {
return err
}
timeoutHeight := packet.GetTimeoutHeight()
if (timeoutHeight.IsZero() || proofHeight.LT(timeoutHeight)) &&
(packet.GetTimeoutTimestamp() == 0 || proofTimestamp < packet.GetTimeoutTimestamp()) {
return sdkerrors.Wrap(types.ErrPacketTimeout, "packet timeout has not been reached for height or timestamp")
}
}

commitment := k.GetPacketCommitment(ctx, packet.GetSourcePort(), packet.GetSourceChannel(), packet.GetSequence())
Expand Down
3 changes: 3 additions & 0 deletions modules/core/exported/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ const (
// for the localhost client.
Localhost string = "09-localhost"

// Proxy is the client type for IBC-Proxy
Proxy string = "proxyclient"

// Active is a status type of a client. An active client is allowed to be used.
Active Status = "Active"

Expand Down

0 comments on commit a627cf5

Please sign in to comment.