Commit graph

1070 commits

Author SHA1 Message Date
Thomas Zander 70477a0bdf
On close of splashscreen interrupt verifyDB
With the splashscreen being able to be closed it is possible to
shutdown during the lengthy verifyDB method. (Takes about a minute
on my machine). This change allows us to shutdown much sooner.

Github-Pull: #5557
2015-01-03 10:22:02 +01:00
Cory Fields a3241998e1 namespace: remove boost namespace pollution 2015-01-02 15:12:03 -05:00
Wladimir J. van der Laan c986972ad7
Merge pull request #5476
73caf47 Display time offset in the debug window's Peers tab (Pavel Janík)
26a6bae Add time offset to getpeerinfo output (Pavel Janík)
2015-01-02 17:54:21 +01:00
Wladimir J. van der Laan 40d65eb66d
Merge pull request #5580
1b178a7 Bugfix: ConnectBlock: In case the genesis block gets in with fJustCheck, behave correctly (Luke Dashjr)
228d238 Make CCoinsViewCache's copy constructor private (Luke Dashjr)
2015-01-02 17:35:45 +01:00
Luke Dashjr 23f3435962 Rename MAX_TX_SIGOPS to MAX_STANDARD_TX_SIGOPS to match similar policy constant MAX_STANDARD_TX_SIZE 2015-01-01 11:35:51 +00:00
Jeff Garzik 664999eb87
Merge #5578 from
branch 'error_typos' of git://github.com/paveljanik/bitcoin into merge-5578
2014-12-31 08:00:37 -05:00
Luke Dashjr 1b178a7f96 Bugfix: ConnectBlock: In case the genesis block gets in with fJustCheck, behave correctly 2014-12-31 03:28:05 +00:00
Pavel Janík 4f1ee565b5 Clean AcceptToMemoryPool error messages 2014-12-30 23:02:46 +01:00
Pavel Vasin de236f57c6 clarify obscure uses of EvalScript()
The 3rd argument of EvalScript() is the unsigned int flags, not a bool.
2014-12-30 10:01:16 +03:00
Pieter Wuille 1c52aad540 Require sufficent priority for relay of free transactions 2014-12-30 02:03:29 +01:00
jtimon 87fb31086d Move UndoWriteToDisk() and UndoReadFromDisk() to anon namespace 2014-12-27 16:01:31 +01:00
jtimon 937ba572d0 MOVEONLY: CBlockUndo from main.h to undo.h 2014-12-27 16:01:31 +01:00
jtimon e035c6a737 Decouple CBlockUndo from CDiskBlockPos 2014-12-27 16:01:31 +01:00
jtimon d7621ccf9d Decouple miner.o and txmempool.o from CTxUndo 2014-12-27 16:01:12 +01:00
jtimon c444c620c6 Decouple CCoins from CTxInUndo 2014-12-27 15:46:09 +01:00
Wladimir J. van der Laan 844ace95de
Merge pull request #5507
c907704 DOS: Respect max per-peer blocks in flight limit (Adam Weiss)
2014-12-23 12:32:47 +01:00
Adam Weiss c90770430d DOS: Respect max per-peer blocks in flight limit
Don't allow immediate inv driven block downloads if
a peer already has MAX_BLOCKS_IN_TRANSIT_PER_PEER
active downloads.  Prevents bogus inv spam from
blowing up block transfer tracking data structures.
2014-12-23 02:19:34 -05:00
Pieter Wuille 3497022347 Reject headers that build on an invalid parent 2014-12-22 15:10:56 +01:00
Wladimir J. van der Laan 203632d20b
Merge pull request #5253
7c041b3 Check against MANDATORY flags prior to accepting to mempool (Peter Todd)
2014-12-22 12:41:40 +01:00
sandakersmann f914f1a746
Added "Core" to copyright headers
Github-Pull: #5494
Rebased-From: 15de949bb9277e442302bdd8dee299a8d6deee60
2014-12-19 19:55:32 +01:00
Philip Kaufmann 84857e87e4
add missing CAutoFile::IsNull() check in main
Rebased-From: ccd056a30db0ba5e04b858a682907b378e464d34
Github-Pull: #5437
2014-12-19 18:47:00 +01:00
Philip Kaufmann 27df4123c4 make all catch() arguments const
- I saw this on http://en.cppreference.com/w/cpp/language/try_catch and
  thought it would be a good idea
- also unify used format to better be able to search for exception
  uses in our codebase
