Commit Graph

14850 Commits

Author SHA1 Message Date
Pieter Wuille f518d9ae6a
Merge #11592: 0.15: Backports
8195cb0d7 rpc: further constrain the libevent workaround (Cory Fields)
34153a7e4 rpc: work-around an upstream libevent bug (Cory Fields)
fc308a6cd Add unit test for stale tip checking (Suhas Daftuar)
2ed0647ac Add CConnmanTest to mutate g_connman in tests (João Barbosa)
a607a95d8 Connect to an extra outbound peer if our tip is stale (Suhas Daftuar)
459f2db42 Track tip update time and last new block announcement from each peer (Suhas Daftuar)
49bf09018 net: Allow connecting to extra outbound peers (Suhas Daftuar)
bb83fe190 Add release notes describing blockmaxweight deprecation (Matt Corallo)
4c82cea99 Use a sensible default for blockmaxweight (Matt Corallo)
7871a7d3b Deprecate confusing blockmaxsize, fix getmininginfo output (Matt Corallo)
6baa317b5 Fix minchainwork test for 0.15 backport (Suhas Daftuar)
55b7abfa8 Make p2p-acceptablock not an extended test (Matt Corallo)
5bec7744d [qa] test that invalid blocks on an invalid chain get a disconnect (Matt Corallo)
92d6105c4 Reject headers building on invalid chains by tracking invalidity (Matt Corallo)
51001d684 Accept unrequested blocks with work equal to our tip (Matt Corallo)
c6e4d0ce8 Stop always storing blocks from whitelisted peers (Matt Corallo)
e976c36dd Rewrite p2p-acceptblock in preparation for slight behavior changes (Matt Corallo)
ec8dedff4 net: Add missing lock in ProcessHeadersMessage(...) (practicalswift)
59b210d9a Disconnect outbound peers relaying invalid headers (Suhas Daftuar)
fc966bbd2 moveonly: factor out headers processing into separate function (Suhas Daftuar)
e3272242e Add unit test for outbound peer eviction (Suhas Daftuar)
9961abf9e Permit disconnection of outbound peers on bad/slow chains (Suhas Daftuar)
bf191a718 Disconnecting from bad outbound peers in IBD (Suhas Daftuar)
d570aa429 Fix uninitialized g_connman crash in Shutdown() (MeshCollider)
0a5477c7e net: stop both net/net_processing before destroying them (Cory Fields)
b4136f21c net: drop unused connman param (Cory Fields)
dc897e53d net: use an interface class rather than signals for message processing (Cory Fields)
8aee55af3 net: pass CConnman via pointer rather than reference (Cory Fields)
6f279652b Rename fAddnode to a more-descriptive "manual_connection" (Matt Corallo)
ffb6ea4e5 Add comment explaining forced processing of compact blocks (Suhas Daftuar)
2df65eeb9 qa: add test for minchainwork use in acceptblock (Suhas Daftuar)
3acec3878 Don't process unrequested, low-work blocks (Suhas Daftuar)
0e9d04bf0 [qa] Test nMinimumChainWork (Suhas Daftuar)
da4908c3a Allow setting nMinimumChainWork on command line (Suhas Daftuar)
41088795d qa: Remove never used return value of sync_with_ping (MarcoFalke)
f3457d0e8 qa: Make tmpdir option an absolute path (MarcoFalke)
9c8006dc3 Avoid opening copied wallet databases simultaneously (Russell Yanofsky)
de7053f11 [wallet] Fix leak in CDB constructor (João Barbosa)
fd79ed6b2 Ensure backupwallet fails when attempting to backup to source file (Tomas van der Wansem)
d94fc336c scripted-diff: rename assert_raises_jsonrpc to assert_raises_rpc error (John Newbery)
623de0acb [tests] do not allow assert_raises_message to be called with JSONRPCException (John Newbery)
5b728c8e9 [tests] remove direct testing on JSONRPCException from individual test cases (John Newbery)

Pull request description:

Tree-SHA512: 9fdb5c47844a899271023d8d445f7fc728e3ad71916490cd9783464684967594b07cda05dd644b722bfcea9fade74d06cfc501e1a68abf118d6d03fbbf7d7707
2017-11-03 15:42:50 -07:00
Cory Fields 8195cb0d7f rpc: further constrain the libevent workaround
The bug was introduced in 2.1.6-beta, versions before that don't need the
workaround.

