Commit Graph

202 Commits

Author SHA1 Message Date
Olaoluwa Osuntokun
f09c517bc6 peer: don't stop global msg router
In this commit, we fix a bug that would cause a global message router to
be stopped anytime a peer disconnected. The global msg router only
allows `Start` to be called once, so afterwards, no messages would
properly be routed.
2024-08-14 19:23:02 -07:00
Olaoluwa Osuntokun
b028af1836 multi: make MsgRouter available in the ImplementationCfg
With this commit, we allow the `MsgRouter` to be available in the
`ImplementationCfg`. With this, programs outside of lnd itself are able
to now hook into the message processing flow to direct handle custom
messages, and even normal wire messages.
2024-08-14 19:23:02 -07:00
Olaoluwa Osuntokun
927aa84b5f peer: update readHandler to dispatch to msgRouter if set
Over time with this, we should be able to significantly reduce the size
of the peer.Brontide struct as we only need all those deps as the peer
needs to recognize and handle each incoming wire message itself.
2024-08-14 19:23:02 -07:00
Olaoluwa Osuntokun
9acad37f57
peer: always send channel update on reconnect
We have existing logic to attempt to reliably send a channel update to
the remote peer. In the wild, we've seen this fail, as it's possible
right when we send the update the peer disconnects.

In this commit, we implement a simple fix which is just to send the chan
update each time we connect to the remote party.

Fixes https://github.com/lightningnetwork/lnd/issues/6870.
2024-08-07 17:48:50 -07:00
Keagan McClelland
2ddc3db5f8
peer: add message summary for Stfu 2024-08-05 17:23:19 -07:00
Keagan McClelland
e3a9d0acbe
multi: break ChannelConstraints into two sub-structures
This commit breaks the ChannelConstraints structure into two
sub-structures that reflect the fundamental differences in how
these parameters are used. On its face it may not seem necessary,
however the distinction introduced here is relevant for how we
will be implementing the Dynamic Commitments proposal.
2024-08-01 12:00:32 -07:00
Keagan McClelland
1d65f5bd12
peer: refactor createChanCloser to use ChannelParty 2024-07-31 14:50:27 -07:00
Keagan McClelland
0996e4f163
multi: refactor lnwallet/channel.go to use ChannelParty in select places
We also include changes to contractcourt, htlcswitch and peer to stitch the
boundaries together.
2024-07-31 14:50:26 -07:00
Eugene Siegel
d6001d033b
htlcswitch+lnwallet: calculate fee exposure as commit fees + dust
This commit expands the definition of the dust limit to take into
account commitment fees as well as dust HTLCs. The dust limit is now
known as a fee exposure threshold. Dust HTLCs are fees anyways so it
makes sense to account for commitment fees as well. The link has
been modified slightly to calculate dust. In the future, the switch
dust calculations can be removed.
2024-07-29 14:13:21 -04:00
yyforyongyu
d992cf94d6
multi: add SpewLogClosure to avoid code repetition 2024-07-25 22:18:49 +08:00
yyforyongyu
b6049ff94b
multi: add NewLogClosure in lnutils to avoid repetition
And replaces all usage of `logClosure` with `lnutils.LogClosure`.
2024-07-25 21:25:23 +08:00
yyforyongyu
e61cba8d22
multi: return verbose errors when fetching edges 2024-06-10 08:40:18 +08:00
yyforyongyu
78cc1619d7
multi: fix complaints from IDE and linter
Fixed unused param and nilness cond.
2024-06-07 00:45:15 +08:00
Olaoluwa Osuntokun
64639fb771
Merge pull request #8762 from ProofOfKeags/bugfix/ping-stability
Adjust ping parameters to improve tor stability
2024-05-21 19:34:57 -07:00
Keagan McClelland
1148e572bf peer: triple timeout parameters to give tor more grace 2024-05-21 13:36:46 -07:00
Keagan McClelland
61191a576d peer: make PingManager.Stop infallible 2024-05-21 13:29:31 -07:00
Keagan McClelland
94a9baefeb peer: reduce upper bound of pong bytes to ease bandwidth load 2024-05-21 13:27:56 -07:00
Oliver Gugger
01e3ac61d8
Merge pull request #8631 from Chinwendu20/brontidetest
[code-health]: reduce duplication in brontide test.
2024-05-21 12:46:16 +02:00
Ononiwu Maureen
b741132a81
peer: Add startPeer test function
Signed-off-by: Ononiwu Maureen <maureen.ononiwu@outlook.com>
2024-05-10 10:23:31 +01:00
Ononiwu Maureen
2ec0fe0717
peer: Add new function to create test peer.
Signed-off-by: Ononiwu Maureen <maureen.ononiwu@outlook.com>
2024-05-08 13:17:14 +01:00
Ononiwu Maureen
8f76c5eeef
peer: Create mockswitch, publTx, notifier in ..
test_utils

