17783 Commits

Author SHA1 Message Date
Elle Mouton
15c2161adf
docs: update release notes 2024-11-28 14:52:50 +02:00
Elle Mouton
791ac91990
remove context.TODOs from tests 2024-11-28 14:52:50 +02:00
Elle Mouton
c5cc6f1392
routing: remove context.TODOs 2024-11-28 14:52:50 +02:00
Elle Mouton
a28102ecd6
netann: remove context.TODO 2024-11-28 14:52:50 +02:00
Elle Mouton
75b1069a08
blindedpath: remove a context.TODO 2024-11-28 14:52:49 +02:00
Elle Mouton
dcfffd6bda
invoicesrpc: remove a context.TODO 2024-11-28 14:52:49 +02:00
Elle Mouton
2192bf4155
lnd+chanbackup: thread contexts through
Remove four context.TODO()s
2024-11-28 14:52:49 +02:00
Elle Mouton
f36fbd0e45
graph+lnd: add BetweennessCentrality to GraphSource interface
So that the calcuation is abstracted behind the interface and not
necessarily dependent on LND's local channel graph.
2024-11-28 14:52:49 +02:00
Elle Mouton
80070618a7
graph+lnd: add NetworkStats to GraphSource interface
so that the external graph source can be used to query network
information rather than depending on the local graph DB.
2024-11-28 14:52:49 +02:00
Elle Mouton
372883ab81
lnd+graph: add GraphBootstrapper to the GraphSource interface
So that LND can use a different GraphSource for network bootstrapping
and does not need to rely on its local graph db.
2024-11-28 14:52:49 +02:00
Elle Mouton
0f33d41c55
discovery: pass contexts to NetworkPeerBootstrapper methods
We will later implement this interface with a backing RPC connection and
so it makes sense to pass a context through for cancellation.
2024-11-28 14:52:49 +02:00
Elle Mouton
28415f5ef2
graph+lnd: add various calls to GraphSource
In this commit, we add a bunch of graph methods to the GraphSource, let
DBSource implement it and then we use the graph source for these
methods for the GetNodeInfo, VerifyMessage, DescribeGraph,
GetNodeMetrics, GetChanInfo and GetNodeInfo RPC calls along with peer
alias lookup.
2024-11-28 14:52:49 +02:00
Elle Mouton
bfe6262b29
graph+channeldb: add AddrSource interface to GraphSource 2024-11-28 14:52:49 +02:00
Elle Mouton
237151d9df
netann+lnd: add netann.ChannelGraph to the GraphSource interface
And let DBSource implement it.
2024-11-28 14:52:49 +02:00
Elle Mouton
6f3d45f5d9
invoicesrpc: remove invoicerpc server's access to ChannelGraph pointer
Define a new GraphSource interface required by the invoicerpc server and
remove its access to the graphdb.ChannelGraph pointer. Add the new
invoicesrpc.GraphSource interface to the GraphSource interface
and let DBSource implement it.
2024-11-28 14:52:48 +02:00
Elle Mouton
9854bad720
graph: add contexts to the ReadOnlyGraph interface
Since the GraphSource interface may be satisfied by an RPC connection,
it is best practice to pass a context through to any call in the
interface.

The ChanGraphSource implementation, which uses a kvdb backend, does not
make use of the ctx. Any call-sites are for now given a `context.TODO()`
which will all be addressed in follow up commits.
2024-11-28 14:52:48 +02:00
Elle Mouton
aa2480464b
graph: add ReadOnlyGraph interface to GraphSource interface
In this commit, we take the existing graphsession.ReadyOnlyGraph
interface and remove its usage of a kvdb.RTx and replace it with a more
abstract `RTx` interface type.

The new GraphSource interface is expanded to include the
graphsession.ReadOnlyGraph interface and the implementation of it,
DBSource, is expanded to include the new methods. It converts the
given RTx to the underlying kvdb read transaction where needed.
2024-11-28 14:52:48 +02:00
Elle Mouton
6c008ff8fb
lnd+graph: add GraphSource interface and implementation
This commit adds a new GraphSources interface that LND requires for
graph related read-only queries. As of this commit, the interface is
empty but it will be populated over the next couple of commits. We add
an implementation of this interface backed by a pointer to a
graphdb.ChannelGraph.