2014-12-17 09:39:24 +01:00
Pavel Janík bf7835c271
Fix small typos in comments and error messages
Rebased-From: 67b2d819cdf6181e7f016e5366ce7479830893bd
Github-Pull: #5404
2014-12-16 11:24:43 +01:00
Pavel Janík 26a6bae753 Add time offset to getpeerinfo output 2014-12-15 11:06:15 +01:00
Pieter Wuille 5ea3bc06d5 Move remaining CBlockIndex methods to chain.cpp 2014-12-11 17:39:10 +01:00
Pieter Wuille 9dcd524f32 Make IsSuperMajority a standalone function 2014-12-11 17:39:09 +01:00
Wladimir J. van der Laan dcc1304426
Merge pull request #5367
63d1ae5 Do all block index writes in a batch (Pieter Wuille)
2014-12-11 16:15:34 +01:00
Matt Corallo 723d12c098 Remove txn which are invalidated by coinbase maturity during reorg 2014-12-08 14:05:42 -08:00
Matt Corallo 868d041622 Remove coinbase-dependant transactions during reorg.
This still leaves transactions in mempool that are potentially
invalid if the maturity period has been reorged out of, but at
least they're not missing inputs entirely.
2014-12-08 14:05:42 -08:00
Wladimir J. van der Laan b5fa132329
Merge pull request #5181
afd4b94 Move CMerkleBlock and CPartialMerkleTree to their own file (Matt Corallo)
2014-12-05 16:50:48 +01:00
Wladimir J. van der Laan c78a18087f
Merge pull request #5308
60d1ecd change nSubsidy's type from int64_t to CAmount (HarryWu)
2014-12-05 11:11:24 +01:00
Matt Corallo afd4b94b6d Move CMerkleBlock and CPartialMerkleTree to their own file 2014-12-05 01:57:40 -08:00
Wladimir J. van der Laan 9ddc8c63ab
Merge pull request #5394
307f7d4 Report script evaluation failures in log and reject messages (Pieter Wuille)
2014-12-04 16:43:35 +01:00
Pieter Wuille 307f7d48d4 Report script evaluation failures in log and reject messages 2014-12-02 22:05:03 +01:00
Michael Ford c5b390b6b9 Make comments in main an init doxygen compatible
Fix typos where appropriate
Update license/copyright
2014-12-02 15:50:58 +08:00
Wladimir J. van der Laan d7c8a830c4
Merge pull request #5316
f86a24b Move `setmocktime` to hidden category (Wladimir J. van der Laan)
bd9aebf Introduce a hidden category (Pieter Wuille)
0dd06b2 Delay writing block indexes in invalidate/reconsider (Pieter Wuille)
9b0a8d3 Add 'invalidateblock' and 'reconsiderblock' RPC commands. (Pieter Wuille)
2014-11-28 11:19:15 +01:00
Pieter Wuille 57be955ba0 Remove -printblock, -printblocktree, and -printblockindex 2014-11-27 09:50:20 +01:00
Pieter Wuille 0dd06b2515 Delay writing block indexes in invalidate/reconsider 2014-11-26 16:36:26 +01:00
Pieter Wuille 9b0a8d3152 Add 'invalidateblock' and 'reconsiderblock' RPC commands.
These can be used for testing reorganizations or for manual intervention in case of
chain forks.
2014-11-26 16:36:25 +01:00
Wladimir J. van der Laan 9ff0bc9beb
Merge pull request #5158
9ec75c5 Add a locking mechanism to IsInitialBlockDownload to ensure it never goes from false to true. (Ruben Dario Ponticelli)
a2d0fc6 Fix IsInitialBlockDownload which was broken by headers first. (Ruben Dario Ponticelli)
2014-11-26 15:09:03 +01:00
Wladimir J. van der Laan 53a87c0355
Merge pull request #5321
34559c7 Make PruneBlockIndexCandidates safer (Pieter Wuille)
cca48f6 Reset setBlockIndexCandidates once block index db loaded (21E14)
2014-11-26 13:31:03 +01:00
Pieter Wuille 63d1ae5556 Do all block index writes in a batch 2014-11-25 16:26:35 +01:00
Wladimir J. van der Laan 397b9011c9
Merge pull request #5241
a206950 Introduce separate flushing modes (Pieter Wuille)
51ce901 Improve chainstate/blockindex disk writing policy (Pieter Wuille)
2014-11-25 12:18:00 +01:00
Wladimir J. van der Laan 1ee685f984
Merge pull request #5154
730b1ed Check pindexBestForkBase for null (21E14)
2014-11-24 15:29:52 +01:00
Pieter Wuille a206950016 Introduce separate flushing modes 2014-11-24 15:15:41 +01:00
Pieter Wuille 51ce901aa3 Improve chainstate/blockindex disk writing policy
There are 3 pieces of data that are maintained on disk. The actual block
and undo data, the block index (which can refer to positions on disk),
and the chainstate (which refers to the best block hash).

Earlier, there was no guarantee that blocks were written to disk before
block index entries referring to them were written. This commit introduces
dirty flags for block index data, and delays writing entries until the actual
block data is flushed.

With this stricter ordering in writes, it is now safe to not always flush
after every block, so there is no need for the IsInitialBlockDownload()
check there - instead we just write whenever enough time has passed or
the cache size grows too large. Also updating the wallet's best known block
is delayed until this is done, otherwise the wallet may end up referring to an
unknown block.

In addition, only do a write inside the block processing loop if necessary
(because of cache size exceeded). Otherwise, move the writing to a point
after processing is done, after relaying.
2014-11-24 15:15:40 +01:00
Wladimir J. van der Laan f24bcce2ac
Merge pull request #1816
b867e40 CreateNewBlock: Stick height in coinbase so we pass template sanity check (Luke Dashjr)
60755db submitblock: Check for duplicate submissions explicitly (Luke Dashjr)
bc6cb41 QA RPC tests: Add tests block block proposals (Luke Dashjr)
9765a50 Implement BIP 23 Block Proposal (Luke Dashjr)
3dcbb9b Abstract DecodeHexBlk and BIP22ValidationResult functions out of submitblock (Luke Dashjr)
132ea9b miner_tests: Disable checkpoints so they don't fail the subsidy-change test (Luke Dashjr)
df08a62 TestBlockValidity function for CBlock proposals (used by CreateNewBlock) (Luke Dashjr)
4ea1be7 CreateNewBlock and miner_tests: Also check generated template is valid by CheckBlockHeader, ContextualCheckBlockHeader, CheckBlock, and ContextualCheckBlock (Luke Dashjr)
a48f2d6 Abstract context-dependent block checking from acceptance (Luke Dashjr)
2014-11-24 14:43:10 +01:00
dexX7 7357893396
Prioritize and display -testsafemode status in UI
Like in a real world situation, a safe mode test should also be visible in the
UI. A test of safe mode is furthermore mostly relevant for developers, so it
should not be overwritten by a warning about a pre-release test build.
2014-11-23 13:10:31 +01:00
21E14 730b1ed1a0 Check pindexBestForkBase for null 2014-11-22 00:12:41 -05:00
Wladimir J. van der Laan f2ada138c2
Merge pull request #5170
092b58d CBlockIndex::GetBlockWork() + GetProofIncrement(nBits) -> GetBlockProof(CBlockIndex) (jtimon)
22c4272 MOVEONLY: Move void UpdateTime() from pow.o to miner.o (plus fix include main.h -> chain.h) (jtimon)
2014-11-21 14:33:22 +01:00
Pieter Wuille 34559c7c73 Make PruneBlockIndexCandidates safer 2014-11-20 12:43:50 +01:00
Daniel Kraft 57425a2425 Check block header before accepting it.
Previously, AcceptBlockHeader did not check the header (in particular
PoW).  This made the client accept invalid-PoW-headers from peers in
headers-first sync.
2014-11-20 08:28:19 +01:00
HarryWu 60d1ecd378 change nSubsidy's type from int64_t to CAmount 2014-11-19 14:01:18 +08:00
Luke Dashjr df08a626e0 TestBlockValidity function for CBlock proposals (used by CreateNewBlock) 2014-11-18 19:20:10 +00:00
Luke Dashjr a48f2d6ddd Abstract context-dependent block checking from acceptance 2014-11-18 19:20:10 +00:00
Wladimir J. van der Laan 0c7862e968
Merge pull request #5161
845c86d Do not use third party services for IP detection. (Gregory Maxwell)
2014-11-12 18:35:45 +01:00
21E14 cca48f69b0 Reset setBlockIndexCandidates once block index db loaded 2014-11-12 00:35:24 -05:00
Peter Todd 7c041b3b91
Check against MANDATORY flags prior to accepting to mempool
Previously transactions were only tested again the
STANDARD_SCRIPT_VERIFY_FLAGS prior to mempool acceptance, so any bugs in
those flags that allowed actually-invalid transactions to pass would
result in allowing invalid transactions into the mempool. Fortunately
there is a second check in CreateNewBlock() that would prevent those
transactions from being mined, resulting in an invalid block, however
this could still be exploited as a DoS attack.
2014-11-10 02:52:28 -05:00
Gregory Maxwell 845c86d128 Do not use third party services for IP detection.
This is a simplified re-do of closed pull #3088.

