Commit Graph

445 Commits

Author SHA1 Message Date
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
yyforyongyu
8b42151edc
chainntnfs: patch unit tests for mempool notifier 2023-04-19 01:18:18 +08:00
yyforyongyu
3b77e9c51f
chainntnfs: add method UnsubscribeEvent to cancel a subscription
This commit adds the method `UnsubscribeEvent` to cancel a single
subscription.
2023-04-19 01:18:18 +08:00
yyforyongyu
5743dd9601
chainntnfs: allow multiple subscriber to the same input
This commit changes the `subscribedInputs` to store a map of subscribers
so multiple subscribers are allowed to receive events from the same
outpoint.
2023-04-19 01:18:18 +08:00
yyforyongyu
81ee3b9fbe
chainntnfs: introduce mempool notifier
This commit adds a mempool notifier which notifies the subscriber the
spending event found in the mempool for a given input.
2023-04-19 01:18:18 +08:00
Elle Mouton
7bf4eee685
chainntnfs: fix temp dir creation and rpcpolling switch
In the NewBitcoindBackend test util function, ensure that the
`rpcpolling` param is switched on in the correct order. Also switch back
to using `ioutil.TempDir` as it seems that the zmq conn strings created
from `t.TempDir()` result in an invalid conn string.
2023-03-07 08:45:58 +02:00
Elle Mouton
641ae28989
chainntnfs: fix sub test names
Some subtest names were incorrectly labeled by if the txindex was
enabled or not but are meant to be labeled by if rpc polling is enabled
or not.
2023-03-06 13:13:51 +02:00
yyforyongyu
1f67d6a548
bitcoindnotify: fix subtest closure in unit tests 2023-01-19 21:06:23 +08:00
positiveblue
c602ac07e7
chainntnfs: move cache implementation to channeldb
This commit moves the `HeightHintCache` implementation to the
`channeldb` package and inverts the dependency relation between
`chainntnfs` and `channeldb`.

Many packages depend on channeldb for type definitions,
interfaces, etc. `chainntnfs` is an example of that. `chainntnfs`
defines the  `SpendHintCache` and `ConfirmHintCache` interfaces but
it also implments them (`HeightHintCache` struct). The implementation
uses logic that should not leak from channeldb (ex: bucket paths).
This makes our code highly coupled + it would not allow us to use any
of these interfaces in a package that is imported by `channeldb`
(circular dependency).
2023-01-16 03:13:17 -08:00
Oliver Gugger
ad8e25cbc9
multi: don't access loop variables in goroutines
This commit makes sure that no loop variables or other temporary
variables are accessed directly in a goroutine but are instead passed
into the goroutine through a parameter. This makes sure a copy of the
value is put on the stack and is not changed while the outside loop
continues.
2022-11-21 13:54:23 +01:00
habibitcoin
0b1e881d18
scripted-diff: replace ⛰ emoji with $ [skip ci]
-BEGIN VERIFY SCRIPT-
sed -i 's/⛰/$/g' $(git grep -l '⛰')
-END VERIFY SCRIPT-
2022-10-28 12:06:49 -04:00
Eng Zer Jun
cac8f54a45
chainntnfs: replace defer cleanup with t.Cleanup
Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
2022-10-13 17:01:35 +08:00
Eng Zer Jun
712177ee03
chainntnfs: use T.TempDir to create temporary test directory
Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
2022-08-24 08:58:16 +08:00
yyforyongyu
0735522194
multi: fix make fmt 2022-08-23 22:10:24 +08:00
Olaoluwa Osuntokun
08f1c2e93a
chainntfns: add new option for conf notifications to send block
In this commit, we add a new option for the existing confirmation
notification system that optionally allows the caller to specify that a
block should be included as well.

The only quirk w/ the implementation here is the neutrino backend:
usually we get filtered blocks, we so need to first fetch the block
again so we can deliver the full block to the notifier. On the notifier
end, it'll only be checking for the transactions we care about, to
sending a full block doesn't affect the correctness.

We also extend the `testBatchConfirmationNotification` test to assert
that a block is only included if the caller specifies it.
2022-08-01 19:59:21 -07:00
Tommy Volk
9a10c80bcb multi: move many t.Fatalf calls to require.NoError 2022-06-17 04:26:55 +00:00
Elle Mouton
0459ccf542
chainntnfs: test both zmq and rpc bitcoind modes 2022-05-11 09:02:13 +02:00