-
Notifications
You must be signed in to change notification settings - Fork 639
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
UnreceivedPackets
grpc query handler only works for unordered channels
#1532
Comments
Thanks for opening this issue, @plafer! This is a very good catch! |
Some pseudocode to discuss a possible way to fix this issue. After this line replace this block with something like this: channel, found := q.GetChannel(ctx, req.PortId, req.ChannelId)
if !found {
return nil, status.Error(
codes.NotFound,
sdkerrors.Wrapf(types.ErrChannelNotFound, "port-id: %s, channel-id %s", req.PortId, req.ChannelId).Error(),
)
}
unreceivedSequences := []uint64{}
switch channel.Ordering {
case types.UNORDERED:
for i, seq := range req.PacketCommitmentSequences {
if seq == 0 {
return nil, status.Errorf(codes.InvalidArgument, "packet sequence %d cannot be 0", i)
}
// if packet receipt exists on the receiving chain, then packet has already been received
if _, found := q.GetPacketReceipt(ctx, req.PortId, req.ChannelId, seq); !found {
unreceivedSequences = append(unreceivedSequences, seq)
}
}
case types.ORDERED:
nextSequenceRecv, found = q.GetNextSequenceRecv(ctx, req.PortId, req.ChannelId)
if !found {
return nil, status.Errorf(...)
}
for _, seq := range req.PacketCommitmentSequences {
if seq == 0 {
return nil, status.Errorf(codes.InvalidArgument, "packet sequence %d cannot be 0", i)
}
if seq >= nextSequenceRecv {
unreceivedSequences = append(unreceivedSequences, seq)
}
}
default:
return nil, status.Errorf(...)
} |
Hi @plafer, what behaviour would be desirable? The functionality of Would love to hear your input. In what context are you using this function and how could we best adjust the functionality to fit your needs? |
I don't believe a separate gRPC endpoint is necessary. From the perspective of relayers (which I assume are the primary users of this endpoint), using a different gRPC endpoint depending on the channel ordering adds complexity, which I don't believe it justified. I assume that on ordered channels, queries similar to
Hence, I believe |
Summary of Bug
UnreceivedPackets
builds the response only by looking for a corresponding packet receipt for every sequence number included in the query (see here). This only works for unordered channels, as ordered channels usenextSequenceRecv
rather than packet receipts. Therefore, on ordered channels, the query response will include all sequence numbers that were present in the query, as no receipt will be found for any of them.Version
v3.0.0
Steps to Reproduce
I used the interchain accounts demo repo to confirm the problem, as interchain accounts use ordered channels. After installation,
In terminal 1,
In terminal 2,
At this point, hit
^C
in terminal 1 to stop hermes from relaying packets. We will create asendPacket
ontest-1
, recv it ontest-2
, and then query unreceived packets ontest-2
to confirm that the chain claims that our packet has not been received, even though it has.In terminal 2, send the packet.
In terminal 1,
For Admin Use
The text was updated successfully, but these errors were encountered: