Commit Graph

443 Commits

Author SHA1 Message Date
Gavin Andresen c8c2fbe07f Shutdown cleanup prep-work
Create a boost::thread_group object at the qt/bitcoind main-loop level
that will hold pointers to all the main-loop threads.

This will replace the vnThreadsRunning[] array.

For testing, ported the BitcoinMiner threads to use its
own boost::thread_group.
2013-04-03 14:04:21 -04:00
Gavin Andresen d8aae1ce1d Merge pull request #2420 from sipa/globclean
Global cleanups
2013-04-02 10:00:31 -07:00
Pieter Wuille c7f039b674 Process getdata invs separately until send buffer overflows
There exists a per-message-processed send buffer overflow protection,
where processing is halted when the send buffer is larger than the
allowed maximum.

This protection does not apply to individual items, however, and
getdata has the potential for causing large amounts of data to be
sent. In case several hundreds of blocks are requested in one getdata,
the send buffer can easily grow 50 megabytes above the send buffer
limit.

This commit breaks up the processing of getdata requests, remembering
them inside a CNode when too many are requested at once.
2013-03-30 18:14:54 +01:00
Pieter Wuille 41b052ad87 Use per-message send buffer, rather than per connection 2013-03-29 23:56:26 +01:00
Pieter Wuille 967f24590b Some fixes to CNetMessage processing
* Change CNode::vRecvMsg to be a deque instead of a vector (less copying)
* Make sure to acquire cs_vRecvMsg in CNode::CloseSocketDisconnect (as it
  may be called without that lock).
2013-03-29 23:56:26 +01:00
Jeff Garzik 607dbfdeaf P2P: parse network datastream into header/data components in socket thread
Replaces CNode::vRecv buffer with a vector of CNetMessage's.  This simplifies
ProcessMessages() and eliminates several redundant data copies.

Overview:

* socket thread now parses incoming message datastream into
  header/data components, as encapsulated by CNetMessage
* socket thread adds each CNetMessage to a vector inside CNode
* message thread (ProcessMessages) iterates through CNode's CNetMessage vector

Message parsing is made more strict:

* Socket is disconnected, if message larger than MAX_SIZE
  or if CMessageHeader deserialization fails (latter is impossible?).
  Previously, code would simply eat garbage data all day long.
* Socket is disconnected, if we fail to find pchMessageStart.
  We do not search through garbage, to find pchMessageStart.  Each
  message must begin precisely after the last message ends.

ProcessMessages() always processes a complete message, and is more efficient:

* buffer is always precisely sized, using CDataStream::resize(),
  rather than progressively sized in 64k chunks.  More efficient
  for large messages like "block".
