diff --git a/modules/core/04-channel/v2/keeper/packet.go b/modules/core/04-channel/v2/keeper/packet.go index 136b5b01940..85594a745cc 100644 --- a/modules/core/04-channel/v2/keeper/packet.go +++ b/modules/core/04-channel/v2/keeper/packet.go @@ -32,8 +32,7 @@ func (k *Keeper) sendPacket( sequence, found := k.GetNextSequenceSend(ctx, sourceClient) if !found { - // initialize sequnce to 1 if it does not exist - sequence = 1 + return 0, "", errorsmod.Wrapf(types.ErrSequenceSendNotFound, "source client: %s", sourceClient) } // construct packet from given fields and channel state diff --git a/modules/core/keeper/msg_server.go b/modules/core/keeper/msg_server.go index 3030014944e..5bb96f2dff4 100644 --- a/modules/core/keeper/msg_server.go +++ b/modules/core/keeper/msg_server.go @@ -61,6 +61,9 @@ func (k *Keeper) RegisterCounterparty(ctx context.Context, msg *clienttypes.MsgR } k.ClientKeeper.SetClientCounterparty(ctx, msg.ClientId, counterpartyInfo) + // initialize next sequence send to enable packet flow + k.ChannelKeeperV2.SetNextSequenceSend(ctx, msg.ClientId, 1) + k.ClientKeeper.DeleteClientCreator(ctx, msg.ClientId) return &clienttypes.MsgRegisterCounterpartyResponse{}, nil } diff --git a/modules/core/keeper/msg_server_test.go b/modules/core/keeper/msg_server_test.go index f913b9eb9d2..480c06a5d73 100644 --- a/modules/core/keeper/msg_server_test.go +++ b/modules/core/keeper/msg_server_test.go @@ -79,6 +79,9 @@ func (suite *KeeperTestSuite) TestRegisterCounterparty() { counterpartyInfo, ok := suite.chainA.App.GetIBCKeeper().ClientKeeper.GetClientCounterparty(suite.chainA.GetContext(), path.EndpointA.ClientID) suite.Require().True(ok) suite.Require().Equal(counterpartyInfo, clienttypes.NewCounterpartyInfo(merklePrefix, path.EndpointB.ClientID)) + nextSeqSend, ok := suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.GetNextSequenceSend(suite.chainA.GetContext(), path.EndpointA.ClientID) + suite.Require().True(ok) + suite.Require().Equal(nextSeqSend, uint64(1)) creator := suite.chainA.App.GetIBCKeeper().ClientKeeper.GetClientCreator(suite.chainA.GetContext(), path.EndpointA.ClientID) suite.Require().Empty(creator) }