Commit graph

3206 commits

Author SHA1 Message Date
Olaoluwa Osuntokun
130ea5bddd
Merge pull request #1462 from wpaulino/verack-version-handshake
peer: include verack as part of version handshake
2019-08-23 17:37:49 -07:00
Wilmer Paulino
5de9e5b6c2
peer: include verack as part of version handshake
It was possible for connections to bitcoind nodes to be closed from
their side if the OnVersion callback queued a message to send. This is
because bitcoind expects a verack message before attempting to process
any other messages. To address this, we ensure the verack is sent as
part of the handshake process, such that any queued messages happen
after the fact.
2019-08-20 16:25:21 -07:00
Wilmer Paulino
2cd83210b5
wire: only write message payload if there actually is one
There are certain messages that won't have a payload, e.g., verack,
causing an unnecessary write of 0 bytes.
2019-08-20 15:26:23 -07:00
Olaoluwa Osuntokun
4063feeff7
Merge pull request #1449 from Roasbeef/rescan-bug-fix
rpc: fix rescan bug if client disconnects
2019-08-06 17:54:14 -07:00
Olaoluwa Osuntokun
677503515e
rpc: fix rescan bug if client disconnects
In this commit, we fix a bug in the rescan logic after a recent
refactoring that would cause the scanning node to potentially panic. If
the client disconnected, before the rescan was finished, then we would
return a nil `lastBlock` and `lastBlockHash`. We would then attempt to
send the rescan finished notification, causing a panic.

We remedy this by simply detecting this case (client disconnect), and
existing once again as the prior code would, pre-refactoring.
2019-07-07 18:03:04 -07:00
Olaoluwa Osuntokun
c26ffa870f
Merge pull request #1444 from Roasbeef/rescan-zero-addr-optimization
rpc: skip rescan if client has no addresses or UTXOs
2019-06-28 17:36:39 -07:00
Olaoluwa Osuntokun
18c37d2eb7
rpc: skip rescan if client has no addresses or UTXOs
In this commit, we implement an optimization that will speed up clients
that attempt to perform a rescan in the past with no addresses. If the
client doesn't have any thing to search for, then we simply exit early
and send them a rescan finished notification with the final block in our
chain.
2019-06-28 16:46:52 -07:00
Olaoluwa Osuntokun
594e2ab48a rpc: extract primary rescan logic into scanBlockChunks helper func 2019-06-28 15:43:47 -07:00
Olaoluwa Osuntokun
962a206e94
Merge pull request #1427 from wpaulino/mempool-rbf
mempool: implement RBF signaling policy
2019-06-14 03:37:41 +02:00
Wilmer Paulino
95d0a371d9
mempool: implement RBF signaling policy 2019-06-13 16:35:53 -07:00
Olaoluwa Osuntokun
a0d1e3e36d
Merge pull request #1431 from wpaulino/var-length-p2pkh
txscript: handle variable length P2PKH signatures in ComputePkScript
2019-06-05 11:43:02 +02:00
Wilmer Paulino
5328af0b63
txscript: refactor ComputePkScript 2019-06-03 13:55:28 -07:00
Wilmer Paulino
545bc5d474
txscript: handle variable length P2PKH signatures in ComputePkScript
Since P2PKH signatures have variable lengths, we would attempt to parse
P2PKH scripts as P2SH if they didn't fit the previous length
constraints.
2019-06-03 13:55:24 -07:00
Olaoluwa Osuntokun
16327141da
Merge pull request #1428 from wpaulino/sendrawtransaction-rpc-error
btcjson+rpc: match bitcoind's RPC error codes for rejected transactions
2019-05-22 17:01:18 -07:00
Wilmer Paulino
d055892599
btcjson+rpc: match bitcoind's RPC error codes for rejected transactions 2019-05-22 13:08:12 -07:00
Olaoluwa Osuntokun
96897255fd
Merge pull request #1417 from cfromknecht/detect-sync-stall
netsync/manager: detect stalled sync peer
2019-04-26 17:42:31 -07:00
Conner Fromknecht
e7f9935099
netsync/manager: add syncPeer stall detector
Adds stall detection when no blocks have been received from the sync
peer for at least 3 minutes.

