Commit Graph

19194 Commits

Author SHA1 Message Date
yyforyongyu
e003cb5d4a accessman: make sure to decrement PendingOpenCount 2025-06-19 16:05:56 +08:00
Olaoluwa Osuntokun
168d63ce37 Merge pull request #9528 from Roasbeef/res-opt
fn: implement ResultOpt type for operations with optional values
2025-06-18 18:22:11 -07:00
Olaoluwa Osuntokun (aider)
0c25bd3f19 fn: implement ResultOpt type for operations with optional values
This commit introduces the ResultOpt type, which represents an operation
that can either succeed with an optional final value or fail with an
error.

The .gitignore file is also updated to exclude specific files related to
the `aider` tool.
2025-06-18 18:16:24 -07:00
Elle Mouton
ece157b40b graph/db: implement ForEachNodeChannel
Which lets us then run `TestIncompleteChannelPolicies` and
`BenchmarkForEachChannel` against our SQL backends.
2025-06-18 16:55:00 +02:00
Elle Mouton
0607982886 graph/db: implement ForEachNodeDirectedChannel and ForEachNodeCacheable
Here we add the `ForEachNodeDirectedChannel` and `ForEachNodeCacheable`
SQLStore implementations which then lets us run
`TestGraphTraversalCacheable` and `TestGraphCacheForEachNodeChannel`
against SQL backends.
2025-06-18 16:55:00 +02:00
Elle Mouton
8af32951c7 graph/db+sqldb: implement ForEachNode
In this commit the `ForEachNode` method is added to the SQLStore. With
this, the `TestGraphCacheTraversal` unit test can be run against SQL
backends.
2025-06-18 16:54:59 +02:00
Elle Mouton
d60761f79c graph/db: fix error check in test
An error in TestChanUpdatesInHorizon was previously not checked
correctly.
2025-06-18 15:24:16 +02:00
Elle Mouton
973d211083 graph/db: fix DecodeHexColor
Ensure that it does a sanity check on the length of its input and also
only call it if the nullable SQL string is not null.

Expand an existing unit tests to cover the DecodeHexColor such that it
would have caught the bug.
2025-06-18 15:19:23 +02:00
Elle Mouton
23d4bfc1b0 graph/db: add comment and switch to length check
Use a length check to determine if a bitcoin signature has been set or
not. Also add a clarifying comment to explain why we only need to check
if one signature field is set to determine if we have the auth proof for
the channel or not.
2025-06-18 15:17:55 +02:00
Oliver Gugger
31c74f20fa Merge pull request #9962 from yyforyongyu/fix-panic
chainio: use package logger instead of instance logger
2025-06-18 15:09:07 +02:00
Oliver Gugger
79294dff35 Merge pull request #9931 from ellemouton/graphSQL10-forEachSourceNode
[10] graph/db+sqldb: implement ForEachSourceNodeChannel
2025-06-18 14:51:38 +02:00
yyforyongyu
b0aa4ae2de chainio: use package logger instead of instance logger
There's no guarantee that the `b.beat` is initialized when the
dispatcher shuts down, especially with the case in the remote signer
where no chainbackend is created.
2025-06-18 19:43:27 +08:00
yyforyongyu
856ec463ff accessman: skip incrementing num of slots for existing peer
When a peer is already existing, we should skip incrementing the
`numRestricted` count.

Also patched unit test for method `addPeerAccess`.
2025-06-18 17:19:10 +08:00
yyforyongyu
0f9332b1d6 lnd: add string representation for peerAccessStatus 2025-06-18 17:19:10 +08:00
yyforyongyu
0c5bb49561 lnd: only restrict slots for inbound connections
For outbound connections, since they are initialized by the users, we
can relax on the restriction. A future global limit may be added - as
for now, we will let them to be managed by the users.
2025-06-18 17:19:10 +08:00
yyforyongyu
00db8c6359 lnd: move peer perms assignment into peerConnected
When the callback is called in `scheduledPeerConnection`, it is
referencing the old `access` variable which was created when the peer
was first connected. However, if this peer opens a channel with us and
goes offline, or another inbound connection is made from this peer, we
may still use the old `access` value. To fix it, we need to make sure we
always get the fresh perm by calling `assignPeerPerms` inside
`peerConnected`.
2025-06-18 17:19:10 +08:00
yyforyongyu
d8d468f459 accessman: reduce lock span by excluding ctx 2025-06-18 17:19:10 +08:00
yyforyongyu
124aabcdb7 accessman+lnd: check if a peer is found in peerScores
We need to also check this map to make sure the peer exists or not.
2025-06-18 17:19:09 +08:00
yyforyongyu
836b527a4e accessman: skip restriction for existing peers
When a peer already has a connection with us, there's no need to check
for available slots as we will either close the old conn or refuse the
new conn.
2025-06-18 17:19:09 +08:00
yyforyongyu
599650fa2d lncfg+lnd: add new dev config unsafeconnect
This flag is added so we can use it in the itest to mimic racing inbound
and outbound connections.
2025-06-18 17:19:09 +08:00
yyforyongyu
cc7ed5a9d2 lncfg: fix typo 2025-06-18 17:19:09 +08:00
Elle Mouton
f89e3ceced graph/db+sqldb: implement ForEachSourceNodeChannel
In this commit, the ForEachSourceNodeChannel implementation of the
SQLStore is added. Since this is the first method of the SQLStore that
fetches channel and policy info, it also adds all the helpers that are
required to do so. These will be re-used in upcoming commits as more
"For"-type methods are added.

With this implementation, we convert the `TestForEachSourceNodeChannel`
such that it is run against SQL backends.
2025-06-18 08:43:56 +02:00
Elle Mouton
3ed53cdcba graph/db: cache source node info
Save future round trips by caching source node info since this info will
never change.
2025-06-18 08:26:38 +02:00
Oliver Gugger
a27bd69b9c Merge pull request #9956 from ellemouton/chanGraphContext
multi: add `context.Context` param to some `graphdb.V1Store` methods
2025-06-17 20:34:56 +02:00
Elle Mouton
e724e1c3e4 multi: thread context through to AddrsForNode 2025-06-17 19:20:59 +02:00
Elle Mouton
d1fa5701eb graph/db: thread context through to DeleteLightningNode 2025-06-17 19:20:59 +02:00
Elle Mouton
dc6259fcc3 graph/db: thread context through to HasLightningNode 2025-06-17 19:20:56 +02:00
Elle Mouton
66c5a97202 graph/db: thread context through to FetchLightingNode 2025-06-17 19:20:27 +02:00
Elle Mouton
d1cfb47428 graph/db: thread context to AddLightningNode 2025-06-17 19:20:27 +02:00
Oliver Gugger
c1740c14ba Merge pull request #9887 from ellemouton/graphSQL9-chan-policies-schema
graph/db+sqldb: channel policy SQL schemas, queries and upsert CRUD
2025-06-17 16:30:23 +02:00
yyforyongyu
2defb116cc docs: update release notes 2025-06-17 21:44:15 +08:00
Elle Mouton
c327988bb3 graph/db+sqldb: implement UpdateEdgePolicy
In this commit, the various SQL queries are defined that we will need in
order to implement the SQLStore UpdateEdgePolicy method. Channel
policies can be "replaced" and so we use the upsert pattern for them
with the rule that any new channel policy must have a timestamp greater
than the previous one we persisted.

As is done for the KVStore implementation of the method, we use the
batch scheduler for this method.
2025-06-17 13:43:07 +02:00
yyforyongyu
755bb09a73 htlcswitch: skip decoding hop if the htlc is already acked
We now move the check earlier in the loop so we don't even need to
decode the hop for already processed ADDs.
2025-06-17 11:39:38 +08:00
yyforyongyu
e3f95dcd09 htlcswitch: remove batchReplayBkt
This commit removes the `batchReplayBkt` as its only effect is to allow
reforwarding htlcs during startup.

Normally for every incoming htlc added, their shared secret is used as
the key to be saved into the `sharedHashBucket`, which will be used for
check for replays. In addition, the fwdPkg's ID, which is SCID+height is
also saved to the bucket `batchReplayBkt`. Since replays of HTLCs cannot
happen at the same commitment height, when a replay happens,
`batchReplayBkt` simply doesn't have this info, and we again rely on
`sharedHashBucket` to detect it. This means most of the time the
`batchReplayBkt` is a list of SCID+height with empty values.

The `batchReplayBkt` was previously used as a mechanism to check for
reforwardings during startup - when reforwarding htlcs, it quries this
bucket and finds an empty map, knowing this is a forwarding and skips
the check in `sharedHashBucket`. Given now we use a bool flag to
explicitly skip the replay check, this bucket is no longer useful.
2025-06-17 11:39:38 +08:00
yyforyongyu
3b9c4eb232 htlcswitch: exit early if the fwdPkg is already completed 2025-06-17 11:39:38 +08:00
yyforyongyu
fb95458a1b htlcswitch: skip checking replays for reforwarded packets
We now rely on the forwarding package's state to decide whether a given
packet is a reforwarding or not. If we know it's a reforwarding packet,
there's no need to check for replays in the `sharedHashes` bucket, which
behaves the same as if we are querying the `batchReplayBkt`.
2025-06-17 11:39:37 +08:00
Yong
a5c4a7c547 Merge pull request #9921 from yyforyongyu/fix-notification
Use spent height as the rescan start height in `RegisterSpendNtfn`
2025-06-16 20:50:53 +08:00
Oliver Gugger
207df8dd7c Merge pull request #9951 from yyforyongyu/fix-cached-policy
graph: fix nil pointer deference in `ForEachChannelCacheable`
2025-06-16 10:28:16 +02:00
Oliver Gugger
cb10536a2f Merge pull request #9943 from ziggie1984/update-lightning-onion
multi: update sphinx lib to latest version
2025-06-16 10:26:25 +02:00
Oliver Gugger
8f8d17de26 Merge pull request #9903 from ziggie1984/sphinx-relays-doc
docs: add sphinx replay description
2025-06-16 10:25:04 +02:00
Oliver Gugger
63e7c2e893 Merge pull request #9933 from Roasbeef/0-19-99
build: bump version to v0.19.99
2025-06-16 08:51:45 +02:00
Oliver Gugger
5d161e8cd0 Merge pull request #9653 from djkazic/reorder-buckets-check
channeldb: perform init of top level buckets first
2025-06-16 08:24:03 +02:00
Yong
94064bed3a Merge pull request #9815 from mohamedawnallah/preventCurrentNodeAnnMutation
server.go: prevent partial mutation of `currentNodeAnn` in `server.genNodeAnnouncement` on `netann.SignNodeAnnouncement` failures
2025-06-16 12:05:44 +08:00
yyforyongyu
46c5715ae5 graph: fix nil pointer deference in ForEachChannelCacheable 2025-06-16 12:02:24 +08:00
Mohamed Awnallah
e7d30e0790 docs: update release notes 2025-06-14 14:31:57 +00:00
Mohamed Awnallah
d26a84e18b server.go: prevent partial mutation of currNodeAnn
In this commit, we prevent partial mutation of current
node announcement during announcement signing. If node
announcement signing failed the current node announcement
becomes inconsistent.
2025-06-14 14:23:34 +00:00
Yong
fe405426ca Merge pull request #9356 from funyug/add-filters-fwdhistory
lnrpc: add incoming/outgoing channel ids filter to forwarding history request
2025-06-14 08:36:51 +08:00
ziggie
1741810065 docs: add sphinx replay description
Previouly the sphinx replay db would cause confusion for what it
is needed at all. We clarify it in a detailed document.
2025-06-13 15:37:03 +02:00
djkazic
759a870072 channeldb: perform init of top level buckets first 2025-06-13 09:02:07 -04:00
ziggie
fe3db6a263 multi: update sphinx lib to latest version 2025-06-13 08:47:31 +02:00