Github-Pull: #11593
Rebased-From: 97932cd268
2017-11-02 15:31:39 -04:00
Cory Fields 34153a7e4a rpc: work-around an upstream libevent bug
A rare race condition may trigger while awaiting the body of a message, see
upsteam commit 5ff8eb26371c4dc56f384b2de35bea2d87814779 for details.

This may fix some reported rpc hangs/crashes.

Github-Pull: #11593
Rebased-From: 6b58360f9b
2017-11-02 15:31:18 -04:00
Wladimir J. van der Laan f224cbc3d8
build: Bump version to 0.15.1
Tree-SHA512: d998b31250208078414a27431d21b847592bdb1e4bd7eb1df6bee7f67671a4124dcaa2971ebef52304528080ab2d2ff6553b7d7138d948a364e64fc4e37dacd3
2017-11-02 20:26:37 +01:00
Suhas Daftuar fc308a6cdb Add unit test for stale tip checking
Github-Pull: #11560
Rebased-From: 626291508c
2017-11-02 15:18:56 -04:00
João Barbosa 2ed0647ac1 Add CConnmanTest to mutate g_connman in tests
Github-Pull: #11560
Rebased-From: 83df25736e
2017-11-02 15:18:56 -04:00
Suhas Daftuar a607a95d81 Connect to an extra outbound peer if our tip is stale
If our tip hasn't updated in a while, that may be because our peers are
not relaying blocks to us that we would consider valid. Allow connection
to an additional outbound peer in that circumstance.

Also, periodically check to see if we are exceeding our target number of
outbound peers, and disconnect the one which has least recently
announced a new block to us (choosing the newest such peer in the case
of tie).

Github-Pull: #11560
Rebased-From: ac7b37cd2b
2017-11-02 15:18:56 -04:00
Suhas Daftuar 459f2db425 Track tip update time and last new block announcement from each peer
Github-Pull: #11560
Rebased-From: db32a65897
2017-11-02 15:18:56 -04:00
Suhas Daftuar 49bf090185 net: Allow connecting to extra outbound peers
Github-Pull: #11560
Rebased-From: 2d4327db19
2017-11-02 15:18:56 -04:00
Matt Corallo bb83fe1902 Add release notes describing blockmaxweight deprecation
Github-Pull: #11100
Rebased-From: 6f703e9bf1
2017-11-02 15:18:56 -04:00
Matt Corallo 4c82cea99b Use a sensible default for blockmaxweight
No sensible user will ever keep the default settings here, so not
having sensible defaults only serves to screw users who are
paying less attention, which makes for terrible defaults.

Github-Pull: #11100
Rebased-From: 3dc263c9b9
2017-11-02 15:18:56 -04:00
Matt Corallo 7871a7d3be Deprecate confusing blockmaxsize, fix getmininginfo output
* This removes block-size-limiting code in favor of GBT clients
  doing the limiting themselves (if at all).
* -blockmaxsize is deprecated and only used to calculate an implied
  blockmaxweight, addressing confusion from multiple users.
* getmininginfo's currentblocksize return value was returning
  garbage values, and has been removed, also removing a
  GetSerializeSize call in some block generation inner loops and
  potentially addressing some performance edge cases.

Github-Pull: #11100
Rebased-From: ba206d2c63
2017-11-02 15:18:56 -04:00
Suhas Daftuar 6baa317b5f Fix minchainwork test for 0.15 backport 2017-11-02 15:02:48 -04:00
Matt Corallo 55b7abfa8a Make p2p-acceptablock not an extended test
Github-Pull: #11531
Rebased-From: f3d4adfa6f
2017-11-02 13:22:25 -04:00
Matt Corallo 5bec7744d1 [qa] test that invalid blocks on an invalid chain get a disconnect
Github-Pull: #11531
Rebased-From: 00dcda60f6
2017-11-02 13:21:23 -04:00
Matt Corallo 92d6105c4e Reject headers building on invalid chains by tracking invalidity
This tracks the set of all known invalid-themselves blocks (ie
blocks which we attempted to connect but which were found to be
invalid). This is used to cheaply check if new headers build on an
invalid chain.

