htlcswitch: increase batch counter for exit hop settle and fail

The idea of the batch counter is to increase it for commit tx updates,
so that if the commit tx cannot be updated immediately (revocation
window exhausted), the batch ticker makes sure it happens later.

The batch counter was increased for forwarded htlcs, but not for exit hop
resolutions.

This lead to the situation where the commitment tx would not be updated,
even though the htlc was settled locally. When no other changes happen
on the channel, the htlc eventually reaches its expiry and the channel
is force closed.
This commit is contained in:
Joost Jager 2019-04-09 16:22:50 +02:00
parent 81bfebe7be
commit 6d2dfed03d
No known key found for this signature in database
GPG Key ID: A61B9D4C393C59C7

@ -945,6 +945,13 @@ out:
break out
}
// If the previous event resulted in a non-empty
// batch, reinstate the batch ticker so that it can be
// cleared.
if l.batchCounter > 0 {
l.cfg.BatchTicker.Resume()
}
select {
// Our update fee timer has fired, so we'll check the network
// fee to see if we should adjust our commitment fee.
@ -1047,13 +1054,6 @@ out:
l.handleDownStreamPkt(packet, true)
// If the downstream packet resulted in a non-empty
// batch, reinstate the batch ticker so that it can be
// cleared.
if l.batchCounter > 0 {
l.cfg.BatchTicker.Resume()
}
// A message from the switch was just received. This indicates
// that the link is an intermediate hop in a multi-hop HTLC
// circuit.
@ -1076,13 +1076,6 @@ out:
l.handleDownStreamPkt(pkt, false)
// If the downstream packet resulted in a non-empty
// batch, reinstate the batch ticker so that it can be
// cleared.
if l.batchCounter > 0 {
l.cfg.BatchTicker.Resume()
}
// A message from the connected peer was just received. This
// indicates that we have a new incoming HTLC, either directly
// for us, or part of a multi-hop HTLC circuit.
@ -1197,6 +1190,8 @@ func (l *channelLink) processHodlEvent(hodlEvent invoices.HodlEvent,
if err := hodlAction(htlc); err != nil {
return err
}
l.batchCounter++
}
return nil