Commit graph

1521 commits

Author SHA1 Message Date
Cory Fields 960cf2e405 net: move nLocalHostNonce to CConnman
This behavior seems to have been quite racy and broken.

Move nLocalHostNonce into CNode, and check received nonces against all
non-fully-connected nodes. If there's a match, assume we've connected
to ourself.
2016-09-08 12:24:06 -04:00
Cory Fields 53347f0cb9 net: create generic functor accessors and move vNodes to CConnman 2016-09-08 12:24:06 -04:00
Cory Fields a0f3d3cdad net: move ban and addrman functions into CConnman 2016-09-08 12:12:57 -04:00
Cory Fields aaf018e3b7 net: handle nodesignals in CConnman 2016-09-08 12:06:24 -04:00
Cory Fields 5b446dd5b1 net: Pass CConnection to wallet rather than using the global 2016-09-08 12:04:35 -04:00
Cory Fields 8d58c4d81f net: Pass CConnman around as needed 2016-09-08 12:04:35 -04:00
Jeremy Rubin ec81881b86 Performance Regression Fix: Pre-Allocate txChanged vector 2016-09-07 20:10:50 -04:00
Pavel Janík 125b946cb4 Do not shadow upper local variable 'send', prevent -Wshadow compiler warning. 2016-09-07 13:45:13 +02:00
Pieter Wuille 5b2ea29cf4
Merge #8594: Do not add random inbound peers to addrman.
eb3596f Do not add random inbound peers to addrman. (Gregory Maxwell)
2016-09-07 13:19:53 +02:00
Pieter Wuille e2a1a1ee89
Merge #8606: Fix some locks
144ed76 Fix some locks (Pieter Wuille)
2016-09-07 13:10:10 +02:00
Pieter Wuille 34521e4d7d Do not store witness txn in rejection cache 2016-09-05 17:48:56 +02:00
Wladimir J. van der Laan 6f939c9080
Merge #8629: C++11: s/boost::scoped_ptr/std::unique_ptr/
cdd79eb C++11: s/boost::scoped_ptr/std::unique_ptr/ (Jorge Timón)
2016-09-02 09:56:33 +02:00
Jorge Timón cdd79eb70f C++11: s/boost::scoped_ptr/std::unique_ptr/ 2016-09-01 19:05:07 +02:00
Pieter Wuille 19b0f33de0
Merge #8524: Precompute sighashes
35fe039 Rename to PrecomputedTransactionData (Pieter Wuille)
ab48c5e Unit test for sighash caching (Nicolas DORIER)
d2c5d04 Precompute sighashes (Pieter Wuille)
2016-09-01 12:20:43 +02:00
Johnson Lau 482f852da6 Implement NULLDUMMY softfork 2016-08-31 19:38:23 +08:00
Pieter Wuille 5127c4f21c Add preciousblock RPC
Includes a bugfix by Luke-Jr.
2016-08-26 23:05:45 +02:00
Pieter Wuille 887919c7b7 Check for compatibility with download in FindNextBlocksToDownload 2016-08-26 21:44:44 +02:00
Pieter Wuille 144ed76ea0 Fix some locks
This makes sure that cs_filter is never held while taking cs_main
or CNode::cs_vSend.
2016-08-26 21:11:57 +02:00
Pieter Wuille 35fe0393f2 Rename to PrecomputedTransactionData 2016-08-26 18:44:10 +02:00
Wladimir J. van der Laan 6c9f1b8c24
Merge #8561: Show "end" instead of many zeros when getheaders request received with a hashStop of Null
259ee09 Show "end" instead of many zeros when getheaders request received with a hashStop of Null. (R E Broadley)
2016-08-26 10:04:26 +02:00
Gregory Maxwell eb3596f7c2 Do not add random inbound peers to addrman.
We should learn about new peers via address messages.

An inbound peer connecting to us tells us nothing about
 its ability to accept incoming connections from us, so
 we shouldn't assume that we can connect to it based on
 this.

The vast majority of nodes on the network do not accept
 incoming connections, adding them will only slow down
 the process of making a successful connection in the
 future.

Nodes which have configured themselves to not announce would prefer we
 not violate their privacy by announcing them in GETADDR responses.