The change backports parts of https://github.com/gcash/bchd/pull/105,
though has different behavior, such as:
 - Rotating the sync peer at tip.
 - Only disconnecting the sync peer if they're height exceeds our own.
   Since we will instead rotate the sync peer at tip, this prevents us
   from disconnecting good peers while waiting for new blocks.
 - Not resetting the progress time when blocks are submitted via rpc.
2019-04-26 17:20:57 -07:00
Conner Fromknecht
a015d8231e
netsync/manager: split out handlePeerDone helpers
Preemptively splits out portions of the handlePeerDone method so that
they can be used in the stall detection logic added in the next commit.
2019-04-26 17:20:57 -07:00
Olaoluwa Osuntokun
63f50db2f7
Merge pull request #1424 from cfromknecht/btcutil-update-bug-optimization
build: update to latest version of btcutil
2019-04-25 18:14:20 -07:00
Olaoluwa Osuntokun
b8cdcc3ffc
build: update to latest version of btcutil
In this commit, we update to the latest version of btcutil which
contains a bug fix for filter matching, and as optimizations speed up
both filter matching and constructions.
2019-04-25 17:38:31 -07:00
Olaoluwa Osuntokun
150379531e
Merge pull request #1418 from cfromknecht/useragent-white-blacklist
Configurable UserAgent filtering
2019-04-24 16:49:38 -07:00
Olaoluwa Osuntokun
8bb9c0b392
Merge pull request #1416 from cfromknecht/prioritize-higher-sync-peer
netsync/manager: prioritize higher height peers for sync peer
2019-04-24 16:21:41 -07:00
Olaoluwa Osuntokun
6867ff3278
Merge pull request #1420 from cfromknecht/moar-ckpts
chaincfg: update checkpoints
2019-04-18 16:24:30 -07:00
Olaoluwa Osuntokun
3fbc9997ce
chaincfg: update testnet checkpoints 2019-04-17 15:33:09 -07:00
Olaoluwa Osuntokun
778c28fcd8
chaincfg: update mainnet checkpoints 2019-04-17 15:33:09 -07:00
Conner Fromknecht
39592eba78
btcd: pass user agent black and white lists to server 2019-04-16 21:31:08 -07:00
Conner Fromknecht
a9f23321d9
netsync/manager: prioritize higher height peers for sync peer
This commit modifies the sync peer selection to prefer peers with a
higher advertised height than our currently known best height. If no
peers are known with a higher height, we will fall back to selecting a
random peer with the same best height as our own.

The current algorithm currently selects a random peer from the union of
these two sets, while this approach will favor trying to make progress.
This will likely help in selecting a good peer once already at tip, such
as after a restart.

Backport of https://github.com/gcash/bchd/pull/96
2019-04-16 21:09:18 -07:00
Conner Fromknecht
0e073b8058
config: adds AgentWhitelist and AgentBlacklist to config 2019-04-15 17:46:08 -07:00
Conner Fromknecht
d3ecdc91a9
server: adds hybrid black/whitelist filtering to user agents 2019-04-15 17:46:08 -07:00
Roei Erez
9bfb2ca034 connmgr: check for canceled connection before connect
This will ensure cancelation is reliable for all cases.
2019-04-09 19:54:18 -07:00
Mawueli Kofi Adzoe
aa6e0f3570 docs: use go modules instead of glide
Fixes https://github.com/btcsuite/btcd/issues/1379
2019-03-15 13:16:42 -07:00
Olaoluwa Osuntokun
306aecffea
Merge pull request #1391 from Roasbeef/btcutil-filter-fix
build: update to latest version of btcutil
2019-02-12 18:52:34 -08:00
Olaoluwa Osuntokun
2bdd957fe1
build: update to latest version of btcutil
In this commit, we update to the latest version of `btcutil`. This version
contains a bug fix for the neutrino filter generation. The implementation
within `btcutil` didn't fully comply with the BIP specification as it
included some OP_RETURN outputs, rather than excluding them all. As a
result, any active `btcd` node on mainnet/testnet will need to _drop their
entire `cfindex`_ and re-index after this is merged in.
2019-02-12 18:36:55 -08:00
Olaoluwa Osuntokun
12ce2fc7d3
Merge pull request #1383 from wpaulino/addrmgr-service-bits
addrmgr: store address' supported service bits
2019-02-08 16:00:34 -08:00
Wilmer Paulino
bcd50ea838
addrmgr: store address' supported service bits
In this commit, we update the serialized version of the AddressManager
to also store each address' service bits. This allows an address'
service bits to be properly set when read from disk, which allows
external callers to reliably filter out addresses which do not support
their required services.

