Commit Graph

1024 Commits

Author SHA1 Message Date
Philip Kaufmann a9ac95c1bc use const references where appropriate 2015-06-04 19:34:18 +02:00
Suhas Daftuar 9be0e6837b Be stricter in processing unrequested blocks
AcceptBlock will no longer process an unrequested block, unless it has not
been previously processed and has more work than chainActive.Tip()
2015-06-02 13:54:29 -04:00
Wladimir J. van der Laan 88a7ead5de
Merge pull request #6172
a1ba077 Ignore getheaders requests when not synced. (Suhas Daftuar)
2015-06-02 07:56:02 +02:00
Wladimir J. van der Laan 87550eefc1
Merge pull request #6183
28bf062 Fix off-by-one error w/ nLockTime in the wallet (Peter Todd)
2015-06-01 11:33:33 +02:00
Wladimir J. van der Laan 921ea89bc3
Merge pull request #6195
8273793 Eliminate compiler warning due to unused variable (Suhas Daftuar)
2015-06-01 08:49:47 +02:00
Suhas Daftuar 8273793350 Eliminate compiler warning due to unused variable 2015-05-27 13:04:59 -04:00
Suhas Daftuar a1ba0778dd Ignore getheaders requests when not synced. 2015-05-27 10:36:04 -04:00
Jorge Timón e69734309c Chainparams: Explicit CMessageHeader::MessageStartChars to functions in main:
-UndoWriteToDisk
-WriteBlockToDisk
2015-05-27 16:01:07 +02:00
Wladimir J. van der Laan c7c9af381c
Merge pull request #5669
da29ecb Consensus: MOVEONLY: Move CValidationState from main consensus/validation (jtimon)
27afcd8 Consensus: Refactor: Decouple CValidationState from main::AbortNode() (Cory Fields)
2015-05-27 15:00:02 +02:00
Peter Todd 28bf06236d
Fix off-by-one error w/ nLockTime in the wallet
Previously due to an off-by-one error the wallet ignored
nLockTime-by-height transactions that would be valid in the next block
even though they are accepted into the mempool. The transactions
wouldn't show up until confirmed, nor would they be included in the
unconfirmed balance. Similar to the mempool behavior fix in 665bdd3b,
the wallet code was calling IsFinalTx() directly without taking into
account the fact that doing so tells you if the transaction could have
been mined in the *current* block, rather than the next block.

To fix this we strip IsFinalTx() of non-consensus-critical
functionality, removing the default arguments, and add CheckFinalTx() to
check if a transaction will be final in the next block.
2015-05-27 05:51:33 -04:00
Wladimir J. van der Laan 9f7809f6c3
Merge pull request #5976
8ba7f84 Reduce download timeouts as blocks arrive (Suhas Daftuar)
2015-05-26 13:02:40 +02:00
Wladimir J. van der Laan e9af4e65b5
Merge pull request #5947
36cba8f Alert if it is very likely we are getting a bad chain (Gavin Andresen)
2015-05-26 10:41:17 +02:00
Wladimir J. van der Laan 377711ff3f
Merge pull request #5996
935bd0a Chainparams: Refactor: Decouple main::GetBlockValue() from Params() [renamed GetBlockSubsidy] (Jorge Timón)
2015-05-19 11:42:47 +02:00
Jorge Timón 935bd0a447 Chainparams: Refactor: Decouple main::GetBlockValue() from Params() [renamed GetBlockSubsidy]
Remove redundant getter CChainParams::SubsidyHalvingInterval()
2015-05-15 16:12:30 +02:00
jtimon da29ecbcc6 Consensus: MOVEONLY: Move CValidationState from main consensus/validation 2015-05-15 16:05:28 +02:00
Cory Fields 27afcd89db Consensus: Refactor: Decouple CValidationState from main::AbortNode() 2015-05-15 16:05:26 +02:00
Alex Morcos c208040354 Fix for clearing fCheckForPruning
Previously this was cleared only after UnlinkPrunedFiles, but it should really be cleared after FindFilesToPrune, regardless of whether there are any files to be pruned.
2015-05-15 07:58:41 -04:00
Wladimir J. van der Laan f0043c2d6d
Merge pull request #5968
51aa249 Chainparams: Refactor: Decouple IsSuperMajority from Params() (Jorge Timón)
2015-05-15 13:52:54 +02:00
Wladimir J. van der Laan 6fb90d8983
Merge pull request #6102
86a5f4b Relocate calls to CheckDiskSpace (Alex Morcos)
67708ac Write block index more frequently than cache flushes (Pieter Wuille)
b3ed423 Cache tweak and logging improvements (Pieter Wuille)
fc684ad Use accurate memory for flushing decisions (Pieter Wuille)
046392d Keep track of memory usage in CCoinsViewCache (Pieter Wuille)
540629c Add memusage.h (Pieter Wuille)
2015-05-15 13:43:02 +02:00
Gavin Andresen 36cba8f118
Alert if it is very likely we are getting a bad chain
Create a monitoring task that counts how many blocks have been found in the last four hours.

