Repository navigation
fix(peer_store): upsert peer address when re-adding known peer - #1175
vincenzopalazzo wants to merge 1 commit into
Conversation
|
👋 Thanks for assigning @tnull as a reviewer! |
There was a problem hiding this comment.
🤖 Potential bug: an unverified address can overwrite a working peer address
connect_peer_if_necessary returns Ok(()) without dialing when the peer is already connected, so the subsequent upsert_peer can persist an address we never connected to. For example, if a peer is connected at good:9735, calling node.connect(X, "typo:9735", true) succeeds and replaces the working address. After a restart, the reconnect loop uses the typo and fails to reconnect. The same issue applies to open_channel_inner.
Could we only upsert when we actually dialed the requested address? Comparing with PeerDetails::socket_address won't work because, for inbound peers, it's the ephemeral source address rather than the listening address. A test covering an already-connected peer with a different requested address would help prevent this regression.
|
Please rebase this onto #1234. |
Node::connect(..., persist=true) and open_channel kept the first stored address, so a later working address was never used for reconnect (lightningdevkit#700). upsert_peer replaces the address through the persist-first update_peers path from lightningdevkit#1234. connect and open_channel call it only when this call dialed the requested address. An already-connected peer keeps add_peer, so an unverified address cannot overwrite a working one. The LSPS2 receive path stays add_peer (lightningdevkit#1147). Co-authored-by: Bartok <259807879+Bartok9@users.noreply.github.com> Assisted-by: goose (AI)
1b28e63 to
358673c
Compare
|
Sorry for delay, this should be ready for another pass! |
Supersedes #1002 and #1115. Addresses the peer-store side of #700; the
liquidity-source side is tracked in #1147.
Rebased onto the persist-first peer store path from #1234. The previous
PeerStorepersist rewrite is dropped.upsert_peerreplaces a stored address throughupdate_peers.Node::connectandopen_channelcall it only when the peer was notalready connected, so an address we never dialed cannot overwrite a
working one. An already-connected peer keeps
add_peer. The LSPS2receive path stays
add_peer.