Commit Graph

17972 Commits

Author SHA1 Message Date
yyforyongyu
36a87ad5f4 itest: assert payment status after sending 2024-12-20 17:54:12 +08:00
yyforyongyu
425877e745 itest: remove redundant block in multiple tests 2024-12-20 17:54:12 +08:00
yyforyongyu
9c0c373b7e itest: flatten and fix testWatchtower 2024-12-20 17:54:12 +08:00
yyforyongyu
b7feeba008 itest+lntest: fix channel force close test
Also flatten the tests to make them easier to be maintained.
2024-12-20 17:54:12 +08:00
yyforyongyu
9d4a60d613 itest: remove redundant blocks in channel backup tests 2024-12-20 17:54:12 +08:00
yyforyongyu
a55408d4a1 itest: remove redudant block in testPsbtChanFundingWithUnstableUtxos 2024-12-20 17:54:11 +08:00
yyforyongyu
22b9350320 itest: remove redunant block mining in testChannelFundingWithUnstableUtxos 2024-12-20 17:54:11 +08:00
yyforyongyu
2494f1ed32 itest: remove redundant block mining in testFailingChannel 2024-12-20 17:54:11 +08:00
yyforyongyu
e1d5bbf171 itest: remove unnecessary force close 2024-12-20 17:54:11 +08:00
yyforyongyu
2adb356668 itest: rename file to reflect the tests 2024-12-20 17:54:11 +08:00
yyforyongyu
2f0256775e itest: flatten testHtlcTimeoutResolverExtractPreimageRemote
Also remove unused code.
2024-12-20 17:54:11 +08:00
yyforyongyu
34951a6153 itest: flatten testHtlcTimeoutResolverExtractPreimageLocal
This commit simplfies the test since we only test the preimage
extraction logic in the htlc timeout resolver, there's no need to test
it for all different channel types as the resolver is made to be
oblivious about them.
2024-12-20 17:54:10 +08:00
yyforyongyu
f95e64f084 itest: flatten testMultiHopHtlcAggregation 2024-12-20 17:54:10 +08:00
yyforyongyu
52e6fb1161 itest: flatten testMultiHopHtlcRemoteChainClaim 2024-12-20 17:54:10 +08:00
yyforyongyu
8dd73a08a9 itest: flatten testMultiHopHtlcLocalChainClaim 2024-12-20 17:54:10 +08:00
yyforyongyu
d7b2025248 lntest+itest: flatten testMultiHopRemoteForceCloseOnChainHtlcTimeout 2024-12-20 17:54:10 +08:00
yyforyongyu
bef17f16cf lntest+itest: flatten testMultiHopLocalForceCloseOnChainHtlcTimeout 2024-12-20 17:54:10 +08:00
yyforyongyu
bc31979f7b itest: simplify and flatten testMultiHopReceiverChainClaim 2024-12-20 17:54:10 +08:00
yyforyongyu
9ab9cd5f99 lntest+itest: start flattening the multi-hop tests
Starting from this commit, we begin the process of flattening the
multi-hop itests to make them easier to be maintained. The tests are
refactored into their own test cases, with each test focusing on testing
one channel type. This is necessary to save effort for future
development.

These tests are also updated to reflect the new `blockbeat` behavior.
2024-12-20 17:54:09 +08:00
yyforyongyu
e45005b310 itest: fix testPaymentSucceededHTLCRemoteSwept 2024-12-20 17:54:09 +08:00
yyforyongyu
0778009ac2 itest: fix testBumpForceCloseFee 2024-12-20 17:54:09 +08:00
yyforyongyu
1aeea8a90f itest: fix testSweepCommitOutputAndAnchor 2024-12-20 17:54:09 +08:00
yyforyongyu
d260a87f3b itest: fix testSweepHTLCs 2024-12-20 17:54:09 +08:00
yyforyongyu
cacf222e11 itest: fix testSweepCPFPAnchorIncomingTimeout 2024-12-20 17:54:09 +08:00
yyforyongyu
40ac04a254 lntest+itest: fix testSweepCPFPAnchorOutgoingTimeout 2024-12-20 17:54:08 +08:00
yyforyongyu
4806b2fda7 multi: optimize loggings around changes from blockbeat 2024-12-20 17:54:08 +08:00
yyforyongyu
fecd5ac735 contractcourt: make sure launchResolvers is called on new blockbeat
This is an oversight from addressing this commment:
https://github.com/lightningnetwork/lnd/pull/9277#discussion_r1882410396

