diff --git a/proto/ibc/lightclients/solomachine/v1/solomachine.proto b/proto/ibc/lightclients/solomachine/v1/solomachine.proto index 8903783de83c..8f7ecbb739f3 100644 --- a/proto/ibc/lightclients/solomachine/v1/solomachine.proto +++ b/proto/ibc/lightclients/solomachine/v1/solomachine.proto @@ -142,9 +142,9 @@ message PacketAcknowledgementData { bytes acknowledgement = 2; } -// PacketAcknowledgementAbsenceSignBytes returns the SignBytes data for -// acknowledgement absence verification. -message PacketAcknowledgementAbsenseData { +// PacketReceiptAbsenceSignBytes returns the SignBytes data for +// packet receipt absence verification. +message PacketReceiptAbsenseData { bytes path = 1; } diff --git a/x/ibc-transfer/keeper/keeper.go b/x/ibc-transfer/keeper/keeper.go index 3cd86ee7f896..e9b1518a7c3c 100644 --- a/x/ibc-transfer/keeper/keeper.go +++ b/x/ibc-transfer/keeper/keeper.go @@ -16,7 +16,6 @@ import ( "github.com/cosmos/cosmos-sdk/x/ibc-transfer/types" channeltypes "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/types" host "github.com/cosmos/cosmos-sdk/x/ibc/24-host" - ibcexported "github.com/cosmos/cosmos-sdk/x/ibc/exported" paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" ) @@ -72,19 +71,8 @@ func (k Keeper) GetTransferAccount(ctx sdk.Context) authtypes.ModuleAccountI { return k.authKeeper.GetModuleAccount(ctx, types.ModuleName) } -// ReceiveExecuted defines a wrapper function for the channel Keeper's function -// in order to expose it to the ICS20 transfer handler. -// Keeper retrieves channel capability and passes it into channel keeper for authentication -func (k Keeper) ReceiveExecuted(ctx sdk.Context, packet ibcexported.PacketI, acknowledgement []byte) error { - chanCap, ok := k.scopedKeeper.GetCapability(ctx, host.ChannelCapabilityPath(packet.GetDestPort(), packet.GetDestChannel())) - if !ok { - return sdkerrors.Wrap(channeltypes.ErrChannelCapabilityNotFound, "channel capability could not be retrieved for packet") - } - return k.channelKeeper.ReceiveExecuted(ctx, chanCap, packet, acknowledgement) -} - // ChanCloseInit defines a wrapper function for the channel Keeper's function -// in order to expose it to the ICS20 trasfer handler. +// in order to expose it to the ICS20 transfer handler. func (k Keeper) ChanCloseInit(ctx sdk.Context, portID, channelID string) error { capName := host.ChannelCapabilityPath(portID, channelID) chanCap, ok := k.scopedKeeper.GetCapability(ctx, capName) diff --git a/x/ibc-transfer/module.go b/x/ibc-transfer/module.go index 547fbb2ba849..0465cbaf8019 100644 --- a/x/ibc-transfer/module.go +++ b/x/ibc-transfer/module.go @@ -323,6 +323,7 @@ func (am AppModule) OnRecvPacket( ), ) + // NOTE: acknowledgement will be written synchronously during IBC handler execution. return &sdk.Result{ Events: ctx.EventManager().Events().ToABCIEvents(), }, acknowledgement.GetBytes(), nil diff --git a/x/ibc-transfer/types/expected_keepers.go b/x/ibc-transfer/types/expected_keepers.go index 9a7f2a73bdf5..87d16c643f65 100644 --- a/x/ibc-transfer/types/expected_keepers.go +++ b/x/ibc-transfer/types/expected_keepers.go @@ -29,7 +29,6 @@ type ChannelKeeper interface { GetChannel(ctx sdk.Context, srcPort, srcChan string) (channel channeltypes.Channel, found bool) GetNextSequenceSend(ctx sdk.Context, portID, channelID string) (uint64, bool) SendPacket(ctx sdk.Context, channelCap *capabilitytypes.Capability, packet ibcexported.PacketI) error - ReceiveExecuted(ctx sdk.Context, chanCap *capabilitytypes.Capability, packet ibcexported.PacketI, acknowledgement []byte) error ChanCloseInit(ctx sdk.Context, portID, channelID string, chanCap *capabilitytypes.Capability) error } diff --git a/x/ibc/02-client/types/errors.go b/x/ibc/02-client/types/errors.go index e90d5f895478..ca0131823a15 100644 --- a/x/ibc/02-client/types/errors.go +++ b/x/ibc/02-client/types/errors.go @@ -23,7 +23,7 @@ var ( ErrFailedChannelStateVerification = sdkerrors.Register(SubModuleName, 16, "channel state verification failed") ErrFailedPacketCommitmentVerification = sdkerrors.Register(SubModuleName, 17, "packet commitment verification failed") ErrFailedPacketAckVerification = sdkerrors.Register(SubModuleName, 18, "packet acknowledgement verification failed") - ErrFailedPacketAckAbsenceVerification = sdkerrors.Register(SubModuleName, 19, "packet acknowledgement absence verification failed") + ErrFailedPacketReceiptVerification = sdkerrors.Register(SubModuleName, 19, "packet receipt verification failed") ErrFailedNextSeqRecvVerification = sdkerrors.Register(SubModuleName, 20, "next sequence receive verification failed") ErrSelfConsensusStateNotFound = sdkerrors.Register(SubModuleName, 21, "self consensus state not found") ErrUpdateClientFailed = sdkerrors.Register(SubModuleName, 22, "unable to update light client") diff --git a/x/ibc/03-connection/keeper/verify.go b/x/ibc/03-connection/keeper/verify.go index e6f447d8b1c9..4c2ab3f81a7d 100644 --- a/x/ibc/03-connection/keeper/verify.go +++ b/x/ibc/03-connection/keeper/verify.go @@ -175,10 +175,10 @@ func (k Keeper) VerifyPacketAcknowledgement( return nil } -// VerifyPacketAcknowledgementAbsence verifies a proof of the absence of an -// incoming packet acknowledgement at the specified port, specified channel, and +// VerifyPacketReceiptAbsence verifies a proof of the absence of an +// incoming packet receipt at the specified port, specified channel, and // specified sequence. -func (k Keeper) VerifyPacketAcknowledgementAbsence( +func (k Keeper) VerifyPacketReceiptAbsence( ctx sdk.Context, connection exported.ConnectionI, height exported.Height, @@ -192,12 +192,12 @@ func (k Keeper) VerifyPacketAcknowledgementAbsence( return sdkerrors.Wrap(clienttypes.ErrClientNotFound, connection.GetClientID()) } - if err := clientState.VerifyPacketAcknowledgementAbsence( + if err := clientState.VerifyPacketReceiptAbsence( k.clientKeeper.ClientStore(ctx, connection.GetClientID()), k.cdc, height, connection.GetCounterparty().GetPrefix(), proof, portID, channelID, sequence, ); err != nil { - return sdkerrors.Wrapf(err, "failed packet acknowledgement absence verification for client (%s)", connection.GetClientID()) + return sdkerrors.Wrapf(err, "failed packet receipt absence verification for client (%s)", connection.GetClientID()) } return nil diff --git a/x/ibc/03-connection/keeper/verify_test.go b/x/ibc/03-connection/keeper/verify_test.go index 343ed2bc17e6..1cb3e619bef7 100644 --- a/x/ibc/03-connection/keeper/verify_test.go +++ b/x/ibc/03-connection/keeper/verify_test.go @@ -336,7 +336,10 @@ func (suite *KeeperTestSuite) TestVerifyPacketAcknowledgement() { err := suite.coordinator.SendPacket(suite.chainA, suite.chainB, packet, clientB) suite.Require().NoError(err) - err = suite.coordinator.ReceiveExecuted(suite.chainB, suite.chainA, packet, clientA) + err = suite.coordinator.WriteReceipt(suite.chainB, suite.chainA, packet, clientA) + suite.Require().NoError(err) + + err = suite.coordinator.WriteAcknowledgement(suite.chainB, suite.chainA, packet, clientA) suite.Require().NoError(err) packetAckKey := host.KeyPacketAcknowledgement(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence()) @@ -361,10 +364,10 @@ func (suite *KeeperTestSuite) TestVerifyPacketAcknowledgement() { } } -// TestVerifyPacketAcknowledgementAbsence has chainA verify the acknowledgement +// TestVerifyPacketReceiptAbsence has chainA verify the receipt // absence on channelB. The channels on chainA and chainB are fully opened and // a packet is sent from chainA to chainB and not received. -func (suite *KeeperTestSuite) TestVerifyPacketAcknowledgementAbsence() { +func (suite *KeeperTestSuite) TestVerifyPacketReceiptAbsence() { cases := []struct { msg string changeClientID bool @@ -396,7 +399,7 @@ func (suite *KeeperTestSuite) TestVerifyPacketAcknowledgementAbsence() { suite.Require().NoError(err) if tc.recvAck { - err = suite.coordinator.ReceiveExecuted(suite.chainB, suite.chainA, packet, clientA) + err = suite.coordinator.WriteReceipt(suite.chainB, suite.chainA, packet, clientA) suite.Require().NoError(err) } else { // need to update height to prove absence @@ -404,10 +407,10 @@ func (suite *KeeperTestSuite) TestVerifyPacketAcknowledgementAbsence() { suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, ibctesting.Tendermint) } - packetAckKey := host.KeyPacketAcknowledgement(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence()) - proof, proofHeight := suite.chainB.QueryProof(packetAckKey) + packetReceiptKey := host.KeyPacketReceipt(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence()) + proof, proofHeight := suite.chainB.QueryProof(packetReceiptKey) - err = suite.chainA.App.IBCKeeper.ConnectionKeeper.VerifyPacketAcknowledgementAbsence( + err = suite.chainA.App.IBCKeeper.ConnectionKeeper.VerifyPacketReceiptAbsence( suite.chainA.GetContext(), connection, malleateHeight(proofHeight, tc.heightDiff), proof, packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence(), ) @@ -455,7 +458,7 @@ func (suite *KeeperTestSuite) TestVerifyNextSequenceRecv() { err := suite.coordinator.SendPacket(suite.chainA, suite.chainB, packet, clientB) suite.Require().NoError(err) - err = suite.coordinator.ReceiveExecuted(suite.chainB, suite.chainA, packet, clientA) + err = suite.coordinator.WriteReceipt(suite.chainB, suite.chainA, packet, clientA) suite.Require().NoError(err) nextSeqRecvKey := host.KeyNextSequenceRecv(packet.GetDestPort(), packet.GetDestChannel()) diff --git a/x/ibc/04-channel/keeper/keeper.go b/x/ibc/04-channel/keeper/keeper.go index 2d220db1acc6..950e396ad66f 100644 --- a/x/ibc/04-channel/keeper/keeper.go +++ b/x/ibc/04-channel/keeper/keeper.go @@ -125,6 +125,23 @@ func (k Keeper) SetNextSequenceAck(ctx sdk.Context, portID, channelID string, se store.Set(host.KeyNextSequenceAck(portID, channelID), bz) } +// GetPacketReceipt gets a packet receipt from the store +func (k Keeper) GetPacketReceipt(ctx sdk.Context, portID, channelID string, sequence uint64) (string, bool) { + store := ctx.KVStore(k.storeKey) + bz := store.Get(host.KeyPacketReceipt(portID, channelID, sequence)) + if bz == nil { + return "", false + } + + return string(bz), true +} + +// SetPacketReceipt sets an empty packet receipt to the store +func (k Keeper) SetPacketReceipt(ctx sdk.Context, portID, channelID string, sequence uint64) { + store := ctx.KVStore(k.storeKey) + store.Set(host.KeyPacketReceipt(portID, channelID, sequence), []byte("")) +} + // GetPacketCommitment gets the packet commitment hash from the store func (k Keeper) GetPacketCommitment(ctx sdk.Context, portID, channelID string, sequence uint64) []byte { store := ctx.KVStore(k.storeKey) @@ -165,6 +182,12 @@ func (k Keeper) GetPacketAcknowledgement(ctx sdk.Context, portID, channelID stri return bz, true } +// HasPacketAcknowledgement check if the packet ack hash is already on the store +func (k Keeper) HasPacketAcknowledgement(ctx sdk.Context, portID, channelID string, sequence uint64) bool { + store := ctx.KVStore(k.storeKey) + return store.Has(host.KeyPacketAcknowledgement(portID, channelID, sequence)) +} + // IteratePacketSequence provides an iterator over all send, receive or ack sequences. // For each sequence, cb will be called. If the cb returns true, the iterator // will close and stop. diff --git a/x/ibc/04-channel/keeper/keeper_test.go b/x/ibc/04-channel/keeper/keeper_test.go index 1c0237828de4..f8b56771bee6 100644 --- a/x/ibc/04-channel/keeper/keeper_test.go +++ b/x/ibc/04-channel/keeper/keeper_test.go @@ -291,13 +291,14 @@ func (suite *KeeperTestSuite) TestSetPacketAcknowledgement() { seq := uint64(10) storedAckHash, found := suite.chainA.App.IBCKeeper.ChannelKeeper.GetPacketAcknowledgement(ctxA, channelA.PortID, channelA.ID, seq) - suite.False(found) - suite.Nil(storedAckHash) + suite.Require().False(found) + suite.Require().Nil(storedAckHash) ackHash := []byte("ackhash") suite.chainA.App.IBCKeeper.ChannelKeeper.SetPacketAcknowledgement(ctxA, channelA.PortID, channelA.ID, seq, ackHash) storedAckHash, found = suite.chainA.App.IBCKeeper.ChannelKeeper.GetPacketAcknowledgement(ctxA, channelA.PortID, channelA.ID, seq) - suite.True(found) - suite.Equal(ackHash, storedAckHash) + suite.Require().True(found) + suite.Require().Equal(ackHash, storedAckHash) + suite.Require().True(suite.chainA.App.IBCKeeper.ChannelKeeper.HasPacketAcknowledgement(ctxA, channelA.PortID, channelA.ID, seq)) } diff --git a/x/ibc/04-channel/keeper/packet.go b/x/ibc/04-channel/keeper/packet.go index e96c7a53e370..42abff725975 100644 --- a/x/ibc/04-channel/keeper/packet.go +++ b/x/ibc/04-channel/keeper/packet.go @@ -201,19 +201,19 @@ func (k Keeper) RecvPacket( ) } - // check if the packet acknowledgement has been received already for unordered channels - if channel.Ordering == types.UNORDERED { - _, found := k.GetPacketAcknowledgement(ctx, packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence()) + switch channel.Ordering { + case types.UNORDERED: + // check if the packet receipt has been received already for unordered channels + _, found := k.GetPacketReceipt(ctx, packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence()) if found { return sdkerrors.Wrapf( types.ErrInvalidPacket, "packet sequence (%d) already has been received", packet.GetSequence(), ) } - } - // check if the packet is being received in order - if channel.Ordering == types.ORDERED { + case types.ORDERED: + // check if the packet is being received in order nextSequenceRecv, found := k.GetNextSequenceRecv(ctx, packet.GetDestPort(), packet.GetDestChannel()) if !found { return sdkerrors.Wrapf( @@ -238,19 +238,18 @@ func (k Keeper) RecvPacket( return sdkerrors.Wrap(err, "couldn't verify counterparty packet commitment") } - // NOTE: the remaining code is located in the ReceiveExecuted function + // NOTE: the remaining code is located in the WriteReceipt function return nil } -// ReceiveExecuted writes the packet execution acknowledgement to the state, -// which will be verified by the counterparty chain using AcknowledgePacket. +// WriteReceipt updates the receive sequence in the case of an ordered channel or sets an empty receipt +// if the channel is unordered. // // CONTRACT: this function must be called in the IBC handler -func (k Keeper) ReceiveExecuted( +func (k Keeper) WriteReceipt( ctx sdk.Context, chanCap *capabilitytypes.Capability, packet exported.PacketI, - acknowledgement []byte, ) error { channel, found := k.GetChannel(ctx, packet.GetDestPort(), packet.GetDestChannel()) if !found { @@ -273,17 +272,8 @@ func (k Keeper) ReceiveExecuted( ) } - if len(acknowledgement) == 0 { - return sdkerrors.Wrap(types.ErrInvalidAcknowledgement, "acknowledgement cannot be empty") - } - - // always set the acknowledgement so that it can be verified on the other side - k.SetPacketAcknowledgement( - ctx, packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence(), - types.CommitAcknowledgement(acknowledgement), - ) - - if channel.Ordering == types.ORDERED { + switch channel.Ordering { + case types.ORDERED: nextSequenceRecv, found := k.GetNextSequenceRecv(ctx, packet.GetDestPort(), packet.GetDestChannel()) if !found { return sdkerrors.Wrapf( @@ -294,20 +284,33 @@ func (k Keeper) ReceiveExecuted( nextSequenceRecv++ - // incrementng nextSequenceRecv and storing under this chain's channelEnd identifiers + // incrementing nextSequenceRecv and storing under this chain's channelEnd identifiers // Since this is the receiving chain, our channelEnd is packet's destination port and channel k.SetNextSequenceRecv(ctx, packet.GetDestPort(), packet.GetDestChannel(), nextSequenceRecv) + + case types.UNORDERED: + // For unordered channels we must set the receipt so it can be verified on the other side. + // This receipt does not contain any data, since the packet has not yet been processed, + // it's just a single store key set to an empty string to indicate that the packet has been received + _, found := k.GetPacketReceipt(ctx, packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence()) + if found { + return sdkerrors.Wrapf( + types.ErrPacketReceived, + "destination port: %s, destination channel: %s, sequence: %d", packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence(), + ) + } + + k.SetPacketReceipt(ctx, packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence()) } // log that a packet has been received & executed - k.Logger(ctx).Info(fmt.Sprintf("packet received & executed: %v", packet)) + k.Logger(ctx).Info("packet received", "packet", fmt.Sprintf("%v", packet)) // emit an event that the relayer can query for ctx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( types.EventTypeRecvPacket, sdk.NewAttribute(types.AttributeKeyData, string(packet.GetData())), - sdk.NewAttribute(types.AttributeKeyAck, string(acknowledgement)), sdk.NewAttribute(types.AttributeKeyTimeoutHeight, packet.GetTimeoutHeight().String()), sdk.NewAttribute(types.AttributeKeyTimeoutTimestamp, fmt.Sprintf("%d", packet.GetTimeoutTimestamp())), sdk.NewAttribute(types.AttributeKeySequence, fmt.Sprintf("%d", packet.GetSequence())), @@ -326,6 +329,56 @@ func (k Keeper) ReceiveExecuted( return nil } +// WriteAcknowledgement writes the packet execution acknowledgement to the state, +// which will be verified by the counterparty chain using AcknowledgePacket. +// +// CONTRACT: +// +// 1) For synchronous execution, this function is be called in the IBC handler . +// For async handling, it needs to be called directly by the module which originally +// processed the packet. +// +// 2) Assumes that packet receipt has been writted previously by WriteReceipt. +func (k Keeper) WriteAcknowledgement( + ctx sdk.Context, + packet exported.PacketI, + acknowledgement []byte, +) error { + // NOTE: IBC app modules might have written the acknowledgement synchronously on + // the OnRecvPacket callback so we need to check if the acknowledgement is already + // set on the store and return an error if so. + if k.HasPacketAcknowledgement(ctx, packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence()) { + return types.ErrAcknowledgementExists + } + + if len(acknowledgement) == 0 { + return sdkerrors.Wrap(types.ErrInvalidAcknowledgement, "acknowledgement cannot be empty") + } + + // always set the acknowledgement so that it can be verified on the other side + k.SetPacketAcknowledgement( + ctx, packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence(), + types.CommitAcknowledgement(acknowledgement), + ) + + // log that a packet has been acknowledged + k.Logger(ctx).Info("packet acknowledged", "packet", fmt.Sprintf("%v", packet)) + + // emit an event that the relayer can query for + ctx.EventManager().EmitEvents(sdk.Events{ + sdk.NewEvent( + types.EventTypeRecvPacket, + sdk.NewAttribute(types.AttributeKeyAck, string(acknowledgement)), + ), + sdk.NewEvent( + sdk.EventTypeMessage, + sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), + ), + }) + + return nil +} + // AcknowledgePacket is called by a module to process the acknowledgement of a // packet previously sent by the calling module on a channel to a counterparty // module on the counterparty chain. Its intended usage is within the ante @@ -459,7 +512,7 @@ func (k Keeper) AcknowledgementExecuted( nextSequenceAck++ - // incrementng NextSequenceAck and storing under this chain's channelEnd identifiers + // incrementing NextSequenceAck and storing under this chain's channelEnd identifiers // Since this is the original sending chain, our channelEnd is packet's source port and channel k.SetNextSequenceAck(ctx, packet.GetSourcePort(), packet.GetSourceChannel(), nextSequenceAck) } diff --git a/x/ibc/04-channel/keeper/packet_test.go b/x/ibc/04-channel/keeper/packet_test.go index 3207da9c0a34..f0fa67e4b899 100644 --- a/x/ibc/04-channel/keeper/packet_test.go +++ b/x/ibc/04-channel/keeper/packet_test.go @@ -280,15 +280,6 @@ func (suite *KeeperTestSuite) TestRecvPacket() { _, _, _, _, channelA, channelB := suite.coordinator.Setup(suite.chainA, suite.chainB, types.UNORDERED) packet = types.NewPacket(validPacketData, 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, disabledTimeoutHeight, uint64(suite.chainB.GetContext().BlockTime().UnixNano())) }, false}, - {"acknowledgement already received", func() { - // setup uses an UNORDERED channel - clientA, clientB, _, _, channelA, channelB := suite.coordinator.Setup(suite.chainA, suite.chainB, types.UNORDERED) - packet = types.NewPacket(validPacketData, 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, timeoutHeight, disabledTimeoutTimestamp) - suite.coordinator.SendPacket(suite.chainA, suite.chainB, packet, clientB) - - // write packet acknowledgement - suite.coordinator.ReceiveExecuted(suite.chainB, suite.chainA, packet, clientA) - }, false}, {"next receive sequence is not found", func() { _, _, connA, connB := suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, ibctesting.Tendermint) channelA := connA.NextTestChannel(ibctesting.TransferPort) @@ -335,12 +326,11 @@ func (suite *KeeperTestSuite) TestRecvPacket() { } -// TestReceiveExecuted tests the ReceiveExecuted call on chainB. -func (suite *KeeperTestSuite) TestReceiveExecuted() { +// TestWriteReceipt tests the WriteReceipt call on chainB. +func (suite *KeeperTestSuite) TestWriteReceipt() { var ( packet types.Packet channelCap *capabilitytypes.Capability - ack []byte ) testCases := []testCase{ @@ -391,31 +381,80 @@ func (suite *KeeperTestSuite) TestReceiveExecuted() { channelCap = capabilitytypes.NewCapability(3) }, false}, - {"acknowledgement is empty", func() { + {"receipt already stored", func() { _, clientB, _, _, channelA, channelB := suite.coordinator.Setup(suite.chainA, suite.chainB, types.UNORDERED) packet = types.NewPacket(validPacketData, 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, timeoutHeight, disabledTimeoutTimestamp) suite.coordinator.SendPacket(suite.chainA, suite.chainB, packet, clientB) + suite.chainB.App.IBCKeeper.ChannelKeeper.SetPacketReceipt(suite.chainB.GetContext(), channelB.PortID, channelB.ID, 1) channelCap = suite.chainB.GetChannelCapability(channelB.PortID, channelB.ID) - - ack = []byte{} }, false}, } for i, tc := range testCases { tc := tc suite.Run(fmt.Sprintf("Case %s, %d/%d tests", tc.msg, i, len(testCases)), func() { - suite.SetupTest() // reset - ack = ibctesting.TestHash // must explicitly be changed in malleate + suite.SetupTest() // reset tc.malleate() - err := suite.chainB.App.IBCKeeper.ChannelKeeper.ReceiveExecuted(suite.chainB.GetContext(), channelCap, packet, ack) + err := suite.chainB.App.IBCKeeper.ChannelKeeper.WriteReceipt(suite.chainB.GetContext(), channelCap, packet) + + if tc.expPass { + suite.Require().NoError(err) + } else { + suite.Require().Error(err) + } + }) + } +} + +func (suite *KeeperTestSuite) TestWriteAcknowledgement() { + var ( + ack []byte + packet exported.PacketI + ) + + testCases := []testCase{ + { + "success", + func() { + _, _, _, _, channelA, channelB := suite.coordinator.Setup(suite.chainA, suite.chainB, types.UNORDERED) + packet = types.NewPacket(validPacketData, 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, timeoutHeight, disabledTimeoutTimestamp) + ack = ibctesting.TestHash + }, + true, + }, + { + "no-op, already acked", + func() { + _, _, _, _, channelA, channelB := suite.coordinator.Setup(suite.chainA, suite.chainB, types.UNORDERED) + packet = types.NewPacket(validPacketData, 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, timeoutHeight, disabledTimeoutTimestamp) + ack = ibctesting.TestHash + suite.chainB.App.IBCKeeper.ChannelKeeper.SetPacketAcknowledgement(suite.chainB.GetContext(), packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence(), ack) + }, + false, + }, + { + "empty acknowledgement", + func() { + _, _, _, _, channelA, channelB := suite.coordinator.Setup(suite.chainA, suite.chainB, types.UNORDERED) + packet = types.NewPacket(validPacketData, 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, timeoutHeight, disabledTimeoutTimestamp) + ack = nil + }, + false, + }, + } + for i, tc := range testCases { + tc := tc + suite.Run(fmt.Sprintf("Case %s, %d/%d tests", tc.msg, i, len(testCases)), func() { + suite.SetupTest() // reset + + tc.malleate() + + err := suite.chainB.App.IBCKeeper.ChannelKeeper.WriteAcknowledgement(suite.chainB.GetContext(), packet, ack) if tc.expPass { suite.Require().NoError(err) - // verify packet ack is written - actualAck := suite.chainB.GetAcknowledgement(packet) - suite.Require().Equal(types.CommitAcknowledgement(ack), actualAck) } else { suite.Require().Error(err) } @@ -438,8 +477,11 @@ func (suite *KeeperTestSuite) TestAcknowledgePacket() { err := suite.coordinator.SendPacket(suite.chainA, suite.chainB, packet, clientB) suite.Require().NoError(err) - // create packet acknowledgement - err = suite.coordinator.ReceiveExecuted(suite.chainB, suite.chainA, packet, clientA) + // create packet receipt and acknowledgement + err = suite.coordinator.WriteReceipt(suite.chainB, suite.chainA, packet, clientA) + suite.Require().NoError(err) + + err = suite.coordinator.WriteAcknowledgement(suite.chainB, suite.chainA, packet, clientA) suite.Require().NoError(err) }, true}, {"success on unordered channel", func() { @@ -451,8 +493,11 @@ func (suite *KeeperTestSuite) TestAcknowledgePacket() { err := suite.coordinator.SendPacket(suite.chainA, suite.chainB, packet, clientB) suite.Require().NoError(err) - // create packet acknowledgement - err = suite.coordinator.ReceiveExecuted(suite.chainB, suite.chainA, packet, clientA) + // create packet receipt and acknowledgement + err = suite.coordinator.WriteReceipt(suite.chainB, suite.chainA, packet, clientA) + suite.Require().NoError(err) + + err = suite.coordinator.WriteAcknowledgement(suite.chainB, suite.chainA, packet, clientA) suite.Require().NoError(err) }, true}, {"channel not found", func() { @@ -542,7 +587,10 @@ func (suite *KeeperTestSuite) TestAcknowledgePacket() { suite.Require().NoError(err) // create packet acknowledgement - err = suite.coordinator.ReceiveExecuted(suite.chainB, suite.chainA, packet, clientA) + err = suite.coordinator.WriteReceipt(suite.chainB, suite.chainA, packet, clientA) + suite.Require().NoError(err) + + err = suite.coordinator.WriteAcknowledgement(suite.chainB, suite.chainA, packet, clientA) suite.Require().NoError(err) // set next sequence ack wrong @@ -588,8 +636,11 @@ func (suite *KeeperTestSuite) TestAcknowledgementExecuted() { err := suite.coordinator.SendPacket(suite.chainA, suite.chainB, packet, clientB) suite.Require().NoError(err) - // create packet acknowledgement - err = suite.coordinator.ReceiveExecuted(suite.chainB, suite.chainA, packet, clientA) + // create packet receipt and acknowledgement + err = suite.coordinator.WriteReceipt(suite.chainB, suite.chainA, packet, clientA) + suite.Require().NoError(err) + + err = suite.coordinator.WriteAcknowledgement(suite.chainB, suite.chainA, packet, clientA) suite.Require().NoError(err) chanCap = suite.chainA.GetChannelCapability(channelA.PortID, channelA.ID) @@ -604,8 +655,11 @@ func (suite *KeeperTestSuite) TestAcknowledgementExecuted() { err := suite.coordinator.SendPacket(suite.chainA, suite.chainB, packet, clientB) suite.Require().NoError(err) - // create packet acknowledgement - err = suite.coordinator.ReceiveExecuted(suite.chainB, suite.chainA, packet, clientA) + // create packet receipt and acknowledgement + err = suite.coordinator.WriteReceipt(suite.chainB, suite.chainA, packet, clientA) + suite.Require().NoError(err) + + err = suite.coordinator.WriteAcknowledgement(suite.chainB, suite.chainA, packet, clientA) suite.Require().NoError(err) chanCap = suite.chainA.GetChannelCapability(channelA.PortID, channelA.ID) diff --git a/x/ibc/04-channel/keeper/timeout.go b/x/ibc/04-channel/keeper/timeout.go index b8af68bea3f1..d35de53e2eac 100644 --- a/x/ibc/04-channel/keeper/timeout.go +++ b/x/ibc/04-channel/keeper/timeout.go @@ -101,7 +101,7 @@ func (k Keeper) TimeoutPacket( packet.GetDestPort(), packet.GetDestChannel(), nextSequenceRecv, ) case types.UNORDERED: - err = k.connectionKeeper.VerifyPacketAcknowledgementAbsence( + err = k.connectionKeeper.VerifyPacketReceiptAbsence( ctx, connectionEnd, proofHeight, proof, packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence(), ) @@ -255,7 +255,7 @@ func (k Keeper) TimeoutOnClose( packet.GetDestPort(), packet.GetDestChannel(), nextSequenceRecv, ) case types.UNORDERED: - err = k.connectionKeeper.VerifyPacketAcknowledgementAbsence( + err = k.connectionKeeper.VerifyPacketReceiptAbsence( ctx, connectionEnd, proofHeight, proof, packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence(), ) diff --git a/x/ibc/04-channel/keeper/timeout_test.go b/x/ibc/04-channel/keeper/timeout_test.go index 2e9a07503a3c..655aded4a62f 100644 --- a/x/ibc/04-channel/keeper/timeout_test.go +++ b/x/ibc/04-channel/keeper/timeout_test.go @@ -126,7 +126,7 @@ func (suite *KeeperTestSuite) TestTimeoutPacket() { tc.malleate() orderedPacketKey := host.KeyNextSequenceRecv(packet.GetDestPort(), packet.GetDestChannel()) - unorderedPacketKey := host.KeyPacketAcknowledgement(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence()) + unorderedPacketKey := host.KeyPacketReceipt(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence()) if ordered { proof, proofHeight = suite.chainB.QueryProof(orderedPacketKey) @@ -327,7 +327,7 @@ func (suite *KeeperTestSuite) TestTimeoutOnClose() { tc.malleate() channelKey := host.KeyChannel(packet.GetDestPort(), packet.GetDestChannel()) - unorderedPacketKey := host.KeyPacketAcknowledgement(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence()) + unorderedPacketKey := host.KeyPacketReceipt(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence()) orderedPacketKey := host.KeyNextSequenceRecv(packet.GetDestPort(), packet.GetDestChannel()) proofClosed, proofHeight := suite.chainB.QueryProof(channelKey) diff --git a/x/ibc/04-channel/types/errors.go b/x/ibc/04-channel/types/errors.go index 2fb51bc4a8be..075adad6858c 100644 --- a/x/ibc/04-channel/types/errors.go +++ b/x/ibc/04-channel/types/errors.go @@ -20,7 +20,8 @@ var ( ErrInvalidPacket = sdkerrors.Register(SubModuleName, 13, "invalid packet") ErrPacketTimeout = sdkerrors.Register(SubModuleName, 14, "packet timeout") ErrTooManyConnectionHops = sdkerrors.Register(SubModuleName, 15, "too many connection hops") - ErrAcknowledgementTooLong = sdkerrors.Register(SubModuleName, 16, "acknowledgement too long") - ErrInvalidAcknowledgement = sdkerrors.Register(SubModuleName, 17, "invalid acknowledgement") - ErrPacketCommitmentNotFound = sdkerrors.Register(SubModuleName, 18, "packet commitment not found") + ErrInvalidAcknowledgement = sdkerrors.Register(SubModuleName, 16, "invalid acknowledgement") + ErrPacketCommitmentNotFound = sdkerrors.Register(SubModuleName, 17, "packet commitment not found") + ErrPacketReceived = sdkerrors.Register(SubModuleName, 18, "packet already received") + ErrAcknowledgementExists = sdkerrors.Register(SubModuleName, 19, "acknowledgement for packet already exists") ) diff --git a/x/ibc/04-channel/types/expected_keepers.go b/x/ibc/04-channel/types/expected_keepers.go index bb021c804fae..194a543235fa 100644 --- a/x/ibc/04-channel/types/expected_keepers.go +++ b/x/ibc/04-channel/types/expected_keepers.go @@ -50,7 +50,7 @@ type ConnectionKeeper interface { sequence uint64, acknowledgement []byte, ) error - VerifyPacketAcknowledgementAbsence( + VerifyPacketReceiptAbsence( ctx sdk.Context, connection exported.ConnectionI, height exported.Height, diff --git a/x/ibc/24-host/keys.go b/x/ibc/24-host/keys.go index 75b3288c1016..bfc34dab7d6e 100644 --- a/x/ibc/24-host/keys.go +++ b/x/ibc/24-host/keys.go @@ -35,6 +35,7 @@ const ( KeyNextSeqAckPrefix = "seqAcks" KeyPacketCommitmentPrefix = "commitments" KeyPacketAckPrefix = "acks" + KeyPacketReceiptPrefix = "receipts" ) // KeyPrefixBytes return the key prefix bytes from a URL string format @@ -163,6 +164,11 @@ func PacketAcknowledgementPath(portID, channelID string, sequence uint64) string return fmt.Sprintf("%s/", KeyPacketAckPrefix) + channelPath(portID, channelID) + fmt.Sprintf("/acknowledgements/%d", sequence) } +// PacketReceiptPath defines the packet receipt store path +func PacketReceiptPath(portID, channelID string, sequence uint64) string { + return fmt.Sprintf("%s/", KeyPacketReceiptPrefix) + channelPath(portID, channelID) + fmt.Sprintf("/receipts/%d", sequence) +} + // KeyChannel returns the store key for a particular channel func KeyChannel(portID, channelID string) []byte { return []byte(ChannelPath(portID, channelID)) @@ -198,6 +204,12 @@ func KeyPacketAcknowledgement(portID, channelID string, sequence uint64) []byte return []byte(PacketAcknowledgementPath(portID, channelID, sequence)) } +// KeyPacketReceipt returns the store key of under which a packet +// receipt is stored +func KeyPacketReceipt(portID, channelID string, sequence uint64) []byte { + return []byte(PacketReceiptPath(portID, channelID, sequence)) +} + func channelPath(portID, channelID string) string { return fmt.Sprintf("ports/%s/channels/%s", portID, channelID) } diff --git a/x/ibc/exported/client.go b/x/ibc/exported/client.go index 57839ff34b3a..4d2af0e4ee66 100644 --- a/x/ibc/exported/client.go +++ b/x/ibc/exported/client.go @@ -109,7 +109,7 @@ type ClientState interface { sequence uint64, acknowledgement []byte, ) error - VerifyPacketAcknowledgementAbsence( + VerifyPacketReceiptAbsence( store sdk.KVStore, cdc codec.BinaryMarshaler, height Height, diff --git a/x/ibc/handler.go b/x/ibc/handler.go index f173d8b77d26..72c8f8723049 100644 --- a/x/ibc/handler.go +++ b/x/ibc/handler.go @@ -192,11 +192,19 @@ func NewHandler(k keeper.Keeper) sdk.Handler { return nil, sdkerrors.Wrap(err, "receive packet callback failed") } - // Set packet acknowledgement - if err = k.ChannelKeeper.ReceiveExecuted(ctx, cap, msg.Packet, ack); err != nil { + if err := k.ChannelKeeper.WriteReceipt(ctx, cap, msg.Packet); err != nil { return nil, err } + // Set packet acknowledgement only if the acknowledgement is not nil. + // NOTE: IBC applications modules may call the WriteAcknowledgement asynchronously if the + // acknowledgement is nil. + if ack != nil { + if err := k.ChannelKeeper.WriteAcknowledgement(ctx, msg.Packet, ack); err != nil { + return nil, err + } + } + return res, nil case *channeltypes.MsgAcknowledgement: diff --git a/x/ibc/handler_test.go b/x/ibc/handler_test.go index 08b3843de261..b217f37bb994 100644 --- a/x/ibc/handler_test.go +++ b/x/ibc/handler_test.go @@ -40,7 +40,7 @@ func TestHandlerTestSuite(t *testing.T) { // tests the IBC handler receiving a packet on ordered and unordered channels. // It verifies that the storing of an acknowledgement on success occurs. It // tests high level properties like ordering and basic sanity checks. More -// rigorous testing of 'RecvPacket' and 'ReceiveExecuted' can be found in the +// rigorous testing of 'RecvPacket' and 'WriteReceipt' can be found in the // 04-channel/keeper/packet_test.go. func (suite *HandlerTestSuite) TestHandleRecvPacket() { var ( @@ -104,7 +104,7 @@ func (suite *HandlerTestSuite) TestHandleRecvPacket() { err := suite.coordinator.SendPacket(suite.chainA, suite.chainB, packet, clientB) suite.Require().NoError(err) - err = suite.coordinator.ReceiveExecuted(suite.chainB, suite.chainA, packet, clientA) + err = suite.coordinator.WriteReceipt(suite.chainB, suite.chainA, packet, clientA) suite.Require().NoError(err) }, false}, {"UNORDERED: packet already received (replay)", func() { @@ -115,7 +115,7 @@ func (suite *HandlerTestSuite) TestHandleRecvPacket() { err := suite.coordinator.SendPacket(suite.chainA, suite.chainB, packet, clientB) suite.Require().NoError(err) - err = suite.coordinator.ReceiveExecuted(suite.chainB, suite.chainA, packet, clientA) + err = suite.coordinator.WriteReceipt(suite.chainB, suite.chainA, packet, clientA) suite.Require().NoError(err) }, false}, } @@ -179,7 +179,10 @@ func (suite *HandlerTestSuite) TestHandleAcknowledgePacket() { err := suite.coordinator.SendPacket(suite.chainA, suite.chainB, packet, clientB) suite.Require().NoError(err) - err = suite.coordinator.ReceiveExecuted(suite.chainB, suite.chainA, packet, clientA) + err = suite.coordinator.WriteReceipt(suite.chainB, suite.chainA, packet, clientA) + suite.Require().NoError(err) + + err = suite.coordinator.WriteAcknowledgement(suite.chainB, suite.chainA, packet, clientA) suite.Require().NoError(err) }, true}, {"success: UNORDERED", func() { @@ -189,7 +192,10 @@ func (suite *HandlerTestSuite) TestHandleAcknowledgePacket() { err := suite.coordinator.SendPacket(suite.chainA, suite.chainB, packet, clientB) suite.Require().NoError(err) - err = suite.coordinator.ReceiveExecuted(suite.chainB, suite.chainA, packet, clientA) + err = suite.coordinator.WriteReceipt(suite.chainB, suite.chainA, packet, clientA) + suite.Require().NoError(err) + + err = suite.coordinator.WriteAcknowledgement(suite.chainB, suite.chainA, packet, clientA) suite.Require().NoError(err) }, true}, {"success: UNORDERED acknowledge out of order packet", func() { @@ -203,9 +209,11 @@ func (suite *HandlerTestSuite) TestHandleAcknowledgePacket() { err := suite.coordinator.SendPacket(suite.chainA, suite.chainB, packet, clientB) suite.Require().NoError(err) - err = suite.coordinator.ReceiveExecuted(suite.chainB, suite.chainA, packet, clientA) + err = suite.coordinator.WriteReceipt(suite.chainB, suite.chainA, packet, clientA) suite.Require().NoError(err) + err = suite.coordinator.WriteAcknowledgement(suite.chainB, suite.chainA, packet, clientA) + suite.Require().NoError(err) } }, true}, {"failure: ORDERED acknowledge out of order packet", func() { @@ -218,7 +226,10 @@ func (suite *HandlerTestSuite) TestHandleAcknowledgePacket() { err := suite.coordinator.SendPacket(suite.chainA, suite.chainB, packet, clientB) suite.Require().NoError(err) - err = suite.coordinator.ReceiveExecuted(suite.chainB, suite.chainA, packet, clientA) + err = suite.coordinator.WriteReceipt(suite.chainB, suite.chainA, packet, clientA) + suite.Require().NoError(err) + + err = suite.coordinator.WriteAcknowledgement(suite.chainB, suite.chainA, packet, clientA) suite.Require().NoError(err) } }, false}, @@ -240,7 +251,10 @@ func (suite *HandlerTestSuite) TestHandleAcknowledgePacket() { err := suite.coordinator.SendPacket(suite.chainA, suite.chainB, packet, clientB) suite.Require().NoError(err) - err = suite.coordinator.ReceiveExecuted(suite.chainB, suite.chainA, packet, clientA) + err = suite.coordinator.WriteReceipt(suite.chainB, suite.chainA, packet, clientA) + suite.Require().NoError(err) + + err = suite.coordinator.WriteAcknowledgement(suite.chainB, suite.chainA, packet, clientA) suite.Require().NoError(err) err = suite.coordinator.AcknowledgementExecuted(suite.chainA, suite.chainB, packet, clientB) @@ -254,7 +268,10 @@ func (suite *HandlerTestSuite) TestHandleAcknowledgePacket() { err := suite.coordinator.SendPacket(suite.chainA, suite.chainB, packet, clientB) suite.Require().NoError(err) - err = suite.coordinator.ReceiveExecuted(suite.chainB, suite.chainA, packet, clientA) + err = suite.coordinator.WriteReceipt(suite.chainB, suite.chainA, packet, clientA) + suite.Require().NoError(err) + + err = suite.coordinator.WriteAcknowledgement(suite.chainB, suite.chainA, packet, clientA) suite.Require().NoError(err) err = suite.coordinator.AcknowledgementExecuted(suite.chainA, suite.chainB, packet, clientB) @@ -338,7 +355,7 @@ func (suite *HandlerTestSuite) TestHandleTimeoutPacket() { // need to update chainA client to prove missing ack suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, ibctesting.Tendermint) - packetKey = host.KeyPacketAcknowledgement(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence()) + packetKey = host.KeyPacketReceipt(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence()) }, true}, {"success: UNORDERED timeout out of order packet", func() { // setup uses an UNORDERED channel @@ -355,8 +372,7 @@ func (suite *HandlerTestSuite) TestHandleTimeoutPacket() { } suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, ibctesting.Tendermint) - packetKey = host.KeyPacketAcknowledgement(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence()) - + packetKey = host.KeyPacketReceipt(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence()) }, true}, {"success: ORDERED timeout out of order packet", func() { clientA, clientB, _, _, channelA, channelB := suite.coordinator.Setup(suite.chainA, suite.chainB, channeltypes.ORDERED) @@ -384,7 +400,7 @@ func (suite *HandlerTestSuite) TestHandleTimeoutPacket() { {"UNORDERED: packet not sent", func() { _, _, _, _, channelA, channelB := suite.coordinator.Setup(suite.chainA, suite.chainB, channeltypes.UNORDERED) packet = channeltypes.NewPacket(ibctesting.MockCommitment, 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, timeoutHeight, 0) - packetKey = host.KeyPacketAcknowledgement(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence()) + packetKey = host.KeyPacketReceipt(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence()) }, false}, } @@ -459,7 +475,6 @@ func (suite *HandlerTestSuite) TestHandleTimeoutOnClosePacket() { // close counterparty channel suite.coordinator.SetChannelClosed(suite.chainB, suite.chainA, counterpartyChannel) - }, true}, {"success: UNORDERED", func() { clientA, clientB, _, _, channelA, channelB := suite.coordinator.Setup(suite.chainA, suite.chainB, channeltypes.UNORDERED) @@ -477,11 +492,10 @@ func (suite *HandlerTestSuite) TestHandleTimeoutOnClosePacket() { // need to update chainA client to prove missing ack suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, ibctesting.Tendermint) - packetKey = host.KeyPacketAcknowledgement(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence()) + packetKey = host.KeyPacketReceipt(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence()) // close counterparty channel suite.coordinator.SetChannelClosed(suite.chainB, suite.chainA, counterpartyChannel) - }, true}, {"success: UNORDERED timeout out of order packet", func() { // setup uses an UNORDERED channel @@ -500,15 +514,13 @@ func (suite *HandlerTestSuite) TestHandleTimeoutOnClosePacket() { // create packet commitment err := suite.coordinator.SendPacket(suite.chainA, suite.chainB, packet, clientB) suite.Require().NoError(err) - } suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, ibctesting.Tendermint) - packetKey = host.KeyPacketAcknowledgement(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence()) + packetKey = host.KeyPacketReceipt(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence()) // close counterparty channel suite.coordinator.SetChannelClosed(suite.chainB, suite.chainA, counterpartyChannel) - }, true}, {"success: ORDERED timeout out of order packet", func() { clientA, clientB, _, _, channelA, channelB := suite.coordinator.Setup(suite.chainA, suite.chainB, channeltypes.ORDERED) @@ -533,7 +545,6 @@ func (suite *HandlerTestSuite) TestHandleTimeoutOnClosePacket() { // close counterparty channel suite.coordinator.SetChannelClosed(suite.chainB, suite.chainA, counterpartyChannel) - }, true}, {"channel does not exist", func() { // any non-nil value of packet is valid @@ -553,7 +564,6 @@ func (suite *HandlerTestSuite) TestHandleTimeoutOnClosePacket() { // close counterparty channel suite.coordinator.SetChannelClosed(suite.chainB, suite.chainA, counterpartyChannel) - }, false}, {"ORDERED: channel not closed", func() { clientA, clientB, _, _, channelA, channelB := suite.coordinator.Setup(suite.chainA, suite.chainB, channeltypes.ORDERED) @@ -572,7 +582,6 @@ func (suite *HandlerTestSuite) TestHandleTimeoutOnClosePacket() { suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, ibctesting.Tendermint) packetKey = host.KeyNextSequenceRecv(packet.GetDestPort(), packet.GetDestChannel()) - }, false}, } diff --git a/x/ibc/light-clients/06-solomachine/types/client_state.go b/x/ibc/light-clients/06-solomachine/types/client_state.go index b54920c3887c..54dc52da17b9 100644 --- a/x/ibc/light-clients/06-solomachine/types/client_state.go +++ b/x/ibc/light-clients/06-solomachine/types/client_state.go @@ -310,10 +310,10 @@ func (cs ClientState) VerifyPacketAcknowledgement( return nil } -// VerifyPacketAcknowledgementAbsence verifies a proof of the absence of an -// incoming packet acknowledgement at the specified port, specified channel, and +// VerifyPacketReceiptAbsence verifies a proof of the absence of an +// incoming packet receipt at the specified port, specified channel, and // specified sequence. -func (cs ClientState) VerifyPacketAcknowledgementAbsence( +func (cs ClientState) VerifyPacketReceiptAbsence( store sdk.KVStore, cdc codec.BinaryMarshaler, height exported.Height, @@ -328,12 +328,12 @@ func (cs ClientState) VerifyPacketAcknowledgementAbsence( return err } - path, err := commitmenttypes.ApplyPrefix(prefix, host.PacketAcknowledgementPath(portID, channelID, packetSequence)) + path, err := commitmenttypes.ApplyPrefix(prefix, host.PacketReceiptPath(portID, channelID, packetSequence)) if err != nil { return err } - signBz, err := PacketAcknowledgementAbsenceSignBytes(cdc, sequence, timestamp, cs.ConsensusState.Diversifier, path) + signBz, err := PacketReceiptAbsenceSignBytes(cdc, sequence, timestamp, cs.ConsensusState.Diversifier, path) if err != nil { return err } diff --git a/x/ibc/light-clients/06-solomachine/types/client_state_test.go b/x/ibc/light-clients/06-solomachine/types/client_state_test.go index ca49ee53c005..1781e99eff2c 100644 --- a/x/ibc/light-clients/06-solomachine/types/client_state_test.go +++ b/x/ibc/light-clients/06-solomachine/types/client_state_test.go @@ -697,14 +697,14 @@ func (suite *SoloMachineTestSuite) TestVerifyPacketAcknowledgement() { } } -func (suite *SoloMachineTestSuite) TestVerifyPacketAcknowledgementAbsence() { +func (suite *SoloMachineTestSuite) TestVerifyPacketReceiptAbsence() { // test singlesig and multisig public keys for _, solomachine := range []*ibctesting.Solomachine{suite.solomachine, suite.solomachineMulti} { - path, err := commitmenttypes.ApplyPrefix(prefix, host.PacketAcknowledgementPath(testPortID, testChannelID, solomachine.Sequence)) + path, err := commitmenttypes.ApplyPrefix(prefix, host.PacketReceiptPath(testPortID, testChannelID, solomachine.Sequence)) suite.Require().NoError(err) - value, err := types.PacketAcknowledgementAbsenceSignBytes(suite.chainA.Codec, solomachine.Sequence, solomachine.Time, solomachine.Diversifier, path) + value, err := types.PacketReceiptAbsenceSignBytes(suite.chainA.Codec, solomachine.Sequence, solomachine.Time, solomachine.Diversifier, path) suite.Require().NoError(err) sig := solomachine.GenerateSignature(value) @@ -770,7 +770,7 @@ func (suite *SoloMachineTestSuite) TestVerifyPacketAcknowledgementAbsence() { expSeq := tc.clientState.Sequence + 1 - err := tc.clientState.VerifyPacketAcknowledgementAbsence( + err := tc.clientState.VerifyPacketReceiptAbsence( suite.store, suite.chainA.Codec, solomachine.GetHeight(), tc.prefix, tc.proof, testPortID, testChannelID, solomachine.Sequence, ) diff --git a/x/ibc/light-clients/06-solomachine/types/proof.go b/x/ibc/light-clients/06-solomachine/types/proof.go index ea9303ef925c..e7f715ad91bd 100644 --- a/x/ibc/light-clients/06-solomachine/types/proof.go +++ b/x/ibc/light-clients/06-solomachine/types/proof.go @@ -287,15 +287,15 @@ func PacketAcknowledgementSignBytes( return cdc.MarshalBinaryBare(signBytes) } -// PacketAcknowledgementAbsenceSignBytes returns the sign bytes for verification -// of the absence of an acknowledgement. -func PacketAcknowledgementAbsenceSignBytes( +// PacketReceiptAbsenceSignBytes returns the sign bytes for verification +// of the absence of a receipt. +func PacketReceiptAbsenceSignBytes( cdc codec.BinaryMarshaler, sequence, timestamp uint64, diversifier string, path commitmenttypes.MerklePath, // nolint: interfacer ) ([]byte, error) { - data := &PacketAcknowledgementAbsenseData{ + data := &PacketReceiptAbsenseData{ Path: []byte(path.String()), } diff --git a/x/ibc/light-clients/06-solomachine/types/solomachine.pb.go b/x/ibc/light-clients/06-solomachine/types/solomachine.pb.go index b4585f389f92..8c8d839e2b63 100644 --- a/x/ibc/light-clients/06-solomachine/types/solomachine.pb.go +++ b/x/ibc/light-clients/06-solomachine/types/solomachine.pb.go @@ -630,24 +630,24 @@ func (m *PacketAcknowledgementData) GetAcknowledgement() []byte { return nil } -// PacketAcknowledgementAbsenceSignBytes returns the SignBytes data for -// acknowledgement absence verification. -type PacketAcknowledgementAbsenseData struct { +// PacketReceiptAbsenceSignBytes returns the SignBytes data for +// packet receipt absence verification. +type PacketReceiptAbsenseData struct { Path []byte `protobuf:"bytes,1,opt,name=path,proto3" json:"path,omitempty"` } -func (m *PacketAcknowledgementAbsenseData) Reset() { *m = PacketAcknowledgementAbsenseData{} } -func (m *PacketAcknowledgementAbsenseData) String() string { return proto.CompactTextString(m) } -func (*PacketAcknowledgementAbsenseData) ProtoMessage() {} -func (*PacketAcknowledgementAbsenseData) Descriptor() ([]byte, []int) { +func (m *PacketReceiptAbsenseData) Reset() { *m = PacketReceiptAbsenseData{} } +func (m *PacketReceiptAbsenseData) String() string { return proto.CompactTextString(m) } +func (*PacketReceiptAbsenseData) ProtoMessage() {} +func (*PacketReceiptAbsenseData) Descriptor() ([]byte, []int) { return fileDescriptor_6cc2ee18f7f86d4e, []int{14} } -func (m *PacketAcknowledgementAbsenseData) XXX_Unmarshal(b []byte) error { +func (m *PacketReceiptAbsenseData) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *PacketAcknowledgementAbsenseData) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *PacketReceiptAbsenseData) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_PacketAcknowledgementAbsenseData.Marshal(b, m, deterministic) + return xxx_messageInfo_PacketReceiptAbsenseData.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -657,19 +657,19 @@ func (m *PacketAcknowledgementAbsenseData) XXX_Marshal(b []byte, deterministic b return b[:n], nil } } -func (m *PacketAcknowledgementAbsenseData) XXX_Merge(src proto.Message) { - xxx_messageInfo_PacketAcknowledgementAbsenseData.Merge(m, src) +func (m *PacketReceiptAbsenseData) XXX_Merge(src proto.Message) { + xxx_messageInfo_PacketReceiptAbsenseData.Merge(m, src) } -func (m *PacketAcknowledgementAbsenseData) XXX_Size() int { +func (m *PacketReceiptAbsenseData) XXX_Size() int { return m.Size() } -func (m *PacketAcknowledgementAbsenseData) XXX_DiscardUnknown() { - xxx_messageInfo_PacketAcknowledgementAbsenseData.DiscardUnknown(m) +func (m *PacketReceiptAbsenseData) XXX_DiscardUnknown() { + xxx_messageInfo_PacketReceiptAbsenseData.DiscardUnknown(m) } -var xxx_messageInfo_PacketAcknowledgementAbsenseData proto.InternalMessageInfo +var xxx_messageInfo_PacketReceiptAbsenseData proto.InternalMessageInfo -func (m *PacketAcknowledgementAbsenseData) GetPath() []byte { +func (m *PacketReceiptAbsenseData) GetPath() []byte { if m != nil { return m.Path } @@ -745,7 +745,7 @@ func init() { proto.RegisterType((*ChannelStateData)(nil), "ibc.lightclients.solomachine.v1.ChannelStateData") proto.RegisterType((*PacketCommitmentData)(nil), "ibc.lightclients.solomachine.v1.PacketCommitmentData") proto.RegisterType((*PacketAcknowledgementData)(nil), "ibc.lightclients.solomachine.v1.PacketAcknowledgementData") - proto.RegisterType((*PacketAcknowledgementAbsenseData)(nil), "ibc.lightclients.solomachine.v1.PacketAcknowledgementAbsenseData") + proto.RegisterType((*PacketReceiptAbsenseData)(nil), "ibc.lightclients.solomachine.v1.PacketReceiptAbsenseData") proto.RegisterType((*NextSequenceRecvData)(nil), "ibc.lightclients.solomachine.v1.NextSequenceRecvData") } @@ -754,70 +754,70 @@ func init() { } var fileDescriptor_6cc2ee18f7f86d4e = []byte{ - // 996 bytes of a gzipped FileDescriptorProto + // 999 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x56, 0x4f, 0x6f, 0xe3, 0x44, - 0x14, 0xaf, 0xb3, 0x61, 0x69, 0x5e, 0xb2, 0x4d, 0xf1, 0x66, 0x97, 0xb4, 0x40, 0x1c, 0xf9, 0x80, - 0x7a, 0xa9, 0x4d, 0x16, 0x69, 0x0f, 0x15, 0x1c, 0x92, 0xec, 0x4a, 0x50, 0xfe, 0x55, 0xee, 0xae, - 0xc4, 0x22, 0x24, 0x6b, 0x62, 0x4f, 0x13, 0xab, 0xce, 0x4c, 0xb0, 0x27, 0x49, 0x83, 0xc4, 0x01, - 0x4e, 0x70, 0xe3, 0xc8, 0x11, 0x21, 0xf1, 0x5d, 0x90, 0xb8, 0x94, 0x1b, 0xa7, 0x08, 0xb5, 0xdf, - 0x20, 0x9f, 0x00, 0x79, 0x66, 0xec, 0xd8, 0x2e, 0x71, 0x05, 0xec, 0xc9, 0xe3, 0x79, 0x6f, 0x7e, - 0xef, 0xbd, 0xdf, 0xbc, 0x37, 0xef, 0x41, 0xc7, 0x1b, 0x38, 0xa6, 0xef, 0x0d, 0x47, 0xcc, 0xf1, - 0x3d, 0x4c, 0x58, 0x68, 0x86, 0xd4, 0xa7, 0x63, 0xe4, 0x8c, 0x3c, 0x82, 0xcd, 0x59, 0x27, 0xfd, - 0x6b, 0x4c, 0x02, 0xca, 0xa8, 0xaa, 0x79, 0x03, 0xc7, 0x48, 0x1f, 0x31, 0xd2, 0x3a, 0xb3, 0xce, - 0x7e, 0xa4, 0x60, 0x3a, 0x94, 0x10, 0xec, 0x30, 0x8f, 0x92, 0xd4, 0x52, 0x20, 0xec, 0xef, 0x71, - 0x85, 0x11, 0x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 0x24, 0xb9, 0xe7, 0x6b, 0xf5, 0x04, 0x6a, 0xb2, 0x34, 0xc4, 0x83, - 0x5e, 0x2a, 0x08, 0xe0, 0xf5, 0xd5, 0x52, 0xbb, 0x9f, 0x29, 0x27, 0xf9, 0x64, 0x57, 0x9d, 0xb5, - 0x25, 0x69, 0xfe, 0x07, 0x05, 0xd4, 0xec, 0x43, 0xba, 0xd1, 0x85, 0x17, 0x37, 0xdb, 0x4a, 0x91, - 0x17, 0xff, 0xa2, 0x77, 0x48, 0x5f, 0x08, 0xdc, 0xef, 0x27, 0x8d, 0xb8, 0xd8, 0x97, 0xf7, 0x01, - 0xd6, 0x3d, 0x5b, 0xba, 0xf1, 0x16, 0x2f, 0xc0, 0x54, 0x2b, 0x5f, 0x83, 0x3d, 0x25, 0xae, 0x95, - 0x3a, 0x20, 0xed, 0x7d, 0x09, 0xbb, 0x7d, 0xd1, 0xda, 0x8b, 0x8d, 0x19, 0xf0, 0xaa, 0x1c, 0x01, - 0x92, 0x80, 0xb9, 0x25, 0x39, 0x16, 0x48, 0x0c, 0x2b, 0x56, 0x92, 0xe8, 0xc7, 0xd0, 0x38, 0x41, - 0xce, 0x39, 0x66, 0x7d, 0x3a, 0x1e, 0x7b, 0x6c, 0x8c, 0x09, 0xdb, 0x68, 0xa1, 0x15, 0x85, 0x13, - 0x6b, 0xc9, 0x52, 0x4d, 0xed, 0xe8, 0x2f, 0x60, 0x4f, 0x60, 0x75, 0x9d, 0x73, 0x42, 0xe7, 0x3e, - 0x76, 0x87, 0xb8, 0x10, 0xf0, 0x00, 0xea, 0x28, 0xab, 0x2a, 0x51, 0xf3, 0xdb, 0xfa, 0x63, 0x68, - 0xff, 0x23, 0x74, 0x77, 0x10, 0x5d, 0xd0, 0x46, 0x52, 0xf4, 0x11, 0x34, 0x3e, 0xc5, 0x17, 0x2c, - 0x1e, 0x3a, 0x2c, 0xec, 0xcc, 0x36, 0x7a, 0xf3, 0x1e, 0xdc, 0x23, 0xf8, 0x82, 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 0x7c, 0xad, 0x85, 0x56, 0x1c, 0x4e, + 0xaa, 0x25, 0x4b, 0x35, 0xb3, 0xa3, 0x3f, 0x87, 0x3d, 0x81, 0xd5, 0x71, 0x2e, 0x28, 0x9b, 0xfa, + 0xe8, 0x0e, 0x70, 0x23, 0xe0, 0x21, 0xd4, 0x49, 0x5e, 0x55, 0xa2, 0x16, 0xb7, 0x75, 0x03, 0x9a, + 0x02, 0xda, 0x42, 0x07, 0xbd, 0x80, 0x77, 0xfa, 0xf1, 0xc5, 0xac, 0x25, 0x43, 0x1f, 0x42, 0xe3, + 0x33, 0xbc, 0xe4, 0xe9, 0xb0, 0x61, 0xa1, 0x33, 0x59, 0xeb, 0xc5, 0xfb, 0x70, 0x8f, 0xe2, 0x25, + 0x8f, 0x47, 0x15, 0x3b, 0x44, 0x67, 0x22, 0x67, 0x99, 0xcc, 0xb3, 0x97, 0x13, 0xeb, 0x56, 0x95, + 0x0a, 0xe8, 0x18, 0xb5, 0x6b, 0xff, 0x7e, 0xd5, 0x52, 0x5e, 0x5c, 0xb5, 0x94, 0xbf, 0xaf, 0x5a, + 0xca, 0x4f, 0xd7, 0xad, 0xad, 0x17, 0xd7, 0xad, 0xad, 0xbf, 0xae, 0x5b, 0x5b, 0x5f, 0x3e, 0x19, + 0x78, 0x7c, 0x38, 0xee, 0x1b, 0x0e, 0x1b, 0x99, 0x0e, 0x8b, 0x46, 0x2c, 0x92, 0x9f, 0xa3, 0xc8, + 0xbd, 0x30, 0x2f, 0xcd, 0xe5, 0xc4, 0x78, 0x94, 0x8e, 0x8c, 0xef, 0xbc, 0x77, 0x94, 0x9d, 0x1a, + 0xf9, 0x2c, 0xc0, 0xa8, 0x7f, 0x37, 0xc9, 0xd7, 0x77, 0xff, 0x09, 0x00, 0x00, 0xff, 0xff, 0x8e, + 0x76, 0x62, 0x2b, 0x62, 0x0a, 0x00, 0x00, } func (m *ClientState) Marshal() (dAtA []byte, err error) { @@ -1443,7 +1443,7 @@ func (m *PacketAcknowledgementData) MarshalToSizedBuffer(dAtA []byte) (int, erro return len(dAtA) - i, nil } -func (m *PacketAcknowledgementAbsenseData) Marshal() (dAtA []byte, err error) { +func (m *PacketReceiptAbsenseData) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1453,12 +1453,12 @@ func (m *PacketAcknowledgementAbsenseData) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *PacketAcknowledgementAbsenseData) MarshalTo(dAtA []byte) (int, error) { +func (m *PacketReceiptAbsenseData) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *PacketAcknowledgementAbsenseData) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *PacketReceiptAbsenseData) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -1787,7 +1787,7 @@ func (m *PacketAcknowledgementData) Size() (n int) { return n } -func (m *PacketAcknowledgementAbsenseData) Size() (n int) { +func (m *PacketReceiptAbsenseData) Size() (n int) { if m == nil { return 0 } @@ -3717,7 +3717,7 @@ func (m *PacketAcknowledgementData) Unmarshal(dAtA []byte) error { } return nil } -func (m *PacketAcknowledgementAbsenseData) Unmarshal(dAtA []byte) error { +func (m *PacketReceiptAbsenseData) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -3740,10 +3740,10 @@ func (m *PacketAcknowledgementAbsenseData) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: PacketAcknowledgementAbsenseData: wiretype end group for non-group") + return fmt.Errorf("proto: PacketReceiptAbsenseData: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: PacketAcknowledgementAbsenseData: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: PacketReceiptAbsenseData: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: diff --git a/x/ibc/light-clients/07-tendermint/types/client_state.go b/x/ibc/light-clients/07-tendermint/types/client_state.go index 6e03675b3ad9..afbe3bf930d5 100644 --- a/x/ibc/light-clients/07-tendermint/types/client_state.go +++ b/x/ibc/light-clients/07-tendermint/types/client_state.go @@ -358,10 +358,10 @@ func (cs ClientState) VerifyPacketAcknowledgement( return nil } -// VerifyPacketAcknowledgementAbsence verifies a proof of the absence of an -// incoming packet acknowledgement at the specified port, specified channel, and +// VerifyPacketReceiptAbsence verifies a proof of the absence of an +// incoming packet receipt at the specified port, specified channel, and // specified sequence. -func (cs ClientState) VerifyPacketAcknowledgementAbsence( +func (cs ClientState) VerifyPacketReceiptAbsence( store sdk.KVStore, cdc codec.BinaryMarshaler, height exported.Height, @@ -376,7 +376,7 @@ func (cs ClientState) VerifyPacketAcknowledgementAbsence( return err } - path, err := commitmenttypes.ApplyPrefix(prefix, host.PacketAcknowledgementPath(portID, channelID, sequence)) + path, err := commitmenttypes.ApplyPrefix(prefix, host.PacketReceiptPath(portID, channelID, sequence)) if err != nil { return err } diff --git a/x/ibc/light-clients/07-tendermint/types/client_state_test.go b/x/ibc/light-clients/07-tendermint/types/client_state_test.go index 6878d1b32b88..d17142d4ce8e 100644 --- a/x/ibc/light-clients/07-tendermint/types/client_state_test.go +++ b/x/ibc/light-clients/07-tendermint/types/client_state_test.go @@ -464,8 +464,11 @@ func (suite *TendermintTestSuite) TestVerifyPacketAcknowledgement() { err := suite.coordinator.SendPacket(suite.chainA, suite.chainB, packet, clientB) suite.Require().NoError(err) - // write ack - err = suite.coordinator.ReceiveExecuted(suite.chainB, suite.chainA, packet, clientA) + // write receipt and ack + err = suite.coordinator.WriteReceipt(suite.chainB, suite.chainA, packet, clientA) + suite.Require().NoError(err) + + err = suite.coordinator.WriteAcknowledgement(suite.chainB, suite.chainA, packet, clientA) suite.Require().NoError(err) var ok bool @@ -500,7 +503,7 @@ func (suite *TendermintTestSuite) TestVerifyPacketAcknowledgement() { // test verification of the absent acknowledgement on chainB being represented // in the light client on chainA. A send from chainB to chainA is simulated, but // no receive. -func (suite *TendermintTestSuite) TestVerifyPacketAcknowledgementAbsence() { +func (suite *TendermintTestSuite) TestVerifyPacketReceiptAbsence() { var ( clientState *types.ClientState proof []byte @@ -562,15 +565,15 @@ func (suite *TendermintTestSuite) TestVerifyPacketAcknowledgementAbsence() { prefix = suite.chainB.GetPrefix() - // make packet acknowledgement absence proof - acknowledgementKey := host.KeyPacketAcknowledgement(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence()) - proof, proofHeight = suite.chainB.QueryProof(acknowledgementKey) + // make packet receipt absence proof + receiptKey := host.KeyPacketReceipt(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence()) + proof, proofHeight = suite.chainB.QueryProof(receiptKey) tc.malleate() // make changes as necessary store := suite.chainA.App.IBCKeeper.ClientKeeper.ClientStore(suite.chainA.GetContext(), clientA) - err = clientState.VerifyPacketAcknowledgementAbsence( + err = clientState.VerifyPacketReceiptAbsence( store, suite.chainA.Codec, proofHeight, &prefix, proof, packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence(), ) @@ -639,8 +642,8 @@ func (suite *TendermintTestSuite) TestVerifyNextSeqRecv() { err := suite.coordinator.SendPacket(suite.chainA, suite.chainB, packet, clientB) suite.Require().NoError(err) - // write ack, next seq recv incremented - err = suite.coordinator.ReceiveExecuted(suite.chainB, suite.chainA, packet, clientA) + // write receipt, next seq recv incremented + err = suite.coordinator.WriteReceipt(suite.chainB, suite.chainA, packet, clientA) suite.Require().NoError(err) // need to update chainA's client representing chainB diff --git a/x/ibc/light-clients/09-localhost/types/client_state.go b/x/ibc/light-clients/09-localhost/types/client_state.go index 22d2ee0a6546..ca09a423fe50 100644 --- a/x/ibc/light-clients/09-localhost/types/client_state.go +++ b/x/ibc/light-clients/09-localhost/types/client_state.go @@ -270,10 +270,10 @@ func (cs ClientState) VerifyPacketAcknowledgement( return nil } -// VerifyPacketAcknowledgementAbsence verifies a proof of the absence of an -// incoming packet acknowledgement at the specified port, specified channel, and +// VerifyPacketReceiptAbsence verifies a proof of the absence of an +// incoming packet receipt at the specified port, specified channel, and // specified sequence. -func (cs ClientState) VerifyPacketAcknowledgementAbsence( +func (cs ClientState) VerifyPacketReceiptAbsence( store sdk.KVStore, _ codec.BinaryMarshaler, _ exported.Height, @@ -283,11 +283,11 @@ func (cs ClientState) VerifyPacketAcknowledgementAbsence( channelID string, sequence uint64, ) error { - path := host.KeyPacketAcknowledgement(portID, channelID, sequence) + path := host.KeyPacketReceipt(portID, channelID, sequence) data := store.Get(path) if data != nil { - return sdkerrors.Wrap(clienttypes.ErrFailedPacketAckAbsenceVerification, "expected no ack absence") + return sdkerrors.Wrap(clienttypes.ErrFailedPacketReceiptVerification, "expected no packet receipt") } return nil diff --git a/x/ibc/light-clients/09-localhost/types/client_state_test.go b/x/ibc/light-clients/09-localhost/types/client_state_test.go index d55a0154a92b..68fc0567096c 100644 --- a/x/ibc/light-clients/09-localhost/types/client_state_test.go +++ b/x/ibc/light-clients/09-localhost/types/client_state_test.go @@ -407,21 +407,21 @@ func (suite *LocalhostTestSuite) TestVerifyPacketAcknowledgement() { } } -func (suite *LocalhostTestSuite) TestVerifyPacketAcknowledgementAbsence() { +func (suite *LocalhostTestSuite) TestVerifyPacketReceiptAbsence() { clientState := types.NewClientState("chainID", clientHeight) - err := clientState.VerifyPacketAcknowledgementAbsence( + err := clientState.VerifyPacketReceiptAbsence( suite.store, suite.cdc, clientHeight, nil, nil, testPortID, testChannelID, testSequence, ) - suite.Require().NoError(err, "ack absence failed") + suite.Require().NoError(err, "receipt absence failed") - suite.store.Set(host.KeyPacketAcknowledgement(testPortID, testChannelID, testSequence), []byte("ack")) + suite.store.Set(host.KeyPacketReceipt(testPortID, testChannelID, testSequence), []byte("receipt")) - err = clientState.VerifyPacketAcknowledgementAbsence( + err = clientState.VerifyPacketReceiptAbsence( suite.store, suite.cdc, clientHeight, nil, nil, testPortID, testChannelID, testSequence, ) - suite.Require().Error(err, "ack exists in store") + suite.Require().Error(err, "receipt exists in store") } func (suite *LocalhostTestSuite) TestVerifyNextSeqRecv() { diff --git a/x/ibc/spec/01_concepts.md b/x/ibc/spec/01_concepts.md index 5a6c8b380253..79bc6d3fcfe9 100644 --- a/x/ibc/spec/01_concepts.md +++ b/x/ibc/spec/01_concepts.md @@ -14,7 +14,7 @@ IBC Client Heights are represented by the struct: ```go type Height struct { EpochNumber uint64 - EpocHeight uint64 + EpochHeight uint64 ``` The `EpochNumber` represents the epoch of the chain that the height is representing. @@ -46,10 +46,10 @@ Ex: Before upgrade ChainID: `gaiamainnet-3` After upgrade ChainID: `gaiamainnet-4` -Clients that do not require epochs, such as the solo-machine client, simply hardcode `0` into the epoch number whenever they +Clients that do not require epochs, such as the solo-machine client, simply hardcode `0` into the epoch number whenever they need to return an IBC height when implementing IBC interfaces and use the `EpochHeight` exclusively. -Other client-types may implement their own logic to verify the IBC Heights that relayers provide in their Update, Misbehavior, and +Other client-types may implement their own logic to verify the IBC Heights that relayers provide in their Update, Misbehavior, and Verify functions respectively. The IBC interfaces expect an `ibcexported.Height` interface, however all clients should use the concrete implementation provided in @@ -77,7 +77,7 @@ Governance may then choose to override a frozen client and provide the correct, canonical Header so that the client can continue operating after the Misbehaviour submission. -## Connection Version Negotation +## Connection Version Negotiation During the handshake procedure for connections a version string is agreed upon between the two parties. This occurs during the first 3 steps of the @@ -116,7 +116,7 @@ with regards to version selection in `ConnOpenTry`. Each version in a set of versions should have a unique version identifier. ::: -## Channel Version Negotation +## Channel Version Negotiation During the channel handshake procedure a version must be agreed upon between the two parties. The selection process is largely left to the callers and @@ -171,4 +171,3 @@ latter flag can be used to unfreeze a client and if necessary it will also unexp It is advised to let a client expire if it has become frozen before proposing a new header. This is to avoid the client from becoming refrozen if the misbehaviour evidence has not expired. These boolean flags are set upon client creation and cannot be updated later. - diff --git a/x/ibc/testing/chain.go b/x/ibc/testing/chain.go index ffeac5d5b96e..a196e80365cb 100644 --- a/x/ibc/testing/chain.go +++ b/x/ibc/testing/chain.go @@ -819,14 +819,31 @@ func (chain *TestChain) SendPacket( return nil } -// ReceiveExecuted simulates receiving and writing an acknowledgement to the chain. -func (chain *TestChain) ReceiveExecuted( +// WriteReceipt simulates receiving and writing a receipt to the chain. +func (chain *TestChain) WriteReceipt( packet exported.PacketI, ) error { channelCap := chain.GetChannelCapability(packet.GetDestPort(), packet.GetDestChannel()) // no need to send message, acting as a handler - err := chain.App.IBCKeeper.ChannelKeeper.ReceiveExecuted(chain.GetContext(), channelCap, packet, TestHash) + err := chain.App.IBCKeeper.ChannelKeeper.WriteReceipt(chain.GetContext(), channelCap, packet) + if err != nil { + return err + } + + // commit changes + chain.App.Commit() + chain.NextBlock() + + return nil +} + +// WriteAcknowledgement simulates writing an acknowledgement to the chain. +func (chain *TestChain) WriteAcknowledgement( + packet exported.PacketI, +) error { + // no need to send message, acting as a handler + err := chain.App.IBCKeeper.ChannelKeeper.WriteAcknowledgement(chain.GetContext(), packet, TestHash) if err != nil { return err } diff --git a/x/ibc/testing/coordinator.go b/x/ibc/testing/coordinator.go index 71f27980f90a..8b5886cb4340 100644 --- a/x/ibc/testing/coordinator.go +++ b/x/ibc/testing/coordinator.go @@ -247,14 +247,33 @@ func (coord *Coordinator) RecvPacket( return coord.SendMsgs(counterparty, source, sourceClient, []sdk.Msg{recvMsg}) } -// ReceiveExecuted receives a packet through the channel keeper on the source chain and updates the +// WriteReceipt receives a packet through the channel keeper on the source chain, writes a receipt, and updates the // counterparty client for the source chain. -func (coord *Coordinator) ReceiveExecuted( +func (coord *Coordinator) WriteReceipt( source, counterparty *TestChain, packet exported.PacketI, counterpartyClientID string, ) error { - if err := source.ReceiveExecuted(packet); err != nil { + if err := source.WriteReceipt(packet); err != nil { + return err + } + coord.IncrementTime() + + // update source client on counterparty connection + return coord.UpdateClient( + counterparty, source, + counterpartyClientID, Tendermint, + ) +} + +// WriteAcknowledgement writes an acknowledgement to the channel keeper on the source chain and updates the +// counterparty client for the source chain. +func (coord *Coordinator) WriteAcknowledgement( + source, counterparty *TestChain, + packet exported.PacketI, + counterpartyClientID string, +) error { + if err := source.WriteAcknowledgement(packet); err != nil { return err } coord.IncrementTime()