Commit Graph

19822 Commits

Author SHA1 Message Date
Elle Mouton
abb9654856 graph/db: gracefully handle duplicate node announcements
It can happen that we are handling 2 of the same node announcements in
the same batch transaction. In that case, our `UpsertNode` conflict
assertion may fail. We need to handle this gracefully.
2025-10-06 11:28:33 +02:00
Elle Mouton
88050da220 lndcfg: add Graph to UseNativeSQL description 2025-10-06 11:00:48 +02:00
Elle Mouton
14cf937419 graph: fix log formatting 2025-10-06 10:59:39 +02:00
Elle Mouton
72821da11c docs: update sample conf with Graph SQL mig info 2025-10-04 05:33:52 +02:00
Elle
1c2ff4a7e7 Merge pull request #10232 from ellemouton/g175MessageFollowup
lnwire: add missing Gossip 1.75 fields and message
2025-10-02 14:58:53 +02:00
Elle Mouton
b8ff9fbef3 lnwire: define NodeAnnouncement2
In this commit, the lnwire.NodeAnnouncement2 type is defined. This will
be used to represent the `node_announcement_2` message used in the
Gossip 2 (1.75) protocol.
2025-10-02 12:15:16 +02:00
Elle Mouton
e24dd2f9e0 lnwire: let DNSAddress implement RecordProducer
In preparation for using this type as a TLV record, we let it implement
the RecordProducer interface.
2025-10-01 13:49:15 +02:00
Elle Mouton
e9a4f22dd6 lnwire: add inbound fee to ChannelUpdate2
We leave a TODO that should be addressed after a discussion at the spec
meeting. For now, having the incorrect TLV type is not a problem since
this ChannelUpdate2 type is not used in production.
2025-10-01 13:13:32 +02:00
Elle Mouton
b8abe130a5 multi: rename lnwire.NodeAnnouncement
In preparation for adding a NodeAnnouncement2 struct along with a
NodeAnnouncement interface, this commit renames the existing
NodeAnnouncment struct to NodeAnnouncement1.
2025-10-01 13:13:32 +02:00
Elle Mouton
8372524edf lnwire: add Outpoint to ChannelAnnouncement2
The latest version of the spec has the outpoint included in the
`channel_announcement2` message.
2025-10-01 13:13:32 +02:00
Elle Mouton
004a68e524 lnwire: add OutPoint type with TLV encoding support
Add a new OutPoint type that wraps wire.OutPoint and provides TLV
encoding/decoding capabilities through the tlv.RecordProducer interface.
This enables OutPoint to be used in TLV streams of messages.
2025-10-01 13:13:32 +02:00
Elle Mouton
769b44bfc6 lnwire: shorten method name 2025-10-01 13:13:31 +02:00
Yong
e386e2bfbe Merge pull request #10251 from ziggie1984/create-21-release-notes
Add release-notes for 0.21.0
2025-10-01 02:33:07 +08:00
ziggie
b8a855f572 docs: add release-notes LND 0.21.0 2025-09-30 19:06:27 +02:00
Olaoluwa Osuntokun
90c96c7df1 Merge pull request #10252 from Roasbeef/v0-20-0-rc1-branch
build: bump version to v0.20.0 rc1
v0.20.0-beta.rc1
2025-09-29 20:33:59 -07:00
Yong
6a22f99824 Merge pull request #10254 from yyforyongyu/docs-deprecate-tor
docs: add deprecation warning for `tor.v2`
2025-09-30 10:39:04 +08:00
Yong
01ca50db26 Merge pull request #10250 from ViktorT-11/2025-08-add-viktor-t-gpg-key
scripts: add gpg key for ViktorT-11
2025-09-29 14:22:46 +08:00
yyforyongyu
dcdc97c70f docs: add release note for tor.v2 deprecation 2025-09-29 13:01:33 +08:00
yyforyongyu
4aff00260d lncfg: makr tor.v2 as deprecated 2025-09-29 13:01:31 +08:00
Olaoluwa Osuntokun
b0314e1ce7 build: bump version to v0.20.0 rc1 2025-09-26 18:46:29 -07:00
Olaoluwa Osuntokun
641456e216 Merge pull request #10128 from Roasbeef/iter-chan-updates
multi: update ChanUpdatesInHorizon and NodeUpdatesInHorizon to return iterators (iter.Seq[T])
fn/v1.2.6
2025-09-26 18:36:44 -07:00
Olaoluwa Osuntokun
506c3d5b0d docs/release-notes: add release notes entry 2025-09-26 17:02:11 -07:00
Olaoluwa Osuntokun
f3a8fd842d graph+discovery: update graph/db gossip backlog interfaces to use iter.Seq2
This lets us emit a rich error if things fail when first creating the
iterator, or if any of the yield attempts fail.
2025-09-26 17:01:11 -07:00
Olaoluwa Osuntokun
0b3816afb9 discovery/test: update mock to support iterator-based UpdatesInHorizon
In this commit, we update the mockChannelGraphTimeSeries to implement
the new iterator-based UpdatesInHorizon interface. The mock maintains
its existing behavior of receiving messages through a channel and
returning them to the caller, but now wraps this in an iterator
function.