where we should focus on skipping the close events but not the
resolvers.
2024-12-20 17:54:08 +08:00
yyforyongyu
bd88948264 docs: add release notes for blockbeat series 2024-12-20 17:54:08 +08:00
yyforyongyu
cc60d2b41c chainntnfs: skip dispatched conf details
We need to check `dispatched` before sending conf details, otherwise the
channel `ntfn.Event.Confirmed` will be blocking, which is the leftover
from #9275.
2024-12-20 17:54:08 +08:00
yyforyongyu
ea7d6a509b contractcourt: register conf notification once and cancel when confirmed 2024-12-20 17:54:08 +08:00
yyforyongyu
a6d3a0fa99 contractcourt: process channel close event on new beat 2024-12-20 17:54:07 +08:00
yyforyongyu
c5b3033427 contractcourt: add close event handlers in ChannelArbitrator
To prepare the next commit where we would handle the event upon
receiving a blockbeat.
2024-12-20 17:54:07 +08:00
yyforyongyu
6eb9bb1ed6 multi: add new method ChainArbitrator.RedispatchBlockbeat
This commit adds a new method to enable us resending the blockbeat in
`ChainArbitrator`, which is needed for the channel restore as the chain
watcher and channel arbitrator are added after the start of the chain
arbitrator.
2024-12-20 17:54:07 +08:00
yyforyongyu
4d765668cc contractcourt: use close height instead of best height
This commit adds the closing height to the logging and fixes a wrong
height used in handling the breach event.
2024-12-20 17:54:07 +08:00
yyforyongyu
3822c23833 contractcourt: notify blockbeat for chainWatcher
We now start notifying the blockbeat from the ChainArbitrator to the
chainWatcher.
2024-12-20 17:54:07 +08:00
yyforyongyu
8237598ed1 contractcourt: handle blockbeat in chainWatcher 2024-12-20 17:54:07 +08:00
yyforyongyu
4e30598263 contractcourt: add method handleCommitSpend
To prepare for the blockbeat handler.
2024-12-20 17:54:07 +08:00
yyforyongyu
c1a9390c36 contractcourt: register spend notification during init
This commit moves the creation of the spending notification from `Start`
to `newChainWatcher` so we subscribe the spending event before handling
the block, which is needed to properly handle the blockbeat.
2024-12-20 17:54:06 +08:00
yyforyongyu
07cb3aef00 contractcourt: implement Consumer on chainWatcher 2024-12-20 17:54:06 +08:00
yyforyongyu
63aa5aa6e9 contractcourt: offer outgoing htlc one block earlier before its expiry
We need to offer the outgoing htlc one block earlier to make sure when
the expiry height hits, the sweeper will not miss sweeping it in the
same block. This also means the outgoing contest resolver now only does
one thing - watch for preimage spend till height expiry-1, which can
easily be moved into the timeout resolver instead in the future.
2024-12-20 17:54:06 +08:00
yyforyongyu
819c15fa0b contractcourt: break launchResolvers into two steps
In this commit, we break the old `launchResolvers` into two steps - step
one is to launch the resolvers synchronously, and step two is to
actually waiting for the resolvers to be resolved. This is critical as
in the following commit we will require the resolvers to be launched at
the same blockbeat when a force close event is sent by the chain watcher.
2024-12-20 17:54:06 +08:00
yyforyongyu
d2e81a19fd contractcourt: fix concurrent access to launched 2024-12-20 17:54:06 +08:00
yyforyongyu
4f5ccb8650 contractcourt: fix concurrent access to resolved
This commit makes `resolved` an atomic bool to avoid data race. This
field is now defined in `contractResolverKit` to avoid code duplication.
2024-12-20 17:54:06 +08:00
yyforyongyu
47722292c5 contractcourt: add Launch method to outgoing contest resolver 2024-12-20 17:54:05 +08:00
yyforyongyu
ef98c52d10 contractcourt: add Launch method to incoming contest resolver
A minor refactor is done to support implementing `Launch`.
2024-12-20 17:54:05 +08:00
yyforyongyu
025d787fd2 invoices: exit early when the subscriber chan is nil
When calling `NotifyExitHopHtlc` it is allowed to pass a chan to
subscribe to the HTLC's resolution when it's settled. However, this
method will also return immediately if there's already a resolution,
which means it behaves like a notifier and a getter. If the caller
decides to only use the getter to do a non-blocking lookup, it can pass
a nil subscriber chan to bypass the notification.
2024-12-20 17:54:05 +08:00
yyforyongyu
71aec7bd94 contractcourt: add Launch method to htlc timeout resolver
This commit breaks the `Resolve` into two parts - the first part is
moved into a `Launch` method that handles sending sweep requests, and
the second part remains in `Resolve` which handles waiting for the
spend. Since we are using both utxo nursery and sweeper at the same
time, to make sure this change doesn't break the existing behavior, we
implement the `Launch` as following,
- zero-fee htlc - handled by the sweeper
- direct output from the remote commit - handled by the sweeper
- legacy htlc - handled by the utxo nursery
2024-12-20 17:54:05 +08:00
yyforyongyu
cf105e67f4 contractcourt: add Launch method to htlc success resolver
This commit breaks the `Resolve` into two parts - the first part is
moved into a `Launch` method that handles sending sweep requests, and
the second part remains in `Resolve` which handles waiting for the
spend. Since we are using both utxo nursery and sweeper at the same
time, to make sure this change doesn't break the existing behavior, we
implement the `Launch` as following,
- zero-fee htlc - handled by the sweeper
- direct output from the remote commit - handled by the sweeper
- legacy htlc - handled by the utxo nursery
2024-12-20 17:54:05 +08:00
yyforyongyu
913f5d4657 contractcourt: add Launch method to commit resolver 2024-12-20 17:54:05 +08:00
yyforyongyu
a98763494f contractcourt: add Launch method to anchor/breach resolver
We will use this and its following commits to break the original
`Resolve` methods into two parts - the first part is moved to a new
method `Launch`, which handles sending a sweep request to the sweeper.
The second part remains in `Resolve`, which is mainly waiting for a
spending tx.

Breach resolver currently doesn't do anything in its `Launch` since the
sweeping of justice outputs are not handled by the sweeper yet.
2024-12-20 17:54:04 +08:00