This patch eliminates the privacy and reliability problematic use
of centralized web services for discovering the node's addresses
for advertisement.

The Bitcoin protocol already allows your peers to tell you what
IP they think you have, but this data isn't trustworthy since
they could lie. So the challenge is using it without creating a
DOS vector.

To accomplish this we adopt an approach similar to the one used
by P2Pool: If we're announcing and don't have a better address
discovered (e.g. via UPNP) or configured we just announce to
each peer the address that peer told us. Since peers could
already replace, forge, or drop our address messages this cannot
create a new vulnerability... but if even one of our peers is
giving us a good address we'll eventually make a useful
advertisement.

We also may randomly use the peer-provided address for the
daily rebroadcast even if we otherwise have a seemingly routable
address, just in case we've been misconfigured (e.g. by UPNP).

To avoid privacy problems, we only do these things if discovery
is enabled.
2014-11-07 12:13:46 -08:00
Ruben Dario Ponticelli 9ec75c5ef4
Add a locking mechanism to IsInitialBlockDownload to ensure it never goes from false to true. 2014-11-07 08:09:31 -03:00
Wladimir J. van der Laan 0778333b8c
Merge pull request #5173
50b43fd Be a bit more verbose during -loadblock if we already have blocks (Matt Corallo)
8375e22 Fix -loadblock after shutdown during IBD (Matt Corallo)
4ead850 Fix for crash during block download (Matt Corallo)
2014-11-05 09:40:25 +01:00
Wladimir J. van der Laan 7f7fede0eb
Merge pull request #5157
b4ee0bd Introduce preferred download peers (Pieter Wuille)
2014-11-03 16:40:36 +01:00
Wladimir J. van der Laan 84d26d3a36
Merge pull request #5106
1bea2bb Rename ProcessBlock to ProcessNewBlock to indicate change of behaviour, and document it (Luke Dashjr)
d29a291 Rename RPC_TRANSACTION_* errors to RPC_VERIFY_* and use RPC_VERIFY_ERROR for submitblock (Luke Dashjr)
f877aaa Bugfix: submitblock: Use a temporary CValidationState to determine accurately the outcome of ProcessBlock, now that it no longer does the full block validity check (Luke Dashjr)
24e8896 Add CValidationInterface::BlockChecked notification (Luke Dashjr)
2014-11-03 12:22:45 +01:00
Matt Corallo 50b43fda08 Be a bit more verbose during -loadblock if we already have blocks 2014-10-29 17:02:48 -07:00
Matt Corallo 8375e2215f Fix -loadblock after shutdown during IBD 2014-10-29 17:01:18 -07:00
Matt Corallo 4ead850fe5 Fix for crash during block download 2014-10-29 17:01:01 -07:00
jtimon 092b58d13d CBlockIndex::GetBlockWork() + GetProofIncrement(nBits) -> GetBlockProof(CBlockIndex) 2014-10-29 21:01:07 +01:00
Pieter Wuille b4ee0bddad Introduce preferred download peers 2014-10-29 08:08:13 -07:00
Ruben Dario Ponticelli a2d0fc658a
Fix IsInitialBlockDownload which was broken by headers first. 2014-10-28 18:16:52 -03:00
Luke Dashjr 1bea2bbddc Rename ProcessBlock to ProcessNewBlock to indicate change of behaviour, and document it 2014-10-28 08:15:14 +00:00
Pieter Wuille 698c6abb25 Add SCRIPT_VERIFY_MINIMALDATA (BIP62 rules 3 and 4)
Also use the new flag as a standard rule, and replace the IsCanonicalPush
standardness check with it (as it is more complete).
2014-10-25 03:03:20 -07:00
Wladimir J. van der Laan 13bddef870
Merge pull request #4988
7b2bb96 Replace some function names with __func__ (Pieter Wuille)
ed6d1a2 Keep information about all block files in memory (Pieter Wuille)
2014-10-22 12:06:03 +02:00
Wladimir J. van der Laan f984c7d7ad
Merge pull request #5108
a873823 CAutoFile: Explicit Get() and remove unused methods (Wladimir J. van der Laan)
fef24ca Add IsNull() to class CAutoFile and remove operator ! (Ruben Dario Ponticeli)
2014-10-22 10:47:14 +02:00
Wladimir J. van der Laan a873823864
CAutoFile: Explicit Get() and remove unused methods
Also add documentation to some methods.
2014-10-22 10:18:19 +02:00
Pieter Wuille 7b2bb96271 Replace some function names with __func__ 2014-10-21 16:17:13 -07:00
Luke Dashjr 24e8896430 Add CValidationInterface::BlockChecked notification 2014-10-21 04:41:46 +00:00
Pieter Wuille a96d113962 Rename CWalletInterface to CValidationInterface
It's useful for much more than wallets.
2014-10-20 10:59:12 -07:00
Ruben Dario Ponticeli fef24cab1a Add IsNull() to class CAutoFile and remove operator ! 2014-10-20 12:46:56 +02:00
Pieter Wuille e11b2ce4c6 Fix large reorgs 2014-10-14 16:13:42 -07:00
Pieter Wuille afc32c5eea Fix rebuild-chainstate feature and improve its performance
Previous refactorings broke the ability to rebuild the chainstate by deleting the chainstate
directory, resulting in an incorrect "Incorrect or no genesis block found" error message. Fix
that.