The implementation creates an iterator that pulls the entire message
slice from the mock's response channel, then yields each message
individually. This preserves the test semantics while conforming to the
new interface, ensuring all existing tests continue to pass without
modification.
2025-09-26 17:00:41 -07:00
Olaoluwa Osuntokun
77f3b35640 discovery: update ApplyGossipFilter to use lazy iterator with Pull2
In this commit, we update ApplyGossipFilter to leverage the new
iterator-based UpdatesInHorizon method. The key innovation here is using
iter.Pull2 to create a pull-based iterator that allows us to check if
any updates exist before launching the background goroutine.

This approach provides several benefits over the previous implementation.
First, we avoid the overhead of launching a goroutine when there are no
updates to send, which was previously unavoidable without materializing
the entire result set. Second, we maintain lazy loading throughout the
sending process, only pulling messages from the database as they're
needed for transmission.

The implementation uses Pull2 to peek at the first message, determining
whether to proceed with sending updates. If updates exist, ownership of
the iterator is transferred to the goroutine, which continues pulling
and sending messages until exhausted. This design ensures memory usage
remains bounded regardless of the number of updates being synchronized.
2025-09-26 17:00:11 -07:00
Olaoluwa Osuntokun
d8f6fd29f7 discovery: convert UpdatesInHorizon to return iter.Seq2[lnwire.Message, error]
In this commit, we complete the iterator conversion work started in PR
10128 by threading the iterator pattern through to the higher-level
UpdatesInHorizon method. This change converts the method from returning
a fully materialized slice of messages to returning a lazy iterator that
yields messages on demand.

The new signature uses iter.Seq2 to allow error propagation during
iteration, eliminating the need for a separate error return value. This
approach enables callers to handle errors as they occur during iteration
rather than failing upfront.

The implementation now lazily processes channel and node updates,
yielding them as they're generated rather than accumulating them in
memory. This maintains the same ordering guarantees (channels before
nodes) while significantly reducing memory pressure when dealing with
large update sets during gossip synchronization.
2025-09-26 16:59:41 -07:00
Olaoluwa Osuntokun
fda989da9c discovery+graph: update callers to use new iterator APIs
In this commit, we update all callers of NodeUpdatesInHorizon and
ChanUpdatesInHorizon to use the new iterator-based APIs. The changes
use fn.Collect to maintain existing behavior while benefiting from the
memory efficiency of iterators when possible.
2025-09-26 16:59:11 -07:00
Olaoluwa Osuntokun
32528afa0a graph/db: add tests for iterator implementations 2025-09-26 16:58:41 -07:00
Olaoluwa Osuntokun
31ab2ae4b6 sqldb: implement iterator support for ChanUpdatesInHorizon
In this commit, we update the SQL store implementation to support the
new iterator-based API for ChanUpdatesInHorizon. This includes adding
SQL query pagination support and helper functions for efficient batch
processing.

The SQL implementation uses cursor-based pagination with configurable
batch sizes, allowing efficient iteration over large result sets without
loading everything into memory. The query is optimized to use indexes
effectively and minimize database round trips.

