Commit graph

3083 commits

Author SHA1 Message Date
Dave Collins
9151ebc90b
server: Reject outbound conns to non-full nodes.
This modifies the server connection code to reject outbound peers that
do not offer full node services.
2018-09-20 22:30:46 -05:00
Dave Collins
7b103e2434
peer: Allow OnVersion callback to reject peer.
This modifies the OnVersion callback to allow a reject message to be
returned in which case the message will be sent to the peer and the peer
will be disconnected.

Backported from Decred.
2018-09-20 22:29:27 -05:00
Dave Collins
118f55233b
peer: Rework version negotiation.
This modifies the negotiation logic to ensure the callback has the
opportunity to see the message before the peer is disconnected and
improves the error handling when reading the remote version message.

It also has the side effect of ensuring the protocol version is
negotiated before sending reject messages with the exception of the
first message not being a version message since negotiation is not
possible in that case.

This is being changed because it is useful for the server to see the
message regardless in order to have the opportunity to things such as
update the address manager and reject peers that don't have desired
services.

Backported from Decred.
2018-09-20 22:26:36 -05:00
Dave Collins
25dfda9bd3
peer: Add duplicate version message test.
This adds a test to ensure duplicate version messages are rejected.

Backported from Decred.
2018-09-20 22:18:36 -05:00
Olaoluwa Osuntokun
92494a5188
Merge pull request #1282 from qshuai/master
server: Fix struct name mismatch
2018-09-20 20:16:19 -07:00
Olaoluwa Osuntokun
934137b22a
Merge pull request #1217 from halseth/node-command-btcsuite
rpcclient: expose the Node command for RPC API.
2018-09-20 20:14:26 -07:00
Olaoluwa Osuntokun
7e475a7259
Merge pull request #1267 from davecgh/txscript_backport_sigencoding_updates
txscript: Cleanup strict signature enforcement.
2018-09-20 20:12:35 -07:00
qshuai
badf5453e9 server: Fix struct name mismatch 2018-09-08 22:34:41 +08:00
Johan T. Halseth
085a2b96e9
rpcclient: expose the Node command for RPC API. 2018-09-04 09:40:08 +02:00
Olaoluwa Osuntokun
cff30e1d23
Merge pull request #1277 from halseth/cf-checkpoint-rlock
server: allow for read concurrency when serving cf checkpoints, fix bug in checkpoint serving
2018-09-03 16:29:27 -07:00
Olaoluwa Osuntokun
222a6dac0d
server: fix panic bug when looking for cf checkpoint cache intersection w/ chain
In this commit, we fix a panic bug that can arise when we attempt to
process a cf checkpoint message from a remote peer. Before this commit,
if the size of the checkpoint cache was large than the number of
checkpoints requested by the peer, we would panic with an out of bounds
error. In order to prevent, this we'll now use the size of the requested
set of hashes as our bound to ensure that we don't panic.
2018-08-27 17:49:45 -07:00
Olaoluwa Osuntokun
c8e6363e22
server: modify locking in OnGetCFCheckpt to allow for read concurrency
In this commit, we modify the locking scheme when serving cf checkpoints
for peers to allow the server to serve multiple peers at the same time.
Before this commit, we would first grab the write lock, check to see for
expansion, then release the read lock. In this commit we reverse this
and instead will grab the read lock, and upgrade to the write lock if we
need to actually expand the size of the cache.
2018-08-27 17:46:41 -07:00
Olaoluwa Osuntokun
79e00513b1
Merge pull request #1268 from cfromknecht/enforce-default-trickle-interval
peer: Enforce default trickle interval
2018-08-23 23:44:22 -07:00
Conner Fromknecht
ae733e7291
server: switch TrickleTimeout -> TrickleInterval 2018-08-23 22:55:21 -07:00
Conner Fromknecht
eb8e117f86
config: use peer.DefaultTrickleInterval as default val 2018-08-23 22:55:21 -07:00
Conner Fromknecht
475eafdc70
peer/example_test: switch TrickleTimeout -> TrickleInterval 2018-08-23 22:55:21 -07:00
Conner Fromknecht
7b402cd63b
peer/peer_test: switch TrickleTimeout -> TrickleInterval 2018-08-23 22:55:21 -07:00
Conner Fromknecht
602bced5f5
peer/peer: switch TrickleTimeout -> TrickleInterval 2018-08-23 22:55:21 -07:00
Conner Fromknecht
7a657ffa2e
wire/msgcfcheckpt: add sanity check for cf checkpoint parsing 2018-08-23 22:55:20 -07:00
Conner Fromknecht
53d846d68c
glide: update lock w/ hash instead of semantic ver 2018-08-23 22:50:35 -07:00
Dave Collins
07edce81b0
txscript: Cleanup strict signature enforcement.
This cleans up the code for handling the checksig and checkmultisig
opcode strict signatures to explicitly call out any semantics that are
likely not obvious and improve readability.

