Skip to content

Commit

Permalink
Rename PacketExecuted to ReceiveExecuted (cosmos#7206)
Browse files Browse the repository at this point in the history
* update ibc-transfer

* rename PacketExecuted -> ReceiveExecuted
  • Loading branch information
colin-axner authored Aug 31, 2020
1 parent 843bd24 commit fc75d14
Show file tree
Hide file tree
Showing 10 changed files with 37 additions and 37 deletions.
6 changes: 3 additions & 3 deletions x/ibc-transfer/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,15 @@ func (k Keeper) GetTransferAccount(ctx sdk.Context) authtypes.ModuleAccountI {
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.
// 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()))
if !ok {
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
Expand Down
2 changes: 1 addition & 1 deletion x/ibc-transfer/types/expected_keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ 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 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
}

Expand Down
6 changes: 3 additions & 3 deletions x/ibc/03-connection/keeper/verify_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ func (suite *KeeperTestSuite) TestVerifyPacketAcknowledgement() {
err := suite.coordinator.SendPacket(suite.chainA, suite.chainB, packet, clientB)
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)

packetAckKey := host.KeyPacketAcknowledgement(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence())
Expand Down Expand Up @@ -392,7 +392,7 @@ func (suite *KeeperTestSuite) TestVerifyPacketAcknowledgementAbsence() {
suite.Require().NoError(err)

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)
} else {
// need to update height to prove absence
Expand Down Expand Up @@ -451,7 +451,7 @@ func (suite *KeeperTestSuite) TestVerifyNextSequenceRecv() {
err := suite.coordinator.SendPacket(suite.chainA, suite.chainB, packet, clientB)
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)

nextSeqRecvKey := host.KeyNextSequenceRecv(packet.GetDestPort(), packet.GetDestChannel())
Expand Down
6 changes: 3 additions & 3 deletions x/ibc/04-channel/keeper/packet.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,15 +243,15 @@ func (k Keeper) RecvPacket(
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
}

// 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.
//
// CONTRACT: this function must be called in the IBC handler
func (k Keeper) PacketExecuted(
func (k Keeper) ReceiveExecuted(
ctx sdk.Context,
chanCap *capabilitytypes.Capability,
packet exported.PacketI,
Expand Down
18 changes: 9 additions & 9 deletions x/ibc/04-channel/keeper/packet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ func (suite *KeeperTestSuite) TestRecvPacket() {
suite.coordinator.SendPacket(suite.chainA, suite.chainB, packet, clientB)

// write packet acknowledgement
suite.coordinator.PacketExecuted(suite.chainB, suite.chainA, packet, clientA)
suite.coordinator.ReceiveExecuted(suite.chainB, suite.chainA, packet, clientA)
}, false},
{"next receive sequence is not found", func() {
_, _, connA, connB := suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, clientexported.Tendermint)
Expand Down Expand Up @@ -354,8 +354,8 @@ func (suite *KeeperTestSuite) TestRecvPacket() {

}

// TestPacketExecuted tests the PacketExecuted call on chainB.
func (suite *KeeperTestSuite) TestPacketExecuted() {
// TestReceiveExecuted tests the ReceiveExecuted call on chainB.
func (suite *KeeperTestSuite) TestReceiveExecuted() {
var (
packet types.Packet
channelCap *capabilitytypes.Capability
Expand Down Expand Up @@ -428,7 +428,7 @@ func (suite *KeeperTestSuite) TestPacketExecuted() {

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 {
suite.Require().NoError(err)
Expand Down Expand Up @@ -458,7 +458,7 @@ func (suite *KeeperTestSuite) TestAcknowledgePacket() {
suite.Require().NoError(err)

// 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)
}, true},
{"success on unordered channel", func() {
Expand All @@ -471,7 +471,7 @@ func (suite *KeeperTestSuite) TestAcknowledgePacket() {
suite.Require().NoError(err)

// 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)
}, true},
{"channel not found", func() {
Expand Down Expand Up @@ -561,7 +561,7 @@ func (suite *KeeperTestSuite) TestAcknowledgePacket() {
suite.Require().NoError(err)

// 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)

// set next sequence ack wrong
Expand Down Expand Up @@ -608,7 +608,7 @@ func (suite *KeeperTestSuite) TestAcknowledgementExecuted() {
suite.Require().NoError(err)

// 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)

chanCap = suite.chainA.GetChannelCapability(channelA.PortID, channelA.ID)
Expand All @@ -624,7 +624,7 @@ func (suite *KeeperTestSuite) TestAcknowledgementExecuted() {
suite.Require().NoError(err)

// 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)

chanCap = suite.chainA.GetChannelCapability(channelA.PortID, channelA.ID)
Expand Down
4 changes: 2 additions & 2 deletions x/ibc/07-tendermint/types/client_state_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ func (suite *TendermintTestSuite) TestVerifyPacketAcknowledgement() {
suite.Require().NoError(err)

// 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)

var ok bool
Expand Down Expand Up @@ -634,7 +634,7 @@ func (suite *TendermintTestSuite) TestVerifyNextSeqRecv() {
suite.Require().NoError(err)

// 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)

// need to update chainA's client representing chainB
Expand Down
2 changes: 1 addition & 1 deletion x/ibc/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ func NewHandler(k keeper.Keeper) sdk.Handler {
}

// 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
}

Expand Down
18 changes: 9 additions & 9 deletions x/ibc/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 'PacketExecuted' can be found in the
// rigorous testing of 'RecvPacket' and 'ReceiveExecuted' can be found in the
// 04-channel/keeper/packet_test.go.
func (suite *HandlerTestSuite) TestHandleRecvPacket() {
var (
Expand Down Expand Up @@ -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.PacketExecuted(suite.chainB, suite.chainA, packet, clientA)
err = suite.coordinator.ReceiveExecuted(suite.chainB, suite.chainA, packet, clientA)
suite.Require().NoError(err)
}, false},
{"UNORDERED: packet already received (replay)", func() {
Expand All @@ -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.PacketExecuted(suite.chainB, suite.chainA, packet, clientA)
err = suite.coordinator.ReceiveExecuted(suite.chainB, suite.chainA, packet, clientA)
suite.Require().NoError(err)
}, false},
}
Expand Down Expand Up @@ -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.PacketExecuted(suite.chainB, suite.chainA, packet, clientA)
err = suite.coordinator.ReceiveExecuted(suite.chainB, suite.chainA, packet, clientA)
suite.Require().NoError(err)
}, true},
{"success: UNORDERED", func() {
Expand All @@ -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.PacketExecuted(suite.chainB, suite.chainA, packet, clientA)
err = suite.coordinator.ReceiveExecuted(suite.chainB, suite.chainA, packet, clientA)
suite.Require().NoError(err)
}, true},
{"success: UNORDERED acknowledge out of order packet", func() {
Expand All @@ -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.PacketExecuted(suite.chainB, suite.chainA, packet, clientA)
err = suite.coordinator.ReceiveExecuted(suite.chainB, suite.chainA, packet, clientA)
suite.Require().NoError(err)

}
Expand All @@ -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.PacketExecuted(suite.chainB, suite.chainA, packet, clientA)
err = suite.coordinator.ReceiveExecuted(suite.chainB, suite.chainA, packet, clientA)
suite.Require().NoError(err)
}
}, false},
Expand All @@ -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.PacketExecuted(suite.chainB, suite.chainA, packet, clientA)
err = suite.coordinator.ReceiveExecuted(suite.chainB, suite.chainA, packet, clientA)
suite.Require().NoError(err)

err = suite.coordinator.AcknowledgementExecuted(suite.chainA, suite.chainB, packet, clientB)
Expand All @@ -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.PacketExecuted(suite.chainB, suite.chainA, packet, clientA)
err = suite.coordinator.ReceiveExecuted(suite.chainB, suite.chainA, packet, clientA)
suite.Require().NoError(err)

err = suite.coordinator.AcknowledgementExecuted(suite.chainA, suite.chainB, packet, clientB)
Expand Down
6 changes: 3 additions & 3 deletions x/ibc/testing/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -737,14 +737,14 @@ func (chain *TestChain) SendPacket(
return nil
}

// PacketExecuted simulates receiving and writing an acknowledgement to the chain.
func (chain *TestChain) PacketExecuted(
// ReceiveExecuted simulates receiving and writing an acknowledgement to the chain.
func (chain *TestChain) ReceiveExecuted(
packet channelexported.PacketI,
) error {
channelCap := chain.GetChannelCapability(packet.GetDestPort(), packet.GetDestChannel())

// 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 {
return err
}
Expand Down
6 changes: 3 additions & 3 deletions x/ibc/testing/coordinator.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,14 +248,14 @@ func (coord *Coordinator) RecvPacket(
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.
func (coord *Coordinator) PacketExecuted(
func (coord *Coordinator) ReceiveExecuted(
source, counterparty *TestChain,
packet channelexported.PacketI,
counterpartyClientID string,
) error {
if err := source.PacketExecuted(packet); err != nil {
if err := source.ReceiveExecuted(packet); err != nil {
return err
}
coord.IncrementTime()
Expand Down

0 comments on commit fc75d14

Please sign in to comment.