* whole-buffer memory copy eliminated (vRecv -> vMsg)
* other buffer-shifting memory copies eliminated (vRecv.insert, vRecv.erase)
2013-03-29 23:56:25 +01:00
Pieter Wuille 3427517d50 Clean up global datastructures at shutdown.
This should make detecting leaks much easier.
2013-03-29 02:24:18 +01:00
Gavin Andresen 402f19b645 Before 15 May, limit created block size to 500K 2013-03-17 21:53:01 -04:00
Gavin Andresen 8c222dca4f CheckBlock rule until 15-May for 10,000 BDB lock compatibility 2013-03-17 21:52:47 -04:00
Wladimir J. van der Laan 0bd573d666 Merge pull request #2186 from Diapolo/misc_stuff
small changes in init, main, checkpoints.h and bitcoin-qt.pro
2013-02-23 23:52:27 -08:00
Gavin Andresen cc67f1e2b4 Merge pull request #2221 from sipa/perfo
Various performance tweaks to CCoinsView
2013-02-22 09:01:30 -08:00
Gavin Andresen b8f4e42e1b Merge pull request #2229 from sipa/prealloc
Native versions for AllocateFileRange()
2013-02-22 09:00:13 -08:00
Philip Kaufmann 69e0774714 small changes in init, main, checkpoints.h and bitcoin-qt.pro
- remove an unneeded MODAL flag, as MSG_ERROR sets MODAL
- re-order an if-clause in main to have bool checks before a function call
- fix some log messages that used wrong function names
- make a log message use a correct ellipsis
- remove some unneded spaces, brackets and line-breaks
- fix style for adding files in the Qt project
2013-02-20 08:46:38 +01:00
Pieter Wuille f7f3a96b74 Improve block database load error reporting 2013-02-17 23:25:42 +01:00
Gavin Andresen 8f66aedfaa Merge pull request #2279 from sipa/cvrbip30
Bugfix CValidationResult for BIP30 + add DoS
2013-02-06 12:58:52 -08:00
Pieter Wuille 7cdc37c0a4 Bugfix CValidationResult for BIP30 + add DoS 2013-02-06 16:33:51 +01:00
Rubén Darío Ponticelli e90b831e83 Do not call ResendWalletTransactions when reindexing, importing or on IBD
Calling ResendWalletTransactions when reindexing, importing or on IBD spams
other nodes with our old transactions, because they become unconfirmed.
2013-02-05 18:29:41 -03:00
Gavin Andresen 79892883d7 Merge branch 'reindexgen' of git://github.com/sipa/bitcoin 2013-02-05 10:15:06 -05:00
Gavin Andresen 1d0851eca8 Merge pull request #2273 from gavinandresen/txsize
Make transactions larger than 100K non-standard
2013-02-05 07:12:27 -08:00
Gavin Andresen 41e1a0d766 Make transactions larger than 100K non-standard
Extremely large transactions with lots of inputs can cost the network
almost as much to process as they cost the sender in fees.

We would never create transactions larger than 100K big; this change
makes transactions larger than 100K non-standard, so they are not
relayed/mined by default. This is most important for miners that might
create blocks larger than 250K big, who could be vulnerable to a
make-your-blocks-so-expensive-to-verify-they-get-orphaned attack.
2013-02-05 10:08:35 -05:00
Pieter Wuille 386037615a Make sure the genesis block is present after reindex 2013-02-01 23:29:59 +01:00
Luke Dashjr 8c4e43130b Bugfix: Enable ConnectBestBlock to properly report back validation problems, and ensure orphan processing (when their parents are found) cannot be used to counter-DDoS the node providing the parent
Also fix a minor typo
2013-01-31 03:53:21 +00:00
Pieter Wuille 1eb578796c Drop padding in blk* when finalizing file 2013-01-30 04:55:38 +01:00
Gavin Andresen db3b4ade7b Merge pull request #2224 from sipa/valstate
Improve error handling during validation
2013-01-29 19:37:44 -08:00
Pieter Wuille 421218d304 Deal with LevelDB errors 2013-01-30 04:30:02 +01:00
Gavin Andresen 15ebd4865a Fix two clang3.3 warnings 2013-01-29 22:03:49 -05:00
Pieter Wuille 7851033dd6 Improve dealing with abort conditions 2013-01-30 03:56:45 +01:00
Pieter Wuille 18379c8087 Add disk space checks before flushing CCoins cache 2013-01-30 03:56:45 +01:00
Pieter Wuille 86c82bf9d0 Treat coinbase value violation as DoS 2013-01-30 03:56:44 +01:00
Pieter Wuille ef3988ca36 CValidationState framework 2013-01-30 03:56:44 +01:00
Gavin Andresen f73abdc82d Merge pull request #2223 from gavinandresen/nonfinalnonstandard
Treat non-final transactions as non-standard
2013-01-28 07:56:58 -08:00
Gavin Andresen 6f8730752c Treat non-final transactions as non-standard
At least one service that accepted zero-confirmation transactions
was vulnerable because an attacker could send a transaction
with a lock time far in the future, and then have plenty of time in
which to get a double-spend mined (perhaps from a miner who wasn't
on the network when the first transaction was broadcast).

