Commit graph

133 commits

Author SHA1 Message Date
Olaoluwa Osuntokun 0b7de5efbb
Merge pull request #735 from guggero/signet
Update btcd dependency, add Signet params
2021-04-27 17:04:10 -07:00
Oliver Gugger 1f1ffb56b5
multi: add signet params
With this commit we add the signet test network parameters to all switch
cases where we distinguish between the different networks.
2021-04-27 09:59:14 +02:00
Wilmer Paulino 526d132f09
chain: implement GetNodeAddresses fallback for PrunedBlockDispatcher
It's possible for bitcoind instances to only have connections to pruned
nodes after its initial block download, which are incompatible with the
PrunedBlockDispatcher. This would result in GetBlock requests for pruned
blocks to never resolve. Since bitcoind also exposes a GetNodeAddresses
RPC, which returns random reachable addresses from its address manager,
we can leverage it to obtain a new candidate set of peers that we
otherwise wouldn't obtain through GetPeers.
2021-04-23 13:28:56 -07:00
Wilmer Paulino f7241cd95f
chain: prevent logging of ping/pong msgs in PrunedBlockDispatcher
These messages are also part of normal operation, so we should log
stating they are unexpected.
2021-04-23 13:28:55 -07:00
Wilmer Paulino 61d3b2da6d
chain: use correct pruned node service bit 2021-04-23 13:28:55 -07:00
Olaoluwa Osuntokun 2ff451f6bc
chain: fix alignment of atomic integers in bitcoind conn struct
As reported by https://github.com/lightningnetwork/lnd/issues/5196, the
new atomic integer isn't properly aligned which can caus panics on
32-bit operating systems.. Tof fix this issue, we move the 64-bit
integer to lay after the two 32-bit integers at the top of the struct.
2021-04-11 16:32:45 -07:00
Wilmer Paulino 20c02df1e3
chain: request pruned blocks from backend peers
At the moment, this is only done for the BitcoindClient, as the other
backends don't support block pruning.
2021-04-02 17:28:07 -07:00
Wilmer Paulino 3fed46822c
chain: refactor BitcoindConn init params into config struct 2021-04-02 17:28:06 -07:00
Wilmer Paulino 178d124b76
chain: add PrunedBlockDispatcher implementation
To minimally support wallets connected to pruned nodes, we add a new
subsystem that can be integrated with chain clients to request blocks
that the server has already pruned. This is done by connecting to the
server's full node peers and querying them directly. Ideally, this is a
capability supported by the server, though this is not yet possible with
bitcoind.
2021-04-02 17:28:05 -07:00
Oliver Gugger 3a5d9f84b0
multi: fix linter issues 2021-03-24 14:44:32 +01:00
Wilmer Paulino 90a0744ae4
chain: batch filter fetches for neutrino chain client
This greatly speeds up wallet recovery with a neutrino backend, as we'll
avoid unnecessary round trips for each block filter fetch.
2020-03-31 13:37:56 -07:00
Wilmer Paulino d7d2f14d61
build+chain: reuse buffers when reading ZMQ messages from bitcoind
`bitcoind` notifies transactions once they're accepted into the mempool
and once they're confirmed in a block. Previously, reading a message
from ZMQ would allocate a buffer with the size of the message. This can
cause nodes to perform a large number of allocations within a small
amount periodically (3000 300B allocations every 10 mins on average),
which can cause a lot of GC pressure on lower resourced nodes. To remedy
this, we introduce two static buffers, one for blocks and another for
transactions, that will be reused for every message read. Each is
constrained by its maximum expected size.
2019-11-12 18:18:59 -08:00
Wilmer Paulino 58ac163d48
chain: trace log timed out ZMQ connections 2019-11-08 12:39:00 -08:00
Wilmer Paulino 36ca842905
chain: extract ZMQ command strings into constants 2019-11-08 12:38:28 -08:00
Wilmer Paulino 333ecbf262 chain: notify block when not filtered for BitcoindClient 2019-09-09 17:10:38 +03:00
Olaoluwa Osuntokun cfb9bb1e32
build: pin against latest neutrino version 2019-09-05 18:31:03 -07:00
Wilmer Paulino 5124978a9b
chain: prevent filtering blocks when BitcoindClient has an empty filter 2019-08-09 18:16:40 -07:00
Wilmer Paulino 6c4dab5f7c
chain: remove extraneous rpcclient.Disconnect calls from BitcoindConn
These are not needed since they have no effect when the RPC client is
making HTTP POST requests.
2019-07-10 16:15:51 -07:00
Wilmer Paulino f02166e5de
chain: explicitly close connections in BitcoindConn's Stop method
Since it's now possible for gozmq.Conn to block when calling Receive,
BitcoindConn hangs upon being stopped because its goroutines are waiting
for a message to be delivered. To address this, we modify it to close
its ZMQ connections driving the goroutines once it's been stopped. This
allows the goroutines to unblock by detecting the EOF error and exiting.
2019-07-10 16:15:50 -07:00
Wilmer Paulino 4a913d02ea
chain: only allow bitcoind block notifications at tip after NotifyBlocks
One could argue that the behavior before this commit was incorrect, as
the ChainClient interface expects a call to NotifyBlocks before
notifying blocks at tip, so we decide to fix this.

