Rename PacketExecuted to ReceiveExecuted (#7206)

* update ibc-transfer

* rename PacketExecuted -> ReceiveExecuted
This commit is contained in:
colin axnér 2020-08-31 17:36:01 +02:00 committed by GitHub
parent 843bd24bca
commit fc75d14c88
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 37 additions and 37 deletions

View File

@ -72,15 +72,15 @@ func (k Keeper) GetTransferAccount(ctx sdk.Context) authtypes.ModuleAccountI {
return k.authKeeper.GetModuleAccount(ctx, types.ModuleName) return k.authKeeper.GetModuleAccount(ctx, types.ModuleName)
} }
// PacketExecuted defines a wrapper function for the channel Keeper's function // ReceiveExecuted defines a wrapper function for the channel Keeper's function
// in order to expose it to the ICS20 transfer handler. // in order to expose it to the ICS20 transfer handler.
// Keeper retrieves channel capability and passes it into channel keeper for authentication // Keeper retrieves channel capability and passes it into channel keeper for authentication
func (k Keeper) PacketExecuted(ctx sdk.Context, packet channelexported.PacketI, acknowledgement []byte) error { func (k Keeper) ReceiveExecuted(ctx sdk.Context, packet channelexported.PacketI, acknowledgement []byte) error {
chanCap, ok := k.scopedKeeper.GetCapability(ctx, host.ChannelCapabilityPath(packet.GetDestPort(), packet.GetDestChannel())) chanCap, ok := k.scopedKeeper.GetCapability(ctx, host.ChannelCapabilityPath(packet.GetDestPort(), packet.GetDestChannel()))
if !ok { if !ok {
return sdkerrors.Wrap(channeltypes.ErrChannelCapabilityNotFound, "channel capability could not be retrieved for packet") return sdkerrors.Wrap(channeltypes.ErrChannelCapabilityNotFound, "channel capability could not be retrieved for packet")
} }
return k.channelKeeper.PacketExecuted(ctx, chanCap, packet, acknowledgement) return k.channelKeeper.ReceiveExecuted(ctx, chanCap, packet, acknowledgement)
} }
// ChanCloseInit defines a wrapper function for the channel Keeper's function // ChanCloseInit defines a wrapper function for the channel Keeper's function

View File

@ -30,7 +30,7 @@ type ChannelKeeper interface {
GetChannel(ctx sdk.Context, srcPort, srcChan string) (channel channeltypes.Channel, found bool) GetChannel(ctx sdk.Context, srcPort, srcChan string) (channel channeltypes.Channel, found bool)
GetNextSequenceSend(ctx sdk.Context, portID, channelID string) (uint64, bool) GetNextSequenceSend(ctx sdk.Context, portID, channelID string) (uint64, bool)
SendPacket(ctx sdk.Context, channelCap *capabilitytypes.Capability, packet channelexported.PacketI) error SendPacket(ctx sdk.Context, channelCap *capabilitytypes.Capability, packet channelexported.PacketI) error
PacketExecuted(ctx sdk.Context, chanCap *capabilitytypes.Capability, packet channelexported.PacketI, acknowledgement []byte) error ReceiveExecuted(ctx sdk.Context, chanCap *capabilitytypes.Capability, packet channelexported.PacketI, acknowledgement []byte) error
ChanCloseInit(ctx sdk.Context, portID, channelID string, chanCap *capabilitytypes.Capability) error ChanCloseInit(ctx sdk.Context, portID, channelID string, chanCap *capabilitytypes.Capability) error
} }

View File