The infrustructure is put into place so that the GraphSoure provided to
LND can be overridden by a caller of the lnd.Main function. By default,
LND will satisfy the interface itself via the new `graphsource.DBSource`
struct.
2024-11-28 14:52:48 +02:00
Elle Mouton
755065b6ab
graph: rename directory from graphsession to session
The package name is kept the same. So this is just for less stuttering
at a path level.
2024-11-28 14:52:48 +02:00
Elle Mouton
9d389ad5f2
graph: let FetchNodeFeatures take an optional read tx
For consistency in the graphsessoin.graph interface, we let the
FetchNodeFeatures method take a read transaction just like the
ForEachNodeDirectedChannel. This is nice because then all calls in the
same pathfinding transaction use the same read transaction.
2024-11-28 14:52:48 +02:00
Elle Mouton
488fa3e68a
graph: remove unused ForEachNode method
Simplify the ChannelGraphSource interface by removing this unused
method.
2024-11-28 14:52:47 +02:00
Oliver Gugger
506586a37e
Merge pull request #9236 from ellemouton/moveGraphDBCode
[1/3] Graph RIP: refactor+graph: move all graph related DB code to the graph package
2024-11-28 13:47:16 +01:00
Elle Mouton
54dbaa60c9
docs: add release notes entry for 9236 2024-11-28 13:51:15 +02:00
Elle Mouton
439a6c7d6c
multi: rename chan DB Open method to OpenForTesting 2024-11-28 13:51:15 +02:00
Elle Mouton
4089fbcb44
multi: fix linter errors 2024-11-28 13:51:15 +02:00
Elle Mouton
fd2ea411be
itest: assert no failed updates in test
So that this fails earlier on if the actual call to UpdateChannelPolicy
fails.
2024-11-28 13:51:14 +02:00
Elle Mouton
adcaa8802f
multi: remove kvdb.Tx from ChannelGraphSource.ForAllOutgoingChannels
and the same for ChannelStateDB.FetchChannel. Most of the calls to these
methods provide a `nil` Tx anyways. The only place that currently
provides a non-nil tx is in the `localchans.Manager`. It takes the
transaction provided to the `ForAllOutgoingChannels` callback and passes
it to it's `updateEdge` method. Note, however, that the
`ForAllOutgoingChannels` call is a call to the graph db and the call to
`updateEdge` is a call to the `ChannelStateDB`. There is no reason that
these two calls need to happen under the same transaction as they are
reading from two completely disjoint databases. And so in the effort to
completely split untangle the relationship between the two databases, we
now dont use the same transaction for these two calls.
2024-11-28 13:49:41 +02:00
Elle Mouton
6e13898981
multi: move LightningNode struct to models package 2024-11-28 13:36:32 +02:00
Elle Mouton
ccb8f0eeb8
refactor: move graphsession pkg to graph package 2024-11-28 13:36: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
2c083bc017
multi: let chan and graph db implement AddrSource
Then use both to construct a multiAddrSource AddrSource and use that
around the code-base.
2024-11-28 13:36:15 +02:00
Elle Mouton
51c2f709e1
channeldb: let AddrsForNode indicate if the node was found or not
Before this commit, the `(channeldb.DB).AddrsForNode` method treats the
results from the channel db and the graph db slightly differently. It
errors out if the channel db is unaware of the node in question but does
not error out if the graph is unaware of the node. So this commit
changes the logic slightly so that a "node-unknown" error from either
backing source is not seen as an error.
2024-11-28 13:36:15 +02:00
Elle Mouton
9537026df9
channeldb: implement a multi-source AddrSource
In this commit, we implement a version of the AddrSource interface which
merges the results of a set of AddrSource implementations. This will
later be used to merge the results of the channel db and graph db.
2024-11-28 13:36:15 +02:00
Elle Mouton
083d3c9d7c
channeldb: define a single AddrSource interface
Our aim is to completely remove the `channeldb.DB`'s direct dependence
on the `graphdb.ChannelGraph` pointer. The only place where it still
depends on this pointer is in the `(DB).AddrsForNode(..)` method where
it queries both the channel DB and the graph db for the known addresses
for the node in question and then combines the results. So, to separate
these out, we will define an AddrsForNodes interface in this commit
which we will later let both the ChannelGraph and channeldb.DB both
implement and we will merge these results outside of the channeldb
package.