New SQL query GetChannelsByPolicyLastUpdateRange is updated to support:
- Cursor-based pagination using (max_update_time, id) compound cursor
- Configurable batch sizes via MaxResults parameter
- Efficient batch caching with updateChanCacheBatch helper
2025-09-26 16:58:11 -07:00
Olaoluwa Osuntokun
c69971c20b sqldb: implement iterator support for NodeUpdatesInHorizon
In this commit, we update the SQL store implementation to support the
new iterator-based API for NodeUpdatesInHorizon. This includes adding a
new SQL query that supports efficient pagination through result sets.

The SQL implementation uses cursor-based pagination with configurable
batch sizes, allowing efficient iteration over large result sets without
loading everything into memory. The query is optimized to use indexes
effectively and minimize database round trips.

New SQL query GetNodesByLastUpdateRange is updated to support:
  * Cursor-based pagination using (last_update, pub_key) compound cursor
  * Optional filtering for public nodes only
  * Configurable batch sizes via MaxResults parameter
2025-09-26 16:57:41 -07:00
Olaoluwa Osuntokun
069888b51a graph/db: convert ChanUpdatesInHorizon to use iterators
In this commit, we refactor the ChanUpdatesInHorizon method to return
an iterator instead of a slice. This change significantly reduces
memory usage when dealing with large result sets by allowing callers to
process items incrementally rather than loading everything into memory
at once.
2025-09-26 16:57:11 -07:00
Olaoluwa Osuntokun
1d6d54e5db graph/db: convert NodeUpdatesInHorizon to use iterators
In this commit, we refactor the NodeUpdatesInHorizon method to return
an iterator instead of a slice. This change significantly reduces
memory usage when dealing with large result sets by allowing callers to
process items incrementally rather than loading everything into memory
at once.

The new implementation uses Go 1.23's iter.Seq type to provide a
standard iterator interface. The method now supports configurable batch
sizes through functional options, allowing fine-tuned control over
memory usage and performance characteristics.

Rather than reading all the entries from disk into memory (before this
commit, we did consult the cache for most entries, skipping the disk
hits), we now expose a chunked iterator instead.

We also make the process of filtering out public nodes first class. This
saves many newly created db transactions later.
2025-09-26 16:56:41 -07:00
Olaoluwa Osuntokun
f8ce00b84a graph/db: add options infrastructure for iterator configuration
In this commit, we introduce a new options pattern for configuring
iterator behavior in the graph database. This includes configuration
for batch sizes when iterating over channel and node updates, as well
as an option to filter for public nodes only.

The new functional options pattern allows callers to customize iterator
behavior without breaking existing APIs. Default batch sizes are set to
1000 entries for both channel and node updates, which provides a good
balance between memory usage and performance.
2025-09-26 16:56:20 -07:00
Olaoluwa Osuntokun
015875e455 fn: add Collect+CollertErr function for iterators
In this commit, we introduce a new utility function `Collect` to the fn
package. This function drains all elements from an iterator and returns
them as a slice. This is particularly useful when transitioning from
iterator-based APIs to code that expects slices, allowing for gradual
migration to the new iterator patterns.

The fn module's go.mod is also updated to require Go 1.23, which is
necessary for the built-in iter.Seq type support.