While we're at it we also resolve an edge-case in invalidateblock
on pruned nodes which results in them needing a reindex if they
fail to reorg.

Github-Pull: #11531
Rebased-From: 015a5258ad
2017-11-02 13:21:07 -04:00
Matt Corallo 51001d684b Accept unrequested blocks with work equal to our tip
This is a simple change that makes our accept requirements the
same as our request requirements, (ever so slightly) further
decoupling our consensus logic from our FindNextBlocksToDownload
logic in net_processing.

Github-Pull: #11531
Rebased-From: 932f118e6a
2017-11-02 13:20:53 -04:00
Matt Corallo c6e4d0ce82 Stop always storing blocks from whitelisted peers
There is no reason to wish to store blocks on disk always just
because a peer is whitelisted. This appears to be a historical
quirk to avoid breaking things when the accept limits were added.

Github-Pull: #11531
Rebased-From: 3d9c70ca0f
2017-11-02 13:20:45 -04:00
Matt Corallo e976c36ddf Rewrite p2p-acceptblock in preparation for slight behavior changes
Removes checking whitelisted behavior (which will be removed, the
difference in behavior here makes little sense) and no longer
requires that blocks at the same work as our tip be dropped if not
requested (in part because we *do* request those blocks).

Github-Pull: #11531
Rebased-From: 3b4ac43bc3
2017-11-02 13:20:38 -04:00
practicalswift ec8dedff46 net: Add missing lock in ProcessHeadersMessage(...)
Reading the variable mapBlockIndex requires holding the mutex cs_main.

The new "Disconnect outbound peers relaying invalid headers" code
added in commit 37886d5e2f and merged
as part of #11568 two days ago did not lock cs_main prior to accessing
mapBlockIndex.

Github-Pull: #11578
Rebased-From: 2530bf27b7
2017-11-02 13:20:18 -04:00
Suhas Daftuar 59b210d9a7 Disconnect outbound peers relaying invalid headers
Github-Pull: #11568
Rebased-From: 37886d5e2f
2017-11-02 13:19:57 -04:00
Suhas Daftuar fc966bbd2b moveonly: factor out headers processing into separate function
ProcessMessages will now return earlier when processing headers
messages, rather than continuing on (and do nothing).

Github-Pull: #11568
Rebased-From: 4637f18522
2017-11-02 13:19:47 -04:00
Suhas Daftuar e3272242e2 Add unit test for outbound peer eviction
Github-Pull: #11490
Rebased-From: e065249c01
2017-11-02 13:18:44 -04:00
Suhas Daftuar 9961abf9e4 Permit disconnection of outbound peers on bad/slow chains
Currently we have no rotation of outbound peers.  If an outbound peer
stops serving us blocks, or is on a consensus-incompatible chain with
less work than our tip (but otherwise valid headers), then we will never
disconnect that peer, even though that peer is using one of our 8
outbound connection slots.  Because we rely on our outbound peers to
find an honest node in order to reach consensus, allowing an
incompatible peer to occupy one of those slots is undesirable,
particularly if it is possible for all such slots to be occupied by such
peers.

Protect against this by always checking to see if a peer's best known
block has less work than our tip, and if so, set a 20 minute timeout --
if the peer is still not known to have caught up to a chain with as much
work as ours after 20 minutes, then send a single getheaders message,
wait 2 more minutes, and if a better header hasn't been received by then,
disconnect that peer.

Note:

- we do not require that our peer sync to the same tip as ours, just an
equal or greater work tip.  (Doing otherwise would risk partitioning the
network in the event of a chain split, and is also unnecessary.)

- we pick 4 of our outbound peers and do not subject them to this logic,
to be more conservative. We don't wish to permit temporary network
issues (or an attacker) to excessively disrupt network topology.

Github-Pull: #11490
Rebased-From: 5a6d00c6de
2017-11-02 13:18:34 -04:00
Suhas Daftuar bf191a7183 Disconnecting from bad outbound peers in IBD
When in IBD, we'd like to use all our outbound peers to help us
sync the chain.  Disconnect any outbound peers whose headers have
insufficient work.

