Commit Graph

266 Commits

Author SHA1 Message Date
ziggie
db7e9e1c53 brontide: remove async goroutine to process gossip process result
We cannot rely on a response currently so we avoid spawning
goroutines. This is just a temporary fix to avoid the goroutine
leak.
2025-07-03 16:18:04 +02:00
ziggie
67e7e29413 multi: fix deadlock in p2p race condition
In case we cannot guarantee that the peers has started up
completely we launch the disconnect method asynchronously.
2025-06-26 08:48:39 +02:00
ziggie
6f8a94c094 brontide: increase logging when processing gossip msgs
We add logging to we can draw conclusions how long the processing
of gossip message last and potentially see whether the syncer
buffer channel size is a bottleneck in processing.
2025-06-04 12:21:00 +02:00
Olaoluwa Osuntokun
0484aa2496 peer+feature: start to signal the prod rbf coop close bit
In this commit, we start to signal the prod bit for the rbf coop close
feature. We keep our signaling of the staging bit in place to ensure
the protocol continues to work between those nodes in the wild that are
still signaling the bit.

Fixes https://github.com/lightningnetwork/lnd/issues/9852
2025-06-04 12:20:23 +02:00
ziggie
49d40c8ea1 brontide: fix peer disconnection issue
In case when the rbf coop close feature was active we would not
properly disconnect the peer.
2025-06-04 12:19:41 +02:00
ziggie
45ebb9b900 discovery: add comments to the ctx creation
We highlight why we do not use the returned cancel method of the
context guard.
2025-06-04 10:55:22 +02:00
Elle Mouton
1a8e7587f9 discovery: pass context to ProcessRemoteAnnouncement
With this, we move a context.TODO() out of the gossiper and into the
brontide package - this will be removed in a future PR which focuses on
threading contexts through that code.
2025-06-04 10:54:33 +02:00
Olaoluwa Osuntokun
c493f0c0a9 peer+lnd: add new CLI option to control if we D/C on slow pongs
In this commit, we add a new CLI option to control if we D/C on slow
pongs or not. Due to the existence of head-of-the-line blocking at
various levels of abstraction (app buffer, slow processing, TCP kernel
buffers, etc), if there's a flurry of gossip messages (eg: 1K channel
updates), then even with a reasonable processing latency, a peer may
still not read our ping in time.

To give users another option, we add a flag that allows users to disable
this behavior. The default remains.
2025-05-15 16:36:38 +02:00
Olaoluwa Osuntokun
c5d3d76c33 peer+server: downgrade to legacy coop close for taproot channels
In this commit, we implement logic to downgrade to the legacy coop close
for taproot channels. Before this commit, we wouldn't allow nodes to
start up with both the taproot flag and the rbf flag activated.

In the future, once we implement the spec updates, we'll add support for
this combo, and can revert parts of this commit.
2025-04-01 16:41:26 -07:00
Elle Mouton
b497c4694e multi: add Start and Stop methods for ChannelGraph
We do this in preparation for moving channel cache population logic out
of the constructor and into the Start method. We also will later on
(when topology subscription is moved to the ChannelGraph), have a
goroutine that will need to be kicked off and stopped.
2025-03-24 15:05:47 +02:00
Elle Mouton
00432e46f3 multi: add ChannelGraph Config struct
And use this struct to pass NewChannelGraph anything it needs to be able
to init the KVStore that it houses. This will allow us to add
ChannelGraph specific options.
2025-03-24 15:05:46 +02:00
yyforyongyu
be4c4cc8ff multi: improve logging 2025-03-21 03:24:26 +08:00
Olaoluwa Osuntokun
3681ba6d8b peer: for RBF state machine block req if RBF iterating is outstanding
This fixes an issue in the itests in the restart case. We'd see an error
like:
```
2025-03-12 23:41:10.754 [ERR] PFSM state_machine.go:661: FSM(rbf_chan_closer(2f20725d9004f7fda7ef280f77dd8d419fd6669bda1a5231dd58d6f6597066e0:0)): Unable to apply event err="invalid state transition: received *chancloser.SendOfferEvent while in ClosingNegotiation(local=LocalOfferSent(proposed_fee=0.00000193 BTC), remote=ClosePending(txid=07229915459cb439bdb8ad4f5bf112dc6f42fca0192ea16a7d6dd05e607b92ae, party=Remote, fee_rate=1 sat/vb))"
```

