Commit Graph

16474 Commits

Author SHA1 Message Date
yyforyongyu
9d5ddf29f3
sweep: add new interface Cluster to manage grouping inputs
This commit adds a new interface `Cluster` to manage cluster-level
inputs grouping. This new interface replaces the `inputCluster` and will
be futher refactored so the sweeper can use a much smaller coin
selection lock.
2024-04-19 21:33:25 +08:00
yyforyongyu
a7e9c08baf
sweep: make sweeper block-driven instead of time-driven
This commit changes the source that drives the state changes in the
sweeper. Previously we used a ticker with default interval of 30s to
trigger sweepings periodically. The assumption is, within this 30s we'd
batch multiple inputs into one transaction to maximize profits. However,
the efficacy of this batch is questionable.

At a high level, we can put our inputs into two categories - one that's
forced, and one that's not. For forced inputs, we should sweep them
immediately as the force flag indicates they are very urgent, eg,
CPFPing the force closing tx. For non-forced inputs, such as anchors
or HTLCs with CLTV that's far away, we can wait to sweep them till a new
block comes in and triggers the sweeping process.

Eventually, all inputs will be deadline-aware, and the sweeper will
consult our fee bumper about the most economical fee rate to be used for
a given deadline. Since the deadlines here are blockstamp, it's also
easier to manage them if the sweeper is also using blockstamp instead of
timestamp.
2024-04-19 21:33:24 +08:00
yyforyongyu
df4e51e2e0
sweep: refactor attachAvailableRBFInfo to decideStateAndRBFInfo
Thus this method `decideStateAndRBFInfo` won't touch the state changes
of a given input.
2024-04-19 21:33:24 +08:00
yyforyongyu
6f5b7a9fd3
lntest+itest: fix testOpenChannelLockedBalance 2024-04-19 21:33:24 +08:00
yyforyongyu
536ac9f8a4
docs: update release notes 2024-04-19 21:33:24 +08:00
yyforyongyu
5fce91caf9
chainntnfs+sweep: add LookupInputMempoolSpend and use it in the
sweeper

This commit implements a new method, `LookupInputMempoolSpend` to do
lookups in the mempool. This method is useful in the case when we only
want to know whether an input is already been spent in the mempool by
the time we call.
2024-04-19 21:33:24 +08:00
yyforyongyu
ebef3679ac
btcdnotify: use chain.NewRPCClientWithConfig to init RPC client
So we can use the methods implemented on the chain RPC client.
2024-04-19 21:33:24 +08:00
yyforyongyu
b5e4384e24
lnd+sweep: remove unused NextAttemptDeltaFunc 2024-04-19 21:33:23 +08:00
yyforyongyu
5496d02b27
sweep: fix logging 2024-04-19 21:33:23 +08:00
yyforyongyu
124d1764f7
sweep: remove unused param testSpendChan 2024-04-19 21:33:23 +08:00
yyforyongyu
fd922942a7
sweep: patch unit tests for markInputsSwept and markInputsPendingPublish
Now that the refactor is done, we start patching unit tests for these
two methods. Minor changes are also made based on the feedback from the
tests.
2024-04-19 21:33:23 +08:00
yyforyongyu
34b6a3d718
sweep: add method markInputFailed 2024-04-19 21:33:23 +08:00
yyforyongyu
a8f5a09dea
sweep: don't give up an input based on number of attempts
This commit removes the logic where we remove an input when it's been
published more than 10 times. This is needed as in our future fee
bumper, we might start with a low fee and rebroadcast the same input for
hundred of blocks.
2024-04-19 21:33:23 +08:00
yyforyongyu
8b876be3b6
sweep: add fee info for published inputs
This commit attaches RBFInfo to an input before it's been published or
it's already been published.
2024-04-19 21:33:22 +08:00
yyforyongyu
a263d68fb9
sweep: delete pending inputs based on their states
This commit uniforms and put the deletion of pending inputs in a single
point.
2024-04-19 21:33:22 +08:00
yyforyongyu
47478718d4
multi: query mempool spend when a new input is received
This commit changes how a new input sweep request is handled - now we
will query the mempool and see if it's already been spent. If so, we'll
update its state as we may need to RBF this input.
2024-04-19 21:33:22 +08:00
yyforyongyu
6a2e3fb203
sweep: make pending input stateful
This commit starts tracking the state of a pending input so it's easier
to control the sweeping flow and provide RBF awareness in the future.
2024-04-19 21:33:22 +08:00
yyforyongyu
1e6e443a0b
docs: update release notes 2024-04-19 21:33:22 +08:00
yyforyongyu
61e9c11881
rpcserver: skip calculating fee rate for PSBT funding 2024-04-19 21:33:22 +08:00
yyforyongyu
519a8749ef
lntest: reflect the updated fee estimator in tests 2024-04-19 21:33:21 +08:00
yyforyongyu
1870caf39c
sweep+lnd: introduce UtxoAggregator to handle clustering inputs
This commit refactors the grouping logic into a new interface
`UtxoAggregator`, which makes it easier to write tests and opens
possibility for future customized clustering strategies.

