Commit Graph

19846 Commits

Author SHA1 Message Date
Elle Mouton
6e98b336f6 graph/db+channeldb: rename test helper 2025-09-03 10:14:35 +02:00
Elle Mouton
330f697937 graph: rename HasLightningNode
to HasNode
2025-09-03 10:14:35 +02:00
Elle Mouton
7a1b548e07 graph/db: rename DeleteLightningNode
to DeleteNode
2025-09-03 10:14:35 +02:00
Elle Mouton
cd3bd05810 multi: rename FetchLightningNode
to FetchNode
2025-09-03 10:14:35 +02:00
Elle Mouton
060219780b multi: rename AddLightningNode methods
to AddNode
2025-09-03 10:14:35 +02:00
Elle Mouton
c663a557c4 multi: rename models.LightningNode to models.Node 2025-09-03 10:14:35 +02:00
Elle Mouton
a74f0b133a graph/db: expand test comment with build tag info 2025-09-03 10:11:49 +02:00
Elle Mouton
af380c9eb1 graph/db: extract DNS addresses during SQL migration
In this commit, we take advantage of the graph SQL migration and use it
to also extract DNS addresses from the opaque address type. We use
opaque addresses to store addresses that we dont understand yet. We
recently added logic for DNS addresses and so we may have persisted node
announcements that have DNS addresses but we would currently have them
stored under the opaque address type. So we use this migration to see if
we can extract such addresses.

A few decisions were made here:
1) If multiple DNS addressees are extracted, this is ok and we continue
   to migrate the node even though this is actually invalid at a
   protocol level. We will currently check (at a higher level) that a node
   announcement only has 1 DNS address in it before we broadcast it though.
