From 1293330fccd9ded7d73613b8d80e937213fc1adc Mon Sep 17 00:00:00 2001 From: Damian Nolan Date: Wed, 31 May 2023 13:05:10 +0200 Subject: [PATCH 01/21] adding boilerplate skeleton for chanUpgradeAck handler --- modules/core/04-channel/keeper/upgrade.go | 78 +++++++++++++++++++++++ modules/core/keeper/msg_server.go | 31 +++++++++ 2 files changed, 109 insertions(+) diff --git a/modules/core/04-channel/keeper/upgrade.go b/modules/core/04-channel/keeper/upgrade.go index a5693e1e3f2..0fb4d390fdc 100644 --- a/modules/core/04-channel/keeper/upgrade.go +++ b/modules/core/04-channel/keeper/upgrade.go @@ -7,6 +7,7 @@ import ( "github.com/cosmos/cosmos-sdk/telemetry" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/ibc-go/v7/internal/collections" clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types" ) @@ -92,6 +93,69 @@ func (k Keeper) WriteUpgradeTryChannel( // grab channel inside this function to get most current channel status } +// ChanUpgradeAck is called by a module to accept the ACKUPGRADE handshake step of the channel upgrade protocol. +func (k Keeper) ChanUpgradeAck( + ctx sdk.Context, + portID, + channelID string, + counterpartyFlushStatus types.Order, + counterpartyUpgrade types.Upgrade, + proofChannel, + proofUpgrade []byte, + proofHeight clienttypes.Height, +) error { + channel, found := k.GetChannel(ctx, portID, channelID) + if !found { + return errorsmod.Wrapf(types.ErrChannelNotFound, "port ID (%s) channel ID (%s)", portID, channelID) + } + + if !collections.Contains(channel.State, []types.State{types.INITUPGRADE, types.TRYUPGRADE}) { + return errorsmod.Wrapf(types.ErrInvalidChannelState, "expected one of [%s, %s], got %s", types.INITUPGRADE, types.TRYUPGRADE, channel.State) + } + + // TODO: rebase with FlushStatus and update args and error return + // abortTransactionUnless(counterpartyFlushStatus == FLUSHING || counterpartyFlushStatus == FLUSHCOMPLETE) + if !collections.Contains(counterpartyFlushStatus, []types.Order{types.UNORDERED, types.ORDERED}) { + return errorsmod.Wrapf(types.ErrInvalidChannelState, "expected one of [%s, %s], got %s", types.INITUPGRADE, types.TRYUPGRADE, channel.State) + } + + connectionEnd, err := k.GetConnection(ctx, channel.ConnectionHops[0]) + if err != nil { + return errorsmod.Wrapf(err, "failed to retrieve connection: %s", channel.ConnectionHops[0]) + } + + counterpartyHops := connectionEnd.GetCounterparty().GetConnectionID() + counterpartyChannel := types.Channel{ + State: types.TRYUPGRADE, + Ordering: channel.Ordering, + ConnectionHops: []string{counterpartyHops}, + Counterparty: types.NewCounterparty(portID, channelID), + Version: channel.Version, + UpgradeSequence: channel.UpgradeSequence, + // FlushStatus: counterpartyFlushStatus, + } + + upgrade, found := k.GetUpgrade(ctx, portID, channelID) + if !found { + return errorsmod.Wrapf(types.ErrUpgradeNotFound, "failed to retrieve channel upgrade: port ID (%s) channel ID (%s)", portID, channelID) + } + + // in the crossing hellos case, the versions returned by both on TRY must be the same + if channel.State == types.TRYUPGRADE { + if upgrade.Fields.Version != counterpartyUpgrade.Fields.Version { + // restoreChannel(portID, channelID) + return errorsmod.Wrap(types.ErrInvalidUpgrade, "todo: return types.UpgradeError(channel.UpgradeSequence, err)") + } + } + + if err := k.startFlushUpgradeHandshake(ctx, portID, channelID, upgrade.Fields, counterpartyChannel, counterpartyUpgrade, + proofChannel, proofUpgrade, proofHeight); err != nil { + return err + } + + return nil +} + // constructProposedUpgrade returns the proposed upgrade from the provided arguments. func (k Keeper) constructProposedUpgrade(ctx sdk.Context, portID, channelID string, fields types.UpgradeFields, upgradeTimeout types.Timeout) (types.Upgrade, error) { seq, found := k.GetNextSequenceSend(ctx, portID, channelID) @@ -104,3 +168,17 @@ func (k Keeper) constructProposedUpgrade(ctx sdk.Context, portID, channelID stri LatestSequenceSend: seq - 1, }, nil } + +func (k Keeper) startFlushUpgradeHandshake( + ctx sdk.Context, + portID, + channelID string, + proposedUpgradeFields types.UpgradeFields, + counterpartyChannel types.Channel, + counterpartyUpgrade types.Upgrade, + proofCounterpartyChannel, + proofUpgrade []byte, + proofHeight clienttypes.Height, +) error { + return nil +} diff --git a/modules/core/keeper/msg_server.go b/modules/core/keeper/msg_server.go index 73d2e39dcbe..e8f8efbf3f3 100644 --- a/modules/core/keeper/msg_server.go +++ b/modules/core/keeper/msg_server.go @@ -10,6 +10,7 @@ import ( clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" connectiontypes "github.com/cosmos/ibc-go/v7/modules/core/03-connection/types" + "github.com/cosmos/ibc-go/v7/modules/core/04-channel/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" coretypes "github.com/cosmos/ibc-go/v7/modules/core/types" @@ -821,6 +822,36 @@ func (k Keeper) ChannelUpgradeTry(goCtx context.Context, msg *channeltypes.MsgCh // ChannelUpgradeAck defines a rpc handler method for MsgChannelUpgradeAck. func (k Keeper) ChannelUpgradeAck(goCtx context.Context, msg *channeltypes.MsgChannelUpgradeAck) (*channeltypes.MsgChannelUpgradeAckResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + module, _, err := k.ChannelKeeper.LookupModuleByChannel(ctx, msg.PortId, msg.ChannelId) + if err != nil { + ctx.Logger().Error("channel upgrade ack failed", "port-id", msg.PortId, "error", errorsmod.Wrap(err, "could not retrieve module from port-id")) + return nil, errorsmod.Wrap(err, "could not retrieve module from port-id") + } + + cbs, ok := k.Router.GetRoute(module) + if !ok { + ctx.Logger().Error("channel upgrade ack failed", "port-id", msg.PortId, "error", errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to module: %s", module)) + return nil, errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to module: %s", module) + } + + // TODO: update msg args + err = k.ChannelKeeper.ChanUpgradeAck(ctx, msg.PortId, msg.ChannelId, channeltypes.NONE, msg.CounterpartyUpgrade, msg.ProofChannel, msg.ProofUpgradeSequence, msg.ProofHeight) + if err != nil { + ctx.Logger().Error("channel upgrade ack failed", "error", errorsmod.Wrap(err, "channel handshake upgrade ack failed")) + return nil, errorsmod.Wrap(err, "channel handshake upgrade ack failed") + } + + // TODO: update callback args?? remove counterparty channel ID?? + err = cbs.OnChanUpgradeAck(ctx, msg.PortId, msg.ChannelId, msg.CounterpartyChannel.Version, msg.CounterpartyChannel.Version) + if err != nil { + ctx.Logger().Error("channel upgrade ack callback failed", "port-id", msg.PortId, "channel-id", msg.ChannelId, "error", err.Error()) + + // restoreChannel(portID, channelID) + return &types.MsgChannelUpgradeAckResponse{}, nil + } + return nil, nil } From a8c6882d860dc92d273d1940ea83303a1d67c994 Mon Sep 17 00:00:00 2001 From: Damian Nolan Date: Mon, 5 Jun 2023 14:26:58 +0200 Subject: [PATCH 02/21] updating msg servers args --- modules/core/keeper/msg_server.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/core/keeper/msg_server.go b/modules/core/keeper/msg_server.go index cf808679ff9..6da4ae0052d 100644 --- a/modules/core/keeper/msg_server.go +++ b/modules/core/keeper/msg_server.go @@ -772,14 +772,14 @@ func (k Keeper) ChannelUpgradeAck(goCtx context.Context, msg *channeltypes.MsgCh } // TODO: update msg args - err = k.ChannelKeeper.ChanUpgradeAck(ctx, msg.PortId, msg.ChannelId, channeltypes.NONE, msg.CounterpartyUpgrade, msg.ProofChannel, msg.ProofUpgradeSequence, msg.ProofHeight) + err = k.ChannelKeeper.ChanUpgradeAck(ctx, msg.PortId, msg.ChannelId, channeltypes.NONE, msg.CounterpartyUpgrade, msg.ProofChannel, msg.ProofUpgrade, msg.ProofHeight) if err != nil { ctx.Logger().Error("channel upgrade ack failed", "error", errorsmod.Wrap(err, "channel handshake upgrade ack failed")) return nil, errorsmod.Wrap(err, "channel handshake upgrade ack failed") } - // TODO: update callback args?? remove counterparty channel ID?? - err = cbs.OnChanUpgradeAck(ctx, msg.PortId, msg.ChannelId, msg.CounterpartyChannel.Version, msg.CounterpartyChannel.Version) + // TODO: update callback args?? remove counterparty channel ID and version?? + err = cbs.OnChanUpgradeAck(ctx, msg.PortId, msg.ChannelId, "", "") if err != nil { ctx.Logger().Error("channel upgrade ack callback failed", "port-id", msg.PortId, "channel-id", msg.ChannelId, "error", err.Error()) From c17c8ed23936622499c513f153d802d7e7373e54 Mon Sep 17 00:00:00 2001 From: Damian Nolan Date: Mon, 5 Jun 2023 15:23:33 +0200 Subject: [PATCH 03/21] adding test scaffolding and syncing latest changes of feat branch --- modules/core/04-channel/keeper/upgrade.go | 10 +- .../core/04-channel/keeper/upgrade_test.go | 100 ++++++++++++++++++ modules/core/keeper/msg_server.go | 5 +- testing/endpoint.go | 7 +- 4 files changed, 110 insertions(+), 12 deletions(-) diff --git a/modules/core/04-channel/keeper/upgrade.go b/modules/core/04-channel/keeper/upgrade.go index 5c34b6f5ac3..8fdd26304d2 100644 --- a/modules/core/04-channel/keeper/upgrade.go +++ b/modules/core/04-channel/keeper/upgrade.go @@ -154,7 +154,7 @@ func (k Keeper) ChanUpgradeAck( ctx sdk.Context, portID, channelID string, - counterpartyFlushStatus types.Order, + counterpartyFlushStatus types.FlushStatus, counterpartyUpgrade types.Upgrade, proofChannel, proofUpgrade []byte, @@ -169,10 +169,8 @@ func (k Keeper) ChanUpgradeAck( return errorsmod.Wrapf(types.ErrInvalidChannelState, "expected one of [%s, %s], got %s", types.INITUPGRADE, types.TRYUPGRADE, channel.State) } - // TODO: rebase with FlushStatus and update args and error return - // abortTransactionUnless(counterpartyFlushStatus == FLUSHING || counterpartyFlushStatus == FLUSHCOMPLETE) - if !collections.Contains(counterpartyFlushStatus, []types.Order{types.UNORDERED, types.ORDERED}) { - return errorsmod.Wrapf(types.ErrInvalidChannelState, "expected one of [%s, %s], got %s", types.INITUPGRADE, types.TRYUPGRADE, channel.State) + if !collections.Contains(counterpartyFlushStatus, []types.FlushStatus{types.FLUSHING, types.FLUSHCOMPLETE}) { + return errorsmod.Wrapf(types.ErrInvalidChannelState, "expected one of [%s, %s], got %s", types.FLUSHING, types.FLUSHCOMPLETE, counterpartyFlushStatus) } connectionEnd, err := k.GetConnection(ctx, channel.ConnectionHops[0]) @@ -188,7 +186,7 @@ func (k Keeper) ChanUpgradeAck( Counterparty: types.NewCounterparty(portID, channelID), Version: channel.Version, UpgradeSequence: channel.UpgradeSequence, - // FlushStatus: counterpartyFlushStatus, + FlushStatus: counterpartyFlushStatus, } upgrade, found := k.GetUpgrade(ctx, portID, channelID) diff --git a/modules/core/04-channel/keeper/upgrade_test.go b/modules/core/04-channel/keeper/upgrade_test.go index f879431a299..bda7de9d183 100644 --- a/modules/core/04-channel/keeper/upgrade_test.go +++ b/modules/core/04-channel/keeper/upgrade_test.go @@ -126,6 +126,106 @@ func (suite *KeeperTestSuite) TestChanUpgradeInit() { } } +func (suite *KeeperTestSuite) TestChanUpgradeAck() { + var ( + path *ibctesting.Path + upgrade types.Upgrade + ) + + testCases := []struct { + name string + malleate func() + expPass bool + }{ + { + "success", + func() {}, + true, + }, + { + "success with later upgrade sequence", + func() { + channel := path.EndpointA.GetChannel() + channel.UpgradeSequence = 4 + path.EndpointA.SetChannel(channel) + }, + true, + }, + { + "channel not found", + func() { + path.EndpointA.ChannelID = "invalid-channel" + path.EndpointA.ChannelConfig.PortID = "invalid-port" + }, + false, + }, + { + "channel state is not in INITUPGRADE or TRYUPGRADE state", + func() { + suite.Require().NoError(path.EndpointA.SetChannelState(types.CLOSED)) + }, + false, + }, + { + "proposed channel connection not found", + func() { + upgrade.Fields.ConnectionHops = []string{"connection-100"} + }, + false, + }, + { + "invalid proposed channel connection state", + func() { + connectionEnd := path.EndpointA.GetConnection() + connectionEnd.State = connectiontypes.UNINITIALIZED + + suite.chainA.GetSimApp().GetIBCKeeper().ConnectionKeeper.SetConnection(suite.chainA.GetContext(), "connection-100", connectionEnd) + upgrade.Fields.ConnectionHops = []string{"connection-100"} + }, + false, + }, + } + + for _, tc := range testCases { + tc := tc + suite.Run(tc.name, func() { + suite.SetupTest() + + path = ibctesting.NewPath(suite.chainA, suite.chainB) + suite.coordinator.Setup(path) + + // path.EndpointA.ChannelConfig.ProposedUpgrade.Fields.Version = mock.UpgradeVersion + path.EndpointA.ChannelConfig.ProposedUpgrade.Fields.Version = fmt.Sprintf("%s-v2", mock.Version) + err := path.EndpointA.ChanUpgradeInit() + suite.Require().NoError(err) + + err = path.EndpointB.ChanUpgradeTry() + suite.Require().NoError(err) + + tc.malleate() + + counterpartyUpgrade, found := suite.chainB.GetSimApp().GetIBCKeeper().ChannelKeeper.GetUpgrade(suite.chainB.GetContext(), path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID) + suite.Require().True(found) + + proofChannel, proofUpgrade, proofHeight := path.EndpointA.QueryChannelUpgradeProof() + + err = suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper.ChanUpgradeAck( + suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, types.FLUSHCOMPLETE, counterpartyUpgrade, + proofChannel, proofUpgrade, proofHeight, + ) + + if tc.expPass { + // suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper.WriteUpgradeAckChannel() + // channel := path.EndpointA.GetChannel() + + suite.Require().NoError(err) + } else { + suite.Require().Error(err) + } + }) + } +} + func (suite *KeeperTestSuite) TestValidateProposedUpgradeFields() { var ( proposedUpgrade *types.UpgradeFields diff --git a/modules/core/keeper/msg_server.go b/modules/core/keeper/msg_server.go index 6da4ae0052d..d724e3fa0dd 100644 --- a/modules/core/keeper/msg_server.go +++ b/modules/core/keeper/msg_server.go @@ -752,7 +752,7 @@ func (k Keeper) ChannelUpgradeInit(goCtx context.Context, msg *channeltypes.MsgC // ChannelUpgradeTry defines a rpc handler method for MsgChannelUpgradeTry. func (k Keeper) ChannelUpgradeTry(goCtx context.Context, msg *channeltypes.MsgChannelUpgradeTry) (*channeltypes.MsgChannelUpgradeTryResponse, error) { - return nil, nil + return &channeltypes.MsgChannelUpgradeTryResponse{}, nil } // ChannelUpgradeAck defines a rpc handler method for MsgChannelUpgradeAck. @@ -771,8 +771,7 @@ func (k Keeper) ChannelUpgradeAck(goCtx context.Context, msg *channeltypes.MsgCh return nil, errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to module: %s", module) } - // TODO: update msg args - err = k.ChannelKeeper.ChanUpgradeAck(ctx, msg.PortId, msg.ChannelId, channeltypes.NONE, msg.CounterpartyUpgrade, msg.ProofChannel, msg.ProofUpgrade, msg.ProofHeight) + err = k.ChannelKeeper.ChanUpgradeAck(ctx, msg.PortId, msg.ChannelId, msg.CounterpartyFlushStatus, msg.CounterpartyUpgrade, msg.ProofChannel, msg.ProofUpgrade, msg.ProofHeight) if err != nil { ctx.Logger().Error("channel upgrade ack failed", "error", errorsmod.Wrap(err, "channel handshake upgrade ack failed")) return nil, errorsmod.Wrap(err, "channel handshake upgrade ack failed") diff --git a/testing/endpoint.go b/testing/endpoint.go index e766a1527ed..7044e5ed349 100644 --- a/testing/endpoint.go +++ b/testing/endpoint.go @@ -600,10 +600,11 @@ func (endpoint *Endpoint) ChanUpgradeInit() error { } // ChanUpgradeTry sends a MsgChannelUpgradeTry on the associated endpoint. -func (endpoint *Endpoint) ChanUpgradeTry(timeout channeltypes.Timeout) error { +func (endpoint *Endpoint) ChanUpgradeTry() error { err := endpoint.UpdateClient() require.NoError(endpoint.Chain.TB, err) + upgrade := endpoint.GetProposedUpgrade() proofChannel, proofUpgrade, height := endpoint.QueryChannelUpgradeProof() counterpartyUpgrade, found := endpoint.Counterparty.Chain.App.GetIBCKeeper().ChannelKeeper.GetUpgrade(endpoint.Counterparty.Chain.GetContext(), endpoint.Counterparty.ChannelConfig.PortID, endpoint.Counterparty.ChannelID) @@ -612,8 +613,8 @@ func (endpoint *Endpoint) ChanUpgradeTry(timeout channeltypes.Timeout) error { msg := channeltypes.NewMsgChannelUpgradeTry( endpoint.ChannelConfig.PortID, endpoint.ChannelID, - []string{endpoint.ConnectionID}, - timeout, + upgrade.Fields.ConnectionHops, + upgrade.Timeout, counterpartyUpgrade, endpoint.Counterparty.GetChannel().UpgradeSequence, proofChannel, From fbacd836c28ca4d121d9ba944b91afb4f7bb5608 Mon Sep 17 00:00:00 2001 From: Damian Nolan Date: Tue, 6 Jun 2023 12:06:58 +0200 Subject: [PATCH 04/21] configure both proposed upgrades to use mock.UpgradeVersion --- modules/core/04-channel/keeper/upgrade_test.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/modules/core/04-channel/keeper/upgrade_test.go b/modules/core/04-channel/keeper/upgrade_test.go index bda7de9d183..b2e9b1de865 100644 --- a/modules/core/04-channel/keeper/upgrade_test.go +++ b/modules/core/04-channel/keeper/upgrade_test.go @@ -194,8 +194,9 @@ func (suite *KeeperTestSuite) TestChanUpgradeAck() { path = ibctesting.NewPath(suite.chainA, suite.chainB) suite.coordinator.Setup(path) - // path.EndpointA.ChannelConfig.ProposedUpgrade.Fields.Version = mock.UpgradeVersion - path.EndpointA.ChannelConfig.ProposedUpgrade.Fields.Version = fmt.Sprintf("%s-v2", mock.Version) + path.EndpointA.ChannelConfig.ProposedUpgrade.Fields.Version = mock.UpgradeVersion + path.EndpointB.ChannelConfig.ProposedUpgrade.Fields.Version = mock.UpgradeVersion + err := path.EndpointA.ChanUpgradeInit() suite.Require().NoError(err) From f92edcb308cb1a3b7cef69d17a28c3aa2b3cb9d0 Mon Sep 17 00:00:00 2001 From: Damian Nolan Date: Mon, 12 Jun 2023 17:56:27 +0200 Subject: [PATCH 05/21] updating chanUpgradeAck test cases --- modules/core/04-channel/keeper/upgrade.go | 9 +- .../core/04-channel/keeper/upgrade_test.go | 85 ++++++++++++++----- 2 files changed, 69 insertions(+), 25 deletions(-) diff --git a/modules/core/04-channel/keeper/upgrade.go b/modules/core/04-channel/keeper/upgrade.go index f893d2dcf61..ea0f019d1f6 100644 --- a/modules/core/04-channel/keeper/upgrade.go +++ b/modules/core/04-channel/keeper/upgrade.go @@ -191,7 +191,7 @@ func (k Keeper) WriteUpgradeTryChannel(ctx sdk.Context, portID, channelID string previousState := channel.State channel.State = types.TRYUPGRADE // TODO: determine flush status - // channel.FlushStatus = flushStatus + channel.FlushStatus = types.FLUSHING upgrade.Fields.Version = upgradeVersion @@ -237,11 +237,11 @@ func (k Keeper) ChanUpgradeAck( return errorsmod.Wrapf(err, "failed to retrieve connection: %s", channel.ConnectionHops[0]) } - counterpartyHops := connectionEnd.GetCounterparty().GetConnectionID() + counterpartyHops := []string{connectionEnd.GetCounterparty().GetConnectionID()} counterpartyChannel := types.Channel{ State: types.TRYUPGRADE, Ordering: channel.Ordering, - ConnectionHops: []string{counterpartyHops}, + ConnectionHops: counterpartyHops, Counterparty: types.NewCounterparty(portID, channelID), Version: channel.Version, UpgradeSequence: channel.UpgradeSequence, @@ -256,8 +256,7 @@ func (k Keeper) ChanUpgradeAck( // in the crossing hellos case, the versions returned by both on TRY must be the same if channel.State == types.TRYUPGRADE { if upgrade.Fields.Version != counterpartyUpgrade.Fields.Version { - // restoreChannel(portID, channelID) - return errorsmod.Wrap(types.ErrInvalidUpgrade, "todo: return types.UpgradeError(channel.UpgradeSequence, err)") + return types.NewUpgradeError(channel.UpgradeSequence, errorsmod.Wrap(types.ErrIncompatibleCounterpartyUpgrade, "both channel ends must agree on the same version")) } } diff --git a/modules/core/04-channel/keeper/upgrade_test.go b/modules/core/04-channel/keeper/upgrade_test.go index 08c1bbe8137..4eb167237a2 100644 --- a/modules/core/04-channel/keeper/upgrade_test.go +++ b/modules/core/04-channel/keeper/upgrade_test.go @@ -327,8 +327,8 @@ func (suite *KeeperTestSuite) TestChanUpgradeTry() { func (suite *KeeperTestSuite) TestChanUpgradeAck() { var ( - path *ibctesting.Path - upgrade types.Upgrade + path *ibctesting.Path + counterpartyFlushStatus types.FlushStatus ) testCases := []struct { @@ -341,15 +341,18 @@ func (suite *KeeperTestSuite) TestChanUpgradeAck() { func() {}, true, }, - { - "success with later upgrade sequence", - func() { - channel := path.EndpointA.GetChannel() - channel.UpgradeSequence = 4 - path.EndpointA.SetChannel(channel) - }, - true, - }, + // { + // "success with later upgrade sequence", + // func() { + // channel := path.EndpointA.GetChannel() + // channel.UpgradeSequence = 4 + // path.EndpointA.SetChannel(channel) + + // err := path.EndpointA.UpdateClient() + // suite.Require().NoError(err) + // }, + // true, + // }, { "channel not found", func() { @@ -366,20 +369,60 @@ func (suite *KeeperTestSuite) TestChanUpgradeAck() { false, }, { - "proposed channel connection not found", + "counterparty flush status is not in FLUSHING or FLUSHCOMPLETE", func() { - upgrade.Fields.ConnectionHops = []string{"connection-100"} + counterpartyFlushStatus = types.NOTINFLUSH }, false, }, { - "invalid proposed channel connection state", + "connection not found", + func() { + channel := path.EndpointA.GetChannel() + channel.ConnectionHops = []string{"connection-100"} + path.EndpointA.SetChannel(channel) + }, + false, + }, + { + "invalid connection state", func() { connectionEnd := path.EndpointA.GetConnection() connectionEnd.State = connectiontypes.UNINITIALIZED + suite.chainA.GetSimApp().GetIBCKeeper().ConnectionKeeper.SetConnection(suite.chainA.GetContext(), path.EndpointA.ConnectionID, connectionEnd) + }, + false, + }, + { + "connection not found", + func() { + channel := path.EndpointA.GetChannel() + channel.ConnectionHops = []string{"connection-100"} + path.EndpointA.SetChannel(channel) + }, + false, + }, + { + "upgrade not found", + func() { + store := suite.chainA.GetContext().KVStore(suite.chainA.GetSimApp().GetKey(exported.ModuleName)) + store.Delete(host.ChannelUpgradeKey(path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID)) + }, + false, + }, + { + "channel end version mismatch on crossing hellos", + func() { + channel := path.EndpointA.GetChannel() + channel.State = types.TRYUPGRADE - suite.chainA.GetSimApp().GetIBCKeeper().ConnectionKeeper.SetConnection(suite.chainA.GetContext(), "connection-100", connectionEnd) - upgrade.Fields.ConnectionHops = []string{"connection-100"} + path.EndpointA.SetChannel(channel) + + upgrade, found := suite.chainA.GetSimApp().GetIBCKeeper().ChannelKeeper.GetUpgrade(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID) + suite.Require().True(found) + + upgrade.Fields.Version = "invalid-version" + suite.chainA.GetSimApp().GetIBCKeeper().ChannelKeeper.SetUpgrade(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, upgrade) }, false, }, @@ -396,12 +439,17 @@ func (suite *KeeperTestSuite) TestChanUpgradeAck() { path.EndpointA.ChannelConfig.ProposedUpgrade.Fields.Version = mock.UpgradeVersion path.EndpointB.ChannelConfig.ProposedUpgrade.Fields.Version = mock.UpgradeVersion + counterpartyFlushStatus = types.FLUSHING + err := path.EndpointA.ChanUpgradeInit() suite.Require().NoError(err) err = path.EndpointB.ChanUpgradeTry() suite.Require().NoError(err) + err = path.EndpointA.UpdateClient() + suite.Require().NoError(err) + tc.malleate() counterpartyUpgrade, found := suite.chainB.GetSimApp().GetIBCKeeper().ChannelKeeper.GetUpgrade(suite.chainB.GetContext(), path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID) @@ -410,14 +458,11 @@ func (suite *KeeperTestSuite) TestChanUpgradeAck() { proofChannel, proofUpgrade, proofHeight := path.EndpointA.QueryChannelUpgradeProof() err = suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper.ChanUpgradeAck( - suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, types.FLUSHCOMPLETE, counterpartyUpgrade, + suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, counterpartyFlushStatus, counterpartyUpgrade, proofChannel, proofUpgrade, proofHeight, ) if tc.expPass { - // suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper.WriteUpgradeAckChannel() - // channel := path.EndpointA.GetChannel() - suite.Require().NoError(err) } else { suite.Require().Error(err) From 0ae120f4184342f8b5b53cd12228b981c5524aed Mon Sep 17 00:00:00 2001 From: Damian Nolan Date: Tue, 13 Jun 2023 01:25:00 +0200 Subject: [PATCH 06/21] updating var naming for consistency, adding additional testcases --- modules/core/04-channel/keeper/upgrade.go | 4 +- .../core/04-channel/keeper/upgrade_test.go | 53 ++++++++++++++----- 2 files changed, 41 insertions(+), 16 deletions(-) diff --git a/modules/core/04-channel/keeper/upgrade.go b/modules/core/04-channel/keeper/upgrade.go index ea0f019d1f6..159e4a409d8 100644 --- a/modules/core/04-channel/keeper/upgrade.go +++ b/modules/core/04-channel/keeper/upgrade.go @@ -232,12 +232,12 @@ func (k Keeper) ChanUpgradeAck( return errorsmod.Wrapf(types.ErrInvalidChannelState, "expected one of [%s, %s], got %s", types.FLUSHING, types.FLUSHCOMPLETE, counterpartyFlushStatus) } - connectionEnd, err := k.GetConnection(ctx, channel.ConnectionHops[0]) + connection, err := k.GetConnection(ctx, channel.ConnectionHops[0]) if err != nil { return errorsmod.Wrapf(err, "failed to retrieve connection: %s", channel.ConnectionHops[0]) } - counterpartyHops := []string{connectionEnd.GetCounterparty().GetConnectionID()} + counterpartyHops := []string{connection.GetCounterparty().GetConnectionID()} counterpartyChannel := types.Channel{ State: types.TRYUPGRADE, Ordering: channel.Ordering, diff --git a/modules/core/04-channel/keeper/upgrade_test.go b/modules/core/04-channel/keeper/upgrade_test.go index 4eb167237a2..a8f544a1c43 100644 --- a/modules/core/04-channel/keeper/upgrade_test.go +++ b/modules/core/04-channel/keeper/upgrade_test.go @@ -329,6 +329,7 @@ func (suite *KeeperTestSuite) TestChanUpgradeAck() { var ( path *ibctesting.Path counterpartyFlushStatus types.FlushStatus + counterpartyUpgrade types.Upgrade ) testCases := []struct { @@ -341,18 +342,24 @@ func (suite *KeeperTestSuite) TestChanUpgradeAck() { func() {}, true, }, - // { - // "success with later upgrade sequence", - // func() { - // channel := path.EndpointA.GetChannel() - // channel.UpgradeSequence = 4 - // path.EndpointA.SetChannel(channel) + { + "success with later upgrade sequence", + func() { + channel := path.EndpointA.GetChannel() + channel.UpgradeSequence = 10 + path.EndpointA.SetChannel(channel) - // err := path.EndpointA.UpdateClient() - // suite.Require().NoError(err) - // }, - // true, - // }, + channel = path.EndpointB.GetChannel() + channel.UpgradeSequence = 10 + path.EndpointB.SetChannel(channel) + + suite.coordinator.CommitBlock(suite.chainA, suite.chainB) + + err := path.EndpointA.UpdateClient() + suite.Require().NoError(err) + }, + true, + }, { "channel not found", func() { @@ -426,6 +433,22 @@ func (suite *KeeperTestSuite) TestChanUpgradeAck() { }, false, }, + { + "startFlushUpgradeHandshake fails due to proof verification failure, counterparty upgrade connection hops are tampered with", + func() { + counterpartyUpgrade.Fields.ConnectionHops = []string{ibctesting.InvalidID} + }, + false, + }, + { + "startFlushUpgradeHandshake fails due to mismatch in upgrade sequences", + func() { + channel := path.EndpointA.GetChannel() + channel.UpgradeSequence = 5 + path.EndpointA.SetChannel(channel) + }, + false, + }, } for _, tc := range testCases { @@ -447,14 +470,16 @@ func (suite *KeeperTestSuite) TestChanUpgradeAck() { err = path.EndpointB.ChanUpgradeTry() suite.Require().NoError(err) + // ensure client is up to date to receive valid proofs err = path.EndpointA.UpdateClient() suite.Require().NoError(err) - tc.malleate() - - counterpartyUpgrade, found := suite.chainB.GetSimApp().GetIBCKeeper().ChannelKeeper.GetUpgrade(suite.chainB.GetContext(), path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID) + var found bool + counterpartyUpgrade, found = suite.chainB.GetSimApp().GetIBCKeeper().ChannelKeeper.GetUpgrade(suite.chainB.GetContext(), path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID) suite.Require().True(found) + tc.malleate() + proofChannel, proofUpgrade, proofHeight := path.EndpointA.QueryChannelUpgradeProof() err = suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper.ChanUpgradeAck( From 73e9352b827bfb3fcc14122b4e8659be52c05683 Mon Sep 17 00:00:00 2001 From: Damian Nolan Date: Tue, 13 Jun 2023 01:27:11 +0200 Subject: [PATCH 07/21] rm msg server implementation --- modules/core/keeper/msg_server.go | 30 ------------------------------ 1 file changed, 30 deletions(-) diff --git a/modules/core/keeper/msg_server.go b/modules/core/keeper/msg_server.go index b163ca822a5..33df77fb5b9 100644 --- a/modules/core/keeper/msg_server.go +++ b/modules/core/keeper/msg_server.go @@ -10,7 +10,6 @@ import ( clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" connectiontypes "github.com/cosmos/ibc-go/v7/modules/core/03-connection/types" - "github.com/cosmos/ibc-go/v7/modules/core/04-channel/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" coretypes "github.com/cosmos/ibc-go/v7/modules/core/types" @@ -806,35 +805,6 @@ func (k Keeper) ChannelUpgradeTry(goCtx context.Context, msg *channeltypes.MsgCh // ChannelUpgradeAck defines a rpc handler method for MsgChannelUpgradeAck. func (k Keeper) ChannelUpgradeAck(goCtx context.Context, msg *channeltypes.MsgChannelUpgradeAck) (*channeltypes.MsgChannelUpgradeAckResponse, error) { - ctx := sdk.UnwrapSDKContext(goCtx) - - module, _, err := k.ChannelKeeper.LookupModuleByChannel(ctx, msg.PortId, msg.ChannelId) - if err != nil { - ctx.Logger().Error("channel upgrade ack failed", "port-id", msg.PortId, "error", errorsmod.Wrap(err, "could not retrieve module from port-id")) - return nil, errorsmod.Wrap(err, "could not retrieve module from port-id") - } - - cbs, ok := k.Router.GetRoute(module) - if !ok { - ctx.Logger().Error("channel upgrade ack failed", "port-id", msg.PortId, "error", errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to module: %s", module)) - return nil, errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to module: %s", module) - } - - err = k.ChannelKeeper.ChanUpgradeAck(ctx, msg.PortId, msg.ChannelId, msg.CounterpartyFlushStatus, msg.CounterpartyUpgrade, msg.ProofChannel, msg.ProofUpgrade, msg.ProofHeight) - if err != nil { - ctx.Logger().Error("channel upgrade ack failed", "error", errorsmod.Wrap(err, "channel handshake upgrade ack failed")) - return nil, errorsmod.Wrap(err, "channel handshake upgrade ack failed") - } - - // TODO: update callback args?? remove counterparty channel ID and version?? - err = cbs.OnChanUpgradeAck(ctx, msg.PortId, msg.ChannelId, msg.CounterpartyUpgrade.Fields.Version) - if err != nil { - ctx.Logger().Error("channel upgrade ack callback failed", "port-id", msg.PortId, "channel-id", msg.ChannelId, "error", err.Error()) - - // restoreChannel(portID, channelID) - return &types.MsgChannelUpgradeAckResponse{}, nil - } - return nil, nil } From 2b8b3fe81f5b482393e713f14b634701aac1b945 Mon Sep 17 00:00:00 2001 From: Damian Nolan Date: Tue, 13 Jun 2023 10:05:50 +0200 Subject: [PATCH 08/21] adding invalid flush status err and rm lint ignore comment --- modules/core/04-channel/keeper/upgrade.go | 4 +--- modules/core/04-channel/types/errors.go | 1 + 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/modules/core/04-channel/keeper/upgrade.go b/modules/core/04-channel/keeper/upgrade.go index 159e4a409d8..d5316bce348 100644 --- a/modules/core/04-channel/keeper/upgrade.go +++ b/modules/core/04-channel/keeper/upgrade.go @@ -229,7 +229,7 @@ func (k Keeper) ChanUpgradeAck( } if !collections.Contains(counterpartyFlushStatus, []types.FlushStatus{types.FLUSHING, types.FLUSHCOMPLETE}) { - return errorsmod.Wrapf(types.ErrInvalidChannelState, "expected one of [%s, %s], got %s", types.FLUSHING, types.FLUSHCOMPLETE, counterpartyFlushStatus) + return errorsmod.Wrapf(types.ErrInvalidFlushStatus, "expected one of [%s, %s], got %s", types.FLUSHING, types.FLUSHCOMPLETE, counterpartyFlushStatus) } connection, err := k.GetConnection(ctx, channel.ConnectionHops[0]) @@ -272,8 +272,6 @@ func (k Keeper) ChanUpgradeAck( // Once the counterparty information has been verified, it will be validated against the self proposed upgrade. // If any of the proposed upgrade fields are incompatible, an upgrade error will be returned resulting in an // aborted upgrade. -// -//lint:ignore U1000 Ignore unused function temporarily for debugging func (k Keeper) startFlushUpgradeHandshake( ctx sdk.Context, portID, diff --git a/modules/core/04-channel/types/errors.go b/modules/core/04-channel/types/errors.go index 1f3ff7890f8..96a33c245be 100644 --- a/modules/core/04-channel/types/errors.go +++ b/modules/core/04-channel/types/errors.go @@ -45,4 +45,5 @@ var ( ErrInvalidUpgradeSequence = errorsmod.Register(SubModuleName, 29, "invalid upgrade sequence") ErrUpgradeNotFound = errorsmod.Register(SubModuleName, 30, "upgrade not found") ErrIncompatibleCounterpartyUpgrade = errorsmod.Register(SubModuleName, 31, "incompatible counterparty upgrade") + ErrInvalidFlushStatus = errorsmod.Register(SubModuleName, 32, "invalid flush status") ) From e53d1aaf92b938aef57f5f45b3ff179cb0747e7b Mon Sep 17 00:00:00 2001 From: Damian Nolan Date: Tue, 13 Jun 2023 10:32:13 +0200 Subject: [PATCH 09/21] adding test helpers to endpoint for get/set channel upgrade --- modules/core/04-channel/keeper/upgrade_test.go | 11 ++++------- testing/endpoint.go | 14 ++++++++++++++ 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/modules/core/04-channel/keeper/upgrade_test.go b/modules/core/04-channel/keeper/upgrade_test.go index a8f544a1c43..298dbc2b204 100644 --- a/modules/core/04-channel/keeper/upgrade_test.go +++ b/modules/core/04-channel/keeper/upgrade_test.go @@ -425,11 +425,10 @@ func (suite *KeeperTestSuite) TestChanUpgradeAck() { path.EndpointA.SetChannel(channel) - upgrade, found := suite.chainA.GetSimApp().GetIBCKeeper().ChannelKeeper.GetUpgrade(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID) - suite.Require().True(found) - + upgrade := path.EndpointA.GetChannelUpgrade() upgrade.Fields.Version = "invalid-version" - suite.chainA.GetSimApp().GetIBCKeeper().ChannelKeeper.SetUpgrade(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, upgrade) + + path.EndpointA.SetChannelUpgrade(upgrade) }, false, }, @@ -474,9 +473,7 @@ func (suite *KeeperTestSuite) TestChanUpgradeAck() { err = path.EndpointA.UpdateClient() suite.Require().NoError(err) - var found bool - counterpartyUpgrade, found = suite.chainB.GetSimApp().GetIBCKeeper().ChannelKeeper.GetUpgrade(suite.chainB.GetContext(), path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID) - suite.Require().True(found) + counterpartyUpgrade = path.EndpointB.GetChannelUpgrade() tc.malleate() diff --git a/testing/endpoint.go b/testing/endpoint.go index ee4567a7c9d..bee6c9421fe 100644 --- a/testing/endpoint.go +++ b/testing/endpoint.go @@ -790,6 +790,20 @@ func (endpoint *Endpoint) SetChannel(channel channeltypes.Channel) { endpoint.Chain.App.GetIBCKeeper().ChannelKeeper.SetChannel(endpoint.Chain.GetContext(), endpoint.ChannelConfig.PortID, endpoint.ChannelID, channel) } +// GetChannelUpgrade retrieves an IBC Channel Upgrade for the endpoint. The upgrade +// is expected to exist otherwise testing will fail. +func (endpoint *Endpoint) GetChannelUpgrade() channeltypes.Upgrade { + upgrade, found := endpoint.Chain.App.GetIBCKeeper().ChannelKeeper.GetUpgrade(endpoint.Chain.GetContext(), endpoint.ChannelConfig.PortID, endpoint.ChannelID) + require.True(endpoint.Chain.TB, found) + + return upgrade +} + +// SetChannelUpgrade sets the channel upgrade for this endpoint. +func (endpoint *Endpoint) SetChannelUpgrade(upgrade channeltypes.Upgrade) { + endpoint.Chain.App.GetIBCKeeper().ChannelKeeper.SetUpgrade(endpoint.Chain.GetContext(), endpoint.ChannelConfig.PortID, endpoint.ChannelID, upgrade) +} + // QueryClientStateProof performs and abci query for a client stat associated // with this endpoint and returns the ClientState along with the proof. func (endpoint *Endpoint) QueryClientStateProof() (exported.ClientState, []byte) { From f9c21676a0fa3ca72be335224a3c41696ad50933 Mon Sep 17 00:00:00 2001 From: Damian Nolan Date: Tue, 13 Jun 2023 11:06:13 +0200 Subject: [PATCH 10/21] lint it --- .golangci.yml | 4 ++++ modules/core/04-channel/keeper/upgrade_test.go | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 123234d42f2..56f4fbcf3c9 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -60,3 +60,7 @@ linters-settings: allow-leading-space: true require-explanation: false require-specific: false + revive: + rules: + - name: if-return + disabled: true \ No newline at end of file diff --git a/modules/core/04-channel/keeper/upgrade_test.go b/modules/core/04-channel/keeper/upgrade_test.go index 298dbc2b204..6aa543614b9 100644 --- a/modules/core/04-channel/keeper/upgrade_test.go +++ b/modules/core/04-channel/keeper/upgrade_test.go @@ -363,8 +363,8 @@ func (suite *KeeperTestSuite) TestChanUpgradeAck() { { "channel not found", func() { - path.EndpointA.ChannelID = "invalid-channel" - path.EndpointA.ChannelConfig.PortID = "invalid-port" + path.EndpointA.ChannelID = ibctesting.InvalidID + path.EndpointA.ChannelConfig.PortID = ibctesting.InvalidID }, false, }, From 566ab66fdc2854f2958fa8b0895cd222631ef7a2 Mon Sep 17 00:00:00 2001 From: Damian Nolan Date: Tue, 13 Jun 2023 11:44:17 +0200 Subject: [PATCH 11/21] adding initial msg server impl skeleton --- modules/core/keeper/msg_server.go | 48 ++++++++++++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) diff --git a/modules/core/keeper/msg_server.go b/modules/core/keeper/msg_server.go index 33df77fb5b9..a43fe239d40 100644 --- a/modules/core/keeper/msg_server.go +++ b/modules/core/keeper/msg_server.go @@ -805,7 +805,53 @@ func (k Keeper) ChannelUpgradeTry(goCtx context.Context, msg *channeltypes.MsgCh // ChannelUpgradeAck defines a rpc handler method for MsgChannelUpgradeAck. func (k Keeper) ChannelUpgradeAck(goCtx context.Context, msg *channeltypes.MsgChannelUpgradeAck) (*channeltypes.MsgChannelUpgradeAckResponse, error) { - return nil, nil + ctx := sdk.UnwrapSDKContext(goCtx) + + module, _, err := k.ChannelKeeper.LookupModuleByChannel(ctx, msg.PortId, msg.ChannelId) + if err != nil { + ctx.Logger().Error("channel upgrade ack failed", "port-id", msg.PortId, "error", errorsmod.Wrap(err, "could not retrieve module from port-id")) + return nil, errorsmod.Wrap(err, "could not retrieve module from port-id") + } + + cbs, ok := k.Router.GetRoute(module) + if !ok { + ctx.Logger().Error("channel upgrade ack failed", "port-id", msg.PortId, "error", errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to module: %s", module)) + return nil, errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to module: %s", module) + } + + err = k.ChannelKeeper.ChanUpgradeAck(ctx, msg.PortId, msg.ChannelId, msg.CounterpartyFlushStatus, msg.CounterpartyUpgrade, msg.ProofChannel, msg.ProofUpgrade, msg.ProofHeight) + if err != nil { + ctx.Logger().Error("channel upgrade ack failed", "error", errorsmod.Wrap(err, "channel handshake upgrade ack failed")) + if upgradeErr, ok := err.(*channeltypes.UpgradeError); ok { + if err := k.ChannelKeeper.AbortUpgrade(ctx, msg.PortId, msg.ChannelId, upgradeErr); err != nil { + return nil, err + } + + // 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. + return &channeltypes.MsgChannelUpgradeAckResponse{ /*Result: channeltypes.FAILURE*/ }, nil + } + + // NOTE: an error is returned to baseapp and transaction state is not committed. + return nil, err + } + + cacheCtx, writeFn := ctx.CacheContext() + err = cbs.OnChanUpgradeAck(cacheCtx, msg.PortId, msg.ChannelId, msg.CounterpartyUpgrade.Fields.Version) + if err != nil { + ctx.Logger().Error("channel upgrade ack callback failed", "port-id", msg.PortId, "channel-id", msg.ChannelId, "error", err.Error()) + if err := k.ChannelKeeper.AbortUpgrade(ctx, msg.PortId, msg.ChannelId, err); err != nil { + return nil, err + } + + return &channeltypes.MsgChannelUpgradeAckResponse{ /*Result: channeltypes.FAILURE*/ }, nil + } + + writeFn() + + // k.ChannelKeeper.WriteUpgradeAckChannel() + + return &channeltypes.MsgChannelUpgradeAckResponse{}, nil } // ChannelUpgradeOpen defines a rpc handler method for MsgChannelUpgradeOpen. From c241a635a3f6e680632cb738e8f77a4aeebee32e Mon Sep 17 00:00:00 2001 From: Damian Nolan Date: Tue, 13 Jun 2023 12:52:01 +0200 Subject: [PATCH 12/21] pull in code for WriteUpgradeAckChannel --- modules/core/04-channel/keeper/upgrade.go | 34 +++++++++++++++++++++++ modules/core/keeper/msg_server.go | 2 +- 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/modules/core/04-channel/keeper/upgrade.go b/modules/core/04-channel/keeper/upgrade.go index d5316bce348..868305933c8 100644 --- a/modules/core/04-channel/keeper/upgrade.go +++ b/modules/core/04-channel/keeper/upgrade.go @@ -268,6 +268,40 @@ func (k Keeper) ChanUpgradeAck( return nil } +// WriteUpgradeAckChannel writes a channel which has successfully passed the UpgradeAck handshake step as well as +// setting the upgrade for that channel. +// An event is emitted for the handshake step. +func (k Keeper) WriteUpgradeAckChannel( + ctx sdk.Context, + portID, channelID string, + upgradeVersion string, +) { + defer telemetry.IncrCounter(1, "ibc", "channel", "upgrade-ack") + + channel, found := k.GetChannel(ctx, portID, channelID) + if !found { + panic(fmt.Sprintf("could not find existing channel when updating channel state in successful ChanUpgradeAck step, channelID: %s, portID: %s", channelID, portID)) + } + + previousState := channel.State + channel.State = types.ACKUPGRADE + channel.FlushStatus = types.FLUSHING + + k.SetChannel(ctx, portID, channelID, channel) + + upgrade, found := k.GetUpgrade(ctx, portID, channelID) + if !found { + panic(fmt.Sprintf("cound not find existing upgrade when updating channel state in successful ChanUpgradeAck step, channelID: %s, portID: %s", channelID, portID)) + } + + upgrade.Fields.Version = upgradeVersion + + k.SetUpgrade(ctx, portID, channelID, upgrade) + + k.Logger(ctx).Info("channel state updated", "port-id", portID, "channel-id", channelID, "previous-state", previousState, "new-state", types.ACKUPGRADE.String()) + emitChannelUpgradeAckEvent(ctx, portID, channelID, channel, upgrade) +} + // startFlushUpgradeHandshake will verify the counterparty proposed upgrade and the current channel state. // Once the counterparty information has been verified, it will be validated against the self proposed upgrade. // If any of the proposed upgrade fields are incompatible, an upgrade error will be returned resulting in an diff --git a/modules/core/keeper/msg_server.go b/modules/core/keeper/msg_server.go index a43fe239d40..2a835ef2cec 100644 --- a/modules/core/keeper/msg_server.go +++ b/modules/core/keeper/msg_server.go @@ -849,7 +849,7 @@ func (k Keeper) ChannelUpgradeAck(goCtx context.Context, msg *channeltypes.MsgCh writeFn() - // k.ChannelKeeper.WriteUpgradeAckChannel() + k.ChannelKeeper.WriteUpgradeAckChannel(ctx, msg.PortId, msg.ChannelId, msg.CounterpartyUpgrade.Fields.Version) return &channeltypes.MsgChannelUpgradeAckResponse{}, nil } From ec604472f0675f5d7b85129ea939a58e7a799e9f Mon Sep 17 00:00:00 2001 From: Damian Nolan Date: Wed, 14 Jun 2023 14:37:22 +0200 Subject: [PATCH 13/21] adding result to MsgChannelUpgradeAckResponse --- modules/core/04-channel/types/tx.pb.go | 264 ++++++++++++++----------- proto/ibc/core/channel/v1/tx.proto | 4 +- 2 files changed, 153 insertions(+), 115 deletions(-) diff --git a/modules/core/04-channel/types/tx.pb.go b/modules/core/04-channel/types/tx.pb.go index a2694565ef8..a96d89d7b1f 100644 --- a/modules/core/04-channel/types/tx.pb.go +++ b/modules/core/04-channel/types/tx.pb.go @@ -1169,6 +1169,7 @@ var xxx_messageInfo_MsgChannelUpgradeAck proto.InternalMessageInfo // MsgChannelUpgradeAckResponse defines MsgChannelUpgradeAck response type type MsgChannelUpgradeAckResponse struct { + Result ResponseResultType `protobuf:"varint,1,opt,name=result,proto3,enum=ibc.core.channel.v1.ResponseResultType" json:"result,omitempty"` } func (m *MsgChannelUpgradeAckResponse) Reset() { *m = MsgChannelUpgradeAckResponse{} } @@ -1204,6 +1205,13 @@ func (m *MsgChannelUpgradeAckResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgChannelUpgradeAckResponse proto.InternalMessageInfo +func (m *MsgChannelUpgradeAckResponse) GetResult() ResponseResultType { + if m != nil { + return m.Result + } + return UNSPECIFIED +} + // MsgChannelUpgradeOpen defines the request type for the ChannelUpgradeOpen rpc type MsgChannelUpgradeOpen struct { PortId string `protobuf:"bytes,1,opt,name=port_id,json=portId,proto3" json:"port_id,omitempty"` @@ -1485,120 +1493,121 @@ func init() { func init() { proto.RegisterFile("ibc/core/channel/v1/tx.proto", fileDescriptor_bc4637e0ac3fc7b7) } var fileDescriptor_bc4637e0ac3fc7b7 = []byte{ - // 1808 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x5a, 0xcd, 0x6f, 0xdb, 0x46, - 0x16, 0x17, 0x25, 0x59, 0xb2, 0x9f, 0xbf, 0x29, 0x27, 0x56, 0x68, 0x5b, 0x52, 0xb4, 0x40, 0xe2, - 0x78, 0x63, 0x29, 0x76, 0x92, 0x5d, 0x24, 0x08, 0xb0, 0x6b, 0x6b, 0xe5, 0x8d, 0xb1, 0x71, 0x6c, - 0x50, 0xd6, 0x62, 0x3f, 0xb2, 0x2b, 0xc8, 0xd4, 0x58, 0x26, 0x24, 0x91, 0x0c, 0x49, 0x29, 0xf1, - 0x02, 0x7b, 0xd8, 0xbd, 0x34, 0x08, 0x50, 0xa0, 0xff, 0x40, 0x80, 0x00, 0x3d, 0xf4, 0xd8, 0x9e, - 0x7b, 0x69, 0x7b, 0xcb, 0xa1, 0x40, 0x03, 0x14, 0x68, 0x73, 0x28, 0x8a, 0x22, 0x39, 0xa4, 0x7f, - 0x44, 0x0e, 0x05, 0x87, 0x43, 0x8a, 0xa4, 0x86, 0x16, 0x6d, 0x39, 0x46, 0x6f, 0xd6, 0xcc, 0x6f, - 0xde, 0xbc, 0xf7, 0xfb, 0xbd, 0x79, 0xf3, 0x41, 0xc3, 0xbc, 0xb8, 0x27, 0xe4, 0x05, 0x59, 0x45, - 0x79, 0xe1, 0xa0, 0x2a, 0x49, 0xa8, 0x99, 0xef, 0xac, 0xe4, 0xf5, 0xc7, 0x39, 0x45, 0x95, 0x75, - 0x99, 0x4d, 0x88, 0x7b, 0x42, 0xce, 0xe8, 0xcd, 0x91, 0xde, 0x5c, 0x67, 0x85, 0x9b, 0xa9, 0xcb, - 0x75, 0x19, 0xf7, 0xe7, 0x8d, 0xbf, 0x4c, 0x28, 0x37, 0x2b, 0xc8, 0x5a, 0x4b, 0xd6, 0xf2, 0x2d, - 0xad, 0x6e, 0x98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ee, 0x82, 0x3d, 0xb9, 0x83, 0x99, - 0xc8, 0xf1, 0x99, 0x59, 0x81, 0x19, 0x41, 0x6e, 0x4b, 0x3a, 0x52, 0x95, 0xaa, 0xaa, 0x1f, 0x56, - 0xac, 0x38, 0xa2, 0xd8, 0xaf, 0x84, 0xb3, 0xef, 0xaf, 0x66, 0x97, 0x41, 0x86, 0xa2, 0xca, 0xf2, - 0x7e, 0x45, 0x94, 0x44, 0x3d, 0x39, 0x94, 0x61, 0x16, 0xc7, 0xf8, 0x11, 0xdc, 0x82, 0x25, 0x2c, - 0xc0, 0x98, 0xd9, 0x7d, 0x80, 0xc4, 0xfa, 0x81, 0x9e, 0x8c, 0x61, 0xa7, 0x38, 0x87, 0x53, 0x66, - 0x36, 0x75, 0x56, 0x72, 0x77, 0x31, 0x82, 0xb8, 0x34, 0x8a, 0x47, 0x99, 0x4d, 0x0e, 0xc1, 0xe2, - 0x3e, 0x82, 0xed, 0xc2, 0x85, 0x1e, 0x62, 0x6d, 0xbd, 0x1c, 0x82, 0x30, 0x2e, 0x41, 0x3c, 0x4a, - 0x86, 0x3d, 0x4a, 0x66, 0x3f, 0xef, 0xd1, 0x6b, 0x4d, 0x68, 0xf8, 0xeb, 0x75, 0xb4, 0x35, 0xf6, - 0x77, 0x30, 0xeb, 0x22, 0xd7, 0x81, 0x35, 0xf3, 0xf0, 0x9c, 0xb3, 0xbb, 0x2b, 0xe9, 0x09, 0x44, - 0x99, 0x03, 0x53, 0x82, 0x8a, 0xae, 0x1e, 0x12, 0x4d, 0x86, 0x71, 0x83, 0x91, 0x6f, 0x67, 0x24, - 0xc9, 0x9c, 0x57, 0x92, 0x35, 0xa1, 0x61, 0x49, 0x92, 0xfd, 0x96, 0x81, 0x73, 0xee, 0xde, 0x82, - 0x2c, 0xed, 0x8b, 0x6a, 0xeb, 0xc4, 0xec, 0xda, 0x21, 0x57, 0x85, 0x06, 0xe6, 0xd3, 0x0a, 0xd9, - 0x90, 0xcc, 0x1b, 0x72, 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0xd7, 0xfc, 0x87, 0x30, 0xdd, - 0x7b, 0xb5, 0xbe, 0x12, 0xcc, 0x90, 0x51, 0x38, 0x56, 0x02, 0x43, 0xfd, 0xa7, 0x34, 0xca, 0x47, - 0xc0, 0x29, 0x8d, 0x0a, 0xb2, 0x12, 0x18, 0xea, 0xcf, 0x2d, 0x3e, 0x25, 0x07, 0xe4, 0xd6, 0xc0, - 0x06, 0xe5, 0xd6, 0x79, 0x76, 0x64, 0xff, 0x0b, 0xe7, 0xe8, 0xe7, 0xc6, 0xe5, 0x80, 0xa4, 0x91, - 0x95, 0x71, 0xf3, 0x58, 0x70, 0x7b, 0xfa, 0xff, 0xc0, 0x0c, 0xf5, 0x00, 0x73, 0x35, 0x98, 0x39, - 0x13, 0xcd, 0xdd, 0x38, 0x0e, 0xda, 0x9a, 0x7b, 0xbd, 0xf4, 0xe2, 0x75, 0x8a, 0x79, 0xf9, 0x3a, - 0xc5, 0xfc, 0xf4, 0x3a, 0xc5, 0x7c, 0xf4, 0x26, 0x15, 0x7a, 0xf9, 0x26, 0x15, 0x7a, 0xf5, 0x26, - 0x15, 0xfa, 0xc7, 0xad, 0xba, 0xa8, 0x1f, 0xb4, 0xf7, 0x72, 0x82, 0xdc, 0xca, 0x93, 0xff, 0x0d, - 0x10, 0xf7, 0x84, 0xe5, 0xba, 0x9c, 0xef, 0xfc, 0x3e, 0xdf, 0x92, 0x6b, 0xed, 0x26, 0xd2, 0xcc, - 0x6f, 0xfa, 0xd7, 0x6e, 0x2c, 0x5b, 0x9f, 0xf5, 0xf5, 0x43, 0x05, 0x69, 0x7b, 0x31, 0xfc, 0x49, - 0xff, 0xfa, 0x2f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x15, 0xd1, 0xe0, 0x59, 0x9d, 0x20, 0x00, 0x00, + // 1810 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x5a, 0x4b, 0x6f,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14, 0xb6, 0xf0, 0x83, 0x5e, 0x45, 0x6e, 0x40, 0x9c, 0x5c, 0xb4, 0x0e, 0xbc, 0x27, 0x11, 0xcb, + 0xa6, 0xaf, 0x64, 0x88, 0x5e, 0x2b, 0xc8, 0x47, 0x6b, 0x75, 0x62, 0xd6, 0xa2, 0xec, 0x38, 0x69, + 0x37, 0xd7, 0x66, 0xf6, 0xe7, 0x28, 0x4c, 0x75, 0x79, 0x7a, 0xe0, 0xe5, 0xa6, 0x87, 0x4e, 0x6f, + 0x43, 0x46, 0x56, 0x24, 0x59, 0x52, 0x51, 0x95, 0x33, 0x9d, 0xe0, 0x25, 0x51, 0x44, 0xbc, 0x26, + 0x48, 0x22, 0xb7, 0x27, 0xc9, 0xba, 0x82, 0x91, 0xf9, 0x21, 0x76, 0xce, 0xc4, 0x91, 0x59, 0x0b, + 0x16, 0xea, 0xa6, 0x24, 0xab, 0xf4, 0x3b, 0x60, 0x3a, 0xcb, 0x1d, 0x5e, 0xb6, 0x31, 0x32, 0xd4, + 0xdc, 0xe6, 0x76, 0x61, 0xce, 0x71, 0x14, 0x77, 0xbb, 0x88, 0x45, 0x0d, 0xc6, 0xf2, 0x8c, 0xdd, + 0xd0, 0x96, 0x33, 0x04, 0x7a, 0xd5, 0x35, 0x4f, 0x97, 0x0c, 0x31, 0x2c, 0x83, 0xc3, 0x46, 0xd9, + 0x29, 0x09, 0xfd, 0x1f, 0x18, 0x25, 0xe5, 0x9b, 0xdc, 0x07, 0xe3, 0xb8, 0x54, 0x18, 0xc5, 0x81, + 0x08, 0xd5, 0x01, 0x99, 0x01, 0x0c, 0xda, 0x40, 0xa6, 0x37, 0xee, 0x8a, 0x32, 0xd4, 0x5f, 0x45, + 0x81, 0xde, 0x89, 0xff, 0x92, 0x82, 0x59, 0xaf, 0x74, 0xfa, 0xb7, 0xe5, 0xbd, 0xad, 0xce, 0x45, + 0x8f, 0x54, 0xe7, 0xb2, 0x3f, 0x44, 0x3c, 0x16, 0x4e, 0x3f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0x05, 0x86, 0xfa, 0x4f, 0xa9, + 0x97, 0x8f, 0x80, 0x53, 0xea, 0x15, 0x64, 0x29, 0x30, 0xd4, 0x9f, 0x5b, 0x7c, 0x4a, 0x0e, 0xc8, + 0xad, 0x8e, 0x0d, 0xca, 0xad, 0xfd, 0xec, 0x48, 0x7f, 0x0a, 0xa7, 0xbc, 0xcf, 0x8d, 0x8b, 0x01, + 0x49, 0x23, 0x2b, 0xe3, 0xea, 0xa1, 0xe0, 0xd6, 0xf4, 0x9f, 0xc0, 0x94, 0xe7, 0x01, 0xe6, 0x62, + 0x30, 0x73, 0x06, 0x9a, 0xb9, 0x72, 0x18, 0xb4, 0x39, 0xf7, 0x6a, 0xe9, 0xc9, 0xf3, 0x14, 0xf5, + 0xf4, 0x79, 0x8a, 0xfa, 0xeb, 0x79, 0x8a, 0xfa, 0xea, 0x45, 0x2a, 0xf4, 0xf4, 0x45, 0x2a, 0xf4, + 0xec, 0x45, 0x2a, 0xf4, 0xc1, 0xb5, 0x9a, 0xa0, 0xed, 0xb5, 0x76, 0x72, 0xbc, 0xd4, 0xcc, 0x93, + 0x3f, 0x17, 0x08, 0x3b, 0xfc, 0x62, 0x4d, 0xca, 0xb7, 0xff, 0x9f, 0x6f, 0x4a, 0xd5, 0x56, 0x03, + 0xa9, 0xc6, 0x9f, 0x02, 0x2e, 0x5d, 0x59, 0x34, 0xff, 0x17, 0xa0, 0xed, 0xcb, 0x48, 0xdd, 0x89, + 0xe1, 0xff, 0x04, 0x5c, 0xfe, 0x27, 0x00, 0x00, 0xff, 0xff, 0x79, 0xf7, 0xad, 0x3a, 0xde, 0x20, + 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -3515,6 +3524,11 @@ func (m *MsgChannelUpgradeAckResponse) MarshalToSizedBuffer(dAtA []byte) (int, e _ = i var l int _ = l + if m.Result != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.Result)) + i-- + dAtA[i] = 0x8 + } return len(dAtA) - i, nil } @@ -4351,6 +4365,9 @@ func (m *MsgChannelUpgradeAckResponse) Size() (n int) { } var l int _ = l + if m.Result != 0 { + n += 1 + sovTx(uint64(m.Result)) + } return n } @@ -8484,6 +8501,25 @@ func (m *MsgChannelUpgradeAckResponse) Unmarshal(dAtA []byte) error { return fmt.Errorf("proto: MsgChannelUpgradeAckResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Result", wireType) + } + m.Result = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Result |= ResponseResultType(b&0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex skippy, err := skipTx(dAtA[iNdEx:]) diff --git a/proto/ibc/core/channel/v1/tx.proto b/proto/ibc/core/channel/v1/tx.proto index ebf2398b631..d9fac6f8fe2 100644 --- a/proto/ibc/core/channel/v1/tx.proto +++ b/proto/ibc/core/channel/v1/tx.proto @@ -324,7 +324,9 @@ message MsgChannelUpgradeAck { } // MsgChannelUpgradeAckResponse defines MsgChannelUpgradeAck response type -message MsgChannelUpgradeAckResponse {} +message MsgChannelUpgradeAckResponse { + ResponseResultType result = 1; +} // MsgChannelUpgradeOpen defines the request type for the ChannelUpgradeOpen rpc message MsgChannelUpgradeOpen { From 7082cd86ca80a16829817e158ee13dafe8f77f4a Mon Sep 17 00:00:00 2001 From: Damian Nolan Date: Wed, 14 Jun 2023 14:52:06 +0200 Subject: [PATCH 14/21] add initial test cases --- modules/core/keeper/msg_server.go | 6 +- modules/core/keeper/msg_server_test.go | 147 +++++++++++++++++++++++++ 2 files changed, 150 insertions(+), 3 deletions(-) diff --git a/modules/core/keeper/msg_server.go b/modules/core/keeper/msg_server.go index 2a835ef2cec..e6487511509 100644 --- a/modules/core/keeper/msg_server.go +++ b/modules/core/keeper/msg_server.go @@ -829,7 +829,7 @@ func (k Keeper) ChannelUpgradeAck(goCtx context.Context, msg *channeltypes.MsgCh // 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. - return &channeltypes.MsgChannelUpgradeAckResponse{ /*Result: channeltypes.FAILURE*/ }, nil + return &channeltypes.MsgChannelUpgradeAckResponse{Result: channeltypes.FAILURE}, nil } // NOTE: an error is returned to baseapp and transaction state is not committed. @@ -844,14 +844,14 @@ func (k Keeper) ChannelUpgradeAck(goCtx context.Context, msg *channeltypes.MsgCh return nil, err } - return &channeltypes.MsgChannelUpgradeAckResponse{ /*Result: channeltypes.FAILURE*/ }, nil + return &channeltypes.MsgChannelUpgradeAckResponse{Result: channeltypes.FAILURE}, nil } writeFn() k.ChannelKeeper.WriteUpgradeAckChannel(ctx, msg.PortId, msg.ChannelId, msg.CounterpartyUpgrade.Fields.Version) - return &channeltypes.MsgChannelUpgradeAckResponse{}, nil + return &channeltypes.MsgChannelUpgradeAckResponse{Result: channeltypes.SUCCESS}, nil } // ChannelUpgradeOpen defines a rpc handler method for MsgChannelUpgradeOpen. diff --git a/modules/core/keeper/msg_server_test.go b/modules/core/keeper/msg_server_test.go index d2e23861d7c..ae461120877 100644 --- a/modules/core/keeper/msg_server_test.go +++ b/modules/core/keeper/msg_server_test.go @@ -924,3 +924,150 @@ func (suite *KeeperTestSuite) TestChannelUpgradeTry() { }) } } + +func (suite *KeeperTestSuite) TestChannelUpgradeAck() { + var ( + path *ibctesting.Path + msg *channeltypes.MsgChannelUpgradeAck + ) + + cases := []struct { + name string + malleate func() + expResult func(res *channeltypes.MsgChannelUpgradeAckResponse, err error) + }{ + { + "success", + func() {}, + func(res *channeltypes.MsgChannelUpgradeAckResponse, err error) { + suite.Require().NoError(err) + suite.Require().NotNil(res) + suite.Require().Equal(channeltypes.SUCCESS, res.Result) + + channel := path.EndpointA.GetChannel() + suite.Require().Equal(channeltypes.ACKUPGRADE, channel.State) + suite.Require().Equal(uint64(1), channel.UpgradeSequence) + }, + }, + { + "module capability not found", + func() { + msg.PortId = ibctesting.InvalidID + msg.ChannelId = ibctesting.InvalidID + }, + func(res *channeltypes.MsgChannelUpgradeAckResponse, err error) { + suite.Require().Error(err) + suite.Require().Nil(res) + + suite.Require().ErrorIs(err, capabilitytypes.ErrCapabilityNotFound) + }, + }, + // { + // "elapsed upgrade timeout returns error", + // func() { + // msg.UpgradeTimeout = channeltypes.NewTimeout(clienttypes.NewHeight(1, 10), 0) + // suite.coordinator.CommitNBlocks(suite.chainB, 100) + // }, + // func(res *channeltypes.MsgChannelUpgradeAckResponse, err error) { + // suite.Require().Error(err) + // suite.Require().Nil(res) + // suite.Require().ErrorIs(err, channeltypes.ErrInvalidUpgrade) + + // errorReceipt, found := suite.chainB.GetSimApp().GetIBCKeeper().ChannelKeeper.GetUpgradeErrorReceipt(suite.chainB.GetContext(), path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID) + // suite.Require().Empty(errorReceipt) + // suite.Require().False(found) + // }, + // }, + // { + // "unsynchronized upgrade sequence writes upgrade error receipt", + // func() { + // channel := path.EndpointB.GetChannel() + // channel.UpgradeSequence = 99 + + // path.EndpointB.SetChannel(channel) + // }, + // func(res *channeltypes.MsgChannelUpgradeAckResponse, err error) { + // suite.Require().NoError(err) + + // suite.Require().NotNil(res) + // suite.Require().Equal(channeltypes.FAILURE, res.Result) + + // errorReceipt, found := suite.chainB.GetSimApp().GetIBCKeeper().ChannelKeeper.GetUpgradeErrorReceipt(suite.chainB.GetContext(), path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID) + // suite.Require().True(found) + // suite.Require().Equal(uint64(100), errorReceipt.Sequence) + // }, + // }, + { + "application callback error writes upgrade error receipt", + func() { + suite.chainA.GetSimApp().IBCMockModule.IBCApp.OnChanUpgradeAck = func( + ctx sdk.Context, portID, channelID, counterpartyVersion string, + ) error { + // set arbitrary value in store to mock application state changes + store := ctx.KVStore(suite.chainA.GetSimApp().GetKey(exported.ModuleName)) + store.Set([]byte("foo"), []byte("bar")) + return fmt.Errorf("mock app callback failed") + } + }, + func(res *channeltypes.MsgChannelUpgradeAckResponse, err error) { + suite.Require().NoError(err) + + suite.Require().NotNil(res) + suite.Require().Equal(channeltypes.FAILURE, res.Result) + + errorReceipt, found := suite.chainA.GetSimApp().GetIBCKeeper().ChannelKeeper.GetUpgradeErrorReceipt(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID) + suite.Require().True(found) + suite.Require().Equal(uint64(1), errorReceipt.Sequence) + + // assert application state changes are not committed + store := suite.chainA.GetContext().KVStore(suite.chainA.GetSimApp().GetKey(exported.ModuleName)) + suite.Require().False(store.Has([]byte("foo"))) + }, + }, + } + + for _, tc := range cases { + tc := tc + suite.Run(tc.name, func() { + suite.SetupTest() + + path = ibctesting.NewPath(suite.chainA, suite.chainB) + suite.coordinator.Setup(path) + + // configure the channel upgrade version on testing endpoints + path.EndpointA.ChannelConfig.ProposedUpgrade.Fields.Version = ibcmock.UpgradeVersion + path.EndpointB.ChannelConfig.ProposedUpgrade.Fields.Version = ibcmock.UpgradeVersion + + err := path.EndpointA.ChanUpgradeInit() + suite.Require().NoError(err) + + err = path.EndpointB.ChanUpgradeTry() + suite.Require().NoError(err) + + err = path.EndpointA.UpdateClient() + suite.Require().NoError(err) + + counterpartyChannel := path.EndpointB.GetChannel() + counterpartyUpgrade := path.EndpointB.GetChannelUpgrade() + + proofChannel, proofUpgrade, proofHeight := path.EndpointA.QueryChannelUpgradeProof() + + msg = &channeltypes.MsgChannelUpgradeAck{ + PortId: path.EndpointB.ChannelConfig.PortID, + ChannelId: path.EndpointB.ChannelID, + CounterpartyFlushStatus: counterpartyChannel.FlushStatus, + CounterpartyUpgrade: counterpartyUpgrade, + ProofChannel: proofChannel, + ProofUpgrade: proofUpgrade, + ProofHeight: proofHeight, + Signer: suite.chainB.SenderAccount.GetAddress().String(), + } + + tc.malleate() + + res, err := suite.chainA.GetSimApp().GetIBCKeeper().ChannelUpgradeAck(suite.chainA.GetContext(), msg) + + tc.expResult(res, err) + }) + } +} From 80326a0ea6c3e07d477f67f7db1de7460b2e2cc3 Mon Sep 17 00:00:00 2001 From: Damian Nolan Date: Wed, 14 Jun 2023 17:34:22 +0200 Subject: [PATCH 15/21] adding additional testcases --- modules/core/keeper/msg_server_test.go | 70 +++++++++++++------------- 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/modules/core/keeper/msg_server_test.go b/modules/core/keeper/msg_server_test.go index ae461120877..0e34f9cd695 100644 --- a/modules/core/keeper/msg_server_test.go +++ b/modules/core/keeper/msg_server_test.go @@ -8,6 +8,7 @@ import ( upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" + "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types" channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types" commitmenttypes "github.com/cosmos/ibc-go/v7/modules/core/23-commitment/types" host "github.com/cosmos/ibc-go/v7/modules/core/24-host" @@ -962,41 +963,40 @@ func (suite *KeeperTestSuite) TestChannelUpgradeAck() { suite.Require().ErrorIs(err, capabilitytypes.ErrCapabilityNotFound) }, }, - // { - // "elapsed upgrade timeout returns error", - // func() { - // msg.UpgradeTimeout = channeltypes.NewTimeout(clienttypes.NewHeight(1, 10), 0) - // suite.coordinator.CommitNBlocks(suite.chainB, 100) - // }, - // func(res *channeltypes.MsgChannelUpgradeAckResponse, err error) { - // suite.Require().Error(err) - // suite.Require().Nil(res) - // suite.Require().ErrorIs(err, channeltypes.ErrInvalidUpgrade) - - // errorReceipt, found := suite.chainB.GetSimApp().GetIBCKeeper().ChannelKeeper.GetUpgradeErrorReceipt(suite.chainB.GetContext(), path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID) - // suite.Require().Empty(errorReceipt) - // suite.Require().False(found) - // }, - // }, - // { - // "unsynchronized upgrade sequence writes upgrade error receipt", - // func() { - // channel := path.EndpointB.GetChannel() - // channel.UpgradeSequence = 99 - - // path.EndpointB.SetChannel(channel) - // }, - // func(res *channeltypes.MsgChannelUpgradeAckResponse, err error) { - // suite.Require().NoError(err) - - // suite.Require().NotNil(res) - // suite.Require().Equal(channeltypes.FAILURE, res.Result) - - // errorReceipt, found := suite.chainB.GetSimApp().GetIBCKeeper().ChannelKeeper.GetUpgradeErrorReceipt(suite.chainB.GetContext(), path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID) - // suite.Require().True(found) - // suite.Require().Equal(uint64(100), errorReceipt.Sequence) - // }, - // }, + { + "invalid counterparty flush status returns error, tx is rejected", + func() { + msg.CounterpartyFlushStatus = types.NOTINFLUSH + }, + func(res *channeltypes.MsgChannelUpgradeAckResponse, err error) { + suite.Require().Error(err) + suite.Require().Nil(res) + suite.Require().ErrorIs(err, channeltypes.ErrInvalidFlushStatus) + + errorReceipt, found := suite.chainA.GetSimApp().GetIBCKeeper().ChannelKeeper.GetUpgradeErrorReceipt(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID) + suite.Require().Empty(errorReceipt) + suite.Require().False(found) + }, + }, + { + "counterparty upgrade ordering is incompatible, writes upgrade error receipt", + func() { + upgrade := path.EndpointA.GetChannelUpgrade() + upgrade.Fields.Ordering = types.NONE + + path.EndpointA.SetChannelUpgrade(upgrade) + }, + func(res *channeltypes.MsgChannelUpgradeAckResponse, err error) { + suite.Require().NoError(err) + + suite.Require().NotNil(res) + suite.Require().Equal(channeltypes.FAILURE, res.Result) + + errorReceipt, found := suite.chainA.GetSimApp().GetIBCKeeper().ChannelKeeper.GetUpgradeErrorReceipt(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID) + suite.Require().True(found) + suite.Require().Equal(uint64(1), errorReceipt.Sequence) + }, + }, { "application callback error writes upgrade error receipt", func() { From d23c6f1a16072636b3d649fdbaf87d9dcc337a83 Mon Sep 17 00:00:00 2001 From: Damian Nolan Date: Tue, 20 Jun 2023 17:14:23 +0200 Subject: [PATCH 16/21] apply testcase naming review suggestions Co-authored-by: Carlos Rodriguez --- modules/core/keeper/msg_server_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/core/keeper/msg_server_test.go b/modules/core/keeper/msg_server_test.go index 0e34f9cd695..ec640ea616a 100644 --- a/modules/core/keeper/msg_server_test.go +++ b/modules/core/keeper/msg_server_test.go @@ -964,7 +964,7 @@ func (suite *KeeperTestSuite) TestChannelUpgradeAck() { }, }, { - "invalid counterparty flush status returns error, tx is rejected", + "core handler returns error and no upgrade error receipt is written", func() { msg.CounterpartyFlushStatus = types.NOTINFLUSH }, @@ -979,7 +979,7 @@ func (suite *KeeperTestSuite) TestChannelUpgradeAck() { }, }, { - "counterparty upgrade ordering is incompatible, writes upgrade error receipt", + "core handler returns error and writes upgrade error receipt", func() { upgrade := path.EndpointA.GetChannelUpgrade() upgrade.Fields.Ordering = types.NONE @@ -998,7 +998,7 @@ func (suite *KeeperTestSuite) TestChannelUpgradeAck() { }, }, { - "application callback error writes upgrade error receipt", + "application callback returns error and error receipt is written", func() { suite.chainA.GetSimApp().IBCMockModule.IBCApp.OnChanUpgradeAck = func( ctx sdk.Context, portID, channelID, counterpartyVersion string, From 4ba1751f16b4e6aa2c42a947a5520dc16a8c6c50 Mon Sep 17 00:00:00 2001 From: Damian Nolan Date: Tue, 20 Jun 2023 17:15:37 +0200 Subject: [PATCH 17/21] apply error return wrapping suggestions from review Co-authored-by: Carlos Rodriguez --- modules/core/keeper/msg_server.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/core/keeper/msg_server.go b/modules/core/keeper/msg_server.go index e6487511509..dd2cd1e4568 100644 --- a/modules/core/keeper/msg_server.go +++ b/modules/core/keeper/msg_server.go @@ -824,7 +824,7 @@ func (k Keeper) ChannelUpgradeAck(goCtx context.Context, msg *channeltypes.MsgCh ctx.Logger().Error("channel upgrade ack failed", "error", errorsmod.Wrap(err, "channel handshake upgrade ack failed")) if upgradeErr, ok := err.(*channeltypes.UpgradeError); ok { if err := k.ChannelKeeper.AbortUpgrade(ctx, msg.PortId, msg.ChannelId, upgradeErr); err != nil { - return nil, err + return nil, errorsmod.Wrap(err, "channel upgrade ack (abort upgrade) failed") } // NOTE: a FAILURE result is returned to the client and an error receipt is written to state. @@ -833,7 +833,7 @@ func (k Keeper) ChannelUpgradeAck(goCtx context.Context, msg *channeltypes.MsgCh } // NOTE: an error is returned to baseapp and transaction state is not committed. - return nil, err + return nil, errorsmod.Wrap(err, "channel upgrade ack failed") } cacheCtx, writeFn := ctx.CacheContext() @@ -841,7 +841,7 @@ func (k Keeper) ChannelUpgradeAck(goCtx context.Context, msg *channeltypes.MsgCh if err != nil { ctx.Logger().Error("channel upgrade ack callback failed", "port-id", msg.PortId, "channel-id", msg.ChannelId, "error", err.Error()) if err := k.ChannelKeeper.AbortUpgrade(ctx, msg.PortId, msg.ChannelId, err); err != nil { - return nil, err + return nil, errorsmod.Wrap(err, "channel upgrade ack callback (abort upgrade) failed for port ID: %s, channel ID: %s", msg.PortId, channelID) } return &channeltypes.MsgChannelUpgradeAckResponse{Result: channeltypes.FAILURE}, nil From a710ee4786b65da19065d4d030d65eeb1561d9ae Mon Sep 17 00:00:00 2001 From: Damian Nolan Date: Tue, 20 Jun 2023 17:20:23 +0200 Subject: [PATCH 18/21] fix error to use Wrapf and correct channel id arg, adding success log --- modules/core/keeper/msg_server.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/core/keeper/msg_server.go b/modules/core/keeper/msg_server.go index dd2cd1e4568..c9f072bb303 100644 --- a/modules/core/keeper/msg_server.go +++ b/modules/core/keeper/msg_server.go @@ -841,7 +841,7 @@ func (k Keeper) ChannelUpgradeAck(goCtx context.Context, msg *channeltypes.MsgCh if err != nil { ctx.Logger().Error("channel upgrade ack callback failed", "port-id", msg.PortId, "channel-id", msg.ChannelId, "error", err.Error()) if err := k.ChannelKeeper.AbortUpgrade(ctx, msg.PortId, msg.ChannelId, err); err != nil { - return nil, errorsmod.Wrap(err, "channel upgrade ack callback (abort upgrade) failed for port ID: %s, channel ID: %s", msg.PortId, channelID) + return nil, errorsmod.Wrapf(err, "channel upgrade ack callback (abort upgrade) failed for port ID: %s, channel ID: %s", msg.PortId, msg.ChannelId) } return &channeltypes.MsgChannelUpgradeAckResponse{Result: channeltypes.FAILURE}, nil @@ -851,6 +851,8 @@ func (k Keeper) ChannelUpgradeAck(goCtx context.Context, msg *channeltypes.MsgCh k.ChannelKeeper.WriteUpgradeAckChannel(ctx, msg.PortId, msg.ChannelId, msg.CounterpartyUpgrade.Fields.Version) + ctx.Logger().Info("channel upgrade ack succeeded", "port-id", msg.PortId, "channel-id", msg.ChannelId) + return &channeltypes.MsgChannelUpgradeAckResponse{Result: channeltypes.SUCCESS}, nil } From e75f1ca12edb0b984a1d2e5740061e026d07ce4f Mon Sep 17 00:00:00 2001 From: Damian Nolan Date: Tue, 20 Jun 2023 17:33:57 +0200 Subject: [PATCH 19/21] correct testing imports and satisy linter --- modules/core/keeper/msg_server_test.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/modules/core/keeper/msg_server_test.go b/modules/core/keeper/msg_server_test.go index ec640ea616a..00686873dce 100644 --- a/modules/core/keeper/msg_server_test.go +++ b/modules/core/keeper/msg_server_test.go @@ -8,7 +8,6 @@ import ( upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" - "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types" channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types" commitmenttypes "github.com/cosmos/ibc-go/v7/modules/core/23-commitment/types" host "github.com/cosmos/ibc-go/v7/modules/core/24-host" @@ -966,7 +965,7 @@ func (suite *KeeperTestSuite) TestChannelUpgradeAck() { { "core handler returns error and no upgrade error receipt is written", func() { - msg.CounterpartyFlushStatus = types.NOTINFLUSH + msg.CounterpartyFlushStatus = channeltypes.NOTINFLUSH }, func(res *channeltypes.MsgChannelUpgradeAckResponse, err error) { suite.Require().Error(err) @@ -982,7 +981,7 @@ func (suite *KeeperTestSuite) TestChannelUpgradeAck() { "core handler returns error and writes upgrade error receipt", func() { upgrade := path.EndpointA.GetChannelUpgrade() - upgrade.Fields.Ordering = types.NONE + upgrade.Fields.Ordering = channeltypes.NONE path.EndpointA.SetChannelUpgrade(upgrade) }, From 0169d982afc963cec63116a9198b972cc210bf5a Mon Sep 17 00:00:00 2001 From: Damian Nolan Date: Wed, 21 Jun 2023 10:43:05 +0200 Subject: [PATCH 20/21] apply self suggestions for testcase context with in-line comments --- modules/core/keeper/msg_server_test.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/modules/core/keeper/msg_server_test.go b/modules/core/keeper/msg_server_test.go index 00686873dce..94e6eb55cfe 100644 --- a/modules/core/keeper/msg_server_test.go +++ b/modules/core/keeper/msg_server_test.go @@ -965,6 +965,7 @@ func (suite *KeeperTestSuite) TestChannelUpgradeAck() { { "core handler returns error and no upgrade error receipt is written", func() { + // force an error by overriding the counterparty flush status to an invalid value msg.CounterpartyFlushStatus = channeltypes.NOTINFLUSH }, func(res *channeltypes.MsgChannelUpgradeAckResponse, err error) { @@ -980,6 +981,7 @@ func (suite *KeeperTestSuite) TestChannelUpgradeAck() { { "core handler returns error and writes upgrade error receipt", func() { + // force an upgrade error by modifying the channel upgrade ordering to an incompatible value upgrade := path.EndpointA.GetChannelUpgrade() upgrade.Fields.Ordering = channeltypes.NONE From 9d71ee522f00b262d1283236e8eafa27b22c4b5b Mon Sep 17 00:00:00 2001 From: Damian Nolan Date: Wed, 21 Jun 2023 10:47:46 +0200 Subject: [PATCH 21/21] updating test func to use path.EndpointA and chainA sender acc --- modules/core/keeper/msg_server_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/core/keeper/msg_server_test.go b/modules/core/keeper/msg_server_test.go index 94e6eb55cfe..f1ba967fd4f 100644 --- a/modules/core/keeper/msg_server_test.go +++ b/modules/core/keeper/msg_server_test.go @@ -1054,14 +1054,14 @@ func (suite *KeeperTestSuite) TestChannelUpgradeAck() { proofChannel, proofUpgrade, proofHeight := path.EndpointA.QueryChannelUpgradeProof() msg = &channeltypes.MsgChannelUpgradeAck{ - PortId: path.EndpointB.ChannelConfig.PortID, - ChannelId: path.EndpointB.ChannelID, + PortId: path.EndpointA.ChannelConfig.PortID, + ChannelId: path.EndpointA.ChannelID, CounterpartyFlushStatus: counterpartyChannel.FlushStatus, CounterpartyUpgrade: counterpartyUpgrade, ProofChannel: proofChannel, ProofUpgrade: proofUpgrade, ProofHeight: proofHeight, - Signer: suite.chainB.SenderAccount.GetAddress().String(), + Signer: suite.chainA.SenderAccount.GetAddress().String(), } tc.malleate()