Since we now wait for the chain backend to be considered "current"
before proceeding to sync the wallet with it, any blocks that were
processed while waiting would result in being notified and scanned
twice, once by processing it at tip, and another while rescanning the
wallet, which is not desirable.
2019-06-13 18:09:06 -07:00
Wilmer Paulino 39f81c630b
chain: add IsCurrent method to chain.Interface
IsCurrent allows us to determine if the chain backend considers itself
"current" with the chain.
2019-06-13 18:08:59 -07:00
Wilmer Paulino eedd5ce1b6
chain: prevent deadlock while notifying RescanFinished for NeutrinoClient 2019-06-07 13:00:09 -07:00
Wilmer Paulino 0efe836773
chain: avoid using defer for BitcoindClient onRescanFinished notification
Since defer will copy the function with the parameters evaluated at its
invocation, the RescanFinished notification would be dispatched with the
incorrect block. To fix this, we'll just send the notification at the
end ourselves manually.
2019-05-11 13:06:25 -07:00
Wilmer Paulino 28161bee42
chain: improve error logging within BitcoindClient.reorg 2019-05-11 13:05:27 -07:00
Wilmer Paulino ecfebcea03
chain: remove unnecessary returned error from BitcoindClient.filterBlock 2019-05-11 13:05:23 -07:00
Wilmer Paulino 8d6dd92706
chain: fix Fatalf format verb error 2019-05-11 13:05:17 -07:00
Wilmer Paulino e0f82255c7
chain: prevent panic if onBlockConnected is called before onFilteredBlockConnected 2019-04-19 12:27:33 -07:00
Wilmer Paulino b3643ed7a9
chain: dispatch RescanFinished notification after BlockConnected
In this commit, we address a bug within the wallet when running with
Neutrino where it wouldn't be able to mark it as synced with the chain
due to not receiving a RescanFinished notification if it was a block
behind the chain. This happened because of the order in which the
notifications are delivered within the underlying Neutrino ChainService,
FilteredBlockConnected gets dispatched before BlockConnected. This
doesn't always work however because there is an implicit dependency
between them in which BlockConnected must occur first.

To address it, rather than switching the order in which the
notifications are dispatched, we just check if we can dispatch the final
RescanFinished notification after dispatching BlockConnected.