Signed-off-by: Ononiwu Maureen <maureen.ononiwu@outlook.com>
2024-05-08 12:04:30 +01:00
Ononiwu Maureen
536c69b793
peer: createTestPeerWithChannel returns a struct
The `createTestPeerWithChannel` function is made to return this newly
created struct and error.

This is useful because upcoming commits would require us returning more
objects from the function.

Signed-off-by: Ononiwu Maureen <maureen.ononiwu@outlook.com>
2024-05-08 11:59:08 +01:00
Ononiwu Maureen
389ecb535b
peer: Change createTestPeer name.
In this function `createTestPeer` is changed to
`createTestPeerWithChannel`. This is useful in coming commits where we
decouple the process of creating test peer from the function.

Signed-off-by: Ononiwu Maureen <maureen.ononiwu@outlook.com>
2024-05-08 11:57:15 +01:00
Tom Kirkpatrick
3837c3f12e
lnwallet: add configurable cache for web fee estimator
Add fee.min-update-timeout and fee.max-update-timeout config options to
allow configuration of the web fee estimator cache.
2024-05-04 14:41:41 +08:00
Oliver Gugger
648fb22f63
multi: wrap all errors 2024-04-11 15:04:03 +02:00
Oliver Gugger
6377f98536
Merge pull request #8615 from ProofOfKeags/bugfix/revert-compulsory-gossip-queries
Revert "feature: make gossip queries compulsory"
2024-04-05 06:57:39 +00:00
Keagan McClelland
dd2da29cba peer: re-add AuthGossiper nil check 2024-04-03 15:47:50 -07:00
Carla Kirk-Cohen
040fcb0f92
multi: add option to disable route blinding, rejecting at link
Add an option to disable route blinding, failing back any HTLC with
a blinding point set when we haven't got the feature enabled.

Note that this commit only handles the case where we're chosen as the
relaying node (where the blinding point is in update_add_htlc), we'll
add handling for the introduction node case once we get to handling of
blinded payloads).
2024-04-03 08:35:41 -04:00
Keagan McClelland
dad53b3f9a Revert "feature: make gossip queries compulsory"
This reverts commit 717facc202.

