1
0

Fix CTNs in should_be_closed_due_to_expiring_htlcs (fixes #7906).

Also fix sending too many fee updates.
Rename lnworker.on_channel_update, that name was misleading.
This commit is contained in:
ThomasV
2022-08-02 18:00:33 +02:00
parent 0c8a828704
commit a5965933d2
5 changed files with 9 additions and 9 deletions

View File

@@ -1576,8 +1576,8 @@ class Channel(AbstractChannel):
# to the present, then unilaterally close channel
recv_htlc_deadline = lnutil.NBLOCK_DEADLINE_BEFORE_EXPIRY_FOR_RECEIVED_HTLCS
for sub, dir, ctn in ((LOCAL, RECEIVED, self.get_latest_ctn(LOCAL)),
(REMOTE, SENT, self.get_oldest_unrevoked_ctn(LOCAL)),
(REMOTE, SENT, self.get_latest_ctn(LOCAL)),):
(REMOTE, SENT, self.get_oldest_unrevoked_ctn(REMOTE)),
(REMOTE, SENT, self.get_latest_ctn(REMOTE)),):
for htlc_id, htlc in self.hm.htlcs_by_direction(subject=sub, direction=dir, ctn=ctn).items():
if not self.hm.was_htlc_preimage_released(htlc_id=htlc_id, htlc_proposer=REMOTE):
continue
@@ -1588,8 +1588,8 @@ class Channel(AbstractChannel):
# will unilaterally close the channel and time out the HTLC
offered_htlc_deadline = lnutil.NBLOCK_DEADLINE_AFTER_EXPIRY_FOR_OFFERED_HTLCS
for sub, dir, ctn in ((LOCAL, SENT, self.get_latest_ctn(LOCAL)),
(REMOTE, RECEIVED, self.get_oldest_unrevoked_ctn(LOCAL)),
(REMOTE, RECEIVED, self.get_latest_ctn(LOCAL)),):
(REMOTE, RECEIVED, self.get_oldest_unrevoked_ctn(REMOTE)),
(REMOTE, RECEIVED, self.get_latest_ctn(REMOTE)),):
for htlc_id, htlc in self.hm.htlcs_by_direction(subject=sub, direction=dir, ctn=ctn).items():
if htlc.cltv_expiry + offered_htlc_deadline > local_height:
continue

View File

@@ -19,7 +19,7 @@ class HTLCManager:
'locked_in': {}, # "side who offered htlc" -> action -> htlc_id -> whose ctx -> ctn
'settles': {}, # "side who offered htlc" -> action -> htlc_id -> whose ctx -> ctn
'fails': {}, # "side who offered htlc" -> action -> htlc_id -> whose ctx -> ctn
'fee_updates': {}, # "side who initiated fee update" -> action -> list of FeeUpdates
'fee_updates': {}, # "side who initiated fee update" -> index -> list of FeeUpdates
'revack_pending': False,
'next_htlc_id': 0,
'ctn': -1, # oldest unrevoked ctx of sub

View File

@@ -1896,7 +1896,7 @@ class Peer(Logger):
self.logger.info("FEES HAVE FALLEN")
elif feerate_per_kw > chan_fee * 2:
self.logger.info("FEES HAVE RISEN")
elif chan.get_oldest_unrevoked_ctn(REMOTE) == 0:
elif chan.get_latest_ctn(REMOTE) == 0:
# workaround eclair issue https://github.com/ACINQ/eclair/issues/1730
self.logger.info("updating fee to bump remote ctn")
if feerate_per_kw == chan_fee:

View File

@@ -431,7 +431,7 @@ class LNWalletWatcher(LNWatcher):
closing_txid=closing_txid,
closing_height=closing_height,
keep_watching=keep_watching)
await self.lnworker.on_channel_update(chan)
await self.lnworker.handle_onchain_state(chan)
@log_exceptions
async def do_breach_remedy(self, funding_outpoint, closing_tx, spenders):

View File

@@ -609,7 +609,7 @@ class LNGossip(LNWorker):
orphaned_ids = [c['short_channel_id'] for c in orphaned]
await self.add_new_ids(orphaned_ids)
if categorized_chan_upds.good:
self.logger.debug(f'on_channel_update: {len(categorized_chan_upds.good)}/{len(chan_upds)}')
self.logger.debug(f'process_gossip: {len(categorized_chan_upds.good)}/{len(chan_upds)}')
class LNWallet(LNWorker):
@@ -985,7 +985,7 @@ class LNWallet(LNWorker):
if chan.funding_outpoint.to_str() == txo:
return chan
async def on_channel_update(self, chan: Channel):
async def handle_onchain_state(self, chan: Channel):
if type(chan) is ChannelBackup:
util.trigger_callback('channel', self.wallet, chan)
return