Skip to content

Commit

Permalink
Merge branch '04-channel-upgrades' into cian/issue#5220-add-comment-f…
Browse files Browse the repository at this point in the history
…or-channel-state
  • Loading branch information
chatton authored Nov 30, 2023
2 parents 0b79bcc + b3c5164 commit 19da0cc
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
2 changes: 0 additions & 2 deletions modules/core/04-channel/keeper/timeout.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,6 @@ func (k Keeper) TimeoutExecuted(
}
// upgrade fields have been set but the timeout has not. This can happen when the counterparty
// upgrade is partially written in WriteUpgradeTryChannel.
} else if counterpartyUpgrade.Fields.Version != "" {
k.MustAbortUpgrade(ctx, packet.GetSourcePort(), packet.GetSourceChannel(), types.ErrInvalidUpgrade)
}
}

Expand Down
10 changes: 5 additions & 5 deletions modules/core/04-channel/keeper/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,8 @@ func (k Keeper) ChanUpgradeAck(

// optimistically accept version that TRY chain proposes and pass this to callback for confirmation
// in the crossing hello case, we do not modify version that our TRY call returned and instead enforce
// that both TRY calls returned the same version
// that both TRY calls returned the same version. It is possible that this will fail in the OnChanUpgradeAck
// callback if the version is invalid.
if channel.IsOpen() {
upgrade.Fields.Version = counterpartyUpgrade.Fields.Version
}
Expand Down Expand Up @@ -935,19 +936,18 @@ func (k Keeper) restoreChannel(ctx sdk.Context, portID, channelID string, upgrad
// delete state associated with upgrade which is no longer required.
k.deleteUpgradeInfo(ctx, portID, channelID)

_ = k.WriteErrorReceipt(ctx, portID, channelID, err)
k.WriteErrorReceipt(ctx, portID, channelID, err)

return channel
}

// WriteErrorReceipt will write an error receipt from the provided UpgradeError.
func (k Keeper) WriteErrorReceipt(ctx sdk.Context, portID, channelID string, upgradeError *types.UpgradeError) error {
func (k Keeper) WriteErrorReceipt(ctx sdk.Context, portID, channelID string, upgradeError *types.UpgradeError) {
channel, found := k.GetChannel(ctx, portID, channelID)
if !found {
return errorsmod.Wrapf(types.ErrChannelNotFound, "port ID (%s) channel ID (%s)", portID, channelID)
panic(errorsmod.Wrapf(types.ErrChannelNotFound, "port ID (%s) channel ID (%s)", portID, channelID))
}

k.SetUpgradeErrorReceipt(ctx, portID, channelID, upgradeError.GetErrorReceipt())
emitErrorReceiptEvent(ctx, portID, channelID, channel, upgradeError)
return nil
}
2 changes: 1 addition & 1 deletion modules/core/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -804,7 +804,7 @@ func (k Keeper) ChannelUpgradeTry(goCtx context.Context, msg *channeltypes.MsgCh
if err != nil {
ctx.Logger().Error("channel upgrade try failed", "error", errorsmod.Wrap(err, "channel upgrade try failed"))
if channeltypes.IsUpgradeError(err) {
_ = k.ChannelKeeper.WriteErrorReceipt(ctx, msg.PortId, msg.ChannelId, err.(*channeltypes.UpgradeError))
k.ChannelKeeper.WriteErrorReceipt(ctx, msg.PortId, msg.ChannelId, err.(*channeltypes.UpgradeError))

// NOTE: a FAILURE result is returned to the client and an error receipt is written to state.
// This signals to the relayer to begin the cancel upgrade handshake subprotocol.
Expand Down

0 comments on commit 19da0cc

Please sign in to comment.