Github-Pull: #11490
Rebased-From: c60fd71a65
2017-11-02 13:18:23 -04:00
MeshCollider d570aa4290 Fix uninitialized g_connman crash in Shutdown()
Github-Pull: #11326
Rebased-From: 77939f27f7
2017-11-02 13:17:58 -04:00
Cory Fields 0a5477c7e3 net: stop both net/net_processing before destroying them
This should avoid either attempting to use an invalid reference/pointer to the
other.

Github-Pull: #10756
Rebased-From: 2525b972af
2017-11-02 13:16:57 -04:00
Cory Fields b4136f21cf net: drop unused connman param
The copy in PeerLogicValidation can be used instead.

Github-Pull: #10756
Rebased-From: 80e2e9d0ce
2017-11-02 13:16:50 -04:00
Cory Fields dc897e53d8 net: use an interface class rather than signals for message processing
Drop boost signals in favor of a stateful class. This will allow the message
processing loop to actually move to net_processing in a future step.

Github-Pull: #10756
Rebased-From: 8ad663c1fa
2017-11-02 13:16:28 -04:00
Cory Fields 8aee55af3d net: pass CConnman via pointer rather than reference
There are a few too many edge-cases here to make this a scripted diff.

The following commits will move a few functions into PeerLogicValidation, where
the local connman instance can be used. This change prepares for that usage.

Github-Pull: #10756
Rebased-From: 28f11e9406
2017-11-02 13:15:02 -04:00
Matt Corallo 6f279652b0 Rename fAddnode to a more-descriptive "manual_connection"
Github-Pull: #11456
Rebased-From: 57edc0b0c8
2017-11-02 13:11:54 -04:00
Suhas Daftuar ffb6ea4e5e Add comment explaining forced processing of compact blocks
Github-Pull: #11458
Rebased-From: 01b52cedd4
2017-11-02 13:09:16 -04:00
Suhas Daftuar 2df65eeb98 qa: add test for minchainwork use in acceptblock
Github-Pull: #11458
Rebased-From: 08fd822771
2017-11-02 13:09:03 -04:00
Suhas Daftuar 3acec38781 Don't process unrequested, low-work blocks
A peer could try to waste our resources by sending us unrequested blocks with
low work, eg to fill up our disk.  Since
e2652002b6 we no longer request blocks until we
know we're on a chain with more than nMinimumChainWork (our anti-DoS
threshold), but we would still process unrequested blocks that had more work
than our tip.  This commit fixes that behavior.

Github-Pull: #11458
Rebased-From: ce8cd7a7da
2017-11-02 13:09:00 -04:00
Suhas Daftuar 0e9d04bf0a [qa] Test nMinimumChainWork
Nodes don't consider themselves out of "initial block download" until
their active chain has more work than nMinimumChainWork.

While in initial block download, nodes won't relay blocks to their
peers, so test that this parameter functions as intended by verifying
that block relay only succeeds past a given node once its
nMinimumChainWork has been exceeded.

Github-Pull: #10357
Rebased-From: eac64bb7a3
2017-11-02 13:08:50 -04:00
Suhas Daftuar da4908c3a0 Allow setting nMinimumChainWork on command line
Github-Pull: #10357
Rebased-From: 0311836f69
2017-11-02 13:08:43 -04:00
MarcoFalke 41088795dd qa: Remove never used return value of sync_with_ping
Github-Pull: #11472
Rebased-From: fafa003970
2017-11-01 15:23:06 -04:00
MarcoFalke f3457d0e83 qa: Make tmpdir option an absolute path
This should fix issues with the multiwallet test and symlinks
when the tmpdir is a relative path.

Rather than fixing os.symlink to work with paths relative to a
directory descriptor, which does not work on Windows, normalize
the path instead.

Github-Pull: #11472
Rebased-From: fa9de370b1
2017-11-01 15:23:06 -04:00
Russell Yanofsky 9c8006dc33 Avoid opening copied wallet databases simultaneously
Make sure wallet databases have unique fileids. If they don't, throw an error.
BDB caches do not work properly when more than one open database has the same
fileid, because values written to one database may show up in reads to other
databases.

Bitcoin will never create different databases with the same fileid, but users
can create them by manually copying database files.

BDB caching bug was reported by Chris Moore <dooglus@gmail.com>
https://github.com/bitcoin/bitcoin/issues/11429

