-
Notifications
You must be signed in to change notification settings - Fork 384
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
ICS04: some questions about function timeoutOnClose and timeoutPacket #968
Comments
Hi @michwqy. Thanks for bringing up these questions! Question 1
I think the comment is not correct and can be removed, Question 2 Optimistic sends (i.e. sending packets before the channel is fully opened) was disabled in ibc-go because it was not working properly. Maybe the spec should be updated as well (so that packets are not allowed to be sent before the channel end is opened) until we specify a fully-working design of optimistic sends sometime in the future. But even if the situation that you describe could theoretically happen according to the spec, it doesn't in practice since ibc-go will allow packets to be sent only when the counterparty has also opened the channel. |
Thanks @crodriguezvega . I find several others that look likely according to spec but I don't know whether they are feasible in reality. Question 3
Though it seems that the sent packet may not require an ack, I think that Assume that module a on chain A sends a packet to module b on chain B (by calling function acknowledgePacket(
packet: OpaquePacket,
acknowledgement: bytes,
proof: CommitmentProof,
proofHeight: Height,
relayer: string): Packet {
...
channel = provableStore.get(channelPath(packet.sourcePort, packet.sourceChannel))
abortTransactionUnless(channel !== null)
abortTransactionUnless(channel.state === OPEN)
...
} And the packet can't be ack or timeout (since it has been received successfully). Question 4For function timeoutPacket(
packet: OpaquePacket,
proof: CommitmentProof,
proofHeight: Height,
nextSequenceRecv: Maybe<uint64>,
relayer: string): Packet {
...
if channel.order === ORDERED_ALLOW_TIMEOUT {
nextSequenceAck = nextSequenceAck + 1
provableStore.set(nextSequenceAckPath(packet.srcPort, packet.srcChannel), nextSequenceAck)
}
...
} Assume that module A sent two packets (e.g. sequences are 1,2 and the init function acknowledgePacket(
packet: OpaquePacket,
acknowledgement: bytes,
proof: CommitmentProof,
proofHeight: Height,
relayer: string): Packet {
...
if (channel.order === ORDERED || channel.order == ORDERED_ALLOW_TIMEOUT) {
nextSequenceAck = provableStore.get(nextSequenceAckPath(packet.sourcePort, packet.sourceChannel))
abortTransactionUnless(packet.sequence === nextSequenceAck)
...
}
...
} |
Question 3
I think this is something that the application callback can take care of and it doesn't necessarily need to be handled at the TAO layer. For example, if packets sent from chain A have been received on chain B AND chain B has closed its side of the channel AND a relayer tries to execute Question 4
I am not sure if the condition should be relaxed here actually... If the condition changes to |
Closing this issue for now. @michwqy I hope my answers above helped, otherwise, please feel free to reopen. |
I hope it is not too late to further discuss these questions. @crodriguezvega Question 2Of course, if there is no optimistic send, there is no problem. But I want to further discuss the problem brought by optimistic sends. In reality, optimistic sends are disabled due to a transaction that cannot be timed out. The public issue behind this event and my example is that the two functions If optimistic sends are allowed, the local channel end may be in a state of no counterparty, tryopen, closed, or open after the packet sent. In spec, Question 3I agree that this issue is more suitable for handling in application callbacks. Question 4If all packets are required to be received and acknowledged in an order they were sent, the correct conditions should be as follows: function timeoutPacket(
packet: OpaquePacket,
proof: CommitmentProof,
proofHeight: Height,
nextSequenceRecv: Maybe<uint64>,
relayer: string): Packet {
...
if channel.order === ORDERED_ALLOW_TIMEOUT {
abortTransactionUnless(packet.sequence === nextSequenceAck)
nextSequenceAck = nextSequenceAck + 1
provableStore.set(nextSequenceAckPath(packet.srcPort, packet.srcChannel), nextSequenceAck)
}
...
} Subsequent packets should wait for the previous packet to be acknowledged or timed out before being acknowledged or timed out. In addition, I believe that although some special examples can be targeted by the application, application developers may not necessarily be aware of the need for special handling. And some special examples may reflect negligence in protocol design. I would be grateful if there could be more discussion. |
@crodriguezvega I can't reopen this issue, shall I open a new one? |
@michwqy Sorry I missed your messages within the rest of all GitHub notifications. Yes, happy to continue the discussion; I will go over your previous comment and reply. |
Question 1
As ICS03, the connection can't be closed.
But as ICS04, there are two comments in
timeoutPacket
andtimeoutOnClose
.It may be a mistake.
Question 2
I found a logical problem, but I'm not sure if it works in reality. (Some mistakes are possible but may not practical.)
As ICS04, A module can call
sendPacket
before a channel open.Assume the module successively calls
chanOpenInit
,sendPacket
andchanCloseInit
, which results that there is a in-flight packet and the closed channel.The module can't call
timeoutOnClose
since there is no counterparty channel.I think it does not match what the
timeoutOnClose
is designed for andWe might be able to use
timeoutPacket
to make the in-flight packet to be timeout.It doesn't matter that it has some problems (As #965). It needs to call
verifyNextSequenceRecv
,verifyPacketReceiptAbsence
andverifyPacketReceipt
anyway.I don't know if there functions work properly when
channel.counterpartyChannelIdentifier
is empty.And in ibc-go,
TimeoutPacket
can't be called when channel is closed.The text was updated successfully, but these errors were encountered: