Commit Graph

15632 Commits

Author SHA1 Message Date
Elle
ed179e3e7d
Merge pull request #8180 from carlaKC/8128-brontideflake
peer/test: fix race in TestHandleNewPendingChannel
2023-11-16 10:10:24 +02:00
Carla Kirk-Cohen
a8a86b290c
peer/test: setup clean peer for each TestHandleNewPendingChannel case
Running test cases in parallel with shared state means that they
can intermingle if they're run at the same time and set up incorrect
values when we assert on the number of channels we have. Moving the
peer setup into the parallel test run fixes this because no single
test case can interfere with the other.
2023-11-14 15:45:19 -05:00
Elle
5e369a02bb
Merge pull request #8171 from ellemouton/zombieChansUseCorrectChanID
channeldb+discovery: pass correct SCID to `MarkEdgeLive`
2023-11-14 11:05:57 +02:00
Elle Mouton
ac58100558
docs: update release notes 2023-11-13 20:58:27 +02:00
Elle Mouton
7ff4a8b157
discovery: use correct channel ID for MarkEdgeLive
In processZombieUpdate, the SCID passed to MarkEdgeLive should _not_ be
derived from the ChannelEdgeInfo ChannelID field since this field will
not be populated when GetChannelByID returns a ChannelEdgeInfo along
with an ErrZombieEdge error. So this commit ensures that a usable
SCID is provided to processZombieUpdate.
2023-11-13 20:58:06 +02:00
Elle Mouton
0193274c10
multi: return error from MarkEdgeLive if not found
Let MarkEdgLive return a new ErrNotZombieEdge error if an entry with the
given channel ID cannot be found. In processZombieUpdate, we then
check for this error and log accordingly.
2023-11-13 20:58:06 +02:00
Elle Mouton
034283db10
channeldb: update TestGraphZombieIndex to use require 2023-11-13 20:58:05 +02:00
Olaoluwa Osuntokun
e02fd39ce6
Merge pull request #8170 from yyforyongyu/0-18-staging-missed
Add missing commits from `0-18-staging`
2023-11-13 10:38:23 -08:00
yyforyongyu
5168af55a9
itest: fix flake in max_htlc_pathfind
```
lnd_max_htlcs_test.go:149:
        	Error Trace:	/home/runner/work/lnd/lnd/itest/lnd_max_htlcs_test.go:149
        	            				/home/runner/work/lnd/lnd/itest/lnd_max_htlcs_test.go:40
        	            				/home/runner/work/lnd/lnd/lntest/harness.go:286
        	            				/home/runner/work/lnd/lnd/itest/lnd_test.go:136
        	Error:      	Not equal:
        	            	expected: 3
        	            	actual  : 0
        	Test:       	TestLightningNetworkDaemon/tranche01/60-of-134/btcd/max_htlc_pathfind
        	Messages:   	expected accepted
```
2023-11-13 16:11:07 +08:00
yyforyongyu
678f416008
routing+docs: make sure non-MPP cannot use skipTempErr 2023-11-13 16:11:06 +08:00
yyforyongyu
168cfd7cd5
docs: emphasize the new payment status StatusInitiated 2023-11-13 16:10:51 +08:00
yyforyongyu
98378d9408
routing: unify all dummy errors to be errDummy 2023-11-13 16:10:28 +08:00
yyforyongyu
7ccb77269d
routing: log preimage when it's failed to be saved to db 2023-11-13 16:10:28 +08:00
yyforyongyu
8f5c6e8367
trivial: fix typos 2023-11-13 16:10:28 +08:00
yyforyongyu
e3dadd528b
routing: mark payment as failed when no route can be found 2023-11-13 16:10:28 +08:00
yyforyongyu
27ee917a20
docs: update release note for payment lifecycle 2023-11-13 16:10:26 +08:00
yyforyongyu
6e93764bc1
routing: make sure payment hash is random in unit tests
This commit makes sure a testing payment is created via
`createDummyLightningPayment` to ensure the payment hash is unique to
avoid collision of the same payment hash being used in uint tests. Since
the tests are running in parallel and accessing db, if two difference
tests are using the same payment hash, no clean test state can be
guaranteed.
2023-11-13 16:09:12 +08:00
yyforyongyu
10052ff4f5
routing: patch unit tests for payment lifecycle
This commit adds unit tests for `resumePayment`. In addition, the
`resumePayment` has been split into two parts so it's easier to be
tested, 1) sending the htlc, and 2) collecting results. As seen in the
new tests, this split largely reduces the complexity involved and makes
the unit test flow sequential.

This commit also makes full use of `mock.Mock` in the unit tests to
provide a more clear testing flow.
2023-11-13 16:09:12 +08:00
yyforyongyu
e46c689bf1
routing: refactor attempt makers to return pointers
Thus adding following unit tests can be a bit easier.
2023-11-13 16:09:12 +08:00
yyforyongyu
ddad6ad4c4
routing: update mockers in unit test
This commit adds more mockers to be used in coming unit tests and
simplified the mockers to be more straightforward.
2023-11-13 16:09:12 +08:00
yyforyongyu
01e3bd87ab
routing: delete old payment lifecycle related unit tests
The old payment lifecycle is removed due to it's not "unit" -
maintaining these tests probably takes as much work as the actual
methods being tested, if not more so. Moreover, the usage of the old
mockers in current payment lifecycle test is removed as it re-implements
other interfaces and sometimes implements it uniquely just for the
tests. This is bad as, not only we need to work on the actual interface
implementations and test them , but also re-implement them again in the
test without testing them!
2023-11-13 16:09:11 +08:00
yyforyongyu
09a5d235ec
routing: fail attempt when no shard is found or circuit generation fails 2023-11-13 16:09:11 +08:00
yyforyongyu
eda24ec871
routing: catch lifecycle quit signal in collectResult 2023-11-13 16:09:11 +08:00
yyforyongyu
da8f1c084a
channeldb+routing: add new interface method TerminalInfo
This commit adds a new interface method `TerminalInfo` and changes its
implementation to return an `*HTLCAttempt` so it includes the route for
a successful payment. Method `GetFailureReason` is now removed as its
returned value can be found in the above method.
2023-11-13 16:09:11 +08:00
yyforyongyu
3c5c37b693
routing: introduce stateStep to manage payment lifecycle
This commit adds a new struct, `stateStep`, to decide the workflow
inside `resumePayment`.

