From ba1152aa2dc50fee9bcaf1c1e011901246749aaf Mon Sep 17 00:00:00 2001 From: Federico Kunze Date: Tue, 22 Sep 2020 15:55:39 +0200 Subject: [PATCH 01/15] rename packet ack abs --- x/ibc/03-connection/keeper/verify.go | 6 +++--- x/ibc/03-connection/keeper/verify_test.go | 6 +++--- x/ibc/04-channel/keeper/timeout.go | 4 ++-- x/ibc/04-channel/types/expected_keepers.go | 2 +- x/ibc/07-tendermint/types/client_state.go | 4 ++-- x/ibc/07-tendermint/types/client_state_test.go | 4 ++-- x/ibc/09-localhost/types/client_state.go | 4 ++-- x/ibc/09-localhost/types/client_state_test.go | 6 +++--- x/ibc/24-host/keys.go | 11 +++++++++++ x/ibc/exported/client.go | 2 +- x/ibc/light-clients/solomachine/types/client_state.go | 4 ++-- .../solomachine/types/client_state_test.go | 4 ++-- 12 files changed, 34 insertions(+), 23 deletions(-) diff --git a/x/ibc/03-connection/keeper/verify.go b/x/ibc/03-connection/keeper/verify.go index e6f447d8b1c9..c7d39ec0970b 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 +// VerifyPacketReceiptAbsence verifies a proof of the absence of an // incoming packet acknowledgement 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,7 +192,7 @@ 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, diff --git a/x/ibc/03-connection/keeper/verify_test.go b/x/ibc/03-connection/keeper/verify_test.go index a8457c3a4636..086e308167d6 100644 --- a/x/ibc/03-connection/keeper/verify_test.go +++ b/x/ibc/03-connection/keeper/verify_test.go @@ -361,10 +361,10 @@ func (suite *KeeperTestSuite) TestVerifyPacketAcknowledgement() { } } -// TestVerifyPacketAcknowledgementAbsence has chainA verify the acknowledgement +// TestVerifyPacketReceiptAbsence has chainA verify the acknowledgement // 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 @@ -407,7 +407,7 @@ func (suite *KeeperTestSuite) TestVerifyPacketAcknowledgementAbsence() { packetAckKey := host.KeyPacketAcknowledgement(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence()) proof, proofHeight := suite.chainB.QueryProof(packetAckKey) - 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(), ) 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/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/07-tendermint/types/client_state.go b/x/ibc/07-tendermint/types/client_state.go index 921afc5db0cd..0a24154565d2 100644 --- a/x/ibc/07-tendermint/types/client_state.go +++ b/x/ibc/07-tendermint/types/client_state.go @@ -340,10 +340,10 @@ func (cs ClientState) VerifyPacketAcknowledgement( return nil } -// VerifyPacketAcknowledgementAbsence verifies a proof of the absence of an +// VerifyPacketReceiptAbsence verifies a proof of the absence of an // incoming packet acknowledgement 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, diff --git a/x/ibc/07-tendermint/types/client_state_test.go b/x/ibc/07-tendermint/types/client_state_test.go index b635651b01a0..ae3fe7c1e1d6 100644 --- a/x/ibc/07-tendermint/types/client_state_test.go +++ b/x/ibc/07-tendermint/types/client_state_test.go @@ -495,7 +495,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 @@ -565,7 +565,7 @@ func (suite *TendermintTestSuite) TestVerifyPacketAcknowledgementAbsence() { 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(), ) diff --git a/x/ibc/09-localhost/types/client_state.go b/x/ibc/09-localhost/types/client_state.go index 709dba02a923..df4d77151008 100644 --- a/x/ibc/09-localhost/types/client_state.go +++ b/x/ibc/09-localhost/types/client_state.go @@ -257,10 +257,10 @@ func (cs ClientState) VerifyPacketAcknowledgement( return nil } -// VerifyPacketAcknowledgementAbsence verifies a proof of the absence of an +// VerifyPacketReceiptAbsence verifies a proof of the absence of an // incoming packet acknowledgement at the specified port, specified channel, and // specified sequence. -func (cs ClientState) VerifyPacketAcknowledgementAbsence( +func (cs ClientState) VerifyPacketReceiptAbsence( store sdk.KVStore, _ codec.BinaryMarshaler, _ exported.Height, diff --git a/x/ibc/09-localhost/types/client_state_test.go b/x/ibc/09-localhost/types/client_state_test.go index fba3cff2d4d8..c8687b3bdaf3 100644 --- a/x/ibc/09-localhost/types/client_state_test.go +++ b/x/ibc/09-localhost/types/client_state_test.go @@ -407,10 +407,10 @@ 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, ) @@ -418,7 +418,7 @@ func (suite *LocalhostTestSuite) TestVerifyPacketAcknowledgementAbsence() { suite.store.Set(host.KeyPacketAcknowledgement(testPortID, testChannelID, testSequence), []byte("ack")) - err = clientState.VerifyPacketAcknowledgementAbsence( + err = clientState.VerifyPacketReceiptAbsence( suite.store, suite.cdc, clientHeight, nil, nil, testPortID, testChannelID, testSequence, ) suite.Require().Error(err, "ack exists in store") diff --git a/x/ibc/24-host/keys.go b/x/ibc/24-host/keys.go index 75b3288c1016..97dbde0cbbf7 100644 --- a/x/ibc/24-host/keys.go +++ b/x/ibc/24-host/keys.go @@ -163,6 +163,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/", KeyPacketAckPrefix) + 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 +203,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 e3a8f9a4fee4..1bf6694e3781 100644 --- a/x/ibc/exported/client.go +++ b/x/ibc/exported/client.go @@ -90,7 +90,7 @@ type ClientState interface { sequence uint64, acknowledgement []byte, ) error - VerifyPacketAcknowledgementAbsence( + VerifyPacketReceiptAbsence( store sdk.KVStore, cdc codec.BinaryMarshaler, height Height, diff --git a/x/ibc/light-clients/solomachine/types/client_state.go b/x/ibc/light-clients/solomachine/types/client_state.go index 6a5c33823eb2..e897461bfed2 100644 --- a/x/ibc/light-clients/solomachine/types/client_state.go +++ b/x/ibc/light-clients/solomachine/types/client_state.go @@ -290,10 +290,10 @@ func (cs ClientState) VerifyPacketAcknowledgement( return nil } -// VerifyPacketAcknowledgementAbsence verifies a proof of the absence of an +// VerifyPacketReceiptAbsence verifies a proof of the absence of an // incoming packet acknowledgement 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, diff --git a/x/ibc/light-clients/solomachine/types/client_state_test.go b/x/ibc/light-clients/solomachine/types/client_state_test.go index 4ed7a0903a9a..994625d27e06 100644 --- a/x/ibc/light-clients/solomachine/types/client_state_test.go +++ b/x/ibc/light-clients/solomachine/types/client_state_test.go @@ -678,7 +678,7 @@ func (suite *SoloMachineTestSuite) TestVerifyPacketAcknowledgement() { } } -func (suite *SoloMachineTestSuite) TestVerifyPacketAcknowledgementAbsence() { +func (suite *SoloMachineTestSuite) TestVerifyPacketReceiptAbsence() { path, err := commitmenttypes.ApplyPrefix(prefix, host.PacketAcknowledgementPath(testPortID, testChannelID, suite.solomachine.Sequence)) suite.Require().NoError(err) @@ -750,7 +750,7 @@ func (suite *SoloMachineTestSuite) TestVerifyPacketAcknowledgementAbsence() { expSeq := tc.clientState.Sequence + 1 - err := tc.clientState.VerifyPacketAcknowledgementAbsence( + err := tc.clientState.VerifyPacketReceiptAbsence( suite.store, suite.chainA.Codec, suite.solomachine.GetHeight(), tc.prefix, tc.proof, testPortID, testChannelID, suite.solomachine.Sequence, ) From c83394d4506760db34248ff37adf0df4c06b690f Mon Sep 17 00:00:00 2001 From: Federico Kunze Date: Mon, 28 Sep 2020 13:55:50 +0200 Subject: [PATCH 02/15] update packet executed --- x/ibc/04-channel/keeper/keeper.go | 17 ++++++++++++++++ x/ibc/04-channel/keeper/packet.go | 27 ++++++++++++++------------ x/ibc/04-channel/keeper/packet_test.go | 2 +- x/ibc/04-channel/types/errors.go | 1 + x/ibc/handler.go | 4 ++-- x/ibc/testing/chain.go | 2 +- 6 files changed, 37 insertions(+), 16 deletions(-) diff --git a/x/ibc/04-channel/keeper/keeper.go b/x/ibc/04-channel/keeper/keeper.go index 2d220db1acc6..4c3ce63ca1de 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) diff --git a/x/ibc/04-channel/keeper/packet.go b/x/ibc/04-channel/keeper/packet.go index e96c7a53e370..12939c4a261a 100644 --- a/x/ibc/04-channel/keeper/packet.go +++ b/x/ibc/04-channel/keeper/packet.go @@ -15,6 +15,8 @@ import ( "github.com/cosmos/cosmos-sdk/x/ibc/exported" ) +const emptyReceipt = "" + // SendPacket is called by a module in order to send an IBC packet on a channel // end owned by the calling module to the corresponding module on the counterparty // chain. @@ -250,7 +252,6 @@ func (k Keeper) ReceiveExecuted( ctx sdk.Context, chanCap *capabilitytypes.Capability, packet exported.PacketI, - acknowledgement []byte, ) error { channel, found := k.GetChannel(ctx, packet.GetDestPort(), packet.GetDestChannel()) if !found { @@ -273,16 +274,6 @@ 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 { nextSequenceRecv, found := k.GetNextSequenceRecv(ctx, packet.GetDestPort(), packet.GetDestChannel()) if !found { @@ -297,6 +288,19 @@ func (k Keeper) ReceiveExecuted( // incrementng 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) + } else { + // 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 @@ -307,7 +311,6 @@ func (k Keeper) ReceiveExecuted( 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())), diff --git a/x/ibc/04-channel/keeper/packet_test.go b/x/ibc/04-channel/keeper/packet_test.go index 3207da9c0a34..e3b1ea200881 100644 --- a/x/ibc/04-channel/keeper/packet_test.go +++ b/x/ibc/04-channel/keeper/packet_test.go @@ -409,7 +409,7 @@ func (suite *KeeperTestSuite) TestReceiveExecuted() { tc.malleate() - err := suite.chainB.App.IBCKeeper.ChannelKeeper.ReceiveExecuted(suite.chainB.GetContext(), channelCap, packet, ack) + err := suite.chainB.App.IBCKeeper.ChannelKeeper.ReceiveExecuted(suite.chainB.GetContext(), channelCap, packet) if tc.expPass { suite.Require().NoError(err) diff --git a/x/ibc/04-channel/types/errors.go b/x/ibc/04-channel/types/errors.go index 2fb51bc4a8be..a1a6b38f3632 100644 --- a/x/ibc/04-channel/types/errors.go +++ b/x/ibc/04-channel/types/errors.go @@ -23,4 +23,5 @@ var ( ErrAcknowledgementTooLong = sdkerrors.Register(SubModuleName, 16, "acknowledgement too long") ErrInvalidAcknowledgement = sdkerrors.Register(SubModuleName, 17, "invalid acknowledgement") ErrPacketCommitmentNotFound = sdkerrors.Register(SubModuleName, 18, "packet commitment not found") + ErrPacketReceived = sdkerrors.Register(SubModuleName, 19, "packet receipt already received") ) diff --git a/x/ibc/handler.go b/x/ibc/handler.go index f173d8b77d26..546bc513805a 100644 --- a/x/ibc/handler.go +++ b/x/ibc/handler.go @@ -187,13 +187,13 @@ func NewHandler(k keeper.Keeper) sdk.Handler { } // Perform application logic callback - res, ack, err := cbs.OnRecvPacket(ctx, msg.Packet) + res, _, err := cbs.OnRecvPacket(ctx, msg.Packet) if err != nil { 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.ReceiveExecuted(ctx, cap, msg.Packet); err != nil { return nil, err } diff --git a/x/ibc/testing/chain.go b/x/ibc/testing/chain.go index e7e80d04c933..36bcd741e131 100644 --- a/x/ibc/testing/chain.go +++ b/x/ibc/testing/chain.go @@ -798,7 +798,7 @@ func (chain *TestChain) ReceiveExecuted( 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.ReceiveExecuted(chain.GetContext(), channelCap, packet) if err != nil { return err } From f8eef5a33ab3aedd524e7366189bfffa1f889c35 Mon Sep 17 00:00:00 2001 From: Federico Kunze Date: Mon, 28 Sep 2020 14:09:55 +0200 Subject: [PATCH 03/15] write ack --- x/ibc/04-channel/keeper/packet.go | 43 ++++++++++++++++++++++++++++--- x/ibc/handler.go | 8 ++++-- 2 files changed, 46 insertions(+), 5 deletions(-) diff --git a/x/ibc/04-channel/keeper/packet.go b/x/ibc/04-channel/keeper/packet.go index 12939c4a261a..b52733a54251 100644 --- a/x/ibc/04-channel/keeper/packet.go +++ b/x/ibc/04-channel/keeper/packet.go @@ -244,8 +244,8 @@ func (k Keeper) RecvPacket( return nil } -// ReceiveExecuted writes the packet execution acknowledgement to the state, -// which will be verified by the counterparty chain using AcknowledgePacket. +// ReceiveExecuted 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( @@ -304,7 +304,7 @@ func (k Keeper) ReceiveExecuted( } // 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 and executed", "packet", fmt.Sprintf("%v", packet)) // emit an event that the relayer can query for ctx.EventManager().EmitEvents(sdk.Events{ @@ -329,6 +329,43 @@ 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: this function must be called in the IBC handler +func (k Keeper) WriteAcknowledgement( + ctx sdk.Context, + packet exported.PacketI, + acknowledgement []byte, +) error { + 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 diff --git a/x/ibc/handler.go b/x/ibc/handler.go index 546bc513805a..7a5162a5848d 100644 --- a/x/ibc/handler.go +++ b/x/ibc/handler.go @@ -187,13 +187,17 @@ func NewHandler(k keeper.Keeper) sdk.Handler { } // Perform application logic callback - res, _, err := cbs.OnRecvPacket(ctx, msg.Packet) + res, ack, err := cbs.OnRecvPacket(ctx, msg.Packet) if err != nil { return nil, sdkerrors.Wrap(err, "receive packet callback failed") } + if err := k.ChannelKeeper.ReceiveExecuted(ctx, cap, msg.Packet); err != nil { + return nil, err + } + // Set packet acknowledgement - if err = k.ChannelKeeper.ReceiveExecuted(ctx, cap, msg.Packet); err != nil { + if err := k.ChannelKeeper.WriteAcknowledgement(ctx, msg.Packet, ack); err != nil { return nil, err } From e9439f9594f7282f352f2fccb858c0a19dc9ef6d Mon Sep 17 00:00:00 2001 From: Federico Kunze Date: Mon, 28 Sep 2020 14:22:06 +0200 Subject: [PATCH 04/15] update clients --- .../lightclients/solomachine/v1/solomachine.proto | 12 ++++++------ x/ibc/02-client/types/errors.go | 2 +- x/ibc/07-tendermint/types/client_state.go | 2 +- x/ibc/09-localhost/types/client_state.go | 6 +++--- .../light-clients/solomachine/types/client_state.go | 6 +++--- .../solomachine/types/client_state_test.go | 2 +- x/ibc/light-clients/solomachine/types/proof.go | 4 ++-- .../solomachine/types/solomachine.pb.go | 2 +- 8 files changed, 18 insertions(+), 18 deletions(-) diff --git a/proto/ibc/lightclients/solomachine/v1/solomachine.proto b/proto/ibc/lightclients/solomachine/v1/solomachine.proto index 45bada7fed75..f2234efd067a 100644 --- a/proto/ibc/lightclients/solomachine/v1/solomachine.proto +++ b/proto/ibc/lightclients/solomachine/v1/solomachine.proto @@ -28,7 +28,7 @@ message ClientState { message ConsensusState { option (gogoproto.goproto_getters) = false; // public key of the solo machine - google.protobuf.Any public_key = 1 [(gogoproto.moretags) = "yaml:\"public_key\""]; + google.protobuf.Any public_key = 1 [(gogoproto.moretags) = "yaml:\"public_key\""]; // diversifier allows the same public key to be re-used across different solo machine clients // (potentially on different chains) without being considered misbehaviour. string diversifier = 2; @@ -39,11 +39,11 @@ message ConsensusState { message Header { option (gogoproto.goproto_getters) = false; // sequence to update solo machine public key at - uint64 sequence = 1; - uint64 timestamp = 2; - bytes signature = 3; + uint64 sequence = 1; + uint64 timestamp = 2; + bytes signature = 3; google.protobuf.Any new_public_key = 4 [(gogoproto.moretags) = "yaml:\"new_public_key\""]; - string new_diversifier = 5 [(gogoproto.moretags) = "yaml:\"new_diversifier\""]; + string new_diversifier = 5 [(gogoproto.moretags) = "yaml:\"new_diversifier\""]; } // Misbehaviour defines misbehaviour for a solo machine which consists @@ -143,7 +143,7 @@ message PacketAcknowledgementData { bytes acknowledgement = 2; } -// PacketAcknowledgementAbsenceSignBytes returns the SignBytes data for +// PacketReceiptAbsenceSignBytes returns the SignBytes data for // acknowledgement absence verification. message PacketAcknowledgementAbsenseData { bytes path = 1; diff --git a/x/ibc/02-client/types/errors.go b/x/ibc/02-client/types/errors.go index fe9099eaec32..af77491bea4a 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/07-tendermint/types/client_state.go b/x/ibc/07-tendermint/types/client_state.go index cd42377b7d0a..67a4df21438c 100644 --- a/x/ibc/07-tendermint/types/client_state.go +++ b/x/ibc/07-tendermint/types/client_state.go @@ -361,7 +361,7 @@ func (cs ClientState) VerifyPacketReceiptAbsence( 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/09-localhost/types/client_state.go b/x/ibc/09-localhost/types/client_state.go index 5a876882fa44..c947016447f2 100644 --- a/x/ibc/09-localhost/types/client_state.go +++ b/x/ibc/09-localhost/types/client_state.go @@ -258,7 +258,7 @@ func (cs ClientState) VerifyPacketAcknowledgement( } // VerifyPacketReceiptAbsence verifies a proof of the absence of an -// incoming packet acknowledgement at the specified port, specified channel, and +// incoming packet receipt at the specified port, specified channel, and // specified sequence. func (cs ClientState) VerifyPacketReceiptAbsence( store sdk.KVStore, @@ -270,11 +270,11 @@ func (cs ClientState) VerifyPacketReceiptAbsence( 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/solomachine/types/client_state.go b/x/ibc/light-clients/solomachine/types/client_state.go index 565388b5fb83..a309052f0f95 100644 --- a/x/ibc/light-clients/solomachine/types/client_state.go +++ b/x/ibc/light-clients/solomachine/types/client_state.go @@ -295,7 +295,7 @@ func (cs ClientState) VerifyPacketAcknowledgement( } // VerifyPacketReceiptAbsence verifies a proof of the absence of an -// incoming packet acknowledgement at the specified port, specified channel, and +// incoming packet receipt at the specified port, specified channel, and // specified sequence. func (cs ClientState) VerifyPacketReceiptAbsence( store sdk.KVStore, @@ -312,12 +312,12 @@ func (cs ClientState) VerifyPacketReceiptAbsence( 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/solomachine/types/client_state_test.go b/x/ibc/light-clients/solomachine/types/client_state_test.go index f0f416847ec9..f8ae5e276c28 100644 --- a/x/ibc/light-clients/solomachine/types/client_state_test.go +++ b/x/ibc/light-clients/solomachine/types/client_state_test.go @@ -704,7 +704,7 @@ func (suite *SoloMachineTestSuite) TestVerifyPacketReceiptAbsence() { path, err := commitmenttypes.ApplyPrefix(prefix, host.PacketAcknowledgementPath(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) diff --git a/x/ibc/light-clients/solomachine/types/proof.go b/x/ibc/light-clients/solomachine/types/proof.go index ea9303ef925c..bb661ac71649 100644 --- a/x/ibc/light-clients/solomachine/types/proof.go +++ b/x/ibc/light-clients/solomachine/types/proof.go @@ -287,9 +287,9 @@ func PacketAcknowledgementSignBytes( return cdc.MarshalBinaryBare(signBytes) } -// PacketAcknowledgementAbsenceSignBytes returns the sign bytes for verification +// PacketReceiptAbsenceSignBytes returns the sign bytes for verification // of the absence of an acknowledgement. -func PacketAcknowledgementAbsenceSignBytes( +func PacketReceiptAbsenceSignBytes( cdc codec.BinaryMarshaler, sequence, timestamp uint64, diversifier string, diff --git a/x/ibc/light-clients/solomachine/types/solomachine.pb.go b/x/ibc/light-clients/solomachine/types/solomachine.pb.go index 392be1a50941..2572986f4bc9 100644 --- a/x/ibc/light-clients/solomachine/types/solomachine.pb.go +++ b/x/ibc/light-clients/solomachine/types/solomachine.pb.go @@ -631,7 +631,7 @@ func (m *PacketAcknowledgementData) GetAcknowledgement() []byte { return nil } -// PacketAcknowledgementAbsenceSignBytes returns the SignBytes data for +// PacketReceiptAbsenceSignBytes returns the SignBytes data for // acknowledgement absence verification. type PacketAcknowledgementAbsenseData struct { Path []byte `protobuf:"bytes,1,opt,name=path,proto3" json:"path,omitempty"` From 224ebaa9265591e137f64a9df96211f277351183 Mon Sep 17 00:00:00 2001 From: Federico Kunze Date: Mon, 28 Sep 2020 14:30:54 +0200 Subject: [PATCH 05/15] update transfer keeper --- x/ibc-transfer/keeper/keeper.go | 2 +- x/ibc-transfer/types/expected_keepers.go | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/x/ibc-transfer/keeper/keeper.go b/x/ibc-transfer/keeper/keeper.go index 3cd86ee7f896..b1216b26d87e 100644 --- a/x/ibc-transfer/keeper/keeper.go +++ b/x/ibc-transfer/keeper/keeper.go @@ -80,7 +80,7 @@ func (k Keeper) ReceiveExecuted(ctx sdk.Context, packet ibcexported.PacketI, ack if !ok { return sdkerrors.Wrap(channeltypes.ErrChannelCapabilityNotFound, "channel capability could not be retrieved for packet") } - return k.channelKeeper.ReceiveExecuted(ctx, chanCap, packet, acknowledgement) + return k.channelKeeper.ReceiveExecuted(ctx, chanCap, packet) } // ChanCloseInit defines a wrapper function for the channel Keeper's function diff --git a/x/ibc-transfer/types/expected_keepers.go b/x/ibc-transfer/types/expected_keepers.go index 9a7f2a73bdf5..b954b8fd7184 100644 --- a/x/ibc-transfer/types/expected_keepers.go +++ b/x/ibc-transfer/types/expected_keepers.go @@ -29,7 +29,8 @@ 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 + ReceiveExecuted(ctx sdk.Context, chanCap *capabilitytypes.Capability, packet ibcexported.PacketI) error + WriteAcknowledgement(ctx sdk.Context, packet ibcexported.PacketI, acknowledgement []byte) error ChanCloseInit(ctx sdk.Context, portID, channelID string, chanCap *capabilitytypes.Capability) error } From 0e987df14b3a91229bc7b78ead781ba9d8128e9c Mon Sep 17 00:00:00 2001 From: Federico Kunze Date: Tue, 29 Sep 2020 11:51:28 +0200 Subject: [PATCH 06/15] changes from reviews --- .../solomachine/v1/solomachine.proto | 4 +- x/ibc-transfer/keeper/keeper.go | 14 +- x/ibc-transfer/module.go | 1 + x/ibc-transfer/types/expected_keepers.go | 2 - x/ibc/04-channel/keeper/keeper.go | 6 + x/ibc/04-channel/keeper/packet.go | 13 +- x/ibc/09-localhost/types/client_state_test.go | 4 +- x/ibc/handler.go | 10 +- .../light-clients/solomachine/types/proof.go | 2 +- .../solomachine/types/solomachine.pb.go | 178 +++++++++--------- 10 files changed, 119 insertions(+), 115 deletions(-) diff --git a/proto/ibc/lightclients/solomachine/v1/solomachine.proto b/proto/ibc/lightclients/solomachine/v1/solomachine.proto index f2234efd067a..fd14fa54ca18 100644 --- a/proto/ibc/lightclients/solomachine/v1/solomachine.proto +++ b/proto/ibc/lightclients/solomachine/v1/solomachine.proto @@ -144,8 +144,8 @@ message PacketAcknowledgementData { } // PacketReceiptAbsenceSignBytes returns the SignBytes data for -// acknowledgement absence verification. -message PacketAcknowledgementAbsenseData { +// 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 b1216b26d87e..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) -} - // 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 b954b8fd7184..87d16c643f65 100644 --- a/x/ibc-transfer/types/expected_keepers.go +++ b/x/ibc-transfer/types/expected_keepers.go @@ -29,8 +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) error - WriteAcknowledgement(ctx sdk.Context, packet ibcexported.PacketI, acknowledgement []byte) error ChanCloseInit(ctx sdk.Context, portID, channelID string, chanCap *capabilitytypes.Capability) error } diff --git a/x/ibc/04-channel/keeper/keeper.go b/x/ibc/04-channel/keeper/keeper.go index 4c3ce63ca1de..950e396ad66f 100644 --- a/x/ibc/04-channel/keeper/keeper.go +++ b/x/ibc/04-channel/keeper/keeper.go @@ -182,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/packet.go b/x/ibc/04-channel/keeper/packet.go index b52733a54251..6607c7d7215a 100644 --- a/x/ibc/04-channel/keeper/packet.go +++ b/x/ibc/04-channel/keeper/packet.go @@ -15,8 +15,6 @@ import ( "github.com/cosmos/cosmos-sdk/x/ibc/exported" ) -const emptyReceipt = "" - // SendPacket is called by a module in order to send an IBC packet on a channel // end owned by the calling module to the corresponding module on the counterparty // chain. @@ -332,12 +330,21 @@ func (k Keeper) ReceiveExecuted( // WriteAcknowledgement writes the packet execution acknowledgement to the state, // which will be verified by the counterparty chain using AcknowledgePacket. // -// CONTRACT: this function must be called in the IBC handler +// CONTRACT: 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. 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 perform a no-op if so. + if k.HasPacketAcknowledgement(ctx, packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence()) { + return nil + } + if len(acknowledgement) == 0 { return sdkerrors.Wrap(types.ErrInvalidAcknowledgement, "acknowledgement cannot be empty") } diff --git a/x/ibc/09-localhost/types/client_state_test.go b/x/ibc/09-localhost/types/client_state_test.go index c8687b3bdaf3..13cfae890d05 100644 --- a/x/ibc/09-localhost/types/client_state_test.go +++ b/x/ibc/09-localhost/types/client_state_test.go @@ -414,14 +414,14 @@ func (suite *LocalhostTestSuite) TestVerifyPacketReceiptAbsence() { 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")) 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/handler.go b/x/ibc/handler.go index 7a5162a5848d..caa5709bdd6e 100644 --- a/x/ibc/handler.go +++ b/x/ibc/handler.go @@ -196,9 +196,13 @@ func NewHandler(k keeper.Keeper) sdk.Handler { return nil, err } - // Set packet acknowledgement - if err := k.ChannelKeeper.WriteAcknowledgement(ctx, msg.Packet, ack); err != nil { - return nil, err + // Set packet acknowledgement only if the acknowledgement is not nil. + // NOTE: IBC applications modules will have to call the WriteAcknowledgement asynchronously if this + // is the case. + if ack != nil { + if err := k.ChannelKeeper.WriteAcknowledgement(ctx, msg.Packet, ack); err != nil { + return nil, err + } } return res, nil diff --git a/x/ibc/light-clients/solomachine/types/proof.go b/x/ibc/light-clients/solomachine/types/proof.go index bb661ac71649..e767256c7da3 100644 --- a/x/ibc/light-clients/solomachine/types/proof.go +++ b/x/ibc/light-clients/solomachine/types/proof.go @@ -295,7 +295,7 @@ func PacketReceiptAbsenceSignBytes( diversifier string, path commitmenttypes.MerklePath, // nolint: interfacer ) ([]byte, error) { - data := &PacketAcknowledgementAbsenseData{ + data := &PacketReceiptAbsenseData{ Path: []byte(path.String()), } diff --git a/x/ibc/light-clients/solomachine/types/solomachine.pb.go b/x/ibc/light-clients/solomachine/types/solomachine.pb.go index 2572986f4bc9..7eb466d9e820 100644 --- a/x/ibc/light-clients/solomachine/types/solomachine.pb.go +++ b/x/ibc/light-clients/solomachine/types/solomachine.pb.go @@ -632,23 +632,23 @@ func (m *PacketAcknowledgementData) GetAcknowledgement() []byte { } // PacketReceiptAbsenceSignBytes returns the SignBytes data for -// acknowledgement absence verification. -type PacketAcknowledgementAbsenseData struct { +// 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) @@ -658,19 +658,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 } @@ -746,7 +746,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") } @@ -755,71 +755,71 @@ func init() { } var fileDescriptor_6cc2ee18f7f86d4e = []byte{ - // 1012 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, 0x6d, 0xf1, 0x66, 0x97, 0xb4, 0x40, 0x1c, 0xf9, 0x00, - 0xbd, 0xac, 0xad, 0x2c, 0x12, 0x87, 0x0a, 0x0e, 0x49, 0x16, 0x09, 0xca, 0xbf, 0xca, 0xdd, 0x95, - 0x58, 0xb4, 0x92, 0x35,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 0xa1, 0xcf, 0x46, 0x13, 0xc7, 0x70, 0xe9, 0xd8, 0x94, 0xad, 0x9f, 0x18, - 0x1e, 0xc4, 0xde, 0xb9, 0x79, 0x61, 0xae, 0x5a, 0xcc, 0x07, 0x2f, 0xea, 0x31, 0xd9, 0x3c, 0xc4, - 0xb1, 0x73, 0x9b, 0x27, 0xed, 0xbb, 0xff, 0x04, 0x00, 0x00, 0xff, 0xff, 0x7f, 0x34, 0x99, 0x52, - 0x90, 0x0a, 0x00, 0x00, + // 1016 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x56, 0xcf, 0x6f, 0xe3, 0xc4, + 0x17, 0xaf, 0xb3, 0xf9, 0xee, 0xb7, 0x79, 0xc9, 0xb6, 0xc5, 0x9b, 0x5d, 0xd2, 0x02, 0x71, 0xe5, + 0x03, 0xf4, 0xb2, 0xb6, 0xb2, 0xdc, 0x2a, 0x38, 0x24, 0x59, 0x24, 0x28, 0xbf, 0x2a, 0x77, 0x57, + 0x62, 0xd1, 0x4a, 0xd6, 0xd8, 0x7e, 0x4d, 0xac, 0x3a, 0x33, 0xc6, 0x9e, 0x24, 0x0d, 0x12, 0x07, + 0x38, 0xc1, 0x8d, 0x23, 0x47, 0x84, 0xc4, 0xff, 0x82, 0xc4, 0x65, 0xb9, 0x71, 0x8a, 0x50, 0xfb, + 0x1f, 0xe4, 0x2f, 0x40, 0xf6, 0x8c, 0x13, 0xdb, 0x25, 0xa9, 0xf8, 0x71, 0x9a, 0x1f, 0xef, 0xcd, + 0xe7, 0xbd, 0xf7, 0x99, 0xf7, 0x66, 0x1e, 0x74, 0x7c, 0xc7, 0x35, 0x03, 0x7f, 0x30, 0xe4, 0x6e, + 0xe0, 0x23, 0xe5, 0xb1, 0x19, 0xb3, 0x80, 0x8d, 0x88, 0x3b, 0xf4, 0x29, 0x9a, 0x93, 0x4e, 0x7e, + 0x69, 0x84, 0x11,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xa3, 0x3f, 0x87, + 0x7d, 0x81, 0xd5, 0x75, 0x2f, 0x28, 0x9b, 0x06, 0xe8, 0x0d, 0x70, 0x23, 0xe0, 0x11, 0xec, 0x92, + 0xa2, 0xaa, 0x44, 0x2d, 0x6f, 0xeb, 0x06, 0xb4, 0x04, 0xb4, 0x85, 0x2e, 0xfa, 0x21, 0xef, 0x3a, + 0xc9, 0xc5, 0xac, 0x25, 0x43, 0x1f, 0x42, 0xf3, 0x13, 0xbc, 0xe4, 0x59, 0xb3, 0x61, 0xa1, 0x3b, + 0x59, 0xeb, 0xc5, 0x3b, 0x70, 0x8f, 0xe2, 0x25, 0x4f, 0x5a, 0x15, 0x3b, 0x42, 0x77, 0x22, 0x7b, + 0x99, 0xdc, 0xb3, 0x57, 0x10, 0xeb, 0x56, 0x9d, 0x0a, 0xe8, 0x04, 0xb5, 0xf7, 0xe2, 0x97, 0xab, + 0xb6, 0xf2, 0xf2, 0xaa, 0xad, 0xfc, 0x71, 0xd5, 0x56, 0xbe, 0xbf, 0x6e, 0x6f, 0xbd, 0xbc, 0x6e, + 0x6f, 0xfd, 0x7e, 0xdd, 0xde, 0xfa, 0xbc, 0x37, 0xf0, 0xf9, 0x70, 0xec, 0x18, 0x2e, 0x1b, 0x99, + 0xb2, 0xe5, 0x13, 0xc3, 0xa3, 0xd8, 0xbb, 0x30, 0x2f, 0xcd, 0x65, 0x6b, 0xf9, 0xe8, 0xaf, 0x7a, + 0x4b, 0x3e, 0x0b, 0x31, 0x76, 0xee, 0xa6, 0xc9, 0xfa, 0xf6, 0x9f, 0x01, 0x00, 0x00, 0xff, 0xff, + 0xbe, 0x55, 0xd1, 0xb7, 0x88, 0x0a, 0x00, 0x00, } func (m *ClientState) Marshal() (dAtA []byte, err error) { @@ -1445,7 +1445,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]) @@ -1455,12 +1455,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 @@ -1789,7 +1789,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 } @@ -3719,7 +3719,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 { @@ -3742,10 +3742,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: From 106f04caae7aae879f865044b237a2b3e8076eb4 Mon Sep 17 00:00:00 2001 From: Federico Kunze Date: Tue, 29 Sep 2020 11:52:31 +0200 Subject: [PATCH 07/15] rename ReceiveExecuted -> WriteReceipt --- x/ibc/03-connection/keeper/verify_test.go | 6 +++--- x/ibc/04-channel/keeper/packet.go | 6 +++--- x/ibc/04-channel/keeper/packet_test.go | 18 +++++++++--------- x/ibc/07-tendermint/types/client_state_test.go | 4 ++-- x/ibc/handler.go | 2 +- x/ibc/handler_test.go | 18 +++++++++--------- x/ibc/testing/chain.go | 6 +++--- x/ibc/testing/coordinator.go | 6 +++--- 8 files changed, 33 insertions(+), 33 deletions(-) diff --git a/x/ibc/03-connection/keeper/verify_test.go b/x/ibc/03-connection/keeper/verify_test.go index fd9f940eefe0..54e7d48618e5 100644 --- a/x/ibc/03-connection/keeper/verify_test.go +++ b/x/ibc/03-connection/keeper/verify_test.go @@ -336,7 +336,7 @@ 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) packetAckKey := host.KeyPacketAcknowledgement(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence()) @@ -396,7 +396,7 @@ func (suite *KeeperTestSuite) TestVerifyPacketReceiptAbsence() { 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 @@ -455,7 +455,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/packet.go b/x/ibc/04-channel/keeper/packet.go index 6607c7d7215a..5a94f62d2f1a 100644 --- a/x/ibc/04-channel/keeper/packet.go +++ b/x/ibc/04-channel/keeper/packet.go @@ -238,15 +238,15 @@ 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 updates the receive sequence in the case of an ordered channel or sets an empty receipt +// 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, diff --git a/x/ibc/04-channel/keeper/packet_test.go b/x/ibc/04-channel/keeper/packet_test.go index e3b1ea200881..4987e7ed2b6a 100644 --- a/x/ibc/04-channel/keeper/packet_test.go +++ b/x/ibc/04-channel/keeper/packet_test.go @@ -287,7 +287,7 @@ func (suite *KeeperTestSuite) TestRecvPacket() { suite.coordinator.SendPacket(suite.chainA, suite.chainB, packet, clientB) // write packet acknowledgement - suite.coordinator.ReceiveExecuted(suite.chainB, suite.chainA, packet, clientA) + suite.coordinator.WriteReceipt(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) @@ -335,8 +335,8 @@ 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 @@ -409,7 +409,7 @@ func (suite *KeeperTestSuite) TestReceiveExecuted() { tc.malleate() - err := suite.chainB.App.IBCKeeper.ChannelKeeper.ReceiveExecuted(suite.chainB.GetContext(), channelCap, packet) + err := suite.chainB.App.IBCKeeper.ChannelKeeper.WriteReceipt(suite.chainB.GetContext(), channelCap, packet) if tc.expPass { suite.Require().NoError(err) @@ -439,7 +439,7 @@ 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) }, true}, {"success on unordered channel", func() { @@ -452,7 +452,7 @@ 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) }, true}, {"channel not found", func() { @@ -542,7 +542,7 @@ 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) // set next sequence ack wrong @@ -589,7 +589,7 @@ func (suite *KeeperTestSuite) TestAcknowledgementExecuted() { 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) chanCap = suite.chainA.GetChannelCapability(channelA.PortID, channelA.ID) @@ -605,7 +605,7 @@ func (suite *KeeperTestSuite) TestAcknowledgementExecuted() { 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) chanCap = suite.chainA.GetChannelCapability(channelA.PortID, channelA.ID) diff --git a/x/ibc/07-tendermint/types/client_state_test.go b/x/ibc/07-tendermint/types/client_state_test.go index b01e7dfb5c99..34e1201352c1 100644 --- a/x/ibc/07-tendermint/types/client_state_test.go +++ b/x/ibc/07-tendermint/types/client_state_test.go @@ -460,7 +460,7 @@ func (suite *TendermintTestSuite) TestVerifyPacketAcknowledgement() { suite.Require().NoError(err) // write ack - err = suite.coordinator.ReceiveExecuted(suite.chainB, suite.chainA, packet, clientA) + err = suite.coordinator.WriteReceipt(suite.chainB, suite.chainA, packet, clientA) suite.Require().NoError(err) var ok bool @@ -635,7 +635,7 @@ func (suite *TendermintTestSuite) TestVerifyNextSeqRecv() { suite.Require().NoError(err) // write ack, next seq recv incremented - err = suite.coordinator.ReceiveExecuted(suite.chainB, suite.chainA, packet, clientA) + 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/handler.go b/x/ibc/handler.go index caa5709bdd6e..65ca316d83a6 100644 --- a/x/ibc/handler.go +++ b/x/ibc/handler.go @@ -192,7 +192,7 @@ func NewHandler(k keeper.Keeper) sdk.Handler { return nil, sdkerrors.Wrap(err, "receive packet callback failed") } - if err := k.ChannelKeeper.ReceiveExecuted(ctx, cap, msg.Packet); err != nil { + if err := k.ChannelKeeper.WriteReceipt(ctx, cap, msg.Packet); err != nil { return nil, err } diff --git a/x/ibc/handler_test.go b/x/ibc/handler_test.go index 08b3843de261..2ab85c87a526 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,7 @@ 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) }, true}, {"success: UNORDERED", func() { @@ -189,7 +189,7 @@ 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) }, true}, {"success: UNORDERED acknowledge out of order packet", func() { @@ -203,7 +203,7 @@ 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) } @@ -218,7 +218,7 @@ 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) } }, false}, @@ -240,7 +240,7 @@ 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.AcknowledgementExecuted(suite.chainA, suite.chainB, packet, clientB) @@ -254,7 +254,7 @@ 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.AcknowledgementExecuted(suite.chainA, suite.chainB, packet, clientB) diff --git a/x/ibc/testing/chain.go b/x/ibc/testing/chain.go index 36bcd741e131..7cbf32193983 100644 --- a/x/ibc/testing/chain.go +++ b/x/ibc/testing/chain.go @@ -791,14 +791,14 @@ 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 an acknowledgement 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) + err := chain.App.IBCKeeper.ChannelKeeper.WriteReceipt(chain.GetContext(), channelCap, packet) if err != nil { return err } diff --git a/x/ibc/testing/coordinator.go b/x/ibc/testing/coordinator.go index 71f27980f90a..cc31340cf3ad 100644 --- a/x/ibc/testing/coordinator.go +++ b/x/ibc/testing/coordinator.go @@ -247,14 +247,14 @@ 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 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() From 4021b0a8aa55bf8c0089702ab622e6764f011329 Mon Sep 17 00:00:00 2001 From: Federico Kunze Date: Tue, 29 Sep 2020 12:31:00 +0200 Subject: [PATCH 08/15] tests --- x/ibc/04-channel/keeper/keeper_test.go | 9 +-- x/ibc/04-channel/keeper/packet.go | 14 ++--- x/ibc/04-channel/keeper/packet_test.go | 85 ++++++++++++++++++++------ x/ibc/testing/chain.go | 19 +++++- x/ibc/testing/coordinator.go | 21 ++++++- 5 files changed, 115 insertions(+), 33 deletions(-) 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 5a94f62d2f1a..e66999c05b6d 100644 --- a/x/ibc/04-channel/keeper/packet.go +++ b/x/ibc/04-channel/keeper/packet.go @@ -201,8 +201,9 @@ func (k Keeper) RecvPacket( ) } - // check if the packet acknowledgement has been received already for unordered channels - if channel.Ordering == types.UNORDERED { + switch channel.Ordering { + case types.UNORDERED: + // check if the packet acknowledgement has been received already for unordered channels _, found := k.GetPacketAcknowledgement(ctx, packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence()) if found { return sdkerrors.Wrapf( @@ -210,10 +211,9 @@ func (k Keeper) RecvPacket( "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( @@ -283,7 +283,7 @@ func (k Keeper) WriteReceipt( 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) } else { @@ -506,7 +506,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 4987e7ed2b6a..b731e27f50fc 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.WriteReceipt(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) @@ -340,7 +331,6 @@ func (suite *KeeperTestSuite) TestWriteReceipt() { var ( packet types.Packet channelCap *capabilitytypes.Capability - ack []byte ) testCases := []testCase{ @@ -391,21 +381,19 @@ func (suite *KeeperTestSuite) TestWriteReceipt() { 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() @@ -413,9 +401,60 @@ func (suite *KeeperTestSuite) TestWriteReceipt() { 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) + } + }) + } +} + +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) + }, + true, + }, + { + "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) } else { suite.Require().Error(err) } @@ -438,9 +477,12 @@ func (suite *KeeperTestSuite) TestAcknowledgePacket() { err := suite.coordinator.SendPacket(suite.chainA, suite.chainB, packet, clientB) suite.Require().NoError(err) - // create packet acknowledgement + // 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() { // setup uses an UNORDERED channel @@ -451,9 +493,12 @@ func (suite *KeeperTestSuite) TestAcknowledgePacket() { err := suite.coordinator.SendPacket(suite.chainA, suite.chainB, packet, clientB) suite.Require().NoError(err) - // create packet acknowledgement + // 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() { // use wrong channel naming diff --git a/x/ibc/testing/chain.go b/x/ibc/testing/chain.go index 7cbf32193983..4d18d2cf95b5 100644 --- a/x/ibc/testing/chain.go +++ b/x/ibc/testing/chain.go @@ -791,7 +791,7 @@ func (chain *TestChain) SendPacket( return nil } -// WriteReceipt simulates receiving and writing an acknowledgement to the chain. +// WriteReceipt simulates receiving and writing a receipt to the chain. func (chain *TestChain) WriteReceipt( packet exported.PacketI, ) error { @@ -810,6 +810,23 @@ func (chain *TestChain) WriteReceipt( 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 + } + + // commit changes + chain.App.Commit() + chain.NextBlock() + + return nil +} + // AcknowledgementExecuted simulates deleting a packet commitment with the // given packet sequence. func (chain *TestChain) AcknowledgementExecuted( diff --git a/x/ibc/testing/coordinator.go b/x/ibc/testing/coordinator.go index cc31340cf3ad..8b5886cb4340 100644 --- a/x/ibc/testing/coordinator.go +++ b/x/ibc/testing/coordinator.go @@ -247,7 +247,7 @@ func (coord *Coordinator) RecvPacket( return coord.SendMsgs(counterparty, source, sourceClient, []sdk.Msg{recvMsg}) } -// WriteReceipt 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) WriteReceipt( source, counterparty *TestChain, @@ -266,6 +266,25 @@ func (coord *Coordinator) WriteReceipt( ) } +// 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() + + // update source client on counterparty connection + return coord.UpdateClient( + counterparty, source, + counterpartyClientID, Tendermint, + ) +} + // AcknowledgePacket acknowledges on the source chain the packet received on // the counterparty chain and updates the client on the counterparty representing // the source chain. From c73075a8a182d2e04f57bfb1936cbc051aa7d0f6 Mon Sep 17 00:00:00 2001 From: Federico Kunze Date: Tue, 29 Sep 2020 12:53:09 +0200 Subject: [PATCH 09/15] fix tests --- x/ibc/03-connection/keeper/verify_test.go | 3 +++ x/ibc/07-tendermint/types/client_state_test.go | 11 +++++++---- x/ibc/09-localhost/types/client_state_test.go | 2 +- x/ibc/handler_test.go | 17 +++++++++++++++++ .../solomachine/types/client_state_test.go | 2 +- 5 files changed, 29 insertions(+), 6 deletions(-) diff --git a/x/ibc/03-connection/keeper/verify_test.go b/x/ibc/03-connection/keeper/verify_test.go index 54e7d48618e5..9749325a7072 100644 --- a/x/ibc/03-connection/keeper/verify_test.go +++ b/x/ibc/03-connection/keeper/verify_test.go @@ -339,6 +339,9 @@ func (suite *KeeperTestSuite) TestVerifyPacketAcknowledgement() { 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()) proof, proofHeight := suite.chainB.QueryProof(packetAckKey) diff --git a/x/ibc/07-tendermint/types/client_state_test.go b/x/ibc/07-tendermint/types/client_state_test.go index 34e1201352c1..5bdcdd920c7b 100644 --- a/x/ibc/07-tendermint/types/client_state_test.go +++ b/x/ibc/07-tendermint/types/client_state_test.go @@ -459,10 +459,13 @@ func (suite *TendermintTestSuite) TestVerifyPacketAcknowledgement() { err := suite.coordinator.SendPacket(suite.chainA, suite.chainB, packet, clientB) suite.Require().NoError(err) - // write ack + // 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 clientStateI := suite.chainA.GetClientState(clientA) clientState, ok = clientStateI.(*types.ClientState) @@ -557,9 +560,9 @@ func (suite *TendermintTestSuite) TestVerifyPacketReceiptAbsence() { 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 diff --git a/x/ibc/09-localhost/types/client_state_test.go b/x/ibc/09-localhost/types/client_state_test.go index 13cfae890d05..af8eff53f94b 100644 --- a/x/ibc/09-localhost/types/client_state_test.go +++ b/x/ibc/09-localhost/types/client_state_test.go @@ -416,7 +416,7 @@ func (suite *LocalhostTestSuite) TestVerifyPacketReceiptAbsence() { 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.VerifyPacketReceiptAbsence( suite.store, suite.cdc, clientHeight, nil, nil, testPortID, testChannelID, testSequence, diff --git a/x/ibc/handler_test.go b/x/ibc/handler_test.go index 2ab85c87a526..8a88d4872c3a 100644 --- a/x/ibc/handler_test.go +++ b/x/ibc/handler_test.go @@ -181,6 +181,9 @@ func (suite *HandlerTestSuite) TestHandleAcknowledgePacket() { 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() { clientA, clientB, _, _, channelA, channelB := suite.coordinator.Setup(suite.chainA, suite.chainB, channeltypes.UNORDERED) @@ -191,6 +194,9 @@ func (suite *HandlerTestSuite) TestHandleAcknowledgePacket() { 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() { // setup uses an UNORDERED channel @@ -206,6 +212,8 @@ func (suite *HandlerTestSuite) TestHandleAcknowledgePacket() { 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() { @@ -220,6 +228,9 @@ func (suite *HandlerTestSuite) TestHandleAcknowledgePacket() { 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}, {"channel does not exist", func() { @@ -243,6 +254,9 @@ func (suite *HandlerTestSuite) TestHandleAcknowledgePacket() { 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) suite.Require().NoError(err) }, false}, @@ -257,6 +271,9 @@ func (suite *HandlerTestSuite) TestHandleAcknowledgePacket() { 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) suite.Require().NoError(err) }, false}, diff --git a/x/ibc/light-clients/solomachine/types/client_state_test.go b/x/ibc/light-clients/solomachine/types/client_state_test.go index f8ae5e276c28..7e99b96881f2 100644 --- a/x/ibc/light-clients/solomachine/types/client_state_test.go +++ b/x/ibc/light-clients/solomachine/types/client_state_test.go @@ -701,7 +701,7 @@ 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.PacketReceiptAbsenceSignBytes(suite.chainA.Codec, solomachine.Sequence, solomachine.Time, solomachine.Diversifier, path) From f35f237d2f739eca0290797bf7c7b3833d675f68 Mon Sep 17 00:00:00 2001 From: Federico Kunze <31522760+fedekunze@users.noreply.github.com> Date: Tue, 29 Sep 2020 15:09:30 +0200 Subject: [PATCH 10/15] Apply suggestions from code review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: colin axnér <25233464+colin-axner@users.noreply.github.com> --- x/ibc/03-connection/keeper/verify.go | 2 +- x/ibc/03-connection/keeper/verify_test.go | 2 +- x/ibc/04-channel/keeper/packet.go | 2 +- x/ibc/04-channel/types/errors.go | 2 +- x/ibc/07-tendermint/types/client_state.go | 2 +- x/ibc/handler.go | 4 ++-- x/ibc/light-clients/solomachine/types/proof.go | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/x/ibc/03-connection/keeper/verify.go b/x/ibc/03-connection/keeper/verify.go index c7d39ec0970b..72d50c13f47d 100644 --- a/x/ibc/03-connection/keeper/verify.go +++ b/x/ibc/03-connection/keeper/verify.go @@ -176,7 +176,7 @@ func (k Keeper) VerifyPacketAcknowledgement( } // VerifyPacketReceiptAbsence verifies a proof of the absence of an -// incoming packet acknowledgement at the specified port, specified channel, and +// incoming packet receipt at the specified port, specified channel, and // specified sequence. func (k Keeper) VerifyPacketReceiptAbsence( ctx sdk.Context, diff --git a/x/ibc/03-connection/keeper/verify_test.go b/x/ibc/03-connection/keeper/verify_test.go index 9749325a7072..216828cfeaf9 100644 --- a/x/ibc/03-connection/keeper/verify_test.go +++ b/x/ibc/03-connection/keeper/verify_test.go @@ -364,7 +364,7 @@ func (suite *KeeperTestSuite) TestVerifyPacketAcknowledgement() { } } -// TestVerifyPacketReceiptAbsence 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) TestVerifyPacketReceiptAbsence() { diff --git a/x/ibc/04-channel/keeper/packet.go b/x/ibc/04-channel/keeper/packet.go index e66999c05b6d..12207f255d3a 100644 --- a/x/ibc/04-channel/keeper/packet.go +++ b/x/ibc/04-channel/keeper/packet.go @@ -302,7 +302,7 @@ func (k Keeper) WriteReceipt( } // log that a packet has been received & executed - k.Logger(ctx).Info("packet received and executed", "packet", fmt.Sprintf("%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{ diff --git a/x/ibc/04-channel/types/errors.go b/x/ibc/04-channel/types/errors.go index a1a6b38f3632..ae18a328b20b 100644 --- a/x/ibc/04-channel/types/errors.go +++ b/x/ibc/04-channel/types/errors.go @@ -23,5 +23,5 @@ var ( ErrAcknowledgementTooLong = sdkerrors.Register(SubModuleName, 16, "acknowledgement too long") ErrInvalidAcknowledgement = sdkerrors.Register(SubModuleName, 17, "invalid acknowledgement") ErrPacketCommitmentNotFound = sdkerrors.Register(SubModuleName, 18, "packet commitment not found") - ErrPacketReceived = sdkerrors.Register(SubModuleName, 19, "packet receipt already received") + ErrPacketReceived = sdkerrors.Register(SubModuleName, 19, "packet already received") ) diff --git a/x/ibc/07-tendermint/types/client_state.go b/x/ibc/07-tendermint/types/client_state.go index 67a4df21438c..e14171021d6a 100644 --- a/x/ibc/07-tendermint/types/client_state.go +++ b/x/ibc/07-tendermint/types/client_state.go @@ -344,7 +344,7 @@ func (cs ClientState) VerifyPacketAcknowledgement( } // VerifyPacketReceiptAbsence verifies a proof of the absence of an -// incoming packet acknowledgement at the specified port, specified channel, and +// incoming packet receipt at the specified port, specified channel, and // specified sequence. func (cs ClientState) VerifyPacketReceiptAbsence( store sdk.KVStore, diff --git a/x/ibc/handler.go b/x/ibc/handler.go index 65ca316d83a6..613bb3fda264 100644 --- a/x/ibc/handler.go +++ b/x/ibc/handler.go @@ -197,8 +197,8 @@ func NewHandler(k keeper.Keeper) sdk.Handler { } // Set packet acknowledgement only if the acknowledgement is not nil. - // NOTE: IBC applications modules will have to call the WriteAcknowledgement asynchronously if this - // is the case. + // NOTE: IBC applications modules will have to 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 diff --git a/x/ibc/light-clients/solomachine/types/proof.go b/x/ibc/light-clients/solomachine/types/proof.go index e767256c7da3..e7f715ad91bd 100644 --- a/x/ibc/light-clients/solomachine/types/proof.go +++ b/x/ibc/light-clients/solomachine/types/proof.go @@ -288,7 +288,7 @@ func PacketAcknowledgementSignBytes( } // PacketReceiptAbsenceSignBytes returns the sign bytes for verification -// of the absence of an acknowledgement. +// of the absence of a receipt. func PacketReceiptAbsenceSignBytes( cdc codec.BinaryMarshaler, sequence, timestamp uint64, From 98865b9510c8e4d2b43ef750648a039123c88f0d Mon Sep 17 00:00:00 2001 From: Federico Kunze <31522760+fedekunze@users.noreply.github.com> Date: Tue, 29 Sep 2020 22:52:15 +0200 Subject: [PATCH 11/15] Update x/ibc/07-tendermint/types/client_state_test.go Co-authored-by: Aditya --- x/ibc/07-tendermint/types/client_state_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x/ibc/07-tendermint/types/client_state_test.go b/x/ibc/07-tendermint/types/client_state_test.go index 5bdcdd920c7b..a601566ea7c8 100644 --- a/x/ibc/07-tendermint/types/client_state_test.go +++ b/x/ibc/07-tendermint/types/client_state_test.go @@ -637,7 +637,7 @@ func (suite *TendermintTestSuite) TestVerifyNextSeqRecv() { err := suite.coordinator.SendPacket(suite.chainA, suite.chainB, packet, clientB) suite.Require().NoError(err) - // write ack, next seq recv incremented + // write receipt, next seq recv incremented err = suite.coordinator.WriteReceipt(suite.chainB, suite.chainA, packet, clientA) suite.Require().NoError(err) From 3d5121dca14b1726ae93ee92a640c31244b317ca Mon Sep 17 00:00:00 2001 From: Federico Kunze Date: Tue, 29 Sep 2020 22:52:32 +0200 Subject: [PATCH 12/15] comments from review --- x/ibc/04-channel/keeper/packet.go | 16 +++++++++++----- x/ibc/04-channel/keeper/packet_test.go | 13 +++++++++++-- x/ibc/04-channel/types/errors.go | 8 ++++---- x/ibc/07-tendermint/types/client_state_test.go | 2 +- x/ibc/24-host/keys.go | 3 ++- x/ibc/handler.go | 2 +- 6 files changed, 30 insertions(+), 14 deletions(-) diff --git a/x/ibc/04-channel/keeper/packet.go b/x/ibc/04-channel/keeper/packet.go index 12207f255d3a..ef2008ce796b 100644 --- a/x/ibc/04-channel/keeper/packet.go +++ b/x/ibc/04-channel/keeper/packet.go @@ -272,7 +272,8 @@ func (k Keeper) WriteReceipt( ) } - 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( @@ -286,7 +287,8 @@ func (k Keeper) WriteReceipt( // 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) - } else { + + 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 @@ -330,9 +332,13 @@ func (k Keeper) WriteReceipt( // WriteAcknowledgement writes the packet execution acknowledgement to the state, // which will be verified by the counterparty chain using AcknowledgePacket. // -// CONTRACT: for synchronous execution, this function is be called in the IBC handler . +// 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, @@ -340,9 +346,9 @@ func (k Keeper) WriteAcknowledgement( ) 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 perform a no-op if so. + // set on the store and return an error if so. if k.HasPacketAcknowledgement(ctx, packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence()) { - return nil + return types.ErrAcknowledgementExists } if len(acknowledgement) == 0 { diff --git a/x/ibc/04-channel/keeper/packet_test.go b/x/ibc/04-channel/keeper/packet_test.go index b731e27f50fc..3fc37a9bbeaa 100644 --- a/x/ibc/04-channel/keeper/packet_test.go +++ b/x/ibc/04-channel/keeper/packet_test.go @@ -590,6 +590,9 @@ func (suite *KeeperTestSuite) TestAcknowledgePacket() { 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 suite.chainA.App.IBCKeeper.ChannelKeeper.SetNextSequenceAck(suite.chainA.GetContext(), channelA.PortID, channelA.ID, 10) }, false}, @@ -633,10 +636,13 @@ func (suite *KeeperTestSuite) TestAcknowledgementExecuted() { err := suite.coordinator.SendPacket(suite.chainA, suite.chainB, packet, clientB) suite.Require().NoError(err) - // create packet acknowledgement + // 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) }, true}, @@ -649,10 +655,13 @@ func (suite *KeeperTestSuite) TestAcknowledgementExecuted() { err := suite.coordinator.SendPacket(suite.chainA, suite.chainB, packet, clientB) suite.Require().NoError(err) - // create packet acknowledgement + // 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) }, true}, {"channel not found", func() { diff --git a/x/ibc/04-channel/types/errors.go b/x/ibc/04-channel/types/errors.go index ae18a328b20b..075adad6858c 100644 --- a/x/ibc/04-channel/types/errors.go +++ b/x/ibc/04-channel/types/errors.go @@ -20,8 +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") - ErrPacketReceived = sdkerrors.Register(SubModuleName, 19, "packet already received") + 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/07-tendermint/types/client_state_test.go b/x/ibc/07-tendermint/types/client_state_test.go index 5bdcdd920c7b..a601566ea7c8 100644 --- a/x/ibc/07-tendermint/types/client_state_test.go +++ b/x/ibc/07-tendermint/types/client_state_test.go @@ -637,7 +637,7 @@ func (suite *TendermintTestSuite) TestVerifyNextSeqRecv() { err := suite.coordinator.SendPacket(suite.chainA, suite.chainB, packet, clientB) suite.Require().NoError(err) - // write ack, next seq recv incremented + // write receipt, next seq recv incremented err = suite.coordinator.WriteReceipt(suite.chainB, suite.chainA, packet, clientA) suite.Require().NoError(err) diff --git a/x/ibc/24-host/keys.go b/x/ibc/24-host/keys.go index 97dbde0cbbf7..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 @@ -165,7 +166,7 @@ func PacketAcknowledgementPath(portID, channelID string, sequence uint64) string // PacketReceiptPath defines the packet receipt store path func PacketReceiptPath(portID, channelID string, sequence uint64) string { - return fmt.Sprintf("%s/", KeyPacketAckPrefix) + channelPath(portID, channelID) + fmt.Sprintf("/receipts/%d", sequence) + return fmt.Sprintf("%s/", KeyPacketReceiptPrefix) + channelPath(portID, channelID) + fmt.Sprintf("/receipts/%d", sequence) } // KeyChannel returns the store key for a particular channel diff --git a/x/ibc/handler.go b/x/ibc/handler.go index 613bb3fda264..72c8f8723049 100644 --- a/x/ibc/handler.go +++ b/x/ibc/handler.go @@ -197,7 +197,7 @@ func NewHandler(k keeper.Keeper) sdk.Handler { } // Set packet acknowledgement only if the acknowledgement is not nil. - // NOTE: IBC applications modules will have to call the WriteAcknowledgement asynchronously if the + // 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 { From 4f8847c77cbd397a474ae618f0e2fc123a29b552 Mon Sep 17 00:00:00 2001 From: Federico Kunze Date: Tue, 29 Sep 2020 22:57:00 +0200 Subject: [PATCH 13/15] update RecvPacket --- x/ibc/04-channel/keeper/packet.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/x/ibc/04-channel/keeper/packet.go b/x/ibc/04-channel/keeper/packet.go index ef2008ce796b..42abff725975 100644 --- a/x/ibc/04-channel/keeper/packet.go +++ b/x/ibc/04-channel/keeper/packet.go @@ -203,8 +203,8 @@ func (k Keeper) RecvPacket( switch channel.Ordering { case types.UNORDERED: - // check if the packet acknowledgement has been received already for unordered channels - _, found := k.GetPacketAcknowledgement(ctx, packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence()) + // 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, From 3b328277bc7aeb99ea3432d880a6b6ca4b155be6 Mon Sep 17 00:00:00 2001 From: Federico Kunze Date: Tue, 29 Sep 2020 23:07:34 +0200 Subject: [PATCH 14/15] spec typo --- x/ibc/spec/01_concepts.md | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) 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. - From 8d2368c4f5458a13c5499ba597a1bfbb7ed93a79 Mon Sep 17 00:00:00 2001 From: Federico Kunze Date: Wed, 30 Sep 2020 15:35:59 +0200 Subject: [PATCH 15/15] test fixes --- x/ibc/03-connection/keeper/verify.go | 2 +- x/ibc/03-connection/keeper/verify_test.go | 4 ++-- x/ibc/04-channel/keeper/packet_test.go | 2 +- x/ibc/04-channel/keeper/timeout_test.go | 4 ++-- x/ibc/handler_test.go | 18 +++++------------- 5 files changed, 11 insertions(+), 19 deletions(-) diff --git a/x/ibc/03-connection/keeper/verify.go b/x/ibc/03-connection/keeper/verify.go index 72d50c13f47d..4c2ab3f81a7d 100644 --- a/x/ibc/03-connection/keeper/verify.go +++ b/x/ibc/03-connection/keeper/verify.go @@ -197,7 +197,7 @@ func (k Keeper) VerifyPacketReceiptAbsence( 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 216828cfeaf9..50d394ade05f 100644 --- a/x/ibc/03-connection/keeper/verify_test.go +++ b/x/ibc/03-connection/keeper/verify_test.go @@ -407,8 +407,8 @@ func (suite *KeeperTestSuite) TestVerifyPacketReceiptAbsence() { 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.VerifyPacketReceiptAbsence( suite.chainA.GetContext(), connection, malleateHeight(proofHeight, tc.heightDiff), proof, diff --git a/x/ibc/04-channel/keeper/packet_test.go b/x/ibc/04-channel/keeper/packet_test.go index 3fc37a9bbeaa..f0fa67e4b899 100644 --- a/x/ibc/04-channel/keeper/packet_test.go +++ b/x/ibc/04-channel/keeper/packet_test.go @@ -432,7 +432,7 @@ func (suite *KeeperTestSuite) TestWriteAcknowledgement() { ack = ibctesting.TestHash suite.chainB.App.IBCKeeper.ChannelKeeper.SetPacketAcknowledgement(suite.chainB.GetContext(), packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence(), ack) }, - true, + false, }, { "empty acknowledgement", 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/handler_test.go b/x/ibc/handler_test.go index 8a88d4872c3a..b217f37bb994 100644 --- a/x/ibc/handler_test.go +++ b/x/ibc/handler_test.go @@ -355,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 @@ -372,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) @@ -401,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}, } @@ -476,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) @@ -494,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 @@ -517,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) @@ -550,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 @@ -570,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) @@ -589,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}, }