It also introduce new distinct errors for each condition which can
result in a signature being rejected due to not following the strict
encoding requirements and updates reference test adaptor accordingly.
2018-08-23 11:56:28 -05:00
Olaoluwa Osuntokun
d81d8877b8
Merge pull request #1266 from cfromknecht/arm-siphash-fix
build: update siphash lib to latest version w/ ARM fix
2018-08-22 20:07:28 -07:00
Olaoluwa Osuntokun
e3a8d7fb29
Merge pull request #1265 from cfromknecht/fix-indexer-reorg
blockchain/indexers: fix bug in indexer re-org catch up
2018-08-22 20:07:08 -07:00
Olaoluwa Osuntokun
b36dce5032
build: update siphash lib to latest version w/ ARM fix
In this commit, we update the siphash lib we use to the latest version
as it was discovered that the assembly for certain ARM machines has a
flaw which causes it to compute an _incorrect_ siphash function. The
upstream lib has since disabled the assembly after this was discovered.
We update as well in order to ensure that ARM machines will produce the
proper GCS filters.
2018-08-22 19:58:59 -07:00
Olaoluwa Osuntokun
be191ca111
blockchain/indexers: fix bug in indexer re-org catch up
In this commit, we fix an existing bug in the re-org catch up logic for
the `IndexManager`. Before this commit, we would assign the block to the
_local_ scope rather than the outer scope. As a result, we would never
properly bisect the chain to find the fork point to be able to reconcile
the index state to the main chain only after a re-org occurs.

Fixes #1261
2018-08-22 19:46:27 -07:00
Olaoluwa Osuntokun
9d15e63c50
Merge pull request #1259 from cfromknecht/bhv-int64-confs
btcjson: use int64 for GetBlockHeader[Verbose] confirmations
2018-08-22 19:45:43 -07:00
Olaoluwa Osuntokun
9f436585d7
Merge pull request #1247 from davecgh/peer_minor_cleanup
peer: Minor function definition order cleanup.
2018-08-22 19:41:16 -07:00
Olaoluwa Osuntokun
8822e27134
Merge pull request #1223 from wpaulino/harness-disable-txindex
integration/rpctest: disable the txindex by default and allow sending txs without change outputs
2018-08-22 19:40:27 -07:00
Olaoluwa Osuntokun
bb912b6e03
Merge pull request #1222 from halseth/trickle-timeout
config/peer: make trickleTimeout configurable
2018-08-22 19:39:33 -07:00
Wilmer Paulino
dfd7f6caf8
integration/rpctest: add ability to create txs without change outputs 2018-08-16 16:24:02 -07:00
Wilmer Paulino
9aa83ad423
integration/rpctest: disable the txindex by default
In this commit, we disable the txindex by default as the flag cannot be
overwritten by btcd once set.
2018-08-16 16:24:01 -07:00
Conner Fromknecht
85cb8f50a0
rpcserver: convert verbose confirmations fields to int64 2018-08-15 21:05:34 -07:00
Conner Fromknecht
f696d49c49
btcjson/chainsvrresults: use int64 for verbose getblock[header] confs
This commit modifies the parsed fields in GetBlockVerbose
and GetBlockHeaderVerbose from a uint64 to an int64.
bitcoind will return -1 if the requested block is not in
the main chain, which causes a panic when trying to
serialize into a uint.
2018-08-15 21:02:33 -07:00
Dave Collins
fd78330fd3
peer: Minor function definition order cleanup.
This rearranges some of the function definitions that pertain to initial
peer version negotiation and bringup so they are more consistent with
the preferred order used throughout the codebase.  In particular, the
functions are defined before they're first used and generally as close
as possible to the first use when they're defined in the same file.

There are no functional changes.