Also, improve the performance of ActivateBestBlockStep by using the skiplist to only discover
a few potential blocks to connect at a time, instead of all blocks forever - as we likely bail
out after connecting a single one anyway.
2014-10-14 15:42:01 -07:00
Pieter Wuille 16d5194165 Skip reindexed blocks individually
Instead of skipping to the last reindexed block in each file (which could
jump over processed out-of-order blocks), just skip each already processed
block individually.
2014-10-14 15:42:01 -07:00
Wladimir J. van der Laan ad96e7ccd9 Make -reindex cope with out-of-order blocks
Remember out-of-order block headers along with disk positions. This is
likely the simplest and least-impact way to make -reindex work with
headers first.

Based on top of #4468.
2014-10-14 15:42:01 -07:00
Pieter Wuille e17bd58392 Rename setBlockIndexValid to setBlockIndexCandidates 2014-10-14 15:42:01 -07:00
R E Broadley 1af838b339 Add height to "Requesting block" debug 2014-10-14 15:42:01 -07:00
R E Broadley 1bcee67ee7 Better logging of stalling 2014-10-14 15:42:01 -07:00
R E Broadley 4c93322923 Improve getheaders (sending) logging 2014-10-14 15:42:01 -07:00
Pieter Wuille f244c99c96 Remove CheckMinWork, as we always know all parent headers 2014-10-14 15:42:01 -07:00
Pieter Wuille ad6e601712 RPC additions after headers-first 2014-10-14 15:42:01 -07:00
Pieter Wuille 341735eb8f Headers-first synchronization
Many changes:
* Do not use 'getblocks', but 'getheaders', and use it to build a headers tree.
* Blocks are fetched in parallel from all available outbound peers, using a
  limited moving window. When one peer stalls the movement of the window, it is
  disconnected.
* No more orphan blocks. At all. We only ever request a block for which we have
  verified the headers, and store it to disk immediately. This means that a
  disk-fill attack would require PoW.
* Require protocol version 31800 for every peer (released in december 2010).
* No more syncnode (we sync from everyone we can, though limited to 1 during
  initial *headers* sync).
* Introduce some extra named constants, comments and asserts.
2014-10-14 15:42:01 -07:00
Gavin Andresen 3222802ea1
Merge pull request #5059
dbca89b Trigger -alertnotify if network is upgrading without you (Gavin Andresen)
e01a793 Refactor -alertnotify code (Gavin Andresen)

Signed-off-by: Gavin Andresen <gavinandresen@gmail.com>
2014-10-09 10:39:29 -04:00
Gavin Andresen dbca89b74b
Trigger -alertnotify if network is upgrading without you
This adds a -regetest-only undocumented (for regression testing only)
command-line option -blockversion=N to set block.nVersion.

Adds to the "has the rest of the network upgraded to a
block.nVersion we don't understand" code so it calls
-alertnotify when 51 of the last 100 blocks are up-version.
But it only alerts once, not with every subsequent new, upversion
block.

And adds a forknotify.py regression test to make sure it works.

Tested using forknotify.py:

Before adding CAlert::Notify, get:
Assertion failed: -alertnotify did not warn of up-version blocks

Before adding code to only alert once:
Assertion failed: -alertnotify excessive warning of up-version blocks

After final code in this pull:
Tests successful
2014-10-09 10:28:27 -04:00
Gavin Andresen e01a7939d3
Refactor -alertnotify code
Refactor common -alertnotify code into static CAlert::Notify method.
2014-10-09 10:25:30 -04:00
Pieter Wuille d4a42334d4
Merge pull request #4834
7c70438 Get rid of the dummy CCoinsViewCache constructor arg (Pieter Wuille)
ed27e53 Add coins_tests with a large randomized CCoinViewCache test. (Pieter Wuille)
058b08c Do not keep fully spent but unwritten CCoins entries cached. (Pieter Wuille)
c9d1a81 Get rid of CCoinsView's SetCoins and SetBestBlock. (Pieter Wuille)
f28aec0 Use ModifyCoins instead of mutable GetCoins. (Pieter Wuille)
2014-10-08 14:58:16 -07:00
Philip Kaufmann 4dc5eb057c fix a lock indentation in main.cpp
- also ensure alphabetical ordering in file header
2014-10-06 13:04:02 +02:00
Pieter Wuille ed6d1a2c7b Keep information about all block files in memory 2014-10-06 07:32:00 +02:00
Wladimir J. van der Laan 5505a1b13f
Merge pull request #5036
eb6b3b2 Update English translation (Wladimir J. van der Laan)
b9b2e3f Don't translate state.Abort() messages (Wladimir J. van der Laan)
2014-10-06 04:42:09 +02:00
Wladimir J. van der Laan 5f1aee066a
Merge pull request #4890
e790c37 Replace SCRIPT_VERIFY_NOCACHE by flag directly to checker (Pieter Wuille)
5c1e798 Make signature cache optional (Pieter Wuille)
c7829ea Abstract out SignatureChecker (Pieter Wuille)
2014-10-06 04:39:17 +02:00
Pieter Wuille 5ccd735d30
Merge pull request #4887
4bb30a1 Correct logging AcceptBlock()->AcceptBlockHeader() (R E Broadley)
2014-10-03 04:31:44 +02:00
Wladimir J. van der Laan 0e64566a82
Merge pull request #4978
938bcce CAutoFile: make file private (Philip Kaufmann)
0c35486 CBufferedFile: add explicit close function (Philip Kaufmann)
c9fb27d CBufferedFile: convert into a non-refcounted RAII wrapper (Philip Kaufmann)
2014-10-02 22:35:36 +02:00
Wladimir J. van der Laan b9b2e3fabd Don't translate state.Abort() messages
There is only one message passed to AbortNode() that makes sense to
translate to the user specifically: Disk space is low. For the others
show a generic message and refer to debug.log for details.