The replace directive will be removed once the fn package changes are
merged and a new version is tagged.
2025-09-26 16:55:46 -07:00
Viktor Torstensson
80c2484e9e scripts: add gpg key for ViktorT-11 2025-09-26 12:16:22 +02:00
Yong
b09b20c699 Merge pull request #10133 from GeorgeTsagk/rpc-find-base-alias
Add `XFindBaseLocalChanAlias` RPC
2025-09-25 21:06:41 +08:00
George Tsagkarelis
e7f7fe418b docs: add release note 2025-09-25 11:15:31 +02:00
George Tsagkarelis
f14190c02d lnrpc: add XFindBaseLocalChanAlias rpc
Add the new RPC method that looks up the base scid for a given alias.
Given the previous stepping stones this commit is fairly simple, we just
call into the alias manager and return the lookup result.
2025-09-25 11:15:31 +02:00
George Tsagkarelis
472a2f967e multi: add base lookup option to AddLocalAlias
We add an extra option to the AddLocalAlias method which only controls
whether we store a reverse lookup from the alias back to the base scid
it corresponds to. The previous flag "gossip" is still maintained, and
in a way supercedes the new flag (it will also store the base scid
lookup even if the base lookup flag isn't set). The only call that sets
this option is the XAddLocalChanAlias RPC endpoint, where we want to
make sure that a reverse lookup is stored in the alias manager in order
to later expose it via the new RPC method.
2025-09-25 11:15:27 +02:00
Yong
f293566849 Merge pull request #10235 from Abdulkbk/fix-externalip-retention-issue
lnd: fix externalip retention issue
2025-09-25 14:23:51 +08:00
Olaoluwa Osuntokun
df46d18626 Merge pull request #10182 from GeorgeTsagk/aux-feature-bits
Aux feature bits
2025-09-24 18:26:35 -07:00
Olaoluwa Osuntokun
8be5de6185 Merge pull request #10183 from Roasbeef/brontide-static-alloac
brontide: eliminate all allocations from WriteMessage+Flush
2025-09-24 15:49:05 -07:00
Abdullahi Yunus
ed2880ef17 lnd: update docs on nodeann addresses retaining 2025-09-24 21:08:04 +01:00
Olaoluwa Osuntokun
4c737d3f02 brontide+peer: use internal sync/pool to reduce allocations
This ensures that under medium to high load, we eliminate all
allocations once we arrive a steady state, re working memory.
2025-09-24 11:52:01 -07:00
Olaoluwa Osuntokun
f968206849 docs: add docs explaining usage of pprof+benchmarks to optimize
In this commit, we add some docs that explain how to use tools like
heap escape analysis and memory profiling to fully eliminate allocations
in a sample program.

This guide is meant to help devs/contributors use Go's excellent perf
tools to zoom in on an optimization problem.
2025-09-24 11:52:01 -07:00
Olaoluwa Osuntokun
83e2811903 brontide: use a static buffer for the packet length
In this commit, we eliminate the final allocation that takes place when
we write out messages. Once again this was escaping to the heap, so we
make it an attribute on the Machine struct, which allows pure static
allocation.

```
goos: darwin
goarch: arm64
pkg: github.com/lightningnetwork/lnd/brontide
cpu: Apple M4 Max
BenchmarkWriteMessage-16    	   25840	     46376 ns/op	       2 B/op	       0 allocs/op
BenchmarkWriteMessage-16    	   25646	     46672 ns/op	       2 B/op	       0 allocs/op
BenchmarkWriteMessage-16    	   25874	     46391 ns/op	       2 B/op	       0 allocs/op
BenchmarkWriteMessage-16    	   25512	     46427 ns/op	       2 B/op	       0 allocs/op
BenchmarkWriteMessage-16    	   25760	     46309 ns/op	       2 B/op	       0 allocs/op
BenchmarkWriteMessage-16    	   25789	     46520 ns/op	       2 B/op	       0 allocs/op
BenchmarkWriteMessage-16    	   25602	     46619 ns/op	       2 B/op	       0 allocs/op
BenchmarkWriteMessage-16    	   25766	     46464 ns/op	       2 B/op	       0 allocs/op
BenchmarkWriteMessage-16    	   25820	     46487 ns/op	       2 B/op	       0 allocs/op
BenchmarkWriteMessage-16    	   25634	     46553 ns/op	       2 B/op	       0 allocs/op
PASS
ok  	github.com/lightningnetwork/lnd/brontide	16.907s
```
2025-09-24 11:52:01 -07:00
Olaoluwa Osuntokun
1fe156f2f4 brontide: use a fixed size buffer for the nonce within the brontide machine
In this commit, we use a fixed sized buffer for the nonce when we
read/write messages. This was actually escaping to the heap. We can
avoid this by statically allocating it alongside the struct itself.

The benchmark state at this point:

```
goos: darwin
goarch: arm64
pkg: github.com/lightningnetwork/lnd/brontide
cpu: Apple M4 Max
BenchmarkWriteMessage-16    	   25264	     47012 ns/op	       4 B/op	       1 allocs/op
BenchmarkWriteMessage-16    	   23542	     46809 ns/op	       4 B/op	       1 allocs/op
BenchmarkWriteMessage-16    	   25989	     47256 ns/op	       4 B/op	       1 allocs/op
BenchmarkWriteMessage-16    	   25542	     46388 ns/op	       4 B/op	       1 allocs/op
BenchmarkWriteMessage-16    	   26083	     46612 ns/op	       4 B/op	       1 allocs/op
BenchmarkWriteMessage-16    	   25860	     46367 ns/op	       4 B/op	       1 allocs/op
BenchmarkWriteMessage-16    	   24967	     46748 ns/op	       4 B/op	       1 allocs/op
BenchmarkWriteMessage-16    	   26088	     46485 ns/op	       4 B/op	       1 allocs/op
BenchmarkWriteMessage-16    	   25561	     46425 ns/op	       4 B/op	       1 allocs/op
BenchmarkWriteMessage-16    	   25474	     47249 ns/op	       4 B/op	       1 allocs/op
PASS
ok  	github.com/lightningnetwork/lnd/brontide	16.911s
```

```
goos: darwin
goarch: arm64
pkg: github.com/lightningnetwork/lnd/brontide
cpu: Apple M4 Max
                │   old.txt   │              new2.txt              │
                │   sec/op    │   sec/op     vs base               │
WriteMessage-16   50.34µ ± 1%   46.68µ ± 1%  -7.28% (p=0.000 n=10)

                │    old.txt     │              new2.txt              │
                │      B/op      │    B/op     vs base                │
WriteMessage-16   73788.000 ± 0%   4.000 ± 0%  -99.99% (p=0.000 n=10)

                │  old.txt   │              new2.txt              │
                │ allocs/op  │ allocs/op   vs base                │
WriteMessage-16   5.000 ± 0%   1.000 ± 0%  -80.00% (p=0.000 n=10)
```
2025-09-24 11:52:01 -07:00
Olaoluwa Osuntokun
06826f85d8 brontide: add new maxMessageSize variable 2025-09-24 11:52:01 -07:00
Olaoluwa Osuntokun
6e0083a369 brontide: add benchark for WriteMessage
In this commit, we add a benchmark for the WriteMessage method. This is
the first step in an upcoming optimizooor series of commits.

The baseline is:
```
goos: darwin
goarch: arm64
pkg: github.com/lightningnetwork/lnd/brontide
cpu: Apple M4 Max
BenchmarkWriteMessage-16    	   22736	     50667 ns/op	   73788 B/op	       5 allocs/op
BenchmarkWriteMessage-16    	   23217	     50463 ns/op	   73788 B/op	       5 allocs/op
BenchmarkWriteMessage-16    	   24241	     49941 ns/op	   73788 B/op	       5 allocs/op
BenchmarkWriteMessage-16    	   23574	     51021 ns/op	   73788 B/op	       5 allocs/op
BenchmarkWriteMessage-16    	   23784	     49926 ns/op	   73788 B/op	       5 allocs/op
BenchmarkWriteMessage-16    	   24230	     50538 ns/op	   73788 B/op	       5 allocs/op
BenchmarkWriteMessage-16    	   24058	     49971 ns/op	   73788 B/op	       5 allocs/op
BenchmarkWriteMessage-16    	   23762	     50224 ns/op	   73788 B/op	       5 allocs/op
BenchmarkWriteMessage-16    	   24266	     53034 ns/op	   73788 B/op	       5 allocs/op
BenchmarkWriteMessage-16    	   23317	     50045 ns/op	   73788 B/op	       5 allocs/op
PASS
ok  	github.com/lightningnetwork/lnd/brontide	17.433s
```
2025-09-24 11:51:59 -07:00
Abdullahi Yunus
141cc571ab itest: check for config addrs precedence
In this commit, we update the itest to check for precedence of the
config addresses over the persisted addresses.

We did not check for address persistence after restart (without the
extraArgs `--externalip`) because in `lntest/node/config.goL300`,
`GenArg` by default sets the `--externalip` flag, which makes
the config addrs to always take precedence over the persisted
addrs, for the tests.
2025-09-24 10:51:19 +01:00