It also refactors `collectResultAsync` introducing a new channel
`resultCollected`. This channel is used to signal the payment
lifecycle that an HTLC attempt result is ready to be processed.
2023-11-13 16:09:11 +08:00
yyforyongyu
e8c0226e1c
routing: add AllowMoreAttempts to decide whether more attempts are allowed 2023-11-13 16:09:11 +08:00
bitromortac
9a0db291b5
routing: fix tests after main refactor
Delete TestSendMPPaymentFailedWithShardsInFlight as it seems to be the
same test as TestSendMPPaymentFailed.
2023-11-13 16:09:11 +08:00
yyforyongyu
173900c8dc
routing: only fail attempt inside handleSwitchErr
This commit makes sure we only fail attempt inside `handleSwitchErr` to
ensure the orders in failing payment and attempts. It refactors
`collectResult` to return `attemptResult`, and expands `handleSwitchErr`
to also handle the case where the attemptID is not found.
2023-11-13 16:09:10 +08:00
yyforyongyu
703ea08316
routing: add methods checkTimeout and requestRoute
This commit refactors the `resumePayment` method by adding the methods
`checkTimeout` and `requestRoute` so it's easier to understand the flow
and reason about the error handling.
2023-11-13 16:09:10 +08:00
yyforyongyu
7209c65ccf
routing: split launchShard into registerAttempt and sendAttempt
This commit removes the method `launchShard` and splits its original
functionality into two steps - first create the attempt, second send the
attempt. This enables us to have finer control over "which error is
returned from which system and how to handle it".
2023-11-13 16:09:10 +08:00
yyforyongyu
49bafc0207
routing: handle switch error when sendAttempt fails
This commit starts handling switch error inside `sendAttempt` when an
error is returned from sending the HTLC. To make sure the updated
`HTLCAttempt` is always returned to the callsite, `handleSwitchErr` now
also returns a `attemptResult`.
2023-11-13 16:09:10 +08:00
yyforyongyu
568b977a1f
routing: add new method registerAttempt
This commit adds a new method `registerAttempt` to take care of creating
and saving an htlc attempt to disk.
2023-11-13 16:09:10 +08:00
yyforyongyu
071d05e0e3
routing: unify shardResult and launchOutcome to be attemptResult
This commit removes the `launchOutcome` and `shardResult` and uses
`attemptResult` instead. This struct is also used in `failAttempt` so we
can future distinguish critical vs non-critical errors when handling
HTLC attempts.
2023-11-13 16:09:10 +08:00
yyforyongyu
4bb8db46df
routing: fail payment before attempt inside handleSwitchErr
`handleSwitchErr` is now responsible for failing the given HTLC attempt
after deciding to fail the payment or not. This is crucial as
previously, we might enter into a state where the payment's HTLC has
already been marked as failed, and while we are marking the payment as
failed, another HTLC attempt can be made at the same time, leading to
potential stuck payments.
2023-11-13 16:09:09 +08:00
yyforyongyu
8458966f02
routing: remove the abstraction shardHandler
This commit removes the unclear abstraction `shardHandler` that's used
in our payment lifecycle. As we'll see in the following commits,
`shardHandler` is an unnecessary layer and everything can be cleanly
managed inside `paymentLifecycle`.
2023-11-13 16:09:09 +08:00
Olaoluwa Osuntokun
9937b1d6de Merge branch 'dyncomms' 2023-11-10 13:30:28 -08:00
Keagan McClelland
9793fbb94b lnwire: add musig2 taproot execution messages for dynamic commitments 2023-11-10 13:29:52 -08:00
Keagan McClelland
9b1c04c210 docs: update release notes 2023-11-10 13:29:51 -08:00
Keagan McClelland
564bf852bb lnwire: add fuzz tests for new dynamic commitment message types 2023-11-10 13:29:30 -08:00
Keagan McClelland
3e84d22eeb lnwire: add TLV extension to channel_reestablish for dynamic commitments 2023-11-10 13:29:30 -08:00
Keagan McClelland
e5f7ed8ba1 lnwire: introduce message types for dynamic commitment negotiation
lnwire: add tests for dynamic commitment wire serialization
2023-11-10 13:29:30 -08:00
Keagan McClelland
b298c84d21 fn: introduce option type
this commit introduces many of the most common functions you will
want to use with the Option type. Not all of them are used
immediately in this PR.
2023-11-10 13:29:30 -08:00
Elle
a3f8011ed6
Merge pull request #8156 from hieblmi/improve-fc-logging
contractcourt: log amount if incoming htlc times out
2023-11-09 17:32:18 +02:00
Elle
6122452509
Merge pull request #8117 from ellemouton/removeDBFromChannelDBSchemas
channeldb+refactor: remove `kvdb.Backend` from channel DB schemas
2023-11-09 07:47:11 +02:00
Olaoluwa Osuntokun
6de3fea8e6
Merge pull request #8158 from Crypt-iQ/writeMessage_fix
peer: send messages in Start via writeMessage to bypass writeHandler
2023-11-08 14:54:54 -08:00
Eugene Siegel
38fb12fb4f
release-notes: update for 0.17.1 2023-11-08 16:36:04 -05:00
Eugene Siegel
955a345153
peer: send messages in Start via writeMessage to bypass writeHandler
Without this the following could happen:

* InboundPeerConnected is called while we already have an inbound
connection with the peer. This calls removePeer which calls Disconnect.
* If the peer is starting up in Start, it may be sending messages
synchronously via SendMessage(true, ...). This eventually calls the
writeMessage function which will exit if disconnect is set to 1.
* Since Disconnect was called, disconnect will be 1 and writeMessage
will exit, causing writeHandler to exit.
* If there is more than 1 message being sent, later messages will
queue in queueHandler but be unable to get into sendQueue as the
writeHandler goroutine has exited.
* The synchronous sends will be waiting on the errChan indefinitely
and startReady will never get closed meaning Disconnect will never
proceed.

The end result is that the server's mutex will be held until shutdown.

Avoid this by using writeMessage to bypass the writeHandler goroutine.
2023-11-08 16:36:02 -05:00
Elle Mouton
0e82293e45
multi: address linter issues 2023-11-08 14:50:35 +02:00
Elle Mouton
84cdcd6847
multi: move DB schemas to channeldb/models
This commit moves the ChannelEdgePolicy, ChannelEdgeInfo,
ChanelAuthProof and CachedEdgePolicy structs to the `channeldb/models`
package.
2023-11-08 14:50:35 +02:00
Elle Mouton
be23986eda
docs: update release notes 2023-11-08 14:50:35 +02:00