Skip to content

Commit

Permalink
imp: modify error string to reflect actual behaviour in receive packe…
Browse files Browse the repository at this point in the history
…t defensive check (#5702)
  • Loading branch information
colin-axner authored Jan 24, 2024
1 parent 378e48d commit 6896814
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions modules/core/04-channel/keeper/packet.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,20 +123,15 @@ func (k Keeper) RecvPacket(
}

// If counterpartyUpgrade is stored we need to ensure that the
// packet sequence is < counterparty next sequence send. This is a defensive
// check and if the counterparty is implemented correctly, this should never abort.
// packet sequence is < counterparty next sequence send. If the
// counterparty is implemented correctly, this may only occur
// when we are in FLUSHCOMPLETE and the counterparty has already
// completed the channel upgrade.
counterpartyUpgrade, found := k.GetCounterpartyUpgrade(ctx, packet.GetDestPort(), packet.GetDestChannel())
if found {
// only error if the counterparty next sequence send is set (> 0)
// this error should never be reached, as under normal circumstances the counterparty
// should not send any packets after the upgrade has been started.
counterpartyNextSequenceSend := counterpartyUpgrade.NextSequenceSend
if packet.GetSequence() >= counterpartyNextSequenceSend {
return errorsmod.Wrapf(
types.ErrInvalidPacket,
"failed to receive packet, cannot flush packet at sequence greater than or equal to counterparty next sequence send (%d) ≥ (%d). UNEXPECTED BEHAVIOUR ON COUNTERPARTY, PLEASE REPORT ISSUE TO RELEVANT CHAIN DEVELOPERS",
packet.GetSequence(), counterpartyNextSequenceSend,
)
return errorsmod.Wrapf(types.ErrInvalidPacket, "cannot flush packet at sequence greater than or equal to counterparty next sequence send (%d) ≥ (%d).", packet.GetSequence(), counterpartyNextSequenceSend)
}
}

Expand Down

0 comments on commit 6896814

Please sign in to comment.