2016-08-25 23:48:59 +00:00
Pieter Wuille 53f8f226bd
Merge #8462: Move AdvertiseLocal debug output to net category
f13c1ba Move AdvertiseLocal debug output to net category (Michael Rotarius)
2016-08-25 15:15:16 +02:00
Jonas Schnelli 0606f95b1e
Merge #7579: [Qt] show network/chain errors in the GUI
2f32c82 [Qt] show network/chain errors in the GUI (Jonas Schnelli)
2016-08-25 14:55:26 +02:00
Wladimir J. van der Laan 026c6edac9
Merge #8282: net: Feeler connections to increase online addrs in the tried table.
dbb1f64 Added feeler connections increasing good addrs in the tried table. (Ethan Heilman)
2016-08-25 10:48:24 +02:00
Ethan Heilman dbb1f640e6 Added feeler connections increasing good addrs in the tried table.
Tests if addresses are online or offline by briefly connecting to them. These short lived connections are referred to as feeler connections. Feeler connections are designed to increase the number of fresh online addresses in tried by selecting and connecting to addresses in new. One feeler connection is attempted on average once every two minutes.

This change was suggested as Countermeasure 4 in
Eclipse Attacks on Bitcoin’s Peer-to-Peer Network, Ethan Heilman,
Alison Kendler, Aviv Zohar, Sharon Goldberg. ePrint Archive Report
2015/263. March 2015.
2016-08-23 16:26:42 -04:00
R E Broadley 259ee09f88 Show "end" instead of many zeros when getheaders request received with a hashStop of Null. 2016-08-23 13:14:07 +07:00
Wladimir J. van der Laan a55a018d5f
Merge #8548: [wallet] Use __func__ to get function name for output printing
fa785d1 Use __func__ to get function name for output printing (MarcoFalke)
2016-08-22 09:58:28 +02:00
MarcoFalke fa785d1211 Use __func__ to get function name for output printing 2016-08-19 18:59:00 +02:00
Wladimir J. van der Laan e753eaeb34
Merge #8505: Trivial: Fix typos in various files
1aacfc2 various typos (leijurv)
2016-08-17 12:51:16 +02:00
Pieter Wuille d2c5d044d0 Precompute sighashes
Original version by Nicolas Dorier. Precomputing version by Pieter Wuille.
2016-08-16 15:35:45 +02:00
leijurv 1aacfc2da5
various typos 2016-08-14 07:57:11 -06:00
Jonas Schnelli b3b3c2a562
Reduce cs_main locks during ConnectTip/SyncWithWallets 2016-08-12 14:53:10 +02:00
Michael Rotarius f13c1bae52 Move AdvertiseLocal debug output to net category 2016-08-05 18:34:32 +02:00
Wladimir J. van der Laan f97d335942
Merge #8392: Fix several node initialization issues
9d4eb9a Do diskspace check before import thread is started (Pieter Wuille)
aa59f2e Add extra message to avoid a long 'Loading banlist' (Pieter Wuille)
0fd2a33 Use a signal to continue init after genesis activation (Pieter Wuille)
2016-08-04 12:33:21 +02:00
Wladimir J. van der Laan 37d83bb0a9
Merge #8391: Consensus: Remove ISM
122786d Consensus: Remove ISM (NicolasDorier)
2016-08-04 12:20:35 +02:00
Pieter Wuille 8ea7d31e38
Merge #8413: Trivial: pass Consensus::Params& instead of CChainParams& in ContextualCheckBlock
c8664ee Trivial: pass Consensus::Params& instead of CChainParams& in ContextualCheckBlock (Jorge Timón)
2016-08-01 01:53:29 +02:00
Pieter Wuille 0fd2a33648 Use a signal to continue init after genesis activation 2016-07-30 02:17:47 +02:00
Wladimir J. van der Laan 5c9e49d12c net: Ignore notfound P2P messages 2016-07-29 17:44:01 +02:00
Wladimir J. van der Laan 7a2d402727
Merge #8274: util: Update tinyformat
a5072a7 util: Remove zero-argument versions of LogPrint and error (Wladimir J. van der Laan)
695041e util: Update tinyformat (Wladimir J. van der Laan)
2016-07-29 12:32:47 +02:00
Wladimir J. van der Laan 842bf8d2c5
Merge #8408: Prevent fingerprinting, disk-DoS with compact blocks
1d06e49 Ignore CMPCTBLOCK messages for pruned blocks (Suhas Daftuar)
1de2a46 Ignore GETBLOCKTXN requests for unknown blocks (Suhas Daftuar)
2016-07-29 08:21:03 +02:00
Wladimir J. van der Laan 64d660a43f
Merge #8348: Trivial: Segwit: Don't call IsWitnessEnabled from ContextualCheckBlock
38c4c8b Trivial: Segwit: Don't call IsWitnessEnabled from ContextualCheckBlock (Jorge Timón)
2016-07-28 09:51:04 +02:00
Jorge Timón c8664eeac7 Trivial: pass Consensus::Params& instead of CChainParams& in ContextualCheckBlock 2016-07-27 23:58:04 +02:00
Suhas Daftuar 1d06e49834 Ignore CMPCTBLOCK messages for pruned blocks
Also ignores CMPCTBLOCK announcements that have too little work.  This is to
prevent disk-exhaustion DoS.
2016-07-26 16:52:35 -04:00
Suhas Daftuar 1de2a46632 Ignore GETBLOCKTXN requests for unknown blocks
Don't disconnect peers, or else we leak information that could be
used for fingerprinting.
2016-07-26 16:50:48 -04:00
Wladimir J. van der Laan 4b1a4d8810
Merge #8381: Make witness v0 outputs non-standard
c59c434 qa: Add test for standardness of segwit v0 outputs (Suhas Daftuar)
1ffaff2 Make witness v0 outputs non-standard before segwit activation (Johnson Lau)
2016-07-26 14:24:11 +02:00
Wladimir J. van der Laan 618c9dd8c6
Merge #8365: Treat high-sigop transactions as larger rather than rejecting them
ab942c1 Treat high-sigop transactions as larger rather than rejecting them (Pieter Wuille)
2016-07-26 11:27:30 +02:00
NicolasDorier 122786d0e0 Consensus: Remove ISM 2016-07-23 01:02:53 +09:00
Johnson Lau 1ffaff2f74 Make witness v0 outputs non-standard before segwit activation 2016-07-22 06:35:07 +00:00
Wladimir J. van der Laan 381917f610
Merge #8347: Trivial: Make CBlockIndex param const in ContextualCheckBlockHeader and ContextualCheckBlock
6f3d616 Trivial: Make CBlockIndex param const in ContextualCheckBlockHeader and ContextualCheckBlock (Jorge Timón)
2016-07-21 14:31:40 +02:00
NicolasDorier 7821889bce Consensus: Remove calls to error() from ContextualCheckBlock 2016-07-21 20:57:08 +09:00
Wladimir J. van der Laan 6f4092da80
Merge #8342: Consensus: Trivial transform BOOST_FOREACH into for loop
a3e1984 Consensus: Trivial transform BOOST_FOREACH into for loop (NicolasDorier)
2016-07-21 11:56:33 +02:00
Jonas Schnelli 2f32c82b3d
[Qt] show network/chain errors in the GUI 2016-07-20 14:42:19 +02:00
Pieter Wuille ab942c15bd Treat high-sigop transactions as larger rather than rejecting them 2016-07-19 12:31:49 +02:00
Suhas Daftuar 2c06bae39e Rename "block cost" to "block weight" 2016-07-18 13:28:26 -04:00
Wladimir J. van der Laan 37303934fe
Merge #8305: Improve handling of unconnecting headers
e91cf4b Add test for handling of unconnecting headers (Suhas Daftuar)
96fa953 Improve handling of unconnecting headers (Suhas Daftuar)
2016-07-18 07:46:12 +02:00
Jorge Timón 38c4c8b701 Trivial: Segwit: Don't call IsWitnessEnabled from ContextualCheckBlock 2016-07-17 02:41:58 +02:00
Jorge Timón 6f3d616dc8 Trivial: Make CBlockIndex param const in ContextualCheckBlockHeader and ContextualCheckBlock 2016-07-17 01:43:15 +02:00
NicolasDorier a3e1984651 Consensus: Trivial transform BOOST_FOREACH into for loop 2016-07-16 11:08:52 +09:00
Wladimir J. van der Laan ca40ef6029
Merge #8312: Fix mempool DoS vulnerability from malleated transactions
46c9620 Test that unnecessary witnesses can't be used for mempool DoS (Suhas Daftuar)
bb66a11 Fix DoS vulnerability in mempool acceptance (Suhas Daftuar)
2016-07-14 08:21:13 +02:00
Wladimir J. van der Laan 1bc9c8085f
Merge #8271: [bugfix] Do not send witnesses in cmpctblock
252675e Do not send witnesses in cmpctblock (Pieter Wuille)
2016-07-14 08:17:22 +02:00
Suhas Daftuar 96fa95361f Improve handling of unconnecting headers
When processing a headers message that looks like a block announcement,
send peer a getheaders if the headers message won't connect.