2) If an invalid DNS address is encountered (so we hit the DNS type
   descriptor but then the rest of the DNS address payload is invalid
   and cannot be parsed into the expected hostname:port, then we skip
   migrating the node completely.
2025-09-03 09:13:42 +02:00
Elle Mouton
d61a8af4c4 lnwire: re-usable address descriptor parsers
In this commit, the logic in ReadElements that is used to read a single
address descriptor from a io.Reader is separated out into a new function
so that the logic can be re-used elsewhere.
2025-09-03 08:32:37 +02:00
Elle
ea6cc8154f Merge pull request #9455 from mohamedawnallah/supportDNSHostnameInNodeAnnouncement
[1/2] discovery+lnwire: add support for DNS host name in NodeAnnouncement msg
2025-09-03 08:13:55 +02:00
Mohamed Awnallah
ad966157fc docs: add release note 2025-09-03 01:11:35 +00:00
Elle Mouton
6ef80db746 graph/db+chanbackup: dns add encoding/decoding for persistence 2025-09-03 01:11:35 +00:00
Elle Mouton
4bd2bbca27 graph/db: update test opaque addr to be valid
The first byte of an opaque addr must be one that we dont understand
yet. We do this update in preparation for doing an on-the-fly parse of
persisted opaque addrs to see if they contain addrs that we now support.
For this to work, the first byte cant be 0x01 since this maps to a known
address.
2025-09-03 01:11:35 +00:00
Elle Mouton
70b5016bc8 discovery+gossip: make sure we dont advertise node anns with bad DNS
We may have already persisted node announcements that have multiple DNS
addresses since we may have received them before updating our code to
check for this. So here we just make sure not to send these on to our
peers.
2025-09-03 01:11:35 +00:00
Elle Mouton
f0a20c9d04 netadd: split ValidatenodeAnn into sig and field checks
Check that the node ann doesnt contain more than 1 DNS addr.
This will ensure that we now start rejecting new node announcements
with multiple DNS addrs since this check is called in the gossiper
before persisting a node ann to our local graph.

It also validates the DNS fields according to BOLT #7 specs.
2025-09-03 01:11:34 +00:00
Elle Mouton
670b26ba3d lnwire: add encoding/decoding for DNS addr
Co-authored-by: Elle Mouton <elle.mouton@gmail.com>
2025-09-02 17:51:31 +00:00
Mohamed Awnallah
a0057c2026 lnwire: add DNSAddress type 2025-09-02 17:51:31 +00:00
Mohamed Awnallah
7acd6018c9 lnwire: remove AddrLen helper
In this commit, we remove `AddrLen` as prepration step
before adding DNS address type which will have a var length.

Co-authored-by: Elle Mouton <elle.mouton@gmail.com>
2025-09-02 17:51:31 +00:00
Yong
f51684dd0f Merge pull request #10103 from yyforyongyu/rate-limit-peer
Rate limit outgoing gossip bandwidth by peer
2025-09-02 23:31:29 +08:00
yyforyongyu
86a915a772 docs: update release notes 2025-09-02 21:23:08 +08:00
yyforyongyu
6d14370e8e lncfg: validate msg-burst-bytes 2025-09-02 21:23:08 +08:00
yyforyongyu
5bc4666efc multi: add new config peer-msg-rate-bytes 2025-09-02 21:23:07 +08:00
yyforyongyu
778456769a discovery: rate limiting sending msgs per peer
We now add another layer of rate limiting before sending the messages
inside `GossipSyncer`.
2025-09-02 21:23:07 +08:00
yyforyongyu
6826703c77 discovery: introduce rate limiter to GossipSyncer 2025-09-02 21:13:46 +08:00
yyforyongyu
19bc941cbd discovery: create common helper methods for rate limiter
This allows us to reuse them in the upcoming commits where we introduce
a rate limiter to the gossip syncer.
2025-09-02 21:13:46 +08:00
Yong
1666764690 Merge pull request #10136 from yyforyongyu/use-btcwallet-interface
lnwallet: use btcwallet's new interface
2025-09-02 20:46:56 +08:00
Olaoluwa Osuntokun
d5f70c0ae3 Merge pull request #10184 from ellemouton/gemini-char-wrap
.gemini: ignore char wrapping during code review
2025-09-01 23:40:06 +01:00
Yong
84b2c20ea0 Merge pull request #10167 from starius/go124
multi: bump Go to 1.24.6
2025-09-01 20:03:54 +08:00
Elle Mouton
d68d1fb355 netann: update ChanAnn2 validation to work for P2WSH channels
This commit expands the ChannelAnnouncement2 validation for the case
where it is announcing a P2WSH channel.
2025-09-01 12:10:31 +02:00
Elle Mouton
06bf0c28b6 multi: let FetchPkScript take SCID by value
Instead of a pointer.
2025-09-01 12:10:30 +02:00
Elle Mouton
b77b698b9d lnwire: update AnnounceSigs2 to use pure TLV 2025-09-01 12:10:30 +02:00
Elle Mouton
b6b764da71 lnwire+netann: update ChannelUpdate2
such that all fields are now TLV including the signature.
2025-09-01 12:10:30 +02:00
Elle Mouton
1f71f14587 lnwire+netann: update ChannelAnnouncement2 structure
Such that all fields are now TLV (including the signature).
2025-09-01 12:06:18 +02:00
Elle Mouton
5e7ca548aa lnwire: let ChannelID implement RecordProducer
So that we can use it as a TLV record type.
2025-09-01 11:05:23 +02:00
Elle Mouton
4addfd1d1f lnwire: introduce PureTLVMessage
PureTLVMessage describes an LN message that is a pure TLV stream. If the
message includes a signature, it will sign all the TLV records in the
inclusive ranges: 0 to 159 and 1000000000 to 2999999999.

A comprehensive test is added that shows how two versions of the same
message remain forward compatible.
2025-09-01 11:04:47 +02:00
Elle Mouton
c2baf6f30e .gemini: ignore char wrapping during code review
Gemini code review agent is bad at counting characters.
2025-09-01 10:16:44 +02:00
Elle
cd6971ea17 Merge pull request #10161 from ellemouton/graphRetry
graph/db+sqldb: Make the SQL migration retry-safe/idempotent
2025-09-01 08:23:38 +01:00
Elle Mouton
ce1df9da34 graph/db: let the rapid migration test also tests idempotency 2025-09-01 08:08:00 +02:00
Elle Mouton
f2ed5564ef graph/db+sqldb: improve performance of chan update sql migration
This commit simplifies insertChanEdgePolicyMig. Much of the logic can be
removed given that this method is only used in the context of the graph
SQL migration.

This should improve the performance of the migration quite a lot since
it removes the extra GetChannelAndNodesBySCID call.
2025-09-01 08:07:57 +02:00
Elle Mouton
22bf88e900 graph/db+sqldb: make policy migration idempotent
Finally, we make the channel-policy part of the SQL migration idempotent
by adding a migration-only policy insert query which will not error out
if the policy already exists and does not have a timestamp that is newer
than the existing records timestamp. To keep the commit simple, a
insertChanEdgePolicyMig function is added which is basically identical
to the updateChanEdgePolicy function except for the fact that it uses
the newly added query. In the next commit, it will be simplified even
more.
2025-09-01 08:06:12 +02:00
Elle Mouton
8736fcafa8 graph/db+sqldb: make channel SQL mig retry-safe
In this commit, we make the channel part of the graph SQL migration
idempotent (retry-safe!). We do this by adding a migration-only channel
insert query that will not error out if a the query is called and a
chanenl with the given scid&version already exists. We also ensure that
errors are not thrown if existing channel features & extra types are
re-added.
2025-09-01 08:05:21 +02:00
Elle Mouton
a291d6f1a6 graph/db+sqldb: improve efficiency of node migration
There is no need to use the "collect-then-update" pattern for node
insertion during the SQL migration since if we do have any previously
persisted data for the node and happen to re-run the insertion for that
node, the data will be exactly the same. So we can make use of "On
conflict, no nothing" here too.
2025-09-01 08:02:38 +02:00
Elle Mouton
ddea6d59ce graph/db+sqldb: make node migration idempotent
In this commit, the graph SQL migration is updated so that the node
migration step is retry-safe. This is done by using migration specific
logic & queries that do not use the same node-update-constraint as the
normal node upsert logic. For normal "run-time" logic, we always expect
a node update to have a newer timestamp than any previously stored one.
But for the migration, we will only ever be dealing with a single
announcement for a given node & to make things retry-safe, we dont want
the query to error if we re-insert the exact same node.
2025-09-01 07:56:34 +02:00
Elle Mouton
2c8ac0c92c graph/db: thread through reset call-backs
In preparation for handling retries on the source DB side, we thread
through the `reset` call-backs properly so that we can reset appropriate
variables.
2025-09-01 07:56:09 +02:00
Elle Mouton
aefc9118a4 graph/db: migration test for channels with no policies
In preparation for making the channel & policy migration logic
idempotent in a step-by-step manner, we add a test here that only tests
the migration of channels _without_ policies so that we can first focus
on just making the channel migration idempotent.
2025-09-01 07:56:09 +02:00
Elle Mouton
68e4970fbb graph/db: let migration test test retry safety
Currently, the graph SQL migration is not retry safe. Meaning that if
the source DB exeutes a retry under the hood, this could result in the
migration failing. In preparation for fixing this, we adust the
migration test accordingly.
2025-09-01 07:56:09 +02:00
Elle Mouton
9019bcaddf graph/db: let test policy have some extra opaque data
This will help us test idempotency later on, but it also ensures that
TestMigrateGraphToSQL is properly testing writes to the
graph_channel_policy_extra_types table.
2025-09-01 07:56:08 +02:00
Boris Nagaev
c86826ac5b lntest: fix error check in shutdownAllNodes
Previously the test failed only if the last node failed to shutdown. The code
was updated to fail if any node failed to shutdown.
2025-08-30 14:13:44 -03:00
Boris Nagaev
630108b13d multi: golang.org/x/net/context -> context 2025-08-30 14:13:44 -03:00
Boris Nagaev
dee8ad3754 multi: context.Background() -> t.Context()
Use the new feature of Go 1.24, fix linter warnings.

This change was produced by:
 - running golangci-lint run --fix
 - sed 's/context.Background/t.Context/' -i `git grep -l context.Background | grep test.go`
 - manually fixing broken tests
 - itest, lntest: use ht.Context() where ht or hn is available
 - in HarnessNode.Stop() we keep using context.Background(), because it is
   called from a cleanup handler in which t.Context() is canceled already.
2025-08-30 14:13:44 -03:00