Skip to content

Commit 830b5b9

Browse files
authored
Fix bug with tracking processing channel msgs (#970)
* 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
1 parent 91182c9 commit 830b5b9

File tree

3 files changed

+9
-14
lines changed

3 files changed

+9
-14
lines changed

relayer/processor/path_end_runtime.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,6 @@ func (pathEnd *pathEndRuntime) mergeMessageCache(messageCache IBCMessagesCache,
130130
}
131131
// can complete channel handshakes on this client
132132
// since PathProcessor holds reference to the counterparty chain pathEndRuntime.
133-
134133
if eventType == chantypes.EventTypeChannelOpenInit {
135134
// CounterpartyConnectionID is needed to construct MsgChannelOpenTry.
136135
for k := range pathEnd.connectionStateCache {
@@ -145,6 +144,7 @@ func (pathEnd *pathEndRuntime) mergeMessageCache(messageCache IBCMessagesCache,
145144
if len(newCmc) == 0 {
146145
continue
147146
}
147+
148148
channelHandshakeMessages[eventType] = newCmc
149149
}
150150
pathEnd.messageCache.ChannelHandshake.Merge(channelHandshakeMessages)

relayer/processor/path_processor.go

+1-4
Original file line numberDiff line numberDiff line change
@@ -138,10 +138,7 @@ func (pp *PathProcessor) channelPairs() []channelPair {
138138
}
139139
pairs := make([]channelPair, len(channels))
140140
i := 0
141-
for k, open := range channels {
142-
if !open {
143-
continue
144-
}
141+
for k, _ := range channels {
145142
pairs[i] = channelPair{
146143
pathEnd1ChannelKey: k,
147144
pathEnd2ChannelKey: k.Counterparty(),

relayer/processor/path_processor_internal.go

+7-9
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ MsgTransferLoop:
7272
},
7373
}
7474

75-
if pathEndPacketFlowMessages.Src.shouldSendChannelMessage(closeChan, pathEndPacketFlowMessages.Dst) {
75+
if pathEndPacketFlowMessages.Dst.shouldSendChannelMessage(closeChan, pathEndPacketFlowMessages.Src) {
7676
res.DstChannelMessage = append(res.DstChannelMessage, closeChan)
7777
}
7878
} else {
@@ -160,14 +160,7 @@ MsgTransferLoop:
160160
res.ToDeleteSrc[chantypes.EventTypeAcknowledgePacket] = append(res.ToDeleteSrc[chantypes.EventTypeAcknowledgePacket], ackSeq)
161161
}
162162
for timeoutSeq, msgTimeout := range pathEndPacketFlowMessages.SrcMsgTimeout {
163-
if msgTimeout.ChannelOrder == chantypes.ORDERED.String() {
164-
if pathEndPacketFlowMessages.DstMsgChannelCloseConfirm != nil {
165-
// For ordered channel packets, flow is not done until channel-close-confirm is observed.
166-
res.ToDeleteDstChannel[chantypes.EventTypeChannelCloseConfirm] = append(res.ToDeleteDstChannel[chantypes.EventTypeChannelCloseConfirm], pathEndPacketFlowMessages.ChannelKey.Counterparty())
167-
res.ToDeleteSrc[chantypes.EventTypeSendPacket] = append(res.ToDeleteSrc[chantypes.EventTypeSendPacket], timeoutSeq)
168-
res.ToDeleteSrc[chantypes.EventTypeTimeoutPacket] = append(res.ToDeleteSrc[chantypes.EventTypeTimeoutPacket], timeoutSeq)
169-
}
170-
} else {
163+
if msgTimeout.ChannelOrder != chantypes.ORDERED.String() {
171164
res.ToDeleteSrc[chantypes.EventTypeSendPacket] = append(res.ToDeleteSrc[chantypes.EventTypeSendPacket], timeoutSeq)
172165
res.ToDeleteSrc[chantypes.EventTypeTimeoutPacket] = append(res.ToDeleteSrc[chantypes.EventTypeTimeoutPacket], timeoutSeq)
173166
}
@@ -176,6 +169,7 @@ MsgTransferLoop:
176169
res.ToDeleteSrc[chantypes.EventTypeSendPacket] = append(res.ToDeleteSrc[chantypes.EventTypeSendPacket], timeoutOnCloseSeq)
177170
res.ToDeleteSrc[chantypes.EventTypeTimeoutPacketOnClose] = append(res.ToDeleteSrc[chantypes.EventTypeTimeoutPacketOnClose], timeoutOnCloseSeq)
178171
}
172+
179173
return res
180174
}
181175

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

982976
pp.pathEnd1.messageCache.ChannelHandshake.DeleteMessages(pathEnd2ProcessRes[i].ToDeleteDstChannel)
977+
pp.pathEnd1.channelProcessing.deleteMessages(pathEnd2ProcessRes[i].ToDeleteDstChannel)
978+
983979
pp.pathEnd2.messageCache.ChannelHandshake.DeleteMessages(pathEnd1ProcessRes[i].ToDeleteDstChannel)
980+
pp.pathEnd2.channelProcessing.deleteMessages(pathEnd1ProcessRes[i].ToDeleteDstChannel)
984981

985982
pp.pathEnd1.messageCache.PacketFlow[channelPair.pathEnd1ChannelKey].DeleteMessages(pathEnd1ProcessRes[i].ToDeleteSrc, pathEnd2ProcessRes[i].ToDeleteDst)
986983
pp.pathEnd2.messageCache.PacketFlow[channelPair.pathEnd2ChannelKey].DeleteMessages(pathEnd2ProcessRes[i].ToDeleteSrc, pathEnd1ProcessRes[i].ToDeleteDst)
984+
987985
pp.pathEnd1.packetProcessing[channelPair.pathEnd1ChannelKey].deleteMessages(pathEnd1ProcessRes[i].ToDeleteSrc, pathEnd2ProcessRes[i].ToDeleteDst)
988986
pp.pathEnd2.packetProcessing[channelPair.pathEnd2ChannelKey].deleteMessages(pathEnd2ProcessRes[i].ToDeleteSrc, pathEnd1ProcessRes[i].ToDeleteDst)
989987
}

0 commit comments

Comments
 (0)