Commit graph

3391 commits

Author SHA1 Message Date
Olaoluwa Osuntokun
4eac390191
Merge pull request #1484 from wpaulino/bitcoind-0.19-compat
btcjson+rpcclient: add compatibility for bitcoind v0.19.0
2019-11-08 18:19:43 -08:00
nsa
c2ca0a408e
server: add addressesMtx to fix race condition 2019-11-08 21:11:24 -05:00
Wilmer Paulino
e2e5cc694d
btcjson+rpcclient: support new bitcoind sendrawtransaction request 2019-11-08 17:53:46 -08:00
Wilmer Paulino
93a84aa014
btcjson: use correct json tag for Bip9SoftForkDescription.StartTime 2019-11-08 17:53:45 -08:00
Wilmer Paulino
266851e329
btcjson+rpcclient: support new unified softfork bitcoind format 2019-11-05 16:28:33 -08:00
Wilmer Paulino
e89d4fca24
rpcclient: allow retrieval of backend version 2019-11-04 17:44:29 -08:00
Wilmer Paulino
bc21593480
server: remove peer from SyncManager on VerAckReceived
Peers are now added to the SyncManager if we receive their verack, but
we'd still attempt to remove them from the SyncManager if we didn't
receive it.
2019-10-29 19:38:38 -07:00
Wilmer Paulino
a46f7b45ab
rpcclient: add GetNetworkInfo method 2019-10-29 18:49:37 -07:00
Olaoluwa Osuntokun
a41498d578
release: remove windows-arm 2019-10-15 10:11:03 +02:00
Olaoluwa Osuntokun
2fb0deccfd
Merge pull request #1478 from Roasbeef/release-0.20.0
btcd: prep for upcoming btcd release
2019-10-14 17:36:16 +02:00
Olaoluwa Osuntokun
860ca32a22
Merge pull request #1480 from wpaulino/add-peer-on-verack
server: refactor OnVersion to instead add peers within OnVerAck
2019-10-14 17:11:47 +02:00
Wilmer Paulino
baeb789a7d
server: prevent adding peers if already disconnected
This addresses an issue where the server ends up tracking a peer that
has been disconnected due to it processing a peer's `done` message
before its `add` message.
2019-10-14 13:26:44 +02:00
Wilmer Paulino
769c4e152f
server: request addresses from new peers once they can process messages
This was previously done within the OnVersion listener, which should not
be a blocking operation. It turns out that requesting these messages
there can lead to blocking due to peers not being able to process
messages since their message queues have yet to start. Therefore, we'll
now request within handleAddPeerMsg, which should allow it to go
through.
2019-10-14 13:26:43 +02:00
Wilmer Paulino
a1a5bfa819
server: add new peers within OnVerAck instead of within OnVersion
This change is needed as part of requiring peers to also send a verack
message following their version message during protocol negotiation.
Peers were previously added to the SyncManager before their message
queues were started, causing the server to stall if a peer didn't
provide a timely verack response following their version. We now do this
within OnVerAck, which happens shortly before peer message queues are
started.
2019-10-14 13:26:42 +02:00
Wilmer Paulino
11b84f5cb5
server: signal SyncManager with new peer within AddPeer
This makes the logic a bit more unified as previously it was possible we
for us to report the new peer to the SyncManager, but for whatever
reason failed to track the peer in the server internally within AddPeer.
This change ensures this can no longer happen.
2019-10-14 13:26:16 +02:00
Olaoluwa Osuntokun
07282a6656
Merge pull request #1477 from wpaulino/conn-fixes
server: miscellaneous connection management fixes
2019-10-11 16:14:09 -07:00
Olaoluwa Osuntokun
c3151ef50d
Merge pull request #1479 from cfromknecht/normalize-decompress
btcec/pubkey: normalize sqrt(x^3) before checking parity
2019-10-10 21:21:31 -07:00
Conner Fromknecht
069ec701df
btcec/pubkey: normalize sqrt(x^3) before checking parity
This commit fixes an issue introduced in the recent #1429, where
the output of SqrtVal is not normalized before using IsOdd() to compare
with the expected parity of the y-coordinate. The IsOdd() is only
guaranteed to work if the value has been denormalized, so a denormalized
sqrt >= p would report the opposite parity. We fix this by normalizing
both after compute sqrt(x^3) and when negating the root as directed by
the ybit.
2019-10-10 18:07:37 -07:00
Olaoluwa Osuntokun
2083acdd24
release: add new release script and documentation
In this commit, we add the new release script that will be used to build
all release binaries going forward. We also remove the existing
Conformal key as it's no longer in use, updating the README to reflect
the new release build/verification process.
2019-10-10 16:18:02 -07:00
Wilmer Paulino
0d00cdf82c
server: request new peer after disconnection of non-persistent peers
Doing so ensures we reach our target number of outbound peers as soon as
possible. This is only necessary after calls to connmgr.Remove, as these
won't request a new peer connection.
2019-10-10 19:05:41 -04:00
Wilmer Paulino
45d66d46f9
server: standardize use of connmanager's Disconnect and Remove methods
The Disconnect method would still attempt to reconnect to the same
peer, which could cause us to reconnect to bad/unstable peers if we came
across them. Instead, we'll now use Remove whenever we intend to remove
a peer that is not persistent.
2019-10-10 19:05:37 -04:00
Olaoluwa Osuntokun
e47518c978
btcd: bump version to v0.20.0-beta 2019-10-10 15:54:11 -07:00
Wilmer Paulino
ab6f3089f6
server: mark address as connected within handleAddPeerMsg
We do this to ensure the address manager contains live addresses.
Previously, addresses with which we established connections with would
not be marked as connected because it would be done once we disconnect
peers. Given that we don't process all of the disconnect logic when
we're shutting down, addresses of stable and good peers would never be
marked as connected unless the connection was lost during operation.
2019-10-10 12:10:52 -04:00
Wilmer Paulino
06baabe5da
server: mark address attempted on attempt rather than upon connection
We should mark addresses as attempted when we attempt to connect to
them, not once we establish a connection with said address.
2019-10-10 12:03:47 -04:00
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