Commit graph

461 commits

Author SHA1 Message Date
yyforyongyu
4bfcfea2ee
lntest+chainntnfs: make sure bitcoind node is synced
This commit makes sure the bitcoind node is synced to the miner when
initialized and returned from `NewBitcoindBackend`.
2025-02-26 19:51:52 +08:00
yyforyongyu
99d49dec6a
multi: change NewBitcoindBackend to take a miner as its param
Prepares for the following commit where we assert the chain backend is
synced to the miner.
2025-02-26 19:51:52 +08:00
yyforyongyu
1618d2c789
chainntnfs+lntest: fix sync to miner block flake
In this commit we document an unexpected behavior found when connecting
a bitcoind node to a btcd node. We mitigate this in our test by
reconnecting the nodes when the connection is broken. We also limit the
connection made from `bitcoind` to be v1 only.
2025-02-26 19:51:52 +08:00
yyforyongyu
121116cff7
sweep: remove dead code and add better logging 2025-02-20 14:40:52 +08:00
Oliver Gugger
1b0f41da48
Merge pull request #9378 from yyforyongyu/fix-unit-test
chainntnfs: fix test `testSingleConfirmationNotification`
2025-01-13 03:13:02 -06:00
chloefeal
852a8d8746
chore: fix typo 2025-01-05 20:45:35 +08:00
yyforyongyu
bafe5d009f
chainntnfs: fix test testSingleConfirmationNotification 2024-12-20 22:08:32 +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
f03e242515
chainntnfs: ensure previous test succeeded before running 2024-12-10 19:56:01 +08:00
Keagan McClelland
ed2989ae33
multi: update to fn v2 2024-12-04 13:19:00 -07:00
Elle Mouton
ab7aae0708
multi: rename nolint:lll to nolint:ll
Find and replace all nolint instances refering to the `lll` linter and
replace with `ll` which is the name of our custom version of the `lll`
linter which can be used to ignore log lines during linting.

The next commit will do the configuration of the custom linter and
disable the default one.
2024-12-02 09:14:21 +02:00
Elle Mouton
439a6c7d6c
multi: rename chan DB Open method to OpenForTesting 2024-11-28 13:51:15 +02:00
yyforyongyu
db6901c9f3
chainntnfs: skip duplicate numConfsLeft notifications
This commit adds a new state to the `ConfNtfn` struct to start tracking
the number of confs left to be notified to avoid sending duplicate
notifications.
2024-11-19 16:27:26 +08:00
yyforyongyu
7695880c13
chainntnfs: add new method notifyNumConfsLeft
So it's easier to handle the following commit where we start skipping
duplicate notifications.
2024-11-19 16:02:19 +08:00
yyforyongyu
4ff1f19fbf
chainntnfs: make sure notification is sent to the whole set
This commit fixes a bug where the confirmation details may be missed.
When the same tx is subscribed via `RegisterConfirmationsNtfn`, we will
put them into the same set and notify the whole set. However, this logic
is missing when performing the rescan - once the confirmation detail is
found, we only notify the current subscriber. Later we will skip
notifying other subscribers in `UpdateConfDetails` due to the
`confSet.details != nil` check. We now fix it by immediately notify all
the subscribers when the confirmation detail is found during the rescan.
2024-11-19 15:56:08 +08:00
yyforyongyu
1200b75546
chainntnfs: always notify txns before block
This commit changes the order of notifications when a relevant tx is
found in a block and now we will always notify the tx subscribers before
notifying the block, which has implications in the upcoming blockbeat.

When a block notification is subscribed via `RegisterBlockEpochNtfn` and
a confirm or spend is subscribed via `RegisterConfirmationsNtfn` or
`RegisterSpendNtfn`, we would always notify the block first before the
tx, causing the subsystem to think there's no relevant txns found in
this block, while the notifications are sent later. We now fix it by
always sending the txns notifications first, so the subsystem can
receive the txns, process them, then attempt to advance its state based
on the block received.
2024-11-19 15:55:22 +08:00
yyforyongyu
523ecc0653
multi: wait for rpcclients shutdown to complete
We need to call `WaitForShutdown` after stopping the rpc clients of the
chain backends.
2024-11-14 01:22:31 +08:00
yyforyongyu
611405f59c
chainntnfs/btcdnotify: remove redundant config params re-assignment 2024-10-30 02:01:14 +08:00
Elle Mouton
23602e017e
multi: start updating various loggers to use the new v2 type 2024-10-22 17:03:55 +02:00
ziggie
02c1264c53
multi: prevent nil panics in stop methods.
With this PR we might call the stop method even when the start
method of a subsystem did not successfully finish therefore we
need to make sure we guard the stop methods for potential panics
if some variables are not initialized in the contructors of the
subsystems.
2024-07-31 14:43:34 +02:00
yyforyongyu
48a0efe40c
bitcoindnotify: add debug logs in unit test 2024-07-24 18:05:06 +08:00
yyforyongyu
9fee656d70
chainntnfs+lntest: fix TestInterfaces
This commit upgrades the test to always use a segwit v0 witness program
when creating testing txns.
2024-07-24 17:43:27 +08:00
Oliver Gugger
f2759dcb1a
Merge pull request #8759 from largemouth/master
chore: fix some function names
2024-07-10 12:16:49 -06:00
yyforyongyu
6de1b026dd
chainntnfs: add verbose logging in unit test 2024-06-13 17:54:34 +08:00
yyforyongyu
347537791e
sweep: improve loggings based on feedback
This commit changes the logging levels and add a few more loggings based
on the testing results from the testnet/mainnet.
2024-05-21 00:53:24 +08:00
largemouth
a1f36e48d3 chore: fix some function names
Signed-off-by: largemouth <largemouth@aliyun.com>
2024-05-15 11:41:23 +08:00
yyforyongyu
11f7e455d1
lnwallet+sweep: introduce TxPublisher to handle fee bump
This commit adds `TxPublisher` which implements `Bumper` interface. This
is part one of the implementation that focuses on implementing the
`Broadcast` method which guarantees a tx can be published with
RBF-compliant. It does so by leveraging the `testmempoolaccept` API,
keep increasing the fee rate until an RBF-compliant tx is made and
broadcasts it.