Reduces the number of confusing jargon translation messages.
2014-10-02 22:20:16 +02:00
Pieter Wuille e790c370b5 Replace SCRIPT_VERIFY_NOCACHE by flag directly to checker 2014-10-02 20:26:58 +02:00
Pieter Wuille 5c1e798a8e Make signature cache optional 2014-10-02 20:26:17 +02:00
R E Broadley 4bb30a1eb8 Correct logging AcceptBlock()->AcceptBlockHeader() 2014-10-03 01:35:51 +08:00
SergioDemianLerner f0fd00cb77 Switch testing framework from MAIN to new UNITTEST network
UNITTEST inherites from MAIN but allows synamically changing its parameters using the ModifiableParams() interface
2014-10-02 13:51:39 +02:00
Philip Kaufmann c9fb27da0a CBufferedFile: convert into a non-refcounted RAII wrapper
- it now takes over the passed file descriptor and closes it in the
  destructor
- this fixes a leak in LoadExternalBlockFile(), where an exception could
  cause the file to not getting closed

- disallow copies (like recently added for CAutoFile)
- make nType and nVersion private
2014-10-02 10:46:31 +02:00
Wladimir J. van der Laan 8d132431b4
Revert merge of pull #4845
It breaks the new mingw tests!

See

- https://travis-ci.org/bitcoin/bitcoin/jobs/36845581
- https://travis-ci.org/bitcoin/bitcoin/jobs/36845582

This reverts commit 4705902777, 5e2e7fcb99, a25fd6be13.
2014-10-02 10:39:55 +02:00
Wladimir J. van der Laan ad51e14583
Merge pull request #4845
4705902 Avoid introducing a virtual into CChainParams (Wladimir J. van der Laan)
5e2e7fc Suggested corrections on comments, variable names. Also new test case testing the PoW skip in UNITTEST. (SergioDemianLerner)
a25fd6b Switch testing framework from MAIN to new UNITTEST network (SergioDemianLerner)
2014-10-02 09:47:54 +02:00
Wladimir J. van der Laan 00eef5d6e9
Merge pull request #5017
f74fc9b Print input index when signature validation fails, to aid debugging. (Mark Friedenbach)
217a5c9 When transaction outputs exceed inputs, show the offending amounts so as to aid debugging. (Mark Friedenbach)
2014-10-02 08:44:08 +02:00
Pieter Wuille 76c171033c
Merge pull request #4926
584a358 Do merkle root and txid duplicates check simultaneously (Pieter Wuille)
2014-10-02 06:10:19 +02:00
Mark Friedenbach f74fc9b22d Print input index when signature validation fails, to aid debugging. 2014-10-01 19:14:38 +02:00
Mark Friedenbach 217a5c9238 When transaction outputs exceed inputs, show the offending amounts so as to aid debugging. 2014-10-01 19:14:38 +02:00
Wladimir J. van der Laan 3fd192f8b4
Merge pull request #4234
c122f55 qt: Register CAmount metatype (Wladimir J. van der Laan)
a372168 Use a typedef for monetary values (Mark Friedenbach)
2014-10-01 11:28:55 +02:00
SergioDemianLerner 5e2e7fcb99 Suggested corrections on comments, variable names.
Also new test case testing the PoW skip in UNITTEST.
2014-09-29 13:03:23 +02:00
SergioDemianLerner a25fd6be13 Switch testing framework from MAIN to new UNITTEST network
UNITTEST inherites from MAIN but allows synamically changing its parameters using the ModifiableParams() interface
2014-09-29 13:03:22 +02:00
Pieter Wuille bf3a5dd7f0
Merge pull request #4796
e8b5f0d Move CBlockIndex, CChain and related code out of main (jtimon)
6db83db Decouple CChain from mapBlockIndex (jtimon)
2014-09-29 06:06:57 +02:00
Mark Friedenbach a372168e77 Use a typedef for monetary values 2014-09-26 15:42:04 -07:00
Cory Fields eee030f6bc autofile: don't copy CAutoFile by value 2014-09-25 19:25:19 -04:00
Pieter Wuille 584a358997 Do merkle root and txid duplicates check simultaneously
Move the txid duplicates check into BuildMerkleTree, where it can be done
much more efficiently (without needing to build a full txid set to detect
duplicates).

The previous version (using the std::set<uint256> to detect duplicates) was
also slightly too weak. A block mined with actual duplicate transactions
(which is invalid, due to the inputs of the duplicated transactions being
seen as double spends) would trigger the duplicates logic, resulting in the
block not being stored on disk, and rerequested. This change fixes that by
only triggering in the case of duplicated transactions that can actually
result in an identical merkle root.
2014-09-24 19:17:02 +02:00
Pieter Wuille 7c70438dc6 Get rid of the dummy CCoinsViewCache constructor arg 2014-09-24 03:19:04 +02:00
Pieter Wuille 058b08c147 Do not keep fully spent but unwritten CCoins entries cached.
Instead of storing CCoins entries directly in CCoinsMap, store a CCoinsCacheEntry
which additionally keeps track of whether a particular entry is:
* dirty: potentially different from its parent view.
* fresh: the parent view is known to not have a non-pruned version.

This allows us to skip non-dirty cache entries when pushing batches of changes up,
and to remove CCoins entries about transactions that are fully spent before the
parent cache learns about them.
2014-09-23 22:29:43 +02:00
Pieter Wuille c9d1a81ce7 Get rid of CCoinsView's SetCoins and SetBestBlock.
All direct modifications are now done through ModifyCoins, and BatchWrite is
used for pushing batches of queued modifications up, so we don't need the
low-level SetCoins and SetBestBlock anymore in the top-level CCoinsView class.
2014-09-23 22:29:21 +02:00
Pieter Wuille f28aec014e Use ModifyCoins instead of mutable GetCoins.
Replace the mutable non-copying GetCoins method with a ModifyCoins, which
returns an encapsulated iterator, so we can keep track of concurrent
modifications (as iterators can be invalidated by those) and run cleanup
code after a modification is finished.