Co-Authored-By: Roei Erez <roeierez@gmail.com>
2019-04-18 19:32:37 -07:00
Wilmer Paulino 767a7a95cf
chain: extract RescanFinished notification dispatch into method
Co-Authored-By: Roei Erez <roeierez@gmail.com>
2019-04-18 19:30:40 -07:00
Wilmer Paulino 8f25b8b4ef
chain: keep track of lastFilteredBlockHeader within NeutrinoClient
Co-Authored-By: Roei Erez <roeierez@gmail.com>
2019-04-18 19:23:05 -07:00
Olaoluwa Osuntokun d9a9f4176b
build+chain: update to latest version of neutrino
The latest version also includes a change to the way we need to
initialize the rescan object.
2019-03-12 21:05:42 -07:00
Wilmer Paulino ec210ad79c
chain/bitcoind_client: extend filterTx with script spend support
In this commit, we extend the BitcoindClient to properly detect the
spend of an arbitrary script on-chain. This is possible by looking at a
transaction's input and re-deriving the PkScript, from its signature
script/witness, of the output it's attempting to spend. Upon detecting
the spend, a chain.RelevantTx will be dispatched.
2019-01-14 18:38:45 -08:00
Johan T. Halseth 060361939b
chain/neutrino: use new neutrino API 2018-10-16 18:18:46 -07:00
Wilmer Paulino 1ddb9f2c11
chain: allow setting the client's birthday after creation 2018-09-12 14:24:30 -07:00
Olaoluwa Osuntokun 0059b9fcd9
Merge pull request #537 from cfromknecht/dont-print-rawtx-garbage
chain/bitcoind_conn: only print ASCII rawtx event types
2018-09-03 17:55:49 -07:00
Conner Fromknecht 042d409236
chain/bitcoind_conn: only print ASCII rawtx event types 2018-08-31 16:31:29 -07:00
Wilmer Paulino d179c276b4
chain/rpc: remove unnecessary ping keep alive
In this commit, we remove the keep-alive logic within the handler of the
RPCClient struct as this logic already exists within the backing
rpclient.Client instance. In this case, we'd completely stop the
connection after the ping timeout (1 min), which would render the
reconnection logic within rpcclient.Client useless.
2018-08-27 17:25:16 -07:00
Olaoluwa Osuntokun caab9f91f0
chain: update neutrino client due to recent API changes 2018-08-22 20:20:31 -07:00
Wilmer Paulino 850ad0959a
chain: ensure eventType from ZMQ response is human-readable
In this commit, we fix a small issue where it's possible that we read a
malformed message from the ZMQ connection to bitcoind due to it shutting
down. To fix this, we ensure that the event type is human readable
before attempting to log it.
2018-08-15 18:17:29 -07:00
Wilmer Paulino d6155a55e9
chain: improve error when filtering blocks and transactions 2018-08-15 17:37:04 -07:00
Wilmer Paulino 5f7060dadf
chain: handle ZMQ timeout error correctly 2018-08-15 17:37:03 -07:00
Wilmer Paulino 8357e86a4d chain: match transaction against currently watched transactions
In this commit, we extend the client's filtering process to also look at
the set of currently watched transactions. The logic to watch for
transaction hashes was previously there, but it was not used to filter
against incoming transactions.
2018-07-30 17:54:08 -07:00
Wilmer Paulino 00428d5828 chain: share the same bitcoind connection between multiple rescan clients 2018-07-30 17:54:08 -07:00
Wilmer Paulino 27e22b1f79 chain: return err when updating the rescan filter while shutting down 2018-07-30 14:55:56 -07:00
Wilmer Paulino 0b269d799e
chain: send empty struct instance rather than bool to reset filters 2018-07-26 16:38:58 -07:00
Wilmer Paulino 7df2b72beb
chain: switch BitcoindClient to use atomic started/stopped pattern 2018-07-26 16:38:57 -07:00
Wilmer Paulino 1aeead0eeb
chain: keep track of the best block within BitcoindClient
In the previous commit, we modified our BitcoindClient struct to use a
ConcurrentQueue struct to handle its notifications to the caller. Before
this, the BitcoindClient had a goroutine that would handle these
notifications in the background and detect when a OnBlockConnected
notification was received in order to update the best block. Due to this
logic being removed, we now keep track of the best block througout the
struct as a whole.
2018-07-26 16:38:56 -07:00
Wilmer Paulino 2091ac0936
chain: use ConcurrentQueue within BitcoindClient to handle event notifications 2018-07-26 16:38:55 -07:00
Wilmer Paulino fc73cc9678
chain: add concurrent unbounded queue implementation 2018-07-26 16:38:54 -07:00
Wilmer Paulino 8e9e4d6926
chain: rename bitcoind.go to bitcoind_client.go 2018-07-26 16:38:38 -07:00