Skip to content

Commit

Permalink
fix(delayedack): use correct port, chan in packet uid (#963)
Browse files Browse the repository at this point in the history
  • Loading branch information
danwt authored Jun 20, 2024
1 parent a262275 commit 48824ed
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions x/delayedack/keeper/transfer.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,27 @@ func (k Keeper) GetValidTransferWithFinalizationInfo(
packet channeltypes.Packet,
packetType commontypes.RollappPacket_Type,
) (data types.TransferDataWithFinalization, err error) {
var port string
var channel string

switch packetType {
case commontypes.RollappPacket_ON_RECV:
data.TransferData, err = k.rollappKeeper.GetValidTransfer(ctx, packet.GetData(), packet.GetDestPort(), packet.GetDestChannel())
port, channel = packet.GetDestPort(), packet.GetDestChannel()
case commontypes.RollappPacket_ON_TIMEOUT, commontypes.RollappPacket_ON_ACK:
data.TransferData, err = k.rollappKeeper.GetValidTransfer(ctx, packet.GetData(), packet.GetSourcePort(), packet.GetSourceChannel())
port, channel = packet.GetSourcePort(), packet.GetSourceChannel()
}

data.TransferData, err = k.rollappKeeper.GetValidTransfer(ctx, packet.GetData(), port, channel)
if err != nil {
err = errors.Wrap(err, "get valid transfer data")
return
}

packetId := commontypes.NewPacketUID(packetType, packet.DestinationPort, packet.DestinationChannel, packet.Sequence)
height, ok := types.PacketProofHeightFromCtx(ctx, packetId)
packetID := commontypes.NewPacketUID(packetType, port, channel, packet.Sequence)
height, ok := types.PacketProofHeightFromCtx(ctx, packetID)
if !ok {
// TODO: should probably be a panic
err = errors.Wrapf(gerrc.ErrNotFound, "get proof height from context: packetID: %s", packetId)
err = errors.Wrapf(gerrc.ErrNotFound, "get proof height from context: packetID: %s", packetID)
return
}
data.ProofHeight = height.RevisionHeight
Expand Down

0 comments on commit 48824ed

Please sign in to comment.