All this commit does is to unify the `AddrSource` interface since this
has been defined separately in a couple of places.
2024-11-28 13:36:15 +02:00
Elle Mouton
1859993734
channeldb+graphdb: init graph DB outside of channel db
We also now use the graph DB's own optional functions. An instance of
the graph is currently still passed to the channeldb's
`CreateWithBackend` function. This will be removed in a later commit
once the two have been completely disjoint.
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
b707fd55b2
contractcourt: use graphdb outpoint helpers
Start using the single set of exported write/read functions for
wire.Outpoint.
2024-11-28 13:34:08 +02:00
Elle Mouton
382539a6eb
channeldb/graphdb: move outpoint ser/deser funcs to graphdb
We have the same helpers for writing and reading a wire.Outpoint type
defined separately in a couple places. We will want to use these from
the graph db package soon though so instead of defining them again
there, this commit unifies things and creates a single exported set of
helpers. The next commit will make use of these.
2024-11-28 13:34:08 +02:00
Elle Mouton
3365461500
channeldb+graph/db: move net.Addr encode/decode to graph db package
In preparation for moving the graph related schema structs to the graph
package in an upcoming commit, we move these methods to the graph
package. The structs we will move make use of these methods but we still
import them from channeldb so as to keep the ReadElement and
WriteElement helpers working as they do today.
2024-11-28 13:34:08 +02:00
Elle Mouton
1e81d83f78
channeldb: export net.Addr encode/decode methods
We'll move these to the new graphdb package later and import them from
there.
2024-11-28 13:34:08 +02:00
Oliver Gugger
1ebdefb943
Merge pull request #9311 from Roasbeef/protofsm-race-fix
protofsm: fix race in state machine executor tests
2024-11-28 09:28:04 +01:00
Oliver Gugger
ae32c29deb
Merge pull request #9295 from ellemouton/logPerformanceFix
go.mod: bump btclog dep
2024-11-27 11:43:43 +01:00
Elle Mouton
c2923e2214
multi: remove PrefixLog
And instead use the new btclog Logger `WithPrefix` method.
2024-11-27 10:44:32 +02:00
Elle Mouton
b98fc168ec
go.mod+build: update btclog dep 2024-11-27 10:44:01 +02:00
Oliver Gugger
c8cfa59316
Merge pull request #8270 from ProofOfKeags/feature/stfu
DynComms [1/n]: Implement Quiescence Protocol
2024-11-27 09:27:34 +01:00
Olaoluwa Osuntokun
0ff0ac84f6
protofsm: fix race in state machine executor tests
In this commit, we fix an existing race in the new `protofsm` state
machine executor tests.

The race would appear as such:
```
--- FAIL: TestStateMachineMsgMapper (0.00s)
    state_machine_test.go:165:
        Error Trace:/home/runner/work/lnd/lnd/protofsm/state_machine_test.go:165
                    /home/runner/work/lnd/lnd/protofsm/state_machine_test.go:451
        Error:      Object expected to be of type *protofsm.dummyStateStart, but was *protofsm.dummyStateFin
        Test:       TestStateMachineMsgMapper
FAIL
FAILgithub.com/lightningnetwork/lnd/protofsm0.116s
FAIL
```

This race condition was triggered as before we would start the state
machine _then_ register for notifications. In `Start` we emit the
starting event, then enter the main loop. If that event gets emitted
before our subscription, then we'll miss the event, as the terminal
event will be the only one received.

We fix this by registering for the events before the daemon has started.
2024-11-26 18:58:53 -06:00
Keagan McClelland
debc43daf2
docs: add quiescence to release notes 2024-11-26 14:13:44 -07:00
Keagan McClelland
127e4fff28
htlcswitch: add logging to quiescer 2024-11-26 14:13:44 -07:00
Keagan McClelland
ac0c24aa7b
htlcswitch: don't pass pending update counts into quiescer
This change simplifies some of the quiescer responsibilities in
favor of making the link check whether or not it has a clean state
to be able to send or receive an stfu. This change was made on the
basis that the only use the quiescer makes of this information is
to assess that it is or is not zero. Further the difficulty of
checking this condition in the link is barely more burdensome than
selecting the proper information to pass to the quiescer anyway.
2024-11-26 14:13:43 -07:00