Commit graph

3267 commits

Author SHA1 Message Date
Olaoluwa Osuntokun
988181ef23
Merge pull request #1472 from wpaulino/go1.13
build: use go 1.13.x in travis
2019-10-09 18:10:42 -07:00
Olaoluwa Osuntokun
b686b0a8eb
Merge pull request #1429 from cfromknecht/btcec-double-is-on-curve
btcec: optimize square root using fieldVal
2019-10-09 17:54:42 -07:00
Conner Fromknecht
2340ad388c
btcec/btcec: deprecate QPlus1Div4() in favor of Q()
The previous naming suggested that the value ((P+1)/4+1)/4 was being
returned, when in fact the returned value is simply (P+1)/4. The old
method is superseded by Q().
2019-10-02 18:22:17 -07:00
Conner Fromknecht
c7d523f83c
btcec/pubkey: optimize decompressPoint using fieldVals
This commit optimizes the decompressPoint subroutine, used in extracting
compressed pubkeys and performing pubkey recovery. We do so by replacing
the use of big.Int.Exp with with square-and-multiply exponentiation of
btcec's more optimized fieldVals, reducing the overall latency and
memory requirements of decompressPoint.

Instead of operating on bits of Q = (P+1)/4, the exponentiation applies
the square-and-multiply operations on full bytes of Q.  Compared to the
original speedup. Compared the bit-wise version, the improvement is
roughly 10%.

A new pair fieldVal methods called Sqrt and SqrtVal are added, which
applies the square-and-multiply exponentiation using precomputed
byte-slice of the value Q.

Comparison against big.Int sqrt and SAM sqrt over bytes of Q:

benchmark                            old ns/op     new ns/op     delta
BenchmarkParseCompressedPubKey-8     35545         23119         -34.96%

benchmark                            old allocs     new allocs     delta
BenchmarkParseCompressedPubKey-8     35             6            -82.86%

benchmark                            old bytes     new bytes     delta
BenchmarkParseCompressedPubKey-8     2777          256           -90.78%
2019-10-02 18:21:59 -07:00
Conner Fromknecht
39500ed5ed
btcec/pubkey: remove redundant checks from compressed pubkey parsing
As of https://github.com/btcsuite/btcd/pull/1193, decompressPoint now
validates that the point is on the curve. The x and y cooordinates are
also implicitly <= P, since the modular reduction is applied to both
before the method returns. The checks are moved so that they are still
applied when parsing an uncompressed pubkey, as the checks are not
redundant in that path.
2019-10-02 15:31:23 -07:00
Conner Fromknecht
4aeb189fc4
btcec: benchmark ParsePubKey for compressed keys 2019-10-02 15:31:23 -07:00
Olaoluwa Osuntokun
e159f05c6e
build: use go 1.13.x in travis 2019-09-25 18:43:43 -07:00
Sad Pencil
ba530c4abb btcec: correct the comment of recoverKeyFromSignature 2019-09-25 17:28:57 -07:00
Iskander (Alex) Sharipov
009f199317 btcd: remove commented-out code
Found using https://go-critic.github.io/overview#commentedOutCode-ref
2019-09-25 17:23:57 -07:00
preminem
e3d3088b80 btcjson+rpc: expose a transaction's weight via RPC 2019-09-25 17:19:03 -07:00
Olaoluwa Osuntokun
5066c212c4
Merge pull request #1162 from jraedisch/patch-1
Update README.md
2019-09-25 17:11:49 -07:00
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