Backported from Decred.
2018-08-10 20:20:11 -05:00
Olaoluwa Osuntokun
f899737d7f
Merge pull request #1169 from stevenroose/filteradd
server: Fix bug disconnecting peer on filteradd
2018-08-09 17:06:19 -07:00
Olaoluwa Osuntokun
0f95fff561
Merge pull request #1243 from Roasbeef/init-block-index-consistency
blockchain: in initChainState mark ancestors of best tip as valid if …
2018-08-09 17:02:37 -07:00
Olaoluwa Osuntokun
69f313436f
blockchain: during fastAdd or if block wasn't already valid, mark as valid in index 2018-08-09 16:57:01 -07:00
Olaoluwa Osuntokun
598808cfd0
blockchain: mark blocks as invalid if they fail connectBlock 2018-08-08 18:30:52 -07:00
Olaoluwa Osuntokun
f9722295f8
blockchain: add new flushIndexState function within connectBestChain 2018-08-08 18:26:34 -07:00
Olaoluwa Osuntokun
4b13e79691
blockchain: in initChainState mark ancestors of best tip as valid if not marked
In this commit, we add an additional consistency check within the
`initChainState` method.  It has been observed that at times, a block
wil lbe written to disk (as it's valid), but then the block index isn't
updated to reflect this. This can cause btcd to fail to do things like
serve cfheaders for valid blocks.

To partially remedy this, when we're loading in the index, we assume
that all ancestors of the current chain tip are valid, and mark them as
such. At the very end, we'll flush the index to ensure the state is
fully consistent. Typically this will be a noop, as only dirty elements
are flushed.
2018-08-08 17:50:00 -07:00
Olaoluwa Osuntokun
cf05f92c3f
Merge pull request #1236 from cfromknecht/backport-optimize-header-access
blockchain: Backport optimize exported header access.
2018-08-02 09:08:37 -07:00
Conner Fromknecht
f470bf0fe8
blockchain: Backport optimize exported header access.
backport of https://github.com/decred/dcrd/pull/1273

Notable difference being that btcd mainline currenlty
doesn't have a blockchain/blockindex_test.go file, so
those changes are omitted.

Great work @davecgh :)
2018-08-01 16:59:49 -07:00
Olaoluwa Osuntokun
f5e261fc9e
Merge pull request #1233 from cfromknecht/zeroheaders
server: always reply with get headers
2018-08-01 16:43:05 -07:00
Conner Fromknecht
90c2094cbd
server: always reply with get headers
backport of https://github.com/decred/dcrd/pull/1295
2018-07-31 21:15:02 -07:00
Johan T. Halseth
ee0740a289
peer test: set TrickleTimeout for test configs 2018-07-24 13:11:02 +02:00
Johan T. Halseth
08619220b4
config/peer: make trickleTimeout configurable 2018-07-24 12:59:44 +02:00
Olaoluwa Osuntokun
9a2f952402
Merge pull request #1228 from Roasbeef/fix-peer-goroutine-leak
peer: ensure the version negotiation goroutine will always exit
2018-07-21 19:02:38 -07:00
Olaoluwa Osuntokun
088eec67ec
peer: ensure the version negotiation goroutine will always exit
In this commit, we patch a goroutine leak within the peer struct. This
goroutine leak can happen, if the remote side fails to actually finish
negotiation the protocol before our timeout ticker ticks. In this case,
the goroutine will be blocked on a send, as the channel is unfired. An
example trace from a btcd node I had on testnet showed:
```
3183 @ 0x42e78a 0x42e83e 0x40540b 0x4051a5 0x872f76 0x45bfc1
```

So, all instances of the goroutine failing to exit due to the remote
peer not finishing the p2p version negotiation handshake.

Our fix is simple: make the `negotiateErr' channel unbuffered. With this
simple change, we ensure that the goroutine will always exit even in the
case that the parent goroutine exists due to a timeout.  # Please enter
the commit message for your changes. Lines starting
2018-07-21 17:41:23 -07:00
Olaoluwa Osuntokun
f673a4b563
Merge pull request #1215 from davecgh/blockchain_generalize_reorganizechain
blockchain: Generalize chain reorg.
2018-07-17 20:36:26 -07:00
Olaoluwa Osuntokun
bc3861a5a2
Merge pull request #1218 from wpaulino/filter-type-verification
server: ensure we only fetch filters we know of
2018-07-16 20:16:23 -07:00