Since the service bits were not previously stored, the serialization
version needed to be bumped. A test has been added to test the behavior
of upgrading from version 1 to 2.
2019-02-06 13:33:18 -08:00
Wilmer Paulino
10f17a8bb0
addrmgr: add AddrManager serialization test 2019-02-06 13:33:11 -08:00
Wilmer Paulino
18a6867124
addrmgr/knownaddress: expose an address' service bits 2019-02-06 13:33:11 -08:00
Olaoluwa Osuntokun
ed77733ec0
Merge pull request #1359 from wpaulino/rescan-script-spends
txscript+rpcwebsocket: detect script spend within rescans
2019-01-14 17:39:29 -08:00
Wilmer Paulino
f6eae62a77
rpcwebsocket: detect and notify spend of script
In this commit, we modify the rescanBlock method to also determine
whether a script (encoded as an address in its rescanKeys) has been
spent. Upon detecting a spend, a btcjson.RedeemingTxNtfn is sent to the
client who requested it.
2019-01-11 18:30:42 -08:00
Wilmer Paulino
be2b6dc98a
rpcwebsocket: modify rescanKeys to take addresses as strings
In this commit, we modify the rescanKeys struct, which contains the
relevant keys that should be matched when rescanning the chain, to take
addresses in their string representation. This ends up simplifying a lot
of the logic as we no longer have to special-case specific script types.
2019-01-11 18:30:42 -08:00
Wilmer Paulino
0cec774a75
txscript: add support to re-derive output's PkScript from input
In this commit, we extend the txscript package to support re-deriving
the PkScript of an output by looking at the input's signature
script/witness attempting to spend it. As of this commit, the only
supported types are P2SH, v0 P2WSH, and v0 P2WPKH.

This will serve useful to detect when a particular script has been spent
on-chain.

A set of test vectors has also been added for the supported script types
to ensure its correctness.
2019-01-11 18:30:42 -08:00
Shuai Qi
5bda5314ca netsync+blockchain: fix typos 2019-01-08 20:07:09 -08:00
Olaoluwa Osuntokun
cfcc5e0305
Merge pull request #1355 from cfromknecht/tidy-go-mod
build: tidy go modules
2019-01-08 20:02:48 -08:00
Conner Fromknecht
2ecf0619f2
build: tidy go modules 2018-11-30 13:52:58 -08:00
Olaoluwa Osuntokun
7d2daa5bfe
Merge pull request #1354 from cfromknecht/go-modules
build: Migrate to go modules
2018-11-29 17:59:35 -08:00
Conner Fromknecht
20388be196
README: require go1.11, document module installation 2018-11-29 17:53:41 -08:00
Conner Fromknecht
2f3be2e337
travis: remove glide, only build 1.11.x, use modules 2018-11-29 17:51:22 -08:00
Conner Fromknecht
2a9e4372c8
goclean: update for go modules 2018-11-29 17:45:40 -08:00
Conner Fromknecht
97c3fea94c
build: remove glide.lock and glide.yaml 2018-11-29 17:38:24 -08:00
Conner Fromknecht
852b39bd6d
build: add go.mod and go.sum for 1.11 modules 2018-11-29 17:34:23 -08:00