Commit graph

419 commits

Author SHA1 Message Date
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
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
Matt Corallo 4c8fc1a588 Let a node opt out of tx invs before we get a their bloom filter
Note that the default value for fRelayTxes is false, meaning we
now no longer relay tx inv messages before receiving the remote
peer's version message.
2013-01-16 12:48:02 -05:00
Matt Corallo b02ddbedcb Relay CMerkleBlocks when asked for MSG_FILTERED_BLOCK 2013-01-16 12:48:02 -05:00
Matt Corallo 9fb106e757 Add a CMerkleBlock to store merkle branches of filtered txes. 2013-01-16 12:48:02 -05:00
Matt Corallo 269d9c6492 Replace RelayMessage with RelayTransaction. 2013-01-16 12:48:02 -05:00
Matt Corallo 422d122537 Add a filter field in CNode, add filterload+filteradd+filterclear 2013-01-16 12:48:02 -05:00
Gavin Andresen ce99358f4a Remove IsFromMe() check in CTxMemPool::accept()
Fixes issue #2178 : attacker could penny-flood with invalid-signature
transactions to deduce which addresses belonged to your node.

I'm committing this early for code review; I still need to write up
a test plan.

Executive summary of fix: check all transactions received from the network
for penny-flood rate-limiting before adding to the memory pool. But do NOT
ratelimit transactions added to the memory pool:
  - because of blockchain reorgs
  - stored in the wallet and added at startup
  - sent from the GUI or one of the send* RPC commands (CWallet::CommitTransaction)

The limit-free-transactions code really should be a method on CNode, with
counters per-peer. But that is a bigger change for another day.
2013-01-15 09:10:22 -05:00
Gavin Andresen 1b72229797 Merge pull request #2161 from sipa/noclient
Remove fClient
2013-01-14 11:41:19 -08:00
Gregory Maxwell 1f4b80a437 Merge pull request #2145 from sipa/checkcoins
Coin database checks
2013-01-11 06:27:30 -08:00
Pieter Wuille 45a1ec51b1 Merge pull request #2115 from forrestv/getblocktemplate_allfees
Provide fee data for all txs in RPC getblocktemplate response
2013-01-10 13:09:51 -08:00
Pieter Wuille c2b72ba27f Remove fClient
Client (SPV) mode never got implemented entirely, and whatever part was already
working, is likely not been tested (or even executed at all) for the past two
years. This removes it entirely.

If we want an SPV implementation, I think we should first get the block chain
data structures to be encapsulated in a class implementing a standard interface,
and then writing an alternate implementation with SPV semantics.
2013-01-09 22:28:46 +01:00
Pieter Wuille ef0f422519 Remove contention on signature cache during block validation
Since block validation happens in parallel, multiple threads may be
accessing the signature cache simultaneously. To prevent contention:
* Turn the signature cache lock into a shared mutex
* Make reading from the cache only acquire a shared lock
* Let block validations not store their results in the cache
2013-01-08 02:00:59 +01:00
Pieter Wuille f9cae832e6 Parallelize script verification
* During block verification (when parallelism is requested), script
  check actions are stored instead of being executed immediately.
* After every processed transactions, its signature actions are
  pushed to a CScriptCheckQueue, which maintains a queue and some
  synchronization mechanism.
* Two or more threads (if enabled) start processing elements from
  this queue,
* When the block connection code is finished processing transactions,
  it joins the worker pool until the queue is empty.

As cs_main is held the entire time, and all verification must be
finished before the block continues processing, this does not reach
the best possible performance. It is a less drastic change than
some more advanced mechanisms (like doing verification out-of-band
entirely, and rolling back blocks when a failure is detected).

The -par=N flag controls the number of threads (1-16). 0 means auto,
and is the default.
2013-01-08 02:00:59 +01:00
Pieter Wuille 1d70f4bde8 Remove CheckSig_mode and move logic out of CheckInputs() 2013-01-08 01:49:15 +01:00
Pieter Wuille 2800ce7367 Add CScriptCheck: a closure representing a script check 2013-01-08 01:49:15 +01:00
Pieter Wuille f1136200a6 Move VerifySignature to main 2013-01-08 01:49:14 +01:00
Philip Kaufmann 54413aab13 Bitcoin-Qt: never display own block count > estimated block count
- some users reported it as weird, that the estimated block count could be
  lower than our own nodes block number (which is indeed true and not good)
- this pull adds a new default behaviour, which displays our own block
  number as estimated block number, if own >= est. block count
- the pull raises space for nodes block counts in cPeerBlockCounts to 8 to
  be more accurate
- also removes a reduntant setNumBlocks() call in RPCConsole and moves
  initialisation of numBlocksAtStartup in ClientModel, where it belongs
2013-01-04 17:21:40 +01:00
Pieter Wuille 1f355b66cd New database check routine
-checklevel gets a new meaning:
0: verify blocks can be read from disk (like before)
1: verify (contextless) block validity (like before)
2: verify undo files can be read and have good checksums
3: verify coin database is consistent with the last few blocks
   (close to level 6 before)
4: verify all validity rules of the last few blocks

Level 3 is the new default, as it's reasonably fast. As level 3 and
4 are implemented using an in-memory rollback of the database, they
are limited to as many blocks as possible without exceeding the
limits set by -dbcache. The default of -dbcache=25 allows for some
150-200 blocks to be rolled back.

In case an error is found, the application quits with a message
instructing the user to restart with -reindex. Better instructions,
and automatic recovery (when possible) or automatic reindexing are
left as future work.
2013-01-04 14:58:47 +01:00
Pieter Wuille 8539361e66 Add checksums to undo data
This should be compatible with older code that didn't write checksums.
2013-01-03 15:29:19 +01:00
Pieter Wuille 2cbd71da06 Make DisconnectBlock fault-tolerant 2013-01-03 15:29:19 +01:00
Jeff Garzik 3f964b3c50 Remove 'T' from remaining date/time format strings. 2013-01-01 15:28:28 -05:00
Forrest Voight 03cac0bb8e changed CreateNewBlock to return a CBlockTemplate object, which includes per-tx fee and sigop count data 2012-12-19 16:12:58 -05:00
Pieter Wuille 33766c9557 Merge pull request #2096 from 94m3k1n9/fix-time-formats
Change timestamps to use ISO8601 formatting
2012-12-13 14:39:57 -08:00
Gavin Andresen 043a8fb98d Merge pull request #2059 from sipa/benchmark
Add -benchmark for reporting block processing times
2012-12-12 09:14:52 -08:00
Gavin Andresen dbd5bb8039 Merge pull request #2062 from sipa/nocoins
Reconstruct coins/ database when missing
2012-12-12 09:11:36 -08:00