It turns out that we can't do this since it would result in
incompatibility with LDK. The spec has been updated to reallow
optional gossip queries so we revert this commit.
2024-04-02 16:43:27 -07:00
Joost Jager
e8c97deaef htlcswitch: add receiver-side inbound fee support 2024-03-31 16:49:19 +02:00
Carla Kirk-Cohen
e4f90ec593
lnwire: add blinding point to update_add_htlc TLVs
Add blinding points to update_add_htlc. This TLV will be set for
nodes that are relaying payments in blinded routes that are _not_
the introduction node.
2024-03-27 09:38:50 -04:00
Keagan McClelland
659ad459bb brontide: placate linter 2024-03-08 15:54:25 -08:00
Keagan McClelland
db39a905cb multi: make NewChanIDFromOutpoint accept value instead of pointer 2024-03-08 15:47:55 -08:00
Keagan McClelland
fd1cd315ce multi: don't leak underlying pointer to LightningChannel.ChannelPoint() 2024-03-08 15:27:19 -08:00
Keagan McClelland
f5f0286e34 peer+lnwire: move LinkUpdater to lnwire
The purpose of this interface is to distinguish messages that are
bound to a particular channel_id from those that are not. There is
no reason this ought to be a property of the peer package as it is
entirely determined by the contents of the message itself. Therefore
we move it to the lnwire package so it can be used without having
import cycles elsewhere in the codebase.
2024-03-06 11:59:19 -08:00
ffranr
cd566eb097
multi: fix fmt.Errorf error wrapping
Refactor fmt.Errorf usage to correctly wrap errors instead of using
non-wrapping format verbs.
2024-02-27 11:13:40 +00:00
Elle Mouton
785790abed
peer/lnwallet: persist shutdown info on send
In this commit, we start persisting shutdown info when we send the
Shutdown message. When starting up a link, we also first check if we
have previously persisted Shutdown info and if we have, we start the
link in shutdown mode meaning that it will not accept any new outgoing
HTLC additions and it will queue the shutdown message after any pending
CommitSig has been sent.
2024-02-21 11:58:18 +02:00
Elle Mouton
8c064b86f1
peer: call DisableAdds before link.OnCommitOnce
This commit moves calls to link.DisableAdds to outside link.OnCommitOnce
call backs. This is done so that if a user requests shutdown, then we
can immediately block any new outgoing HTLCs. It's only the sending of
the Shutdown message that needs to wait until after any pending
CommitSig message is sent.
2024-02-21 11:35:11 +02:00
Elle Mouton
972f57e9a7
peer+htlcswitch: update Enable/DisableAdds API
In this commit, the `ChannelUpdateHandler`'s `EnableAdds` and
`DisableAdds` methods are adjusted to return booleans instead of errors.
This is done becuase currently, any error returned by these methods is
treated by just logging the error since today all it means is that the
proposed update has already been done. And so all we do today is log the
error. But in future, if these methods are updated to return actual
errors that need to be handled, then we might forget to handle them
correctly at the various call sights. So we instead change the signature
of the function to just return a boolean. In future, if we do need to
return any error, we will have to go inspect every call sight in any
case to fix compliation & then we can be sure we are handling the errors
correctly.
2024-02-21 11:35:11 +02:00
Elle Mouton
71753af8ee
multi: fix various typos 2024-02-21 11:35:10 +02:00
Keagan McClelland
317aaf9940 peer: fix issue where we echo remote Shutdown 2024-01-30 12:15:59 -05:00
Olaoluwa Osuntokun
1caca81ba1
Merge pull request #8167 from ProofOfKeags/bugfix/htlc-flush-shutdown
Bugfix/htlc flush shutdown
2024-01-23 18:49:47 -08:00
Keagan McClelland
69ef1b2b3b docs: update release notes 2024-01-23 14:31:57 -08:00
Olaoluwa Osuntokun
185119f5c3
peer: refactor main event loop for ping handler
The error was never used as the init couldn't return an error, so we do
away with that. We also modify the main event loop dispatch to more
closely match other areas of the codebase.
2024-01-22 18:20:30 -08:00
Olaoluwa Osuntokun
b5cbeb4ad7
peer: make PingManager disconnect call async
In this commit, we make all calls to disconnect after a ping/pong
violation is detected in the `PingManager` async. We do this to avoid
circular waiting that may occur if the disconnect call back ends up
waiting on the peer goroutine to be torn down. If this happens, then the
peer goroutine will be blocked on the ping manager fully tearing down,
which is blocked on the peer disconnect succeeding.

This is a similar class of issue we've delt with recently as pertains to
the peer and the server: sync all back execution must not lead to
a circular waiting loop.

Fixes #8379
2024-01-22 18:20:23 -08:00
Keagan McClelland
ec55831229 htlcswitch+peer: remove ShutdownIfChannelClean 2024-01-22 16:08:59 -08:00
Keagan McClelland
64fda6ca65 htlcswitch: implement flush and commit lifecycle hooks for channelLink 2024-01-22 16:08:55 -08:00
Keagan McClelland
5ab69aedc7 peer: remove tryLinkShutdown due to redundance
We don't need to try a link shutdown when the chan closer is fetched
since, by this commit, the only callsite manages the shutdown semantics.
After removing the call to tryLinkShutdown, we no longer need the
function at all.
2024-01-22 12:19:58 -08:00
Keagan McClelland
025e569f07 peer: fix local close requests to shutdown via link lifecycle hooks
In order to handle shutdown requests when there are still HTLCs on
the link, we have to manage the shutdown process via the link's
lifecycle hooks. This means we can't use the simple `tryLinkShutdown`
anymore and instead queue a `Shutdown` message at the next opportunity
to do so -- when we send our next `CommitSig`
2024-01-22 12:19:58 -08:00
Keagan McClelland
442f1dd677 peer: handle close messages using link lifecycle hooks 2024-01-22 12:19:58 -08:00