The old clustering logic is kept as and moved into `SimpleAggregator`.
2024-04-19 21:33:21 +08:00
yyforyongyu
3bcac318eb
sweep+lnrpc: add new interface FeePreference
This commit adds a new interface `FeePreference` which makes it easier
to write unit tests and allows more customized implementation in
following commits.
2024-04-19 21:33:21 +08:00
yyforyongyu
530eed92a0
multi: rename FeePreference to FeeEstimateInfo
Results from running,
```
gofmt -d -w -r 'FeePreference -> FeeEstimateInfo' .
```
2024-04-19 21:33:21 +08:00
yyforyongyu
6ff6c86155
multi: merge DetermineFeePerKw and Estimate
This commit moves `DetermineFeePerKw` into the `Estimate` method on
`FeePreference`. A few callsites previously calling `DetermineFeePerKw`
without the max fee rate is now also temporarily fixed by forcing them
to use `Estimate` with the default sweeper max fee rate.
2024-04-19 21:33:21 +08:00
yyforyongyu
18b06b7303
sweep: replace feeRateForPreference with Estimate
This commit refactors the sweeper so the method `feeRateForPreference`
is now moved to `FeePreference`, which makes our following refactor
easier to handle.
2024-04-19 21:33:20 +08:00
yyforyongyu
84a6fdcda3
sweep+contractcourt: track best height in UtxoSweeper
Thus we can use shorter method signatures. In doing so we also remove an
old TODO in one use case of `CreateSweepTx`.
2024-04-19 21:33:20 +08:00
yyforyongyu
ca0813b1bf
docs: update release docs 2024-04-19 21:33:20 +08:00
yyforyongyu
f13a3a8053
sweep: use testify/mock for MockSweeperStore 2024-04-19 21:33:20 +08:00
yyforyongyu
8b9d5e0548
sweep: add new methods GetTx and DeleteTx to manage TxRecord 2024-04-19 21:33:20 +08:00
yyforyongyu
b37444d0de
sweep: expand sweeper store to also save RBF-related info
This commit modifies the sweeper store to save a `TxRecord` in db
instead of an empty byte slice. This record will later be used to bring
RBF-awareness to our sweeper.
2024-04-19 21:33:20 +08:00
yyforyongyu
1ace1fdf4c
sweep: return fees from method createSweepTx
Which will be used to make the sweeper RBF-aware.
2024-04-19 21:33:19 +08:00
yyforyongyu
e86843da6e
sweep: rename NotifyPublishTx to StoreTx
To properly reflect what the method really does. We also changes the
method signature so only a hash is used.
2024-04-19 21:33:19 +08:00
Olaoluwa Osuntokun
d4c1937572
Merge pull request #8573 from guggero/bitcoind-27
GitHub: use bitcoind v27.0 for CI
2024-04-18 14:36:58 -07:00
Olaoluwa Osuntokun
63ef2f8433
Merge pull request #8643 from Roasbeef/kvdb-top-level-module-bump
build: bump top level module to kvdb v1.4.6
2024-04-18 14:22:08 -07:00
Keagan McClelland
6257df31e0 tlv: add axiomatic RecordProducer implementation for Record
This commit introduces a RecordProducer implementation for Record
that serves as the identity function. This makes it easier for us
to mix Primitive and Dynamic records in the same RecordProducer
collections.
2024-04-18 12:03:27 -06:00
Oliver Gugger
a42fc24220
docs: add release notes 2024-04-18 18:13:02 +02:00
Oliver Gugger
f41d6087d1
mod: bump btcd to fix sendrawtransaction max fee issue 2024-04-18 17:44:04 +02:00
Oliver Gugger
817ddb807b
GitHub+scripts: use bitcoind v27.0 2024-04-18 17:44:04 +02:00
Oliver Gugger
2ccf58e2af
Merge pull request #8630 from guggero/addr-master-fingerprint
mod: bump btcwallet to latest version
2024-04-16 07:00:13 +00:00
Olaoluwa Osuntokun
2162c943de
build: bump top level module to kvdb v1.4.6 2024-04-12 15:32:22 -07:00
Olaoluwa Osuntokun
07b6af41db
Merge pull request #8642 from Roasbeef/kvdb-update
kvdb: bump to sqldb/v1.0.1
2024-04-12 15:29:28 -07:00
Olaoluwa Osuntokun
06e4ffb3f3
kvdb: bump to sqldb/v1.0.1
Post merge module clean up after
https://github.com/lightningnetwork/lnd/pull/8611.
2024-04-12 15:16:26 -07:00
Oliver Gugger
f35ce0981d
docs: update release notes 2024-04-12 08:34:56 +02:00
Oliver Gugger
333fc6eb1d
mod: bump btcwallet to latest version
Fixes #8626.
This commit updates btcwallet to the latest version that correctly
includes the MasterKeyFingerprint for all generated addresses, including
change addresses derived from imported watch-only accounts.
2024-04-12 08:34:54 +02:00
Olaoluwa Osuntokun
1c229e4422
Merge pull request #8611 from bhandras/sql-tx-retry
sqldb+kvdb: unify SQL error mapping and transaction retry for between the `kvdb` and `sqldb` packages
2024-04-11 15:41:56 -07:00
Andras Banki-Horvath
024598266d
docs: update release notes for 0.18 2024-04-11 15:04:04 +02:00
Andras Banki-Horvath
043e4aff01
sqldb+invoices: fix ordering bug in FilterInvoices
Previously if the `reverse` named arg was unset (value of NULL), then
SQL would order by NULL instead of ID causing undifined ordering of the
returned rows. To fix that we check for NULL and also make sure to set
the `reverse` arg in the code explicitly as it in the generated code it
is an `interface{}` instead of `bool`.
2024-04-11 15:04:04 +02:00
Andras Banki-Horvath
478ae1e9b0
sqldb: cleanup scope state reset by adding reset closure to ExecTx
For SQL transactions, we often accumulate results in variables declared
outside the closure's scope. To eliminate the need for manually clearing
these containers, we introduce a reset function to ExecTx, mirroring the
approach already adopted in kvdb.
2024-04-11 15:04:04 +02:00
Andras Banki-Horvath
c6073a14ca
sqldb: ensure that we're using serializable isolation 2024-04-11 15:04:04 +02:00
Olaoluwa Osuntokun
0609431a0c
channeldb: fix payment control unit tests w/ errors.Is 2024-04-11 15:04:04 +02:00