Apply DoS points after too many consecutive unconnecting headers messages.
2016-07-12 13:12:40 -04:00
Suhas Daftuar bb66a11396 Fix DoS vulnerability in mempool acceptance
Moves the IsStandard check to happen after the premature-witness check,
so that adding a witness to a transaction can't prevent mempool acceptance.

Note that this doesn't address the broader category of potential mempool DoS
issues that affect transactions after segwit activation.
2016-07-07 15:49:26 -04:00
Wladimir J. van der Laan 042c323922
Merge #8275: Remove bad chain alert partition check
ab8be98 Remove bad chain alert partition check (BtcDrak)
2016-07-06 07:35:54 +02:00
Gregory Maxwell 4fbdc4365b Revert "net: Avoid duplicate getheaders requests." PR #8054
This reverts commit f93c2a1b7e.

This can cause synchronization to get stuck.
2016-07-05 20:45:14 +00:00
Wladimir J. van der Laan a5072a7730 util: Remove zero-argument versions of LogPrint and error
Changes in tinyformat, recently imported from upstream have made the
zero-argument versions of formatting functions unnecessary. Remove them.

This is a slight semantic change: `%` characters in the zero-argument
call are now regarded and need to be escaped. As for as I know, the only
use of this is in `main.cpp`.
2016-06-27 18:39:25 +02:00
Pieter Wuille 252675efc6 Do not send witnesses in cmpctblock 2016-06-26 20:19:00 +02:00
Alex Morcos 4f7ff00497 [qa] Add rpc test for segwit
Amended by Pieter Wuille to use multisig 1-of-1 for P2WSH tests, and BIP9
based switchover logic.