@ -332,7 +332,7 @@ func (suite *KeeperTestSuite) TestVerifyPacketAcknowledgement() {
err := suite.coordinator.SendPacket(suite.chainA, suite.chainB, packet, clientB) err := suite.coordinator.SendPacket(suite.chainA, suite.chainB, packet, clientB)
suite.Require().NoError(err) suite.Require().NoError(err)
err = suite.coordinator.PacketExecuted(suite.chainB, suite.chainA, packet, clientA) err = suite.coordinator.ReceiveExecuted(suite.chainB, suite.chainA, packet, clientA)
suite.Require().NoError(err) suite.Require().NoError(err)
packetAckKey := host.KeyPacketAcknowledgement(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence()) packetAckKey := host.KeyPacketAcknowledgement(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence())
@ -392,7 +392,7 @@ func (suite *KeeperTestSuite) TestVerifyPacketAcknowledgementAbsence() {
suite.Require().NoError(err) suite.Require().NoError(err)
if tc.recvAck { if tc.recvAck {
err = suite.coordinator.PacketExecuted(suite.chainB, suite.chainA, packet, clientA) err = suite.coordinator.ReceiveExecuted(suite.chainB, suite.chainA, packet, clientA)
suite.Require().NoError(err) suite.Require().NoError(err)
} else { } else {
// need to update height to prove absence // need to update height to prove absence
@ -451,7 +451,7 @@ func (suite *KeeperTestSuite) TestVerifyNextSequenceRecv() {
err := suite.coordinator.SendPacket(suite.chainA, suite.chainB, packet, clientB) err := suite.coordinator.SendPacket(suite.chainA, suite.chainB, packet, clientB)
suite.Require().NoError(err) suite.Require().NoError(err)
err = suite.coordinator.PacketExecuted(suite.chainB, suite.chainA, packet, clientA) err = suite.coordinator.ReceiveExecuted(suite.chainB, suite.chainA, packet, clientA)
suite.Require().NoError(err) suite.Require().NoError(err)
nextSeqRecvKey := host.KeyNextSequenceRecv(packet.GetDestPort(), packet.GetDestChannel()) nextSeqRecvKey := host.KeyNextSequenceRecv(packet.GetDestPort(), packet.GetDestChannel())

View File

@ -243,15 +243,15 @@ func (k Keeper) RecvPacket(
return sdkerrors.Wrap(err, "couldn't verify counterparty packet commitment") return sdkerrors.Wrap(err, "couldn't verify counterparty packet commitment")
} }
// NOTE: the remaining code is located in the PacketExecuted function // NOTE: the remaining code is located in the ReceiveExecuted function
return nil return nil
} }
// PacketExecuted writes the packet execution acknowledgement to the state, // ReceiveExecuted writes the packet execution acknowledgement to the state,
// which will be verified by the counterparty chain using AcknowledgePacket. // which will be verified by the counterparty chain using AcknowledgePacket.
// //
// CONTRACT: this function must be called in the IBC handler // CONTRACT: this function must be called in the IBC handler
func (k Keeper) PacketExecuted( func (k Keeper) ReceiveExecuted(
ctx sdk.Context, ctx sdk.Context,
chanCap *capabilitytypes.Capability, chanCap *capabilitytypes.Capability,
packet exported.PacketI, packet exported.PacketI,

View File

@ -306,7 +306,7 @@ func (suite *KeeperTestSuite) TestRecvPacket() {
suite.coordinator.SendPacket(suite.chainA, suite.chainB, packet, clientB) suite.coordinator.SendPacket(suite.chainA, suite.chainB, packet, clientB)
// write packet acknowledgement // write packet acknowledgement
suite.coordinator.PacketExecuted(suite.chainB, suite.chainA, packet, clientA) suite.coordinator.ReceiveExecuted(suite.chainB, suite.chainA, packet, clientA)
}, false}, }, false},
{"next receive sequence is not found", func() { {"next receive sequence is not found", func() {
_, _, connA, connB := suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, clientexported.Tendermint) _, _, connA, connB := suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, clientexported.Tendermint)
@ -354,8 +354,8 @@ func (suite *KeeperTestSuite) TestRecvPacket() {
} }
// TestPacketExecuted tests the PacketExecuted call on chainB. // TestReceiveExecuted tests the ReceiveExecuted call on chainB.
func (suite *KeeperTestSuite) TestPacketExecuted() { func (suite *KeeperTestSuite) TestReceiveExecuted() {
var ( var (
packet types.Packet packet types.Packet
channelCap *capabilitytypes.Capability channelCap *capabilitytypes.Capability
@ -428,7 +428,7 @@ func (suite *KeeperTestSuite) TestPacketExecuted() {
tc.malleate() tc.malleate()
err := suite.chainB.App.IBCKeeper.ChannelKeeper.PacketExecuted(suite.chainB.GetContext(), channelCap, packet, ack) err := suite.chainB.App.IBCKeeper.ChannelKeeper.ReceiveExecuted(suite.chainB.GetContext(), channelCap, packet, ack)
if tc.expPass { if tc.expPass {
suite.Require().NoError(err) suite.Require().NoError(err)
@ -458,7 +458,7 @@ func (suite *KeeperTestSuite) TestAcknowledgePacket() {
suite.Require().NoError(err) suite.Require().NoError(err)
// create packet acknowledgement // create packet acknowledgement
err = suite.coordinator.PacketExecuted(suite.chainB, suite.chainA, packet, clientA) err = suite.coordinator.ReceiveExecuted(suite.chainB, suite.chainA, packet, clientA)
suite.Require().NoError(err) suite.Require().NoError(err)
}, true}, }, true},
{"success on unordered channel", func() { {"success on unordered channel", func() {
@ -471,7 +471,7 @@ func (suite *KeeperTestSuite) TestAcknowledgePacket() {
suite.Require().NoError(err) suite.Require().NoError(err)
// create packet acknowledgement // create packet acknowledgement
err = suite.coordinator.PacketExecuted(suite.chainB, suite.chainA, packet, clientA) err = suite.coordinator.ReceiveExecuted(suite.chainB, suite.chainA, packet, clientA)
suite.Require().NoError(err) suite.Require().NoError(err)
}, true}, }, true},
{"channel not found", func() { {"channel not found", func() {
@ -561,7 +561,7 @@ func (suite *KeeperTestSuite) TestAcknowledgePacket() {
suite.Require().NoError(err) suite.Require().NoError(err)
// create packet acknowledgement // create packet acknowledgement
err = suite.coordinator.PacketExecuted(suite.chainB, suite.chainA, packet, clientA) err = suite.coordinator.ReceiveExecuted(suite.chainB, suite.chainA, packet, clientA)
suite.Require().NoError(err) suite.Require().NoError(err)
// set next sequence ack wrong // set next sequence ack wrong
@ -608,7 +608,7 @@ func (suite *KeeperTestSuite) TestAcknowledgementExecuted() {
suite.Require().NoError(err) suite.Require().NoError(err)
// create packet acknowledgement // create packet acknowledgement
err = suite.coordinator.PacketExecuted(suite.chainB, suite.chainA, packet, clientA) err = suite.coordinator.ReceiveExecuted(suite.chainB, suite.chainA, packet, clientA)
suite.Require().NoError(err) suite.Require().NoError(err)
chanCap = suite.chainA.GetChannelCapability(channelA.PortID, channelA.ID) chanCap = suite.chainA.GetChannelCapability(channelA.PortID, channelA.ID)
@ -624,7 +624,7 @@ func (suite *KeeperTestSuite) TestAcknowledgementExecuted() {
suite.Require().NoError(err) suite.Require().NoError(err)
// create packet acknowledgement // create packet acknowledgement
err = suite.coordinator.PacketExecuted(suite.chainB, suite.chainA, packet, clientA) err = suite.coordinator.ReceiveExecuted(suite.chainB, suite.chainA, packet, clientA)
suite.Require().NoError(err) suite.Require().NoError(err)
chanCap = suite.chainA.GetChannelCapability(channelA.PortID, channelA.ID) chanCap = suite.chainA.GetChannelCapability(channelA.PortID, channelA.ID)

View File

@ -459,7 +459,7 @@ func (suite *TendermintTestSuite) TestVerifyPacketAcknowledgement() {
suite.Require().NoError(err) suite.Require().NoError(err)
// write ack // write ack
err = suite.coordinator.PacketExecuted(suite.chainB, suite.chainA, packet, clientA) err = suite.coordinator.ReceiveExecuted(suite.chainB, suite.chainA, packet, clientA)
suite.Require().NoError(err) suite.Require().NoError(err)
var ok bool var ok bool
@ -634,7 +634,7 @@ func (suite *TendermintTestSuite) TestVerifyNextSeqRecv() {
suite.Require().NoError(err) suite.Require().NoError(err)
// write ack, next seq recv incremented // write ack, next seq recv incremented
err = suite.coordinator.PacketExecuted(suite.chainB, suite.chainA, packet, clientA) err = suite.coordinator.ReceiveExecuted(suite.chainB, suite.chainA, packet, clientA)
suite.Require().NoError(err) suite.Require().NoError(err)
// need to update chainA's client representing chainB // need to update chainA's client representing chainB

View File

@ -193,7 +193,7 @@ func NewHandler(k keeper.Keeper) sdk.Handler {
} }
// Set packet acknowledgement // Set packet acknowledgement
if err = k.ChannelKeeper.PacketExecuted(ctx, cap, msg.Packet, ack); err != nil { if err = k.ChannelKeeper.ReceiveExecuted(ctx, cap, msg.Packet, ack); err != nil {
return nil, err return nil, err
} }

View File

@ -40,7 +40,7 @@ func TestHandlerTestSuite(t *testing.T) {
// tests the IBC handler receiving a packet on ordered and unordered channels. // tests the IBC handler receiving a packet on ordered and unordered channels.
// It verifies that the storing of an acknowledgement on success occurs. It // It verifies that the storing of an acknowledgement on success occurs. It
// tests high level properties like ordering and basic sanity checks. More // tests high level properties like ordering and basic sanity checks. More
// rigorous testing of 'RecvPacket' and 'PacketExecuted' can be found in the // rigorous testing of 'RecvPacket' and 'ReceiveExecuted' can be found in the
// 04-channel/keeper/packet_test.go. // 04-channel/keeper/packet_test.go.
func (suite *HandlerTestSuite) TestHandleRecvPacket() { func (suite *HandlerTestSuite) TestHandleRecvPacket() {
var ( var (
@ -104,7 +104,7 @@ func (suite *HandlerTestSuite) TestHandleRecvPacket() {
err := suite.coordinator.SendPacket(suite.chainA, suite.chainB, packet, clientB) err := suite.coordinator.SendPacket(suite.chainA, suite.chainB, packet, clientB)
suite.Require().NoError(err) suite.Require().NoError(err)
err = suite.coordinator.PacketExecuted(suite.chainB, suite.chainA, packet, clientA) err = suite.coordinator.ReceiveExecuted(suite.chainB, suite.chainA, packet, clientA)
suite.Require().NoError(err) suite.Require().NoError(err)
}, false}, }, false},
{"UNORDERED: packet already received (replay)", func() { {"UNORDERED: packet already received (replay)", func() {
@ -115,7 +115,7 @@ func (suite *HandlerTestSuite) TestHandleRecvPacket() {
err := suite.coordinator.SendPacket(suite.chainA, suite.chainB, packet, clientB) err := suite.coordinator.SendPacket(suite.chainA, suite.chainB, packet, clientB)
suite.Require().NoError(err) suite.Require().NoError(err)
err = suite.coordinator.PacketExecuted(suite.chainB, suite.chainA, packet, clientA) err = suite.coordinator.ReceiveExecuted(suite.chainB, suite.chainA, packet, clientA)
suite.Require().NoError(err) suite.Require().NoError(err)
}, false}, }, false},
} }
@ -179,7 +179,7 @@ func (suite *HandlerTestSuite) TestHandleAcknowledgePacket() {
err := suite.coordinator.SendPacket(suite.chainA, suite.chainB, packet, clientB) err := suite.coordinator.SendPacket(suite.chainA, suite.chainB, packet, clientB)
suite.Require().NoError(err) suite.Require().NoError(err)
err = suite.coordinator.PacketExecuted(suite.chainB, suite.chainA, packet, clientA) err = suite.coordinator.ReceiveExecuted(suite.chainB, suite.chainA, packet, clientA)
suite.Require().NoError(err) suite.Require().NoError(err)
}, true}, }, true},
{"success: UNORDERED", func() { {"success: UNORDERED", func() {
@ -189,7 +189,7 @@ func (suite *HandlerTestSuite) TestHandleAcknowledgePacket() {
err := suite.coordinator.SendPacket(suite.chainA, suite.chainB, packet, clientB) err := suite.coordinator.SendPacket(suite.chainA, suite.chainB, packet, clientB)
suite.Require().NoError(err) suite.Require().NoError(err)
err = suite.coordinator.PacketExecuted(suite.chainB, suite.chainA, packet, clientA) err = suite.coordinator.ReceiveExecuted(suite.chainB, suite.chainA, packet, clientA)
suite.Require().NoError(err) suite.Require().NoError(err)
}, true}, }, true},
{"success: UNORDERED acknowledge out of order packet", func() { {"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) err := suite.coordinator.SendPacket(suite.chainA, suite.chainB, packet, clientB)
suite.Require().NoError(err) suite.Require().NoError(err)
err = suite.coordinator.PacketExecuted(suite.chainB, suite.chainA, packet, clientA) err = suite.coordinator.ReceiveExecuted(suite.chainB, suite.chainA, packet, clientA)
suite.Require().NoError(err) suite.Require().NoError(err)
} }
@ -218,7 +218,7 @@ func (suite *HandlerTestSuite) TestHandleAcknowledgePacket() {
err := suite.coordinator.SendPacket(suite.chainA, suite.chainB, packet, clientB) err := suite.coordinator.SendPacket(suite.chainA, suite.chainB, packet, clientB)
suite.Require().NoError(err) suite.Require().NoError(err)
err = suite.coordinator.PacketExecuted(suite.chainB, suite.chainA, packet, clientA) err = suite.coordinator.ReceiveExecuted(suite.chainB, suite.chainA, packet, clientA)
suite.Require().NoError(err) suite.Require().NoError(err)
} }
}, false}, }, false},
@ -240,7 +240,7 @@ func (suite *HandlerTestSuite) TestHandleAcknowledgePacket() {
err := suite.coordinator.SendPacket(suite.chainA, suite.chainB, packet, clientB) err := suite.coordinator.SendPacket(suite.chainA, suite.chainB, packet, clientB)
suite.Require().NoError(err) suite.Require().NoError(err)
err = suite.coordinator.PacketExecuted(suite.chainB, suite.chainA, packet, clientA) err = suite.coordinator.ReceiveExecuted(suite.chainB, suite.chainA, packet, clientA)
suite.Require().NoError(err) suite.Require().NoError(err)
err = suite.coordinator.AcknowledgementExecuted(suite.chainA, suite.chainB, packet, clientB) 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) err := suite.coordinator.SendPacket(suite.chainA, suite.chainB, packet, clientB)
suite.Require().NoError(err) suite.Require().NoError(err)
err = suite.coordinator.PacketExecuted(suite.chainB, suite.chainA, packet, clientA) err = suite.coordinator.ReceiveExecuted(suite.chainB, suite.chainA, packet, clientA)
suite.Require().NoError(err) suite.Require().NoError(err)
err = suite.coordinator.AcknowledgementExecuted(suite.chainA, suite.chainB, packet, clientB) err = suite.coordinator.AcknowledgementExecuted(suite.chainA, suite.chainB, packet, clientB)

View File

@ -737,14 +737,14 @@ func (chain *TestChain) SendPacket(
return nil return nil
} }
// PacketExecuted simulates receiving and writing an acknowledgement to the chain. // ReceiveExecuted simulates receiving and writing an acknowledgement to the chain.
func (chain *TestChain) PacketExecuted( func (chain *TestChain) ReceiveExecuted(
packet channelexported.PacketI, packet channelexported.PacketI,
) error { ) error {
channelCap := chain.GetChannelCapability(packet.GetDestPort(), packet.GetDestChannel()) channelCap := chain.GetChannelCapability(packet.GetDestPort(), packet.GetDestChannel())
// no need to send message, acting as a handler // no need to send message, acting as a handler
err := chain.App.IBCKeeper.ChannelKeeper.PacketExecuted(chain.GetContext(), channelCap, packet, TestHash) err := chain.App.IBCKeeper.ChannelKeeper.ReceiveExecuted(chain.GetContext(), channelCap, packet, TestHash)
if err != nil { if err != nil {
return err return err
} }

View File

@ -248,14 +248,14 @@ func (coord *Coordinator) RecvPacket(
return coord.SendMsgs(counterparty, source, sourceClient, []sdk.Msg{recvMsg}) return coord.SendMsgs(counterparty, source, sourceClient, []sdk.Msg{recvMsg})
} }
// PacketExecuted receives a packet through the channel keeper on the source chain and updates the // ReceiveExecuted receives a packet through the channel keeper on the source chain and updates the
// counterparty client for the source chain. // counterparty client for the source chain.
func (coord *Coordinator) PacketExecuted( func (coord *Coordinator) ReceiveExecuted(
source, counterparty *TestChain, source, counterparty *TestChain,
packet channelexported.PacketI, packet channelexported.PacketI,
counterpartyClientID string, counterpartyClientID string,
) error { ) error {
if err := source.PacketExecuted(packet); err != nil { if err := source.ReceiveExecuted(packet); err != nil {
return err return err
} }
coord.IncrementTime() coord.IncrementTime()