lightningnetwork / lnd

Lightning Network Daemon ⚡️
MIT License
7.71k stars 2.09k forks source link

Backup exports fails when static channel backups is updated #5262

Open alexbosworth opened 3 years ago

alexbosworth commented 3 years ago

Background

When subscribing to changes to static channel backups using the SubscribeChannelBackups method, sometimes an error event is raised:

unable to fetch all static chan backups: link node with target identity not found

Your environment

Steps to reproduce

  1. Subscribe to backups sub
  2. Receive a backups event

Expected behavior

No error events should be raised

Actual behavior

An error is published to the subscription:

2 UNKNOWN: unable to fetch all static chan backups: link node with target identity not found
wpaulino commented 3 years ago

I looked into this and found that it could happen when multiple channels with a peer are closed cooperatively and they confirm within the same block. A subscription update is sent within MarkChannelClosed for each channel, which causes us to fetch all open channels to update our backups. If the other channels haven't had MarkChannelClosed invoked yet, they'll show up in that list of open channels. Once all the channels are fully closed, the link node for that channel will be pruned, since there aren't any open channels left with that peer. If that happens before assembleChanBackup, which does another pass on each open channel to retrieve all addresses for the peer, then the error above is possible.

saubyk commented 3 weeks ago

Haven't seen this issue reported anywhere else. Closing for now.

saubyk commented 3 weeks ago

Reopening as confirmed by @alexbosworth that this issue still occurs