This also removes the overloading of the 'GetCoins' name.
2014-09-23 22:29:12 +02:00
Pieter Wuille ab15b2ec71 Avoid copying undo data 2014-09-17 20:38:20 +02:00
Wladimir J. van der Laan 438c7e4cd2
Merge pull request #4555
6dcfda2 Don't pass nHashType to EvalScript nor CheckSig (jtimon)
2b23a87 Don't pass nHashType to VerifyScript (jtimon)
ce3649fb Remove CScriptCheck::nHashType (was always 0) (jtimon)
358562b Remove unused function main:VerifySignature (jtimon)
2014-09-17 13:44:22 +02:00
Pieter Wuille 13168ea46c
Merge pull request #4903
efad808 Avoid reject message feedback loops (Pieter Wuille)
2014-09-16 18:54:46 +02:00
Wladimir J. van der Laan f010344156
Merge pull request #4460
604ee2a Remove tx from AlreadyAskedFor list once we receive it, not when we process it. (R E Broadley)
2014-09-16 11:31:54 +02:00
Pieter Wuille 765f398436
Merge pull request #4875
f7e3637 Eliminate extra assignment (Suhas Daftuar)
ec7eb0f When reindexing check for file before trying to open (refactored) (Suhas Daftuar)
2014-09-16 03:21:21 +02:00
Suhas Daftuar f7e36370f3 Eliminate extra assignment 2014-09-15 09:56:10 -04:00
ENikS ec91092df8
Fixing compiler warning C4101
Github-Pull: #4856
2014-09-15 14:35:32 +02:00
Wladimir J. van der Laan c362c57568
Merge pull request #4798
d920f7d Move g_signals.SetBestChain(..) below SyncWithWallets (Cozz Lovan)
2014-09-15 10:32:59 +02:00
jtimon 6dcfda2dc4 Don't pass nHashType to EvalScript nor CheckSig 2014-09-12 20:04:31 +02:00
jtimon 2b23a87599 Don't pass nHashType to VerifyScript 2014-09-12 20:04:31 +02:00
jtimon ce3649fb61 Remove CScriptCheck::nHashType (was always 0) 2014-09-12 20:03:03 +02:00
jtimon 358562b651 Remove unused function main:VerifySignature 2014-09-12 20:03:03 +02:00
Pieter Wuille efad808aae Avoid reject message feedback loops 2014-09-12 17:50:31 +02:00
Gavin Andresen aa3c697e90
Store fewer orphan tx by default, add -maxorphantx option
There is no reason to store thousands of orphan transactions;
normally an orphan's parents will either be broadcast or
mined reasonably quickly.

This pull drops the maximum number of orphans from 10,000 down
to 100, and adds a command-line option (-maxorphantx) that is
just like -maxorphanblocks to override the default.
2014-09-10 14:09:40 -04:00
Gavin Andresen c74332c678
Stricter handling of orphan transactions
Prevent denial-of-service attacks by banning
peers that send us invalid orphan transactions
and only storing orphan transactions given to
us by a peer while the peer is connected.
2014-09-10 14:09:40 -04:00
Suhas Daftuar ec7eb0fa80 When reindexing check for file before trying to open (refactored) 2014-09-10 13:51:53 -04:00
Gavin Andresen def2fdb4b9
Fix crashing bug caused by orphan(s) with duplicate prevout.hash 2014-09-10 16:53:54 +02:00
Wladimir J. van der Laan d6af9856b0
Merge pull request #4878
540ac45 Avoid returning many "inv" orphans (Jeff Garzik)
d4168c8 Limit CNode::mapAskFor (Wladimir J. van der Laan)
2014-09-10 16:52:57 +02:00
Pieter Wuille f7cdcb80ab
Merge pull request #4822
629d75f Combine CCoinsViewCache's HaveCoins and const GetCoins into AccessCoins. (Pieter Wuille)
2014-09-10 01:44:30 +02:00
Pieter Wuille 1575c5171f
Merge pull request #4868
2c2cc5d Remove some unnecessary c_strs() in logging and the GUI (Philip Kaufmann)
f7d0a86 netbase: Use .data() instead of .c_str() on binary string (Wladimir J. van der Laan)
2014-09-09 16:43:06 +02:00
Philip Kaufmann 2c2cc5dac1
Remove some unnecessary c_strs() in logging and the GUI
Includes `core: remove unneeded c_str() / Qt: replace c_str() with Qt code`
by P. Kaufmann.
2014-09-09 11:31:17 +02:00
Jeff Garzik 540ac4514d Avoid returning many "inv" orphans 2014-09-09 09:26:52 +02:00
jtimon e8b5f0d549 Move CBlockIndex, CChain and related code out of main 2014-09-08 22:17:19 +02:00
jtimon 6db83db3eb Decouple CChain from mapBlockIndex 2014-09-08 22:14:24 +02:00
Wladimir J. van der Laan 89d91f6aa7 Avoid repeated lookups in mapOrphanTransactions and mapOrphanTransactionsByPrev 2014-09-08 17:38:43 +02:00
R E Broadley 346193bd93 Cleanup messy error messages 2014-09-06 14:18:32 +07:00
Pieter Wuille 145d5be896 Introduce BlockMap type for mapBlockIndex 2014-09-04 02:04:51 +02:00
Pieter Wuille a0dbe433bd checkpoints.cpp depends on main, it can use mapBlockIndex directly 2014-09-04 02:01:10 +02:00
Pieter Wuille 629d75faac Combine CCoinsViewCache's HaveCoins and const GetCoins into AccessCoins.
The efficient version of CCoinsViewCache::GetCoins only works for known-to-exist
cache entries, requiring a separate HaveCoins call beforehand. This is
inefficient as both perform a hashtable lookup.

Replace the non-mutable GetCoins with AccessCoins, which returns a potentially-NULL
pointer. This also decreases the overloading of GetCoins.