That is a variation on the "Finney attack". We still don't
recommend anybody accept 0-confirmation transactions as final
payment for anything. This change keeps non-final transactions
from appearing in the wallet, and, assuming most of the network
accepts this change, will prevent them from being relayed until
they are final.
2013-01-26 14:38:40 -05:00
Gavin Andresen 434fa60d75 Merge pull request #2182 from gavinandresen/addressoracle
Remove IsFromMe() check in CTxMemPool::accept()
2013-01-26 11:27:48 -08:00
Pieter Wuille 56869fc07c Check only 288 blocks at startup by default 2013-01-26 18:57:07 +01:00
Pieter Wuille f369d02c51 Various performance tweaks to CCoinsView
* Pass txid's to CCoinsView functions by reference instead of by value
* Add a method to swap CCoins, and use it in some places to avoid a
  allocating copy + destruct.
* Optimize CCoinsViewCache::FetchCoins to do only a single search
  through the backing map.
2013-01-26 18:46:12 +01:00
Gavin Andresen 63cc7661a5 Merge pull request #2168 from sipa/txindex
Add optional transaction index to databases
2013-01-25 12:55:52 -08:00
Gavin Andresen 9c9f5c1303 Let limitfreerelay=0 reject ALL free transactions 2013-01-23 20:24:10 -05:00
Gavin Andresen 09c69c03f7 Merge pull request #2187 from CodeShark/SyncWithWalletsFix
Bugfix - Moved SyncWithWallets out of ProcessMessage and into CTxMemPool::accept()
2013-01-23 09:29:01 -08:00
Gavin Andresen a337505bd7 Merge pull request #2192 from mikehearn/notfoundmsg
Add a notfound message to getdata.
2013-01-23 06:48:57 -08:00
Gavin Andresen 1a2e45d8d5 Merge pull request #2188 from TheBlueMatt/bloom
Send transactions after a CMerkleBlock when asked for it in an inv.
2013-01-23 06:48:17 -08:00
Mike Hearn 903d146030 Add a notfound message to getdata that is sent if any transactions that aren't in the relayable set are requested. 2013-01-19 18:48:26 +01:00
Pieter Wuille 8301ff5077 Bugfix + simplify special case for genesis 2013-01-19 00:35:17 +01:00
Matt Corallo 192cc910ec Replace 520 constant with MAX_SCRIPT_ELEMENT_SIZE 2013-01-18 13:55:18 -05:00
Matt Corallo 28b80e6065 Send transactions after a CMerkleBlock when asked for it in an inv.
This actually simplifies some SPV code, as they can keep track of
a filtered block and its txn before accepting both in one step.
The previous argument was that SPV nodes should handle the txn the
same as any other free txn and then mark them as connected to a
block when they get the filtered block itself.  However, it now
appears that SPV nodes will need to put in more effort to verify
loose txn than they would to verify txn in blocks, thus making it
more approriate to send the txn after the filtered block.
2013-01-18 12:16:39 -05:00
Eric Lombrozo 35c12d176e Moved SyncWithWallets out of ProcessMessage and into CTxMemPool::accept() so that when adding multiple wallets they will be aware of each other's transactions. 2013-01-18 07:01:05 -08:00
Pieter Wuille 2d1fa42e85 Add optional transaction index to databases
By specifying -txindex when initializing the database, a txid-to-diskpos
index is maintained in the blktree database. This database is used to
help answering getrawtransaction() RPC queries, when enabled.

Changing the -txindex value requires a -reindex; the client will abort
at startup if the database and the specified -txindex mismatch.
2013-01-18 14:39:11 +01:00
Gavin Andresen 0e31ae9818 Merge pull request #2060 from sipa/parallel
Parallel script verification
2013-01-17 16:58:58 -08:00
Matt Corallo c51694eb9b Filter mempool command 2013-01-16 14:34:06 -05:00
Matt Corallo 21aaf255ff Use CPartialMerkleTree for CMerkleBlock transactions. 2013-01-16 14:34:06 -05:00
Pieter Wuille 4bedfa9223 Add CPartialMerkleTree
This adds a compact representation for a subset of a merkle tree's
nodes.
2013-01-16 14:34:06 -05:00