Commit Graph

416 Commits

Author SHA1 Message Date
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
Elle Mouton
5a08788a05
multi: update btcwallet to v0.15.0
Update go.mod to point to latest btcwallet version.
2022-05-11 08:45:06 +02:00
Olaoluwa Osuntokun
a90dfff9a5
build: update to Go 1.18 2022-04-12 16:14:04 -07:00
Oliver Gugger
3b5585c12b
multi: fix and test v1 output spend ntfns
Because Taproot key spend only spends don't allow us to re-construct the
spent pkScript from the witness alone, we cannot support registering
spend notifications for v1 pkScripts only. We instead require the
outpoint to be specified. This commit makes it possible to only match by
outpoint and also adds an itest for it.
2022-03-24 18:02:40 +01:00
Oliver Gugger
7dfe4018ce
multi: use btcd's btcec/v2 and btcutil modules
This commit was previously split into the following parts to ease
review:
 - 2d746f68: replace imports
 - 4008f0fd: use ecdsa.Signature
 - 849e33d1: remove btcec.S256()
 - b8f6ebbd: use v2 library correctly
 - fa80bca9: bump go modules
2022-03-09 19:02:37 +01:00
Oliver Gugger
895a2e497b
multi: formatting and comment fixes 2022-02-10 11:02:02 +01:00
Oliver Gugger
ffee7d1bcf
multi: fix newly detected linter issues 2022-02-10 11:02:02 +01:00
Oliver Gugger
b77c1fb200
Merge pull request #6149 from bhandras/graph_import_rpc
lnd: add `devrpc` sub server and `devrpc.ImportGraph` to import graph dumps
2022-01-28 10:24:59 +01:00
Andras Banki-Horvath
d059f78b4d
build: add dev tag to the linter config 2022-01-24 17:43:00 +01:00
Dimitris Apostolou
530a2059e5
multi: Fix typos [skip ci] 2022-01-24 12:19:02 +02:00
yyforyongyu
eb5e32f221
chainntnfs: add more verbose logs for txnotifier 2022-01-05 04:27:32 +08:00
Oliver Gugger
0b4e03f5fc
multi: add golang 1.17 compatible build tags
With go 1.17 a change to the build flags was implemented:
https://go.googlesource.com/proposal/+/master/design/draft-gobuild.md

The formatter now automatically adds the forward-compatible build tag
format and the linter checks for them, so we need to include them in our
code.
2021-09-29 17:31:37 -07:00
yyforyongyu
3204e2d74b
multi: add shutdown logs in subservers
This commit adds a simple shutdown to every subserver to assist
debugging.
2021-09-15 19:52:03 +08:00
eugene
2fbee31c6e
chainntnfs: populate spendsByHeight during historical dispatch
This commit fixes a buggy scenario where:
- a spend of the desired outpoint occurs
- RegisterSpend is called, not immediately notifying
- caller performs a historical dispatch, calling UpdateSpendDetails
- caller is notified on the Spend channel
- re-org occurs
- caller is not notified of the re-org
We fix this by correctly populating the spendsByHeight map when
dispatchSpendDetails is called. This mirrors the confirmation case.
2021-09-01 16:45:13 -04:00
Olaoluwa Osuntokun
3b026c401c
chainntnfs/neutrinonotify: fix rebase Conflict compilation issue 2021-08-30 19:16:33 -07:00
Olaoluwa Osuntokun
480a111c54
Merge pull request #5453 from Crypt-iQ/neutrino_conf_0629
chainntnfs: neutrinonotify patches
2021-08-30 16:04:57 -07:00
eugene
de71195bcb
chainntnfs/neutrinonotify: update EndHeight after filter update
After the error is received on the filter update errChan, update the
EndHeight if we're performing a historical scan. If a block was mined
after the call to RegisterConf/RegisterSpend but before the filter was
updated, then the block would not have the filter applied. This means
that a block containing the desired conf/spend parameters would be
undetected. Fix this by ensuring the historical scan also includes this
height, as it would previously not be included.
2021-08-27 14:12:02 -04:00
eugene
0d39c0799a
chainntnfs/neutrinonotify: call drainChainUpdates when updating filter
Moves filter handling logic for connecting blocks to the
connectFilteredBlock method. The disconnect logic now lives in
disconnectFilteredBlock. After updating the filter, drainChainUpdates
is called which will drain everything from the chainUpdates chan and
apply all updates by calling either connectFilteredBlock or
disconnectFilteredBlock. This will allow callers to update their
EndHeight if performing a historical dispatch, as blocks up to this
height may not have had the filter applied.
2021-08-27 14:12:01 -04:00
eugene
b7de0eae93
chainntnfs/neutrinonotify: make chainUpdates a buffered chan
ConcurrentQueue has internal structures so if a filterUpdate exists
in it, the idea of draining the queue may not work reliably. The
update may exist in the ConcurrentQueue but may not be available via
ChanOut() when we're ready to drain the ConcurrentQueue. Fix this by
using a regular buffered chan, which will either have the update or
not have the update. Its size is set to 100 as our tests may generate
quite a bit of updates.
2021-08-27 14:12:01 -04:00
eugene
86f28cdc1d
chainntnfs: skip conf dispatch if ntfn already dispatched
This mirrors the logic for the spend case. This prevents a double
dispatch scenario when combined with a later commit. Otherwise, the
confirmation would linger in the buffer which is not ideal.
2021-08-27 14:11:55 -04:00
Olaoluwa Osuntokun
0d8ffd95dd
chainntnfs/test: add new test assertion to ensure block epoch headers set 2021-08-25 16:47:04 -07:00
Olaoluwa Osuntokun
67aa7a0df7
chainntnfs/bitcoindnotify: always populate block headers for block epochs 2021-08-25 16:47:01 -07:00
Olaoluwa Osuntokun
b2cc4cf088
chainntnfs/btcdnotify: always populate block headers for block epochs 2021-08-25 16:46:59 -07:00
Olaoluwa Osuntokun
99afad1105
chainntnfs/neutrinonotify: always populate block headers for block epochs 2021-08-25 16:46:56 -07:00
Olaoluwa Osuntokun
4eac8577cd
chainntnfs: update impl independent functions to populate new block header 2021-08-25 16:46:53 -07:00
Olaoluwa Osuntokun
4fc6d15075
chainntnfs: add the current block header to the block epoch struct 2021-08-25 16:46:51 -07:00
Oliver Gugger
482f76a0f4
mod+kvdb+channeldb: use btcwallet new DB interface
Depends on btcsuite/btcwallet#757.
Pulls in the updated version of btcwallet and walletdb that have the DB
interface enhanced by their own View() and Update() methods with the
reset callback/closure supported out of the box. That way the global
package-level View() and Update() functions now become pure redirects.
2021-08-04 14:55:55 +02:00
Oliver Gugger
c4917ae7fc
multi: use kvdb.Backend for height hint DB
In order to separate our databases more clearly, we refactor the height
hint cache DB to use a kvdb backend instead of the channel DB instance
directly.
2021-08-04 14:55:51 +02:00
Andras Banki-Horvath
14c851c8fc
kvdb: move channeldb/kvdb to top level 2021-05-07 14:18:56 +02:00
Elle Mouton
f8de10511e chainntnfs: add block cache to NeutrinoNotifier
This commit adds gives BtcdNotifier access to the block cache and wraps
its GetBlock method so that the block cache's mutex map for the specific
hash is used.
2021-04-28 09:59:50 +02:00