Also replace some copying (inefficient) GetCoins calls with equivalent AccessCoins,
decreasing the copying.
2014-09-03 14:24:52 +02:00
Wladimir J. van der Laan 93f97aab62
Merge pull request #4768
2e28031 Perform CVerifyDB on pcoinsdbview instead of pcoinsTip (Wladimir J. van der Laan)
2014-09-01 09:42:10 +02:00
Cozz Lovan d920f7dcf8 Move g_signals.SetBestChain(..) below SyncWithWallets 2014-08-31 16:17:39 +02:00
Jeff Garzik 135a43df7b
Merge pull request #4778 2014-08-29 20:22:06 -04:00
Jeff Garzik 309aa76d27
Merge pull request #4599 2014-08-29 15:23:13 -04:00
Wladimir J. van der Laan 0101483f46
Move CMerkleTx to wallet.cpp/h
It is only used by the wallet so it has no place in main.
2014-08-29 17:26:01 +02:00
Pieter Wuille d1062e32fa
Merge pull request #4377
654871d replace ComputeMinWork with CheckMinWork (jtimon)
b343c1a Move CBlockIndex::GetBlockWork() to pow::GetProofIncrement(nBits) (jtimon)
c2c02f3 Move UpdateTime to pow (jtimon)
2014-08-27 22:39:28 +02:00
Pieter Wuille cd3d80be67
Merge pull request #4764
92bb6f2 Bypass reloading blocks from disk (Pieter Wuille)
2014-08-27 22:21:33 +02:00
Wladimir J. van der Laan 70352e11c0
Revert "Add a getutxos command to the p2p protocol. It allows querying of the UTXO set"
This reverts commit da2ec100f3.
2014-08-27 18:04:29 +02:00
Wladimir J. van der Laan 2e280311b8
Perform CVerifyDB on pcoinsdbview instead of pcoinsTip
Bypassing the main coins cache allows more thorough checking with the same
memory budget.

This has no effect on performance because everything ends up in the child
cache created by VerifyDB itself.

It has bugged me ever since #4675, which effectively reduced the
number of checked blocks to reduce peak memory usage.

- Pass the coinsview to use as argument to VerifyDB

- This also avoids that the first `pcoinsTip->Flush()` after VerifyDB
  writes a large slew of unchanged coin records back to the database.
2014-08-27 09:20:33 +02:00
Pieter Wuille 3da58b216b
Merge pull request #4748
ad49c25 Split up util.cpp/h (Wladimir J. van der Laan)
f841aa2 Move `COIN` and `CENT` to core.h (Wladimir J. van der Laan)
6e5fd00 Move `*Version()` functions to version.h/cpp (Wladimir J. van der Laan)
b4aa769 Move `S_I*` constants and `MSG_NOSIGNAL` to compat.h (Wladimir J. van der Laan)
af8297c Move functions in wallet.h to implementation file (Wladimir J. van der Laan)
651480c move functions in main and net to implementation files (Wladimir J. van der Laan)
610a8c0 Move SetThreadPriority implementation to util.cpp instead of the header (Wladimir J. van der Laan)
f780e65 Remove unused function `ByteReverse` from util.h (Wladimir J. van der Laan)
121d6ad Remove unused `alignup` function from util.h (Wladimir J. van der Laan)
d1e26d4 Move CMedianFilter to timedata.cpp (Wladimir J. van der Laan)
2014-08-26 16:57:05 +02:00
Wladimir J. van der Laan ad49c256c3 Split up util.cpp/h
Split up util.cpp/h into:

- string utilities (hex, base32, base64): no internal dependencies, no dependency on boost (apart from foreach)
- money utilities (parsesmoney, formatmoney)
- time utilities (gettime*, sleep, format date):
- and the rest (logging, argument parsing, config file parsing)

The latter is basically the environment and OS handling,
and is stripped of all utility functions, so we may want to
rename it to something else than util.cpp/h for clarity (Matt suggested
osinterface).

Breaks dependency of sha256.cpp on all the things pulled in by util.
2014-08-26 13:25:22 +02:00
Wladimir J. van der Laan 651480c8e4 move functions in main and net to implementation files 2014-08-26 13:25:21 +02:00
Daniel Kraft d0867acb0e Use const CCoinsView's at some places.
At some places where it is possible (e. g., CheckInputs), use a const
version of CCoinsView instead of a non-const one.
2014-08-26 11:29:18 +02:00
Pieter Wuille 92bb6f2f17 Bypass reloading blocks from disk 2014-08-26 02:26:41 +02:00
Wladimir J. van der Laan 49f954f154
Merge pull request #4716
0d27dad Clean-up SyncWithWallets/SyncTransaction (Cozz Lovan)
2014-08-25 15:04:28 +02:00
Wladimir J. van der Laan 11270ebde4
Merge pull request #4351
da2ec10 Add a getutxos command to the p2p protocol. It allows querying of the UTXO set given a set of outpoints. (Mike Hearn)
2014-08-25 10:37:40 +02:00
Pieter Wuille 5cd00bc8cb
Merge pull request #4618
eb0b56b Simplify serialize.h's exception handling (Pieter Wuille)
2014-08-24 02:06:09 +02:00
jtimon 654871d436 replace ComputeMinWork with CheckMinWork 2014-08-23 13:21:51 +02:00
jtimon c2c02f3fa9 Move UpdateTime to pow 2014-08-23 13:21:50 +02:00
Wladimir J. van der Laan 3802224110 Remove all other print() methods
All unused.
2014-08-20 20:54:27 +02:00
Wladimir J. van der Laan 21e7a5690f
Merge pull request #4655
216e9a4 Add a way to limit deserialized string lengths (Pieter Wuille)
2014-08-18 09:55:24 +02:00
Cozz Lovan 0d27dad845 Clean-up SyncWithWallets/SyncTransaction 2014-08-17 17:39:30 +02:00
Jeff Garzik c7b6117deb Create new signal for notification of new blocks. Use w/ -blocknotify 2014-08-14 12:32:34 -04:00
Jeff Garzik beb36e800c ui_interface: remove unused NotifyBlocksChanged signal 2014-08-14 12:19:54 -04:00
Peter Todd 9ee09dc64f
Reapply: Reject transactions with excessive numbers of sigops
Reverting was based on a misunderstanding, it appears.

