lnwallet/channel: add more info in case of crash
This commit adds a call to panic in case the HTLC we are looking for is not found in the update log. It _should_ always be there, but we have seen crashes resulting from it not being found. Since it will crash with a nil pointer dereference below, we instead call panic giving us a bit more information to work with.
This commit is contained in:
1 file changed
+30
@@ -2407,6 +2407,21 @@ func (lc *LightningChannel) evaluateHTLCView(view *htlcView, ourBalance,
|
|||||||
|
|
||||||
addEntry := lc.remoteUpdateLog.lookupHtlc(entry.ParentIndex)
|
addEntry := lc.remoteUpdateLog.lookupHtlc(entry.ParentIndex)
|
||||||
|
|
||||||
|
// We check if the parent entry is not found at this point. We
|
||||||
|
// have seen this happening a few times and panic with some
|
||||||
|
// addtitional info to figure out why.
|
||||||
|
// TODO(halseth): remove when bug is fixed.
|
||||||
|
if addEntry == nil {
|
||||||
|
panic(fmt.Sprintf("unable to find parent entry %d "+
|
||||||
|
"in remote update log: %v\nUpdatelog: %v",
|
||||||
|
entry.ParentIndex, newLogClosure(func() string {
|
||||||
|
return spew.Sdump(entry)
|
||||||
|
}), newLogClosure(func() string {
|
||||||
|
return spew.Sdump(lc.remoteUpdateLog)
|
||||||
|
}),
|
||||||
|
))
|
||||||
|
}
|
||||||
|
|
||||||
skipThem[addEntry.HtlcIndex] = struct{}{}
|
skipThem[addEntry.HtlcIndex] = struct{}{}
|
||||||
processRemoveEntry(entry, ourBalance, theirBalance,
|
processRemoveEntry(entry, ourBalance, theirBalance,
|
||||||
nextHeight, remoteChain, true, mutateState)
|
nextHeight, remoteChain, true, mutateState)
|
||||||
@@ -2427,6 +2442,21 @@ func (lc *LightningChannel) evaluateHTLCView(view *htlcView, ourBalance,
|
|||||||
|
|
||||||
addEntry := lc.localUpdateLog.lookupHtlc(entry.ParentIndex)
|
addEntry := lc.localUpdateLog.lookupHtlc(entry.ParentIndex)
|
||||||
|
|
||||||
|
// We check if the parent entry is not found at this point. We
|
||||||
|
// have seen this happening a few times and panic with some
|
||||||
|
// addtitional info to figure out why.
|
||||||
|
// TODO(halseth): remove when bug is fixed.
|
||||||
|
if addEntry == nil {
|
||||||
|
panic(fmt.Sprintf("unable to find parent entry %d "+
|
||||||
|
"in local update log: %v\nUpdatelog: %v",
|
||||||
|
entry.ParentIndex, newLogClosure(func() string {
|
||||||
|
return spew.Sdump(entry)
|
||||||
|
}), newLogClosure(func() string {
|
||||||
|
return spew.Sdump(lc.localUpdateLog)
|
||||||
|
}),
|
||||||
|
))
|
||||||
|
}
|
||||||
|
|
||||||
skipUs[addEntry.HtlcIndex] = struct{}{}
|
skipUs[addEntry.HtlcIndex] = struct{}{}
|
||||||
processRemoveEntry(entry, ourBalance, theirBalance,
|
processRemoveEntry(entry, ourBalance, theirBalance,
|
||||||
nextHeight, remoteChain, false, mutateState)
|
nextHeight, remoteChain, false, mutateState)
|
||||||
|
|||||||
Reference in new issue
Block a user