Skip to content

Commit

Permalink
Fix bug with tracking processing channel msgs (#970)
Browse files Browse the repository at this point in the history
* add debug output

* add more debug output

* NEEDS MOAR DEBUG OUTPUT

* test purging MsgTimeout on src vs. counterparty

* reverse channel close msg purging

* don't delete channel close msgs until another iteration in getUnrelayedPacketsAndAcks

* add debug output

* add more debug output

* NEEDS MOAR DEBUG OUTPUT

* test purging MsgTimeout on src vs. counterparty

* reverse channel close msg purging

* don't delete channel close msgs until another iteration in getUnrelayedPacketsAndAcks

* reverse channel close msg purging

* don't delete channel close msgs until another iteration in getUnrelayedPacketsAndAcks

* undo previous changes regarding purging cache on max retries

* undo more changes made in shouldSendChannelMessage

* more undo

* add debug output on msg send and channel cache purge

* add debug output

* remove pointless log

* add logs in process latest msgs

* more logs

* logs

* remove all debug logs and implement fix for tracking processing packets correctly
  • Loading branch information
jtieri authored Sep 4, 2022
1 parent 91182c9 commit 830b5b9
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 14 deletions.
2 changes: 1 addition & 1 deletion relayer/processor/path_end_runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ func (pathEnd *pathEndRuntime) mergeMessageCache(messageCache IBCMessagesCache,
}
// can complete channel handshakes on this client
// since PathProcessor holds reference to the counterparty chain pathEndRuntime.

if eventType == chantypes.EventTypeChannelOpenInit {
// CounterpartyConnectionID is needed to construct MsgChannelOpenTry.
for k := range pathEnd.connectionStateCache {
Expand All @@ -145,6 +144,7 @@ func (pathEnd *pathEndRuntime) mergeMessageCache(messageCache IBCMessagesCache,
if len(newCmc) == 0 {
continue
}

channelHandshakeMessages[eventType] = newCmc
}
pathEnd.messageCache.ChannelHandshake.Merge(channelHandshakeMessages)
Expand Down
5 changes: 1 addition & 4 deletions relayer/processor/path_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,7 @@ func (pp *PathProcessor) channelPairs() []channelPair {
}
pairs := make([]channelPair, len(channels))
i := 0
for k, open := range channels {
if !open {
continue
}
for k, _ := range channels {
pairs[i] = channelPair{
pathEnd1ChannelKey: k,
pathEnd2ChannelKey: k.Counterparty(),
Expand Down
16 changes: 7 additions & 9 deletions relayer/processor/path_processor_internal.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ MsgTransferLoop:
},
}

if pathEndPacketFlowMessages.Src.shouldSendChannelMessage(closeChan, pathEndPacketFlowMessages.Dst) {
if pathEndPacketFlowMessages.Dst.shouldSendChannelMessage(closeChan, pathEndPacketFlowMessages.Src) {
res.DstChannelMessage = append(res.DstChannelMessage, closeChan)
}
} else {
Expand Down Expand Up @@ -160,14 +160,7 @@ MsgTransferLoop:
res.ToDeleteSrc[chantypes.EventTypeAcknowledgePacket] = append(res.ToDeleteSrc[chantypes.EventTypeAcknowledgePacket], ackSeq)
}
for timeoutSeq, msgTimeout := range pathEndPacketFlowMessages.SrcMsgTimeout {
if msgTimeout.ChannelOrder == chantypes.ORDERED.String() {
if pathEndPacketFlowMessages.DstMsgChannelCloseConfirm != nil {
// For ordered channel packets, flow is not done until channel-close-confirm is observed.
res.ToDeleteDstChannel[chantypes.EventTypeChannelCloseConfirm] = append(res.ToDeleteDstChannel[chantypes.EventTypeChannelCloseConfirm], pathEndPacketFlowMessages.ChannelKey.Counterparty())
res.ToDeleteSrc[chantypes.EventTypeSendPacket] = append(res.ToDeleteSrc[chantypes.EventTypeSendPacket], timeoutSeq)
res.ToDeleteSrc[chantypes.EventTypeTimeoutPacket] = append(res.ToDeleteSrc[chantypes.EventTypeTimeoutPacket], timeoutSeq)
}
} else {
if msgTimeout.ChannelOrder != chantypes.ORDERED.String() {
res.ToDeleteSrc[chantypes.EventTypeSendPacket] = append(res.ToDeleteSrc[chantypes.EventTypeSendPacket], timeoutSeq)
res.ToDeleteSrc[chantypes.EventTypeTimeoutPacket] = append(res.ToDeleteSrc[chantypes.EventTypeTimeoutPacket], timeoutSeq)
}
Expand All @@ -176,6 +169,7 @@ MsgTransferLoop:
res.ToDeleteSrc[chantypes.EventTypeSendPacket] = append(res.ToDeleteSrc[chantypes.EventTypeSendPacket], timeoutOnCloseSeq)
res.ToDeleteSrc[chantypes.EventTypeTimeoutPacketOnClose] = append(res.ToDeleteSrc[chantypes.EventTypeTimeoutPacketOnClose], timeoutOnCloseSeq)
}

return res
}

Expand Down Expand Up @@ -980,10 +974,14 @@ func (pp *PathProcessor) packetMessagesToSend(
pathEnd2ChannelMessage = append(pathEnd2ChannelMessage, pathEnd1ProcessRes[i].DstChannelMessage...)

pp.pathEnd1.messageCache.ChannelHandshake.DeleteMessages(pathEnd2ProcessRes[i].ToDeleteDstChannel)
pp.pathEnd1.channelProcessing.deleteMessages(pathEnd2ProcessRes[i].ToDeleteDstChannel)

pp.pathEnd2.messageCache.ChannelHandshake.DeleteMessages(pathEnd1ProcessRes[i].ToDeleteDstChannel)
pp.pathEnd2.channelProcessing.deleteMessages(pathEnd1ProcessRes[i].ToDeleteDstChannel)

pp.pathEnd1.messageCache.PacketFlow[channelPair.pathEnd1ChannelKey].DeleteMessages(pathEnd1ProcessRes[i].ToDeleteSrc, pathEnd2ProcessRes[i].ToDeleteDst)
pp.pathEnd2.messageCache.PacketFlow[channelPair.pathEnd2ChannelKey].DeleteMessages(pathEnd2ProcessRes[i].ToDeleteSrc, pathEnd1ProcessRes[i].ToDeleteDst)

pp.pathEnd1.packetProcessing[channelPair.pathEnd1ChannelKey].deleteMessages(pathEnd1ProcessRes[i].ToDeleteSrc, pathEnd2ProcessRes[i].ToDeleteDst)
pp.pathEnd2.packetProcessing[channelPair.pathEnd2ChannelKey].deleteMessages(pathEnd2ProcessRes[i].ToDeleteSrc, pathEnd1ProcessRes[i].ToDeleteDst)
}
Expand Down

0 comments on commit 830b5b9

Please sign in to comment.