We resolve this by waiting to send in the new request unil the old one
has been completed.
2025-03-18 11:44:59 -05:00
Olaoluwa Osuntokun
fccd984ac1 multi: extract new DeriveHeightHint() function, use for new rbf closer
With this commit, we make sure we set the right height hint, even if the
channel is a zero conf channel.
2025-03-18 11:44:59 -05:00
Olaoluwa Osuntokun
3a18bf088c multi: enable RBF co-op bumps after reconnection
In this commit, we alter the existing co-op close flow to enable RBF
bumps after re connection. With the new RBF close flow, it's possible
that after a success round _and_ a re connection, either side wants to do
another fee bump. Typically we route these requests through the switch,
but in this case, the link no longer exists in the switch, so any
requests to fee bump again would find that the link doesn't exist.

In this commit, we implement a work around wherein if we have an RBF
chan closer active, and the link isn't in the switch, then we just route
the request directly to the chan closer via the peer. Once we have the
chan closer, we can use the exact same flow as prior.
2025-03-18 11:44:21 -05:00
Olaoluwa Osuntokun
80b48fb49b peer: update rbf close client logic w/ error and iteration awareness
We'll properly handle a protocol error due to user input by halting, and
sending the error back to the user.

When a user goes to issue a new update, based on which state we're in,
we'll either kick off the shutdown, or attempt a new offer. This matches
the new spec update where we'll only send `Shutdown` once per
connection.
2025-03-18 11:44:21 -05:00
Olaoluwa Osuntokun
81d34c4ac2 peer+rpc: set new rbf coop close rbf update fields 2025-03-18 11:44:20 -05:00
Olaoluwa Osuntokun
282c50e444 peer: attempt to unregister endpoint before registering
If we hit an error, we want to wipe the state machine state, which also
includes removing the old endpoint.
2025-03-18 11:44:20 -05:00
Olaoluwa Osuntokun
029fbd22fd peer: make activeChanCloses a SyncMap
This fixes some existing race conditions, as the `finalizeChanClosure`
function was being called from outside the main event loop.
2025-03-18 11:44:20 -05:00
Olaoluwa Osuntokun
6364e98f0e peer: conditionally create rbf coop close fsm based on feature bits
In this commit, we fully integrate the new RBF close state machine into
the peer.

For the restart case after shutdown, we can short circuit the existing
logic as the new FSM will handle retransmitting the shutdown message
itself, and doesn't need to delegate that duty to the link.

Unlike the existing state machine, we're able to restart the flow to
sign a coop close with a new higher fee rate. In this case, we can now
send multiple updates to the RPC caller, one for each newly singed coop
close transaction.

To implement the async flush case, we'll launch a new goroutine to wait
until the state machine reaches the `ChannelFlushing` state, then we'll
register the hook. We don't do this at start up, as otherwise the
channel may _already_ be flushed, triggering an invalid state
transition.
2025-03-18 11:44:20 -05:00
Olaoluwa Osuntokun
f22cba9de1 peer: conditionally create new RBF chan closer 2025-03-18 11:44:20 -05:00
Olaoluwa Osuntokun
4fff0d8401 peer: create ErrorReporter implementation for rbf-fsm 2025-03-18 11:44:20 -05:00
Olaoluwa Osuntokun
2dae0ba96e peer: add new composite chanCloserFsm type
In this commit, we add a new composite chanCloserFsm type. This'll allow
us to store a single value that might be a negotiator or and rbf-er.

In a follow up commit, we'll use this to conditionally create the new
rbf closer.
2025-03-18 11:44:20 -05:00
Olaoluwa Osuntokun
23a9a761e3 peer: add initial awareness of new rbf coop closer
In this commit, we use the interfaces we created in the prior commit to
make a new method capable of spinning up the new rbf coop closer.
2025-03-18 11:44:20 -05:00
Olaoluwa Osuntokun
047d3532f9 peer: move existing chan closer init logic to new method
In the next commit, we'll start checking feature bits to decide how to
init the chan closer.

In the future, we can move the current chan closer handling logic into
an `MsgEndpoint`, which'll allow us to get rid of the explicit chan
closer map and direct handling.
2025-03-18 11:44:20 -05:00
Olaoluwa Osuntokun
baf0d83c37 peer: update chooseDeliveryScript to gen script if needed
In this commit, we update `chooseDeliveryScript` to generate a new
script if needed. This allows us to fold in a few other lines that
always followed this function into this expanded function.

