lnd/peer
Olaoluwa Osuntokun ac71ea7559 discovery+funding+peer+server: migrate gossip result to actor.Future[error]
In this commit, we eliminate the three buffered chan error patterns in
the discovery package and replace them with actor.Promise[error]/
actor.Future[error]. The old pattern is error-prone: if a channel is
completed more than once (e.g. when a deferred message copy is
re-enqueued and processed again), the second write to a capacity-1
channel blocks forever. actor.Promise.Complete() is idempotent via
sync.Once, so the second call is always a safe no-op regardless of
whether anyone holds a reference to the Future.

Additionally, PropagateChanPolicyUpdate previously blocked on <-errChan
after enqueuing a policy update with no quit-channel check, creating a
latent deadlock if the gossiper shut down between enqueue and send. It
now uses AwaitGossipResult with a ContextFromQuit-derived context, so
shutdown is always respected.

This is an atomic migration that updates all callers in the same
commit so each commit builds standalone. The three main pieces are:

discovery

networkMsg.err chan error becomes errPromise actor.Promise[error].
chanPolicyUpdateRequest.errChan chan error becomes errPromise.
syncTransitionReq.errChan chan error becomes errPromise. All ~65 sites
that previously wrote to the error channel now call
completeGossipResult(nMsg.errPromise, err) instead.

ProcessRemoteAnnouncement and ProcessLocalAnnouncement now return
actor.Future[error] instead of chan error. The capacity-2 buffer
comment on ProcessRemoteAnnouncement, which was itself a workaround
for the old pattern, is removed along with the TODO referencing the
actor model redesign. ProcessSyncTransition in syncer.go follows the
same pattern: the errChan select is replaced with AwaitGossipResult
using a ContextFromQuit-derived context.

funding

The SendAnnouncement function type in funding.Config changes from
returning chan error to returning actor.Future[error]. The call sites
in addToGraph and announceChannel are updated to await the future with
AwaitGossipResult, passing a context derived from f.quit via
ContextFromQuit. Shutdown signals (context.Canceled and
discovery.ErrGossiperShuttingDown) are both mapped to
ErrFundingManagerShuttingDown via the new mapGossipError helper, which
also factors out the duplicated graph-rejected / unknown-error
handling. The three mock SendAnnouncement implementations in
manager_test.go are updated accordingly.

peer+server

In peer/brontide.go, the ProcessRemoteAnnouncement call in the gossip
stream handler intentionally discards the result since remote gossip
messages are fire-and-forget from the peer's perspective. The old
comment explaining why the chan error was unsafe to use is replaced
with a note that an unawaited Future[error] carries no overhead.

In server.go (applyChannelUpdate), the previous select on errChan and
the quit channel is replaced with ContextFromQuit + AwaitGossipResult.
2026-04-10 19:16:49 -07:00
..
brontide.go discovery+funding+peer+server: migrate gossip result to actor.Future[error] 2026-04-10 19:16:49 -07:00
brontide_test.go peer: include ping pong-size in debug summaries 2026-03-26 18:55:13 +08:00
chan_observer.go peer: fix MarkCoopBroadcasted to correctly use local parameter 2026-02-02 12:16:29 +01:00
daemon_adapters.go peer: conditionally create rbf coop close fsm based on feature bits 2025-03-18 11:44:20 -05:00
interfaces.go peer+lnwire: move LinkUpdater to lnwire 2024-03-06 11:59:19 -08:00
log.go multi: start updating various loggers to use the new v2 type 2024-10-22 17:03:55 +02:00
musig_chan_closer.go lnwallet/chancloser: fix MuSig2 nonce reuse across RBF rounds 2026-03-27 14:04:25 -07:00
musig_nonce_order_test.go lnwallet/chancloser: address lint and PR review feedback 2026-03-27 14:04:25 -07:00
ping_manager.go peer+lnd: add new CLI option to control if we D/C on slow pongs 2025-05-15 16:36:38 +02:00
ping_manager_test.go peer+lnd: add new CLI option to control if we D/C on slow pongs 2025-05-15 16:36:38 +02:00
setup_test.go multi: use MakeTestGraph everywhere for test graph creation 2025-05-22 14:14:42 +02:00
test_utils.go peer: add mock BestBlockView to test peer config 2026-03-24 11:49:48 +02:00