Github-Pull: #4150
2014-08-13 14:37:56 +02:00
Wladimir J. van der Laan 3b72fdfb86 Revert "Reject transactions with excessive numbers of sigops"
This reverts commit 4fad8e6d83.
2014-08-12 15:06:20 +02:00
Wladimir J. van der Laan 8ebe42435a
Merge pull request #4150
4fad8e6 Reject transactions with excessive numbers of sigops (Peter Todd)
2014-08-12 14:57:13 +02:00
Mike Hearn da2ec100f3 Add a getutxos command to the p2p protocol. It allows querying of the UTXO set
given a set of outpoints.
2014-08-11 13:59:47 +02:00
Wladimir J. van der Laan ea100c73fa Reduce maximum coinscache size during verification
Due to growing coinsviewcaches, the memory usage with checklevel=3
(and standard settings for dbcache) could be up to 500MiB on a
64-bit system. This is about twice the peak during reindexing,
unnecessarily extending bitcoind's memory envelope.

This commit reduces the maximum total size of the caches used during
verification to just nCoinCacheSize, which should be the limit.
2014-08-11 08:43:06 +02:00
Pieter Wuille eb0b56b190 Simplify serialize.h's exception handling
Remove the 'state' and 'exceptmask' from serialize.h's stream implementations,
as well as related methods.

As exceptmask always included 'failbit', and setstate was always called with
bits = failbit, all it did was immediately raise an exception. Get rid of
those variables, and replace the setstate with direct exception throwing
(which also removes some dead code).

As a result, good() is never reached after a failure (there are only 2
calls, one of which is in tests), and can just be replaced by !eof().

fail(), clear(n) and exceptions() are just never called. Delete them.
2014-08-09 01:43:23 +02:00
Pieter Wuille 216e9a4456 Add a way to limit deserialized string lengths
and use it for most strings being serialized.
2014-08-09 01:37:16 +02:00
Jeff Garzik 70b9d36a2c
Log "version" message IP addresses in client connect summary
The only other method of logging remote addresses is via

     -logips=1 -debug=net

which increases the logged activity by 100x or more.

Github-Pull: #4608
Amended-By: Wladimir J. van der Laan <laanwj@gmail.com>
2014-08-04 16:59:28 +02:00
Daniel Kraft b33bd7a3be Implement "getchaintips" RPC command to monitor blockchain forks.
Port over https://github.com/chronokings/huntercoin/pull/19 from
Huntercoin:  This implements a new RPC command "getchaintips" that can be
used to find all currently active chain heads.  This is similar to the
-printblocktree startup option, but it can be used without restarting
just via the RPC interface on a running daemon.
2014-08-03 18:12:19 +02:00
Pieter Wuille e8cb5c30b0
Merge pull request #4497
714a3e6 Only keep setBlockIndexValid entries that are possible improvements (Pieter Wuille)
2014-07-31 00:07:47 +02:00
Pieter Wuille d70bc52ee3 Rework block processing benchmark code
* Replace -benchmark (and the related fBenchmark) with a regular debug option, -debug=bench.
* Increase coverage and granularity of individual block processing steps.
* Add cummulative times.
2014-07-27 00:41:03 +02:00
Wladimir J. van der Laan 70d0325999
Merge pull request #4496
5734d4d Only remove actualy failed blocks from setBlockIndexValid (Pieter Wuille)
2014-07-24 16:55:48 +02:00
Wladimir J. van der Laan 98e84aae7a Revert "Relay double-spends, subject to anti-DOS"
This reverts commit d640a3ceab.
2014-07-21 07:46:34 +02:00
Wladimir J. van der Laan ad26dc9c31 Revert "Formatting, spelling, comment fixes."
This reverts commit 7a19efe040.
2014-07-21 07:46:33 +02:00
Wladimir J. van der Laan cd057bfd41 Revert "Check signatures before respend relay"
This reverts commit 88dd3598d2.
2014-07-21 07:46:33 +02:00
Wladimir J. van der Laan 67cc8f25c2 Revert "Remove signal DoubleSpendDetected, use function"
This reverts commit 0da6b3fd18.
2014-07-21 07:46:33 +02:00
Jeff Garzik 3da434a2ef Introduce option to disable relay/mining of bare multisig scripts in TX outputs
First and foremost, this defaults to OFF.

This option lets a node consider such transactions non-standard,
meaning they will not be relayed or mined by default, but other miners
are free to mine these as usual.
2014-07-18 10:16:47 -04:00
Wladimir J. van der Laan ea8c288a35
Merge pull request #4533
43005cf Fix semantic typo in state.CorruptionPossible check (kazcw)
2014-07-17 13:57:51 +02:00
R E Broadley 604ee2aa7d Remove tx from AlreadyAskedFor list once we receive it, not when we process it. 2014-07-16 18:00:34 +07:00
Wladimir J. van der Laan 2c0f019bfc
Merge pull request #4505
d4d3fbd Do not flush the cache after every block outside of IBD (Pieter Wuille)
2014-07-15 09:14:33 +02:00
kazcw 43005cffa3 Fix semantic typo in state.CorruptionPossible check
state.Invalid() is always false, check should be IsInvalid()

Broken since 942b33a
2014-07-14 19:57:43 -07:00
Wladimir J. van der Laan 6513a9f703
Merge pull request #4400
4eedf4f make RandAddSeed() use OPENSSL_cleanse() (Philip Kaufmann)
6354935 move rand functions from util to new random.h/.cpp (Philip Kaufmann)
001a53d add GetRandBytes() as wrapper for RAND_bytes() (Philip Kaufmann)
2014-07-14 11:35:30 +02:00
Wladimir J. van der Laan c9bc398ad9
Merge pull request #4378
dc942e6 Introduce whitelisted peers. (Pieter Wuille)
2014-07-14 10:23:39 +02:00
Peter Todd 4fad8e6d83
Reject transactions with excessive numbers of sigops 2014-07-13 10:12:49 -04:00
Pieter Wuille d4d3fbd828 Do not flush the cache after every block outside of IBD 2014-07-11 16:44:53 +02:00