If very few or too many have been found, an alert is triggered.

"Very few" and "too many" are set based on a false positive rate of once every fifty years of constant running with constant hashing power, which works out to getting 5 or fewer or 48 or more blocks in four hours (instead of the average of 24).

Only one alert per day is triggered, so if you get disconnected from the network (or are being Sybil'ed) -alertnotify will be triggered after 3.5 hours but you won't get another -alertnotify for 24 hours.

Tested with a new unit test and by running on the main network with -debug=partitioncheck

Run test/test_bitcoin --log_level=message to see the alert messages:
    WARNING: check your network connection, 3 blocks received in the last 4 hours (24 expected)
    WARNING: abnormally high number of blocks generated, 60 blocks received in the last 4 hours (24 expected)

The -debug=partitioncheck debug.log messages look like:
    ThreadPartitionCheck : Found 22 blocks in the last 4 hours
    ThreadPartitionCheck : likelihood: 0.0777702
2015-05-14 14:58:44 -04:00
Suhas Daftuar b89f30775d Fix incorrect variable name in FindFilesToPrune 2015-05-13 14:58:55 -04:00
Wladimir J. van der Laan 2cc1372190
Merge pull request #5159
b649e03 Create new BlockPolicyEstimator for fee estimates (Alex Morcos)
2015-05-13 17:10:02 +02:00
Alex Morcos b649e03954 Create new BlockPolicyEstimator for fee estimates
This class groups transactions that have been confirmed in blocks into buckets, based on either their fee or their priority.  Then for each bucket, the class calculates what percentage of the transactions were confirmed within various numbers of blocks.  It does this by keeping an exponentially decaying moving history for each bucket and confirm block count of the percentage of transactions in that bucket that were confirmed within that number of blocks.

-Eliminate txs which didn't have all inputs available at entry from fee/pri calcs

-Add dynamic breakpoints and tracking of confirmation delays in mempool transactions

-Remove old CMinerPolicyEstimator and CBlockAverage code

-New smartfees.py

-Pass a flag to the estimation code, using IsInitialBlockDownload as a proxy for when we are still catching up and we shouldn't be counting how many blocks it takes for transactions to be included.

-Add a policyestimator unit test
2015-05-13 10:36:24 -04:00
Alex Morcos 86a5f4b54e Relocate calls to CheckDiskSpace
Make sure we're checking disk space for block index writes and allow for pruning to happen before chainstate writes.
2015-05-12 21:44:56 +02:00
Pieter Wuille 67708acff9 Write block index more frequently than cache flushes 2015-05-11 17:58:14 -07:00
Pieter Wuille b3ed4236be Cache tweak and logging improvements 2015-05-11 17:58:14 -07:00
Pieter Wuille fc684ad8af Use accurate memory for flushing decisions 2015-05-11 17:57:27 -07:00
Jorge Timón 51aa24927e Chainparams: Refactor: Decouple IsSuperMajority from Params() 2015-05-06 16:39:15 +02:00
Wladimir J. van der Laan 00820f921d
Merge pull request #6055
a8cdaf5 checkpoints: move the checkpoints enable boolean into main (Cory Fields)
11982d3 checkpoints: Decouple checkpoints from Params (Cory Fields)
6996823 checkpoints: make checkpoints a member of CChainParams (Cory Fields)
9f13a10 checkpoints: store mapCheckpoints in CCheckpointData rather than a pointer (Cory Fields)
2015-05-06 11:38:39 +02:00
Wladimir J. van der Laan 00e76db8c2
Merge pull request #6085
b05a89b Non-grammatical language improvements (Luke Dashjr)
7e6d23b Bugfix: Grammar fixes (Corinne Dashjr)
2015-05-04 08:01:58 +02:00
Luke Dashjr b05a89b2de Non-grammatical language improvements 2015-05-02 15:23:59 +00:00
Corinne Dashjr 7e6d23b171 Bugfix: Grammar fixes 2015-05-01 11:21:27 +00:00
Cory Fields a8cdaf5c96 checkpoints: move the checkpoints enable boolean into main
This pertains to app-state, so it doesn't make sense to handle inside the
checkpoint functions.
2015-04-30 23:14:48 -04:00
Cory Fields 11982d366d checkpoints: Decouple checkpoints from Params
Pass checkpoint data in as necessary
2015-04-30 23:14:48 -04:00
Gavin Andresen d81cff32e5 Replace mruset setAddrKnown with CRollingBloomFilter addrKnown
Use a probabilistic bloom filter to keep track of which addresses
we think we have given our peers, instead of a list.

This uses much less memory, at the cost of sometimes failing to
relay an address to a peer-- worst case if the bloom filter happens
to be as full as it gets, 1-in-1,000.

Measured memory usage of a full mruset setAddrKnown: 650Kbytes
Constant memory usage of CRollingBloomFilter addrKnown: 37Kbytes.

This will also help heap fragmentation, because the 37K of storage
is allocated when a CNode is created (when a connection to a peer
is established) and then there is no per-item-remembered memory
allocation.

I plan on testing by restarting a full node with an empty peers.dat,
running a while with -debug=addrman and -debug=net, and making sure
that the 'addr' message traffic out is reasonable.
(suggestions for better tests welcome)
2015-04-30 08:16:20 -07:00
Pieter Wuille 7bf5d5efa6
Merge pull request #5918
f7303f9 Use equivalent PoW for non-main-chain requests (Pieter Wuille)
2015-04-28 07:46:27 -07:00
Wladimir J. van der Laan 5048465fc5
Merge pull request #5662
00dcaf4 Change download logic to allow calling getheaders/getdata on inbound peers (Suhas Daftuar)
2015-04-28 10:17:04 +02:00
mrbandrews f9ec3f0fad Add block pruning functionality
This adds a -prune=N option to bitcoind, which if set to N>0 will enable block
file pruning. When pruning is enabled, block and undo files will be deleted to
try to keep total space used by those files to below the prune target (N, in
MB) specified by the user, subject to some constraints:

- The last 288 blocks on the main chain are always kept (MIN_BLOCKS_TO_KEEP),
- N must be at least 550MB (chosen as a value for the target that could
  reasonably be met, with some assumptions about block sizes, orphan rates,
  etc; see comment in main.h),
- No blocks are pruned until chainActive is at least 100,000 blocks long (on
  mainnet; defined separately for mainnet, testnet, and regtest in chainparams
  as nPruneAfterHeight).

This unsets NODE_NETWORK if pruning is enabled.

Also included is an RPC test for pruning (pruning.py).

Thanks to @rdponticelli for earlier work on this feature; this is based in
part off that work.
2015-04-22 15:53:48 -04:00
Pieter Wuille f7303f9793 Use equivalent PoW for non-main-chain requests 2015-04-22 03:53:25 -07:00
Wladimir J. van der Laan 2bc6332df8
Merge pull request #6010
c1ecee8 Set nSequenceId when a block is fully linked (Suhas Daftuar)
2015-04-20 13:47:14 +02:00
Nicolas Benoit 52070c87fd Removed '()' where used without contents inside
This additional patch removes '()' from current function name in LogPrintf output.
2015-04-20 13:29:21 +02:00
Nicolas Benoit 30c1db1c61 Replaced current function names with __func__ in LogPrintf() calls. 2015-04-20 13:29:21 +02:00
Wladimir J. van der Laan 8f955b9661
Merge pull request #6012
0421c18 Fix CheckBlockIndex for reindex. (mrbandrews)
2015-04-16 10:33:29 +02:00
Suhas Daftuar 8ba7f842e5 Reduce download timeouts as blocks arrive
Compare the block download timeout to what the timeout would be if calculated
based on current time and current value of nQueuedValidatedHeaders, but
ignoring other in-flight blocks from the same peer. If the calculation based on
present conditions is shorter, then set that to be the time after which we
disconnect the peer for not delivering this block.
2015-04-15 09:28:00 -04:00
Wladimir J. van der Laan ea2b425b00
Merge pull request #5997
4e38217 Chainparams: Refactor: Remove redundant HashGenesisBlock() getter (Jorge Timón)
2015-04-15 12:06:55 +02:00
mrbandrews 0421c18f3a Fix CheckBlockIndex for reindex.
Some tests in CheckBlockIndex require chainActive.Tip(), but when reindexing, chainActive has not been set on the first call to CheckBlockIndex.

reindex.py starts a node, mines 3 blocks, stops, and reindexes with CheckBlockIndex enabled.
2015-04-14 14:10:19 -04:00
Suhas Daftuar c1ecee8f72 Set nSequenceId when a block is fully linked
Also adds a test to CheckBlockIndex
2015-04-14 12:51:20 -04:00
Jorge Timón e8e8904dda Chainparams: Cleanup: Delete CChainParams getters to attributes from Consensus::Params 2015-04-13 18:39:53 +02:00
Jorge Timón 4e382177ed Chainparams: Refactor: Remove redundant HashGenesisBlock() getter 2015-04-12 23:01:30 +02:00
Wladimir J. van der Laan 91cba1aaed
Merge pull request #5969
f14e687 Chainparams: Decouple CAlert from CChainParams (Jorge Timón)
2015-04-08 09:41:14 +02:00