[bug]: btcd backend: closed channels stay in the graph after a websocket reconnect, so peers ban the node for outdated gossip
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 48/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- go
- Ambito
- backend, networking
Direzione di ricerca
Start with routing/chainview/btcd.go and trace how the chain filter is loaded and restored after an RPC websocket reconnect; the issue also points to rpcclient.reregisterNtfns in infrastructure.go. Use the linked reproduction bundle to confirm the failure after the proxy reconnect. Done means closed channels are removed from the graph after reconnect, and the issue’s question about cleanup of already stale graph edges is addressed.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Background
Main impact: peers ban the node for gossiping outdated channels. A node on
the btcd backend keeps its own closed channels in its graph and keeps
announcing them. Peers on lnd with gossip banning (#9009) reply with
outdated channel announcement. After enough of these, they ban the node for
48h and disconnect it if they share no channel with it. The node cannot fix
this by itself. Each restart and each new peer starts the same cycle again.
Why the channels stay: with bitcoin.node=btcd, a short drop of the
lnd↔btcd websocket makes lnd miss the spends of all channels that exist at
that moment. When one of these channels closes later, lnd lists it in
closedchannels, but its edge stays in the channel graph. An lnd restart does
not remove it.
We found this on a production node that ran on btcd before we moved it to
bitcoind. 126 of its own channels were still in its graph, and 125 of them
were closed on chain. About 60% of all closes from the btcd period stayed in
the graph. After the move to bitcoind, all 52 later closes were removed from
the graph correctly. Peers still banned the node after the move, because the
old stale edges stay in the graph.
Your environment
- lnd: v0.21.3-beta and v0.21.6-beta (Docker images
lightninglabs/lnd) - backend: btcd v0.26.0 (built from source)
- OS: Linux containers (Docker Compose v2)
- production node: btcd backend, later moved to bitcoind
Steps to reproduce
Repro bundle: https://gist.github.com/bufo24/67812acc91add20c1d1c8cd57f76f5eb
git clone https://gist.github.com/67812acc91add20c1d1c8cd57f76f5eb.git lnd-btcd-repro
cd lnd-btcd-repro && bash run.sh
Set LND_IMAGE=<image> to test another build. Exit code 1 means the bug
reproduced. Requirements: Docker Compose v2, bash, jq.
Topology: alice, bob (lnd) → socat proxy → btcd. A proxy restart drops
all lnd↔btcd websockets and btcd keeps running. (In our tests, a btcd restart
in regtest lost the chain, so we use the proxy.)
- Control: open alice→bob, close, mine 6 blocks. The edge is removed
(GRPH: Block … closed 1 channels). - Open alice→bob. Restart the proxy. All 4 lnd rpcclients log
Reestablished connection to RPC server. Close the channel, mine 6 blocks. - Restart alice.
Expected behavior
After step 2, the closed channel is removed from alice's graph, the same as
in the control case.
Actual behavior
RESULT[control]: closed channel 122045790748672 was REMOVED from the graph
alice has 4 btcd connections: ... (all through the proxy)
alice logged 4 'Reestablished connection to RPC server' lines
RESULT[after-reconnect]: closed channel 135239930281984 is STILL IN THE GRAPH (closedchannels lists it as closed)
RESULT[after-lnd-restart]: closed channel 135239930281984 is STILL IN THE GRAPH
lnd logs no closed 1 channels for the block with the close. After the
restart, Prune tip for Channel Graph: height=135 is already after the spend,
so the startup sync does not rescan it. Same result on v0.21.3 and v0.21.6,
in 3 of 3 runs.
Cause
routing/chainview/btcd.gosends the watched outpoints to btcd with
LoadTxFilter. It finds spends from the server-filtered
OnFilteredBlockConnectednotifications. It does not set
OnClientConnected.- btcd stores the tx filter per websocket client (
rpcwebsocket.go,
wsClient.filterData). A new connection has no filter, so
filteredblockconnectedhas no matched transactions. rpcclient.reregisterNtfns(infrastructure.go) re-sendsnotifyblocks,
notifynewtx,notifyspentandnotifyreceived, but notloadtxfilter.- New channels call
UpdateFilter, which adds only their own outpoints. So
only the channels that exist at the reconnect are lost. - The graph builder still moves the prune tip forward for each block, so
syncGraphWithChainnever rescans the missed spends. Zombie pruning skips
the node's own channels, so nothing else removes them.
Possible fix
- On reconnect, reload the full
chainFilterwithLoadTxFilter(reload=true)
from anOnClientConnectedhandler, or - match each connected block against the local
chainFilterinstead of
relying on the server-side filter.
Question: will a fix also clean up the stale channels that already exist,
or only prevent new ones? A fix in the chain view only prevents new stale
channels. Affected nodes keep the old edges, so they keep gossiping them and
keep getting banned, also after a backend change (as in our case). A cleanup
could, for example, check the node's own graph edges against the
closed-channel records, or against the chain, at startup.
Workaround
lncli abandonchannel --chan_point <txid:idx> --i_know_what_i_am_doing for
each channel that is closed on chain but still in the graph. In the repro
(KEEP=1 ./run.sh), this removes the stale edge.
- Lingua principale
- Go
- Stelle
- 8.2k
- Fork
- 2.3k
- Merge medio
- 1g 11h
- PR unite (30g)
- 103
Preparare l'ambiente
- Include un Dockerfile o un file Docker Compose
- Ha un modello di pull request
- Nessuna guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di lightningnetwork/lnd
-
funding: failure logs print `<nil>` error and zero channel IDForse già presa @litbot-9000 l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 90/100
lightningnetwork/lnd#11676 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 Mezza giornata Idoneità per principianti 85/100
lightningnetwork/lnd#11674 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
lightningnetwork/lnd#11672 ·
I maintainer di solito rispondono entro 1 giorno
-
test flake
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
lightningnetwork/lnd#11663 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
[flake]: lnwallet/test/bitcoind.TestLightningWalletBitcoindRPCPolling/spend_unconfirmed_outputsApertatest flake
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
lightningnetwork/lnd#11642 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di lightningnetwork/lnd
Issue simili
-
ConcatAgenticMessages loses the approval request ID of a streamed MCP tool callForse già presa @ningsiyuan1024 l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 86/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
containers/gvisor-tap-vsock#796 ·
I maintainer di solito rispondono entro 2 giorni
-
external needs:triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
celestiaorg/celestia-node#5448 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 79/100
I maintainer di solito rispondono entro 1 giorno
-
[Bug]: Azure SAS signing uses local time instead of UTC, shifting validity window on non-UTC hostsForse già presa @huanghaoyuanhhy l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
zilliztech/milvus-backup#1418 ·
I maintainer di solito rispondono entro 1 giorno