Fixes #11429

Github-Pull: #11476
Rebased-From: 478a89c1ef
2017-11-01 15:23:06 -04:00
João Barbosa de7053f114 [wallet] Fix leak in CDB constructor
Now using a std::unique_ptr, the Db instance is correctly released
when CDB initialization fails.
The internal CDB state and mapFileUseCount are only mutated when
the CDB initialization succeeds.

Github-Pull: #11492
Rebased-From: 7104de8b1f
2017-11-01 15:23:06 -04:00
Tomas van der Wansem fd79ed6b20 Ensure backupwallet fails when attempting to backup to source file
Previous behaviour was to destroy the wallet (to zero-length)

Github-Pull: #11376
Rebased-From: 5d465e3962
2017-11-01 15:23:06 -04:00
John Newbery d94fc336c4 scripted-diff: rename assert_raises_jsonrpc to assert_raises_rpc error
-BEGIN VERIFY SCRIPT-
sed -i 's/assert_raises_jsonrpc/assert_raises_rpc_error/g' test/functional/*py test/functional/test_framework/*py
-END VERIFY SCRIPT-

Github-Pull: #10853
Rebased-From: 47ba8cf71e
2017-11-01 10:42:30 -04:00
John Newbery 623de0acbb [tests] do not allow assert_raises_message to be called with JSONRPCException
Github-Pull: #10853
Rebased-From: 677d893ff7
2017-11-01 10:40:22 -04:00
John Newbery 5b728c8e98 [tests] remove direct testing on JSONRPCException from individual test cases
Github-Pull: #10853
Rebased-From: 5864e9c161
2017-11-01 10:40:09 -04:00
Wladimir J. van der Laan 34833534b6
Merge #11550: [0.15.1] qa: Backports
01223a0 [verify-commits] Allow revoked keys to expire (Matt Corallo)
adbc9d1 qa: Fix race condition in sendheaders.py (Suhas Daftuar)
fdad04e qa: Fix replace-by-fee race condition failures (Suhas Daftuar)

Pull request description:

Tree-SHA512: e1532a02a84d9406cc78975a59201dbde78750217d504896e7e448aa86d6b4df98dc959fae440044c8f9aedebf296a9537b18e281976344ca8e4b705d7bd50b0
2017-11-01 14:21:39 +01:00
Russell Yanofsky 7d4546f17d
Make listsinceblock refuse unknown block hash
Change suggested by Cory Fields <cory-nospam-@coryfields.com> who noticed
listsinceblock would ignore invalid block hashes causing it to return a
completely unfiltered list of transactions.

Github-Pull: #11565
Rebased-From: 659b2061c4
Tree-SHA512: 2091a830b730421b49c806cb83a16c7da2ec0a7adac2bac0585324aad12a32bb99a840264c3d346937ea84786fac56e44befb6641511a417977803875efe5a21
2017-11-01 14:15:59 +01:00
fanquake cf18f42899
[Docs] Update OpenBSD Build Instructions for OpenBSD 6.2
Github-Pull: #11442
Rebased-From: 9d30f54ef1
Tree-SHA512: fc7ae48126ed9569bda7d444a2464c09ba3db2398d05933df7e1ca92a0d03c2bd3c370fea977d1a3ffe70c76e9caf45ee69d41c9dc24abcc0139e4146d8c1abd
2017-11-01 14:04:27 +01:00
MarcoFalke 265bb214ec
Add share/rpcuser to dist. source code archive
Github-Pull: #11530
Rebased-From: fa81534d06
Tree-SHA512: 97bc91760a3284a9b60dcde04e789aed3c83539ec6621cb38dbc5bd852bfc0cdcaffceff7ca6de0c64f00149e6774d7dd651520b39876a674f1e82efba98945d
2017-10-26 17:28:32 +02:00
Matt Corallo 01223a0261 [verify-commits] Allow revoked keys to expire
Github-Pull: #11539
Rebased-From: d23be309c2
2017-10-23 17:28:32 +02:00
Suhas Daftuar adbc9d164a qa: Fix race condition in sendheaders.py
Github-Pull: #11538
Rebased-From: 6d51eaefe9
2017-10-23 17:23:14 +02:00