The tests have been updated accordingly.
2025-03-18 11:44:20 -05:00
Olaoluwa Osuntokun
bf3007a2ce multi: thread thru RPC caller context from CloseChannel 2025-03-18 11:44:20 -05:00
Olaoluwa Osuntokun
daed552bf1 peer: make a DaemonAdapter impl for lnd
Similar to the last commit, in this commit, we make a daemon adapter
impl for lnd. We'll use this for any future protofsm based state
machine.
2025-03-18 11:44:20 -05:00
Olaoluwa Osuntokun
c32d4f9695 peer: add an implementation of chancloser.ChanObserver
In this commit, we add an implementation of a new interface the rbf coop
state machine needs. We take care to accept interfaces everywhere, to
make this easier to test, and decouple from the concrete types we'll end
up using elsewhere.
2025-03-18 11:44:20 -05:00
Eugene Siegel
6eb746fbba server.go+accessman.go: introduce caches for access permissions
Here we introduce the access manager which has caches that will
determine the access control status of our peers. Peers that have
had their funding transaction confirm with us are protected. Peers
that only have pending-open channels with us are temporary access
and can have their access revoked. The rest of the peers are granted
restricted access.
2025-03-11 20:42:34 -04:00
Olaoluwa Osuntokun
540d3c0fc7 multi: switch to lock time from sequence for coop close v2 2024-12-10 23:07:01 +01:00
Olaoluwa Osuntokun
fb429d658b Merge pull request #9330 from ProofOfKeags/update/fn2
multi: update to fn v2
2024-12-09 12:56:23 +01:00
Oliver Gugger
86b3be71fe multi: thread through and use AuxTrafficShaper 2024-12-05 12:39:34 +01:00
Keagan McClelland
ed2989ae33 multi: update to fn v2 2024-12-04 13:19:00 -07:00
Elle Mouton
ab7aae0708 multi: rename nolint:lll to nolint:ll
Find and replace all nolint instances refering to the `lll` linter and
replace with `ll` which is the name of our custom version of the `lll`
linter which can be used to ignore log lines during linting.

The next commit will do the configuration of the custom linter and
disable the default one.
2024-12-02 09:14:21 +02:00
Elle Mouton
439a6c7d6c multi: rename chan DB Open method to OpenForTesting 2024-11-28 13:51:15 +02:00
Elle Mouton
b86980ec40 channeldb: remove graph db from channeldb
Now that the channel.DB no longer uses the ChannelGraph pointer, we can
completely remove it as a member of channeldb.DB.
2024-11-28 13:36:15 +02:00
Elle Mouton
74a4b1922b refactor: move graph related DB code to graph/db from channeldb
This is a pure refactor commit. It moves over all the graph related CRUD
code from `channeldb` to `graph/db`.
2024-11-28 13:36:13 +02:00
Elle Mouton
9f54ec90aa multi+refactor: move models package to graph/db
All the structs defined in the `channeldb/models` package are graph
related. So once we move all the graph CRUD code to the graph package,
it makes sense to have the schema structs there too. So this just moves
the `models` package over to `graph/db/models`.
2024-11-28 13:34:33 +02:00
Elle Mouton
c2923e2214 multi: remove PrefixLog
And instead use the new btclog Logger `WithPrefix` method.
2024-11-27 10:44:32 +02:00
Keagan McClelland
111c9b05f3 htlcswitch+peer: allow the disabling of quiescence
Here we add a flag where we can disable quiescence. This will be used
in the case where the feature is not negotiated with our peer.
2024-11-26 14:13:39 -07:00
Keagan McClelland
70e3804121 htlcswitch: add link operation for initiating quiescence 2024-11-26 13:51:57 -07:00
Carla Kirk-Cohen
774bfa740a htlcswitch: relay experimental endorsement signal with update_add_htlc 2024-11-22 09:16:56 -05:00
yyforyongyu
fe03aa0201 peer+lnd: fix peer blocking on node shutdown
This commit fixes a case where the peer blocks the shutdown process.
During the shutdown, the server will call `s.DisconnectPeer`, which
calls `peer.Disconnect`. Because the peer never enters `peer.Start` via
`s.peerInitializer`, the `startReady` chan will not be closed, causing
`peer.Disconnect` to hang forever. We now fix it by only block on
`startReady` when the peer is started.
2024-11-18 18:49:34 +08:00
Elle Mouton
9d0cd3ff4f multi: update more loggers to the v2 type 2024-10-22 17:03:56 +02:00
Elle Mouton
23602e017e multi: start updating various loggers to use the new v2 type 2024-10-22 17:03:55 +02:00
Olaoluwa Osuntokun
49275e1d46 Merge pull request #9197 from guggero/aux-signer-batching-fixes
[custom channels]: Aux signer batching fixes
2024-10-21 17:49:15 -07:00
Boris Nagaev
04a2003f3b peer: fix logging (missing argument) [skip ci]
Previously, LND log used to have such records:
[WRN] PEER: Peer(...): Link=%!v(MISSING) is not active

Now the short channel ID is printed there instead of "%!v(MISSING)".
2024-10-18 12:09:44 -03:00
Jonathan Harvey-Buschel
b3f953b1c4 multi: allow mock aux signer to customize sig jobs 2024-10-17 17:33:14 +02:00
Olaoluwa Osuntokun
9a181105e2 multi: hook up new aux interfaces 2024-10-02 18:10:00 -07:00