Fixes and py3 conversion by Marco Falke.
2016-06-22 15:43:01 +02:00
Pieter Wuille af87a67eff Do not use compact blocks when segwit is enabled 2016-06-22 15:43:00 +02:00
Pieter Wuille 6032f6930a Add rewind logic to deal with post-fork software updates
Includes logic for dealing with pruning by Suhas Daftuar.
2016-06-22 15:43:00 +02:00
Pieter Wuille 2b1f6f9ccf BIP141: Other consensus critical limits, and BIP145
Includes changes by Suhas Daftuar, Luke-jr, and mruddy.
2016-06-22 15:43:00 +02:00
Pieter Wuille 0ef1dd3e11 Refactor script validation to observe amounts
This is a preparation for BIP143 support.
2016-06-22 15:43:00 +02:00
Pieter Wuille b8a97498df BIP144: Handshake and relay (receiver side)
Service bit logic by Nicolas Dorier.

Only download blocks from witness peers after fork.
2016-06-22 15:42:59 +02:00
Pieter Wuille 8b49040854 BIP141: Commitment structure and deployment
Includes a fix by Suhas Daftuar and LongShao007
2016-06-22 15:42:59 +02:00
Pieter Wuille 449f9b8deb BIP141: Witness program 2016-06-22 15:42:59 +02:00
Pieter Wuille 7030d9eb47 BIP144: Serialization, hashes, relay (sender side)
Contains refactorings by Eric Lombrozo.
Contains fixup by Nicolas Dorier.
Contains cleanup of CInv::GetCommand by Alex Morcos
2016-06-22 15:42:59 +02:00
Wladimir J. van der Laan e9d76a161d
Merge #8068: Compact Blocks
48efec8 Fix some minor compact block issues that came up in review (Matt Corallo)
ccd06b9 Elaborate bucket size math (Pieter Wuille)
0d4cb48 Use vTxHashes to optimize InitData significantly (Matt Corallo)
8119026 Provide a flat list of txid/terators to txn in CTxMemPool (Matt Corallo)
678ee97 Add BIP 152 to implemented BIPs list (Matt Corallo)
56ba516 Add reconstruction debug logging (Matt Corallo)
2f34a2e Get our "best three" peers to announce blocks using cmpctblocks (Matt Corallo)
927f8ee Add ability to fetch CNode by NodeId (Matt Corallo)
d25cd3e Add receiver-side protocol implementation for CMPCTBLOCK stuff (Matt Corallo)
9c837d5 Add sender-side protocol implementation for CMPCTBLOCK stuff (Matt Corallo)
00c4078 Add protocol messages for short-ids blocks (Matt Corallo)
e3b2222 Add some blockencodings tests (Matt Corallo)
f4f8f14 Add TestMemPoolEntryHelper::FromTx version for CTransaction (Matt Corallo)
85ad31e Add partial-block block encodings API (Matt Corallo)
5249dac Add COMPACTSIZE wrapper similar to VARINT for serialization (Matt Corallo)
cbda71c Move context-required checks from CheckBlockHeader to Contextual... (Matt Corallo)
7c29ec9 If AcceptBlockHeader returns true, pindex will be set. (Matt Corallo)
96806c3 Stop trimming when mapTx is empty (Pieter Wuille)
2016-06-22 14:30:38 +02:00
Matt Corallo 48efec82f3 Fix some minor compact block issues that came up in review 2016-06-21 16:09:46 -07:00
Wladimir J. van der Laan 94ab58b5cc
Merge #8179: Evict orphans which are included or precluded by accepted blocks.
54326a6 Increase maximum orphan size to 100,000 bytes. (Gregory Maxwell)
8c99d1b Treat orphans as implicit inv for parents, discard when parents rejected. (Gregory Maxwell)
11cc143 Adds an expiration time for orphan tx. (Gregory Maxwell)
db0ffe8 This eliminates the primary leak that causes the orphan map to  always grow to its maximum size. (Gregory Maxwell)
1b0bcc5 Track orphan by prev COutPoint rather than prev hash (Pieter Wuille)
2016-06-20 14:53:33 +02:00
Matt Corallo 2f34a2e476 Get our "best three" peers to announce blocks using cmpctblocks 2016-06-19 23:06:55 -07:00
Matt Corallo d25cd3ec4e Add receiver-side protocol implementation for CMPCTBLOCK stuff 2016-06-19 23:06:55 -07:00
Matt Corallo 9c837d5468 Add sender-side protocol implementation for CMPCTBLOCK stuff 2016-06-19 01:34:58 -07:00
Matt Corallo cbda71cf04 Move context-required checks from CheckBlockHeader to Contextual... 2016-06-19 01:34:57 -07:00
Matt Corallo 7c29ec9449 If AcceptBlockHeader returns true, pindex will be set.
Assert this instead of checking (and then dref'ing later anyway)
to make sure no one thinks they can change that postcondition of
AcceptBlockHeader..
2016-06-19 01:34:57 -07:00
Wladimir J. van der Laan e4bb4a85a5
Merge #8084: Add recently accepted blocks and txn to AttemptToEvictConnection.
6ee7f05 Allow disconnecting a netgroup with only one member in eviction. (Gregory Maxwell)
5d0ca81 Add recently accepted blocks and txn to AttemptToEvictConnection. (Gregory Maxwell)
2016-06-16 11:03:52 +02:00
Gregory Maxwell 5d0ca81f74 Add recently accepted blocks and txn to AttemptToEvictConnection.
This protects any not-already-protected peers who were the most
 recent four to relay transactions and most recent four to send
 blocks to us.
2016-06-15 20:19:07 +00:00
Gregory Maxwell 54326a6808 Increase maximum orphan size to 100,000 bytes.
Although this increases node memory usage in the worst case by perhaps
 30MB, the current behavior causes severe issues with dependent tx relay.
2016-06-15 09:56:42 +00:00
Gregory Maxwell 8c99d1b525 Treat orphans as implicit inv for parents, discard when parents rejected.
An orphan whos parents were rejected is never going to connect, so there
 is little utility in keeping it.

Orphans also helpfully tell us what we're missing, so go ahead and treat
 it as INVed.
2016-06-15 09:56:37 +00:00
Gregory Maxwell 11cc143895 Adds an expiration time for orphan tx.
This prevents higher order orphans and other junk from
 holding positions in the orphan map.  Parents delayed
 twenty minutes are more are unlikely to ever arrive.

The freed space will improve the orphan matching success rate for
 other transactions.
2016-06-15 09:56:28 +00:00
BtcDrak ab8be98fdb Remove bad chain alert partition check
As per meeting 2016-03-31
https://bitcoincore.org/en/meetings/2016/03/31/#bad-chain-alerts

The partition checker was producing huge number of false-positives
and was disabled in 0.12.1 on the understanding it would either be
fixed in 0.13 or removed entirely from master if not.
2016-06-14 12:26:59 +01:00
Pieter Wuille ecd7fd37c8 Introduce REQUIRED_SERVICES constant 2016-06-13 17:40:16 +02:00
Pieter Wuille ee06e04369 Introduce enum ServiceFlags for service flags 2016-06-13 17:40:16 +02:00
Pieter Wuille 5e7ab16d29 Only store and connect to NODE_NETWORK nodes 2016-06-13 17:40:16 +02:00
Pieter Wuille fc83f18153 Verify that outbound connections have expected services 2016-06-13 17:40:16 +02:00
Pieter Wuille 3764dec36c Keep addrman's nService bits consistent with outbound observations 2016-06-13 17:40:16 +02:00
Wladimir J. van der Laan 44c1b1c9bb
Merge #8141: Continuing port of java comparison tool
ff2dcf2 Tests: Edit bloated varint test and add option for 'barely expensive' tests (mrbandrews)
12c5a16 Catch exceptions from non-canonical encoding and print only to log (mrbandrews)
291f8aa Continuing port of java comptool (mrbandrews)
8c9e681 Tests: Rework blockstore to avoid re-serialization. (mrbandrews)
2016-06-13 11:37:37 +02:00
Gregory Maxwell db0ffe80a0 This eliminates the primary leak that causes the orphan map to
always grow to its maximum size.

This does not go so far as to attempt to connect orphans made
 connectable by a new block.

Keeping the orphan map less full helps improve the reliability
 of relaying chains of transactions.
2016-06-10 20:42:03 +00:00
Pieter Wuille 1b0bcc5f95 Track orphan by prev COutPoint rather than prev hash 2016-06-10 19:51:20 +00:00
Wladimir J. van der Laan 1445835bd3
Merge #8154: drop vAddrToSend after sending big addr message
d3d02d5 drop vAddrToSend after sending big addr message (Kaz Wesley)
2016-06-09 08:13:14 +02:00
Pieter Wuille 4286f43025
Merge #8173: Use SipHash for node eviction (cont'd)
eebc232 test: Add more test vectors for siphash (Wladimir J. van der Laan)
8884830 Use C++11 thread-safe static initializers (Pieter Wuille)
c31b24f Use 64-bit SipHash of netgroups in eviction (Pieter Wuille)
9bf156b Support SipHash with arbitrary byte writes (Pieter Wuille)
053930f Avoid recalculating vchKeyedNetGroup in eviction logic. (Patrick Strateman)
2016-06-08 18:32:34 +02:00
Pieter Wuille 66ed450d77
Merge #7935: Versionbits: GBT support
12c708a getblocktemplate: Use version/force mutation to support pre-BIP9 clients (Luke Dashjr)
9879060 getblocktemplate: Explicitly handle the distinction between GBT-affecting softforks vs not (Luke Dashjr)
72cd6b2 qa/rpc-tests: bip9-softforks: Add tests for getblocktemplate versionbits updates (Luke Dashjr)
d3df40e Implement BIP 9 GBT changes (Luke Dashjr)
2016-06-08 15:44:07 +02:00