cosmos / ibc

Interchain Standards (ICS) for the Cosmos network & interchain ecosystem.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ICS004(channel-upgrades): change counterparty `LastSequenceSend` to `NextSequenceSend`

damiannolan opened this issue · comments

In the current channel upgradability spec, we introduce a new concept of LastSequenceSend / LatestSequenceSend in order to provide a "watermark" or checkpoint for packet flushing while within the upgrade handshake.

This can easily be changed to NextSequenceSend which is already a well-known concept within ibc.

Conditional logic in recvPacket would change like so:

Spec:

- abortTransactionUnless(channel.state === OPEN || (channel.state === FLUSHING && packet.sequence <= counterpartyLastPacketSent))
+ abortTransactionUnless(channel.state === OPEN || (channel.state === FLUSHING && packet.sequence < counterpartyNextSequenceSend))

ibc-go example:

- if packet.GetSequence() > counterpartyUpgrade.LatestSequenceSend {
+ if packet.GetSequence() >= counterpartyUpgrade.NextSequenceSend {
	return errorsmod.Wrapf(
		types.ErrInvalidPacket,
		"failed to receive packet, cannot flush packet at sequence greater than counterparty last sequence send (%d) > (%d)", packet.GetSequence(), counterpartyUpgrade.LatestSequenceSend,
	)
}

I would consider this an improvement as we can reuse existing ibc concepts without introducing more concepts around send/recv sequencing.