This tx will then be monitored by the `TxPublisher` and in the following
commit, the monitoring process will be added.
2024-04-19 21:33:29 +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
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
Oliver Gugger
648fb22f63
multi: wrap all errors 2024-04-11 15:04:03 +02:00
yyforyongyu
bf799719b5
chainntnfs: fix race in TestInterfaces 2024-03-26 12:59:02 +08:00
Oliver Gugger
17b93db5cc
chainntnfs: fix race unit test issue
Because we pass in the same config into multiple notifiers, we sometimes
get a data race in the unit tests. By creating a copy of the config we
avoid that.
2024-03-18 17:08:17 +01:00
Oliver Gugger
d40312c36b
multi: move unit test backend funcs to new package
To avoid circular dependency issues between packages, we move the unit
test backend creation function to a new package in the lntest parent
package.
2024-03-18 16:13:39 +01:00
Oliver Gugger
c170a9830b
multi: use chainntnfs.NewMiner for miners in unit tests
With the chainntnfs.NewMiner now being optimized for not creating
nodes with colliding ports, we use it in all unit tests that spin up
temporary miners.
2024-03-18 16:13:39 +01:00
Oliver Gugger
2884389ce4
chainntnfs: fix issues with NewBitcoindBackend
This commit fixes a number of issues with our temporary bitcoind nodes
that we spin up for unit tests:
 - We didn't remove the node's temporary data dir after tests finished.
 - We used random ports which lead to unwanted port collisions.
 - We used ipc:// unix sockets for ZMQ which currently isn't supported
   in bitcoind v26.0 due to a regression. Since we can reliably create
   new non-colliding ports now, we should use TCP for ZMQ anyway.
2024-03-18 16:13:39 +01:00
Oliver Gugger
2cc28baa84
chainntnfs: re-try miner connection more often
Make sure we wait for the initial connection long enough.
2024-03-18 16:13:39 +01:00
Oliver Gugger
11ba14ab02
chainntnfs: add netParams arg to backend funcs 2024-03-18 16:13:39 +01:00
ffranr
cd566eb097
multi: fix fmt.Errorf error wrapping
Refactor fmt.Errorf usage to correctly wrap errors instead of using
non-wrapping format verbs.
2024-02-27 11:13:40 +00:00
Mohamed Awnallah
99908ed2dc
routing: deep copy any transaciton we obtain from GetBlock call. 2024-01-15 11:35:55 +02:00
yyforyongyu
ee883c332f
chainntnfs: stop lnd when received witness stack is empty
This commit uses `Criticalf` to gracefully stop `lnd` when the received
witness data is empty.
2023-10-31 01:44:43 +08:00
yyforyongyu
28c3c835bf
chainntnfs: return an error when witness stack is empty
This commit adds a check when receiving transactions from
`BitcoindClient` so an error is returned when empty witness is found.
2023-10-31 01:44:43 +08:00
Keagan McClelland
405d4e5f73 chainntnfs: introduce system for chain state tracking and querying
This change adds a new subsystem that is responsible for providing
an up to date view of some global chainstate parameters.
2023-10-19 09:22:07 -07:00
yyforyongyu
66b8700c0b multi: add debug logs to catch slow shutdown 2023-10-06 16:34:47 -07:00
yyforyongyu
1968034075
chainntnfs: fix testHistoricalConfDetailsTxIndex
Fix the following uint test flake,
```
--- FAIL: TestHistoricalConfDetailsTxIndex (0.00s)
    --- FAIL: TestHistoricalConfDetailsTxIndex/rpc_polling_enabled (1.16s)
        bitcoind_test.go:174: should have found the transaction within the mempool, but did not: TxNotFoundIndex
FAIL
```
2023-09-05 07:44:01 +08:00
Oliver Gugger
4332413fba
chainntnfs: remove block info from conf detail copy
Noticed this while updating to latest master in another project:
If there are two notifications for the same output being registered and
the first one does _NOT_ request the block to be included, then the
second one also will not receive the block, even if it explicitly
requests it.
This is caused by the block being removed from the original confirmation
set instead of a copy (as it is done in NotifyHeight and
UpdateConfDetails).
2023-08-02 15:23:14 +02:00
yyforyongyu
e9c10bf0a1
chainntnfs: remove subscriptions when the relevant tx is confirmed
This commit removes the subscribed inputs from mempool notifier when the
relevant transaction is confirmed.
2023-04-19 01:18:19 +08:00
yyforyongyu
e81d62fc70
chainntnfs+chainreg: add interface MempoolWatcher
This commit adds the interface `MempoolWatcher` and uses it in the chain
registry.
2023-04-19 01:18:19 +08:00
yyforyongyu
ad5e798392
chainntnfs+chainreg: add mempool watcher to BtcdNotifier
This commit adds the mempool watcher to btcd notifier to allow the
notifier managing the starting and stopping of the watcher.
2023-04-19 01:18:18 +08:00
yyforyongyu
454e76cbb6
chainntnfs+chainreg: add mempool watcher to BitcoindNotifier
This commit adds the mempool watcher to bitcoind notifier to allow the
notifier managing the starting and stopping of the watcher.
2023-04-19 01:18:18 +08:00