aboutsummaryrefslogtreecommitdiff
path: root/src/validation.cpp
AgeCommit message (Collapse)Author
2017-06-01Reduce reserved memory space for flushingPieter Wuille
As the maximum amount of data that can be pulled into the cache due to a block validation is much lower now (at most one CCoin entry per input and per output), reduce the conservative estimate used to determine flushing time.
2017-06-01Switch CCoinsView and chainstate db from per-txid to per-txoutPieter Wuille
This patch makes several related changes: * Changes the CCoinsView virtual methods (GetCoins, HaveCoins, ...) to be COutPoint/Coin-based rather than txid/CCoins-based. * Changes the chainstate db to a new incompatible format that is also COutPoint/Coin based. * Implements reconstruction code for hash_serialized_2. * Adapts the coins_tests unit tests (thanks to Russell Yanofsky). A side effect of the new CCoinsView model is that we can no longer use the (unreliable) test for transaction outputs in the UTXO set to determine whether we already have a particular transaction.
2017-06-01Switch CScriptCheck to use Coin instead of CCoinsPieter Wuille
2017-06-01Only pass things committed to by tx's witness hash to CScriptCheckMatt Corallo
This clarifies a bit more the ways in which the new script execution cache could break consensus in the future if additional data from the CCoins object were to be used as a part of script execution. After this change, any such consensus breaks should be very visible to reviewers, hopefully ensuring no such changes can be made.
2017-06-01Switch from per-tx to per-txout CCoinsViewCache methods in some placesPieter Wuille
2017-06-01Optimization: Coin&& to ApplyTxInUndoPieter Wuille
This avoids a prevector copy in ApplyTxInUndo.
2017-06-01Replace CTxInUndo with CoinPieter Wuille
The earlier CTxInUndo class now holds the same information as the Coin class. Instead of duplicating functionality, replace CTxInUndo with a serialization adapter for Coin.
2017-05-26Store/allow tx metadata in all undo recordsPieter Wuille
Previously, transaction metadata (height, coinbase or not, and before the previous commit also nVersion) was only stored for undo records that correspond to the last output of a transaction being spent. This only saves 2 bytes per undo record. Change this to storing this information for every undo record, and stop complaining for having it in non-last output spends. This means that undo dat written with this patch won't be readable by older versions anymore.
2017-05-26Remove/ignore tx version in utxo and undoPieter Wuille
This makes the following changes: * In undo data and the chainstate database, the transaction nVersion field is removed from the data structures, always written as 0, and ignored when reading. * The definition of hash_serialized in gettxoutsetinfo is changed to no longer incude the nVersion field. It is renamed to hash_serialized_2 to avoid confusion. The new definition also includes transaction height and coinbase information, as this information was missing before. This depends on having a CHashVerifier-based undo data checksum verifier. Apart from changing the definition of serialized_hash, downgrading after using this patch is supported, as no release ever used the value of nVersion field in UTXO entries.
2017-05-26Introduce CHashVerifier to hash read dataPieter Wuille
This is necessary later, when we drop the nVersion field from the undo data. At that point deserializing and reserializing the data won't roundtrip anymore, and thus that approach can't be used to verify checksums anymore. With this CHashVerifier approach, we can deserialize while hashing the exact serialized form that was used. This is both more efficient and more correct in that case.
2017-05-26error() in disconnect for disk corruption, not inconsistencyPieter Wuille
The error() function unconditionally reports an error. It should only be used for actually exception situations, and not for the type of inconsistencies that ApplyTxInUndo/DisconnectBlock can graciously deal with. This also makes a subtle semantics change: in ApplyTxInUndo, when a record with metadata is encountered (indicating it is the last spend from a tx), don't wipe the CCoins record if it wasn't empty at that point. This makes sure that UTXO operations never affect any other UTXOs (including those from the same tx).
2017-05-23Merge #10347: Use range-based for loops (C++11) when looping over vector ↵Pieter Wuille
elements 211adc0 Use range-based for loops (C++11) when looping over vector elements (practicalswift) Tree-SHA512: 0e007f20dcef99d3c7a1036265e00f689d69f42e02fd82dd8389f45b52d31947e5f9388de2610d3d9bd9f554915ce0d35ebce561e5ae3a9013956d0ee4937145
2017-05-23Merge #9571: RPC: getblockchaininfo returns BIP signaling statisticsWladimir J. van der Laan
557c9a6 RPC: getblockchaininfo: BIP9 stats (Matthew Zipkin) Tree-SHA512: ecf0bf47f04f92becc77acc649fdfa270e768939acce42df39d30069398d40d9a30539862f7c307e08239f78d5c58c470ca5f6e717d2ab8e24db9be0dd7bec0c
2017-05-19Use range-based for loops (C++11) when looping over vector elementspracticalswift
2017-05-18Merge #8329: Consensus: MOVEONLY: Move functions for tx verificationWladimir J. van der Laan
618d07f MOVEONLY: tx functions to consensus/tx_verify.o (Jorge Timón) Tree-SHA512: 63fa2777c070a344dbfe61974526a770d962e049881c6f371b0034b1682c1e6e24f47454f01ee35ded20ade34488e023d4467a05369662906b99a73bb5de8497
2017-05-11Output line to debug.log when IsInitialBlockDownload latches to falseAlex Morcos
2017-05-02Merge #10297: Simplify DisconnectBlock arguments/return valuePieter Wuille
db994b2 Simplify DisconnectBlock arguments/return value (Pieter Wuille) Tree-SHA512: 62ce1a85bde2a5baffb9173ed28f2d8008200ecf8b09332122f1516fe68b33b9d7223cc1c2fffe804e38f767874c6353b76bd483e8ad7d48c4a5e80d6b683039
2017-05-02Merge #10175: Remove excess logic.Wladimir J. van der Laan
9a763d4 Remove excess logic. (practicalswift) Tree-SHA512: cfef280cc9cccf5042c9c49a8cd6fb6700764671cdd0d988149121f56c2d43a9ac38c5fc99c92385a9619d2d846480e02a9d655fa2586b1c284961b4634c229b
2017-05-01Fix potential NPD introduced in b297426cMatt Corallo
See https://github.com/bitcoin/bitcoin/pull/10290#discussion_r113954232 for more info.
2017-04-28Simplify DisconnectBlock arguments/return valuePieter Wuille
DisconnectBlock currently has a complicated interface: Situation Return value pfClean != nullptr pfClean == nullptr All good: true true Failure: false false Unclean rewind: true false with *pfClean=false Change this to return a tristate enum instead. As an added bonus, remove the ValidationState& argument which was unused.
2017-04-27Add -stopatheight for benchmarkingPieter Wuille
2017-04-21Merge #10201: pass Consensus::Params& to ReceivedBlockTransactions()Wladimir J. van der Laan
25660e9 pass Consensus::Params& to ReceivedBlockTransactions() (Mario Dian) Tree-SHA512: d3a5b19d93313e4bda622b322bc9cbfb7e31486010eac40fca6eea9703f814f9667f778122ba7366bb304482a2c03e2e3325083beecac374751692361952e467
2017-04-20Merge #10181: Include cleanupWladimir J. van der Laan
1c897fc Missing includes (Jorge Timón) a1fd450 Trivial: Remove unneeded includes from .h: (Jorge Timón) Tree-SHA512: ada3e62cc2435e58172a88b380be371b717a05725956c15e5493b6e19fe2903e5e6e43fd22dc24699333a0e8a0c7b42eb1ae61b41cb4ba82495be18e2d4ef3c6
2017-04-20Merge #9942: Refactor CBlockPolicyEstimatorWladimir J. van der Laan
68af651 MOVEONLY: move TxConfirmStats to cpp (Alex Morcos) 2332f19 Initialize TxConfirmStats in constructor (Alex Morcos) 5ba81e5 Read and Write fee estimate file directly from CBlockPolicyEstimator (Alex Morcos) 14e10aa Call estimate(Smart)Fee directly from CBlockPolicyEstimator (Alex Morcos) dbb9e36 Give CBlockPolicyEstimator it's own lock (Alex Morcos) f6187d6 Make processBlockTx private. (Alex Morcos) ae7327b Make feeEstimator its own global instance of CBlockPolicyEstimator (Alex Morcos) Tree-SHA512: dbf3bd2b30822e609a35f3da519b62d23f8a50e564750695ddebd08553b4c01874ae3e07d792c6cc78cc377d2db33b951ffedc46ac7edaf5793f9ebb931713af
2017-04-13pass Consensus::Params& to ReceivedBlockTransactions()Mario Dian
2017-04-13Remove CValidationInterface::UpdatedTransactionMatt Corallo
This removes another callback from block connection logic, making it easier to reason about the wallet-RPCs-returns-stale-info issue. UpdatedTransaction was previously used by the GUI to display coinbase transactions only after they have a block built on top of them. This worked fine for in most cases, but only worked due to a corner case if the user received a coinbase payout in a block immediately prior to restart. In that case, the normal process of caching the most recent coinbase transaction's hash would not work, and instead it would only work because of the on-load -checkblocks calling DisconnectBlock and ConnectBlock on the current tip. In order to make this more robust, a full mapWallet loop after the first block which is connected after restart was added.
2017-04-13Trivial: Remove unneeded includes from .h:Jorge Timón
- validation.h doesn't need to include chain.h anymore - Remove unneeded includes from net.h
2017-04-10Make DisconnectBlock and ConnectBlock static in validation.cppMatt Corallo
2017-04-10Merge #9725: CValidationInterface CleanupsWladimir J. van der Laan
b1a6d4c Take a CTransactionRef in AddToWalletIfInvolvingMe to avoid a copy (Matt Corallo) 1c95e2f Use std::shared_ptr instead of boost::shared_ptr in ScriptForMining (Matt Corallo) 91f1e6c Remove dead-code tracking of requests for blocks we generated (Matt Corallo) acad82f Add override to functions using CValidationInterface methods (Matt Corallo) e6d5e6c Hold cs_wallet for whole block [dis]connection processing (Matt Corallo) 461e49f SyncTransaction->TxAddedToMempool/BlockConnected/Disconnected (Matt Corallo) f404334 Handle SyncTransaction in ActivateBestChain instead of ConnectTrace (Matt Corallo) a147687 Keep conflictedTxs in ConnectTrace per-block (Matt Corallo) d3167ba Handle conflicted transactions directly in ConnectTrace (Matt Corallo) 29e6e23 Make ConnectTrace::blocksConnected private, hide behind accessors (Matt Corallo) 822000c Add pblock to connectTrace at the end of ConnectTip, not start (Matt Corallo) f5e9a01 Include missing #include in zmqnotificationinterface.h (Matt Corallo) Tree-SHA512: 8893d47559da3b28d2ef7359768547cba8a4b43b6f891d80f5848f995a84b1517bfb0f706fdc8cd43f09a1350349eb440d9724a59363ab517dfcc4fcb31b2018
2017-04-10Make feeEstimator its own global instance of CBlockPolicyEstimatorAlex Morcos
2017-04-10Merge #10135: [p2p] Send the correct error code in reject messagesWladimir J. van der Laan
5d08c9c Send the correct error code in reject messages (John Newbery) Tree-SHA512: 0cd3ef3ae202584b138cc0bbfba4125635822e0c5a755fb9276a604b39286959ab22dabc3104aa5d7e71358cd69d965de2a333ff04bf3e8ed43cf0296ac01264
2017-04-10Remove excess logic.practicalswift
2017-04-07SyncTransaction->TxAddedToMempool/BlockConnected/DisconnectedMatt Corallo
This simplifies fixing the wallet-returns-stale-info issue as we can now hold cs_wallet across an entire block instead of only per-tx (though we only actually do so in the next commit). This change also removes the NOT_IN_BLOCK constant in favor of only passing the CBlockIndex* parameter to SyncTransactions when a new block is being connected, instead of also when a block is being disconnected. This change adds a parameter to BlockConnectedDisconnected which lists the transactions which were removed from mempool due to confliction as a result of this operation. While its somewhat of a shame to make block-validation-logic generate a list of mempool changes to be included in its generated callbacks, fixing this isnt too hard. Further in this change-set, CValidationInterface starts listening to mempool directly, placing it in the middle and giving it a bit of logic to know how to route notifications from block-validation, mempool, etc (though not listening for conflicted-removals yet).
2017-04-07Handle SyncTransaction in ActivateBestChain instead of ConnectTraceMatt Corallo
This makes a later change to move it all into one per-block callback simpler.
2017-04-07Keep conflictedTxs in ConnectTrace per-blockMatt Corallo
2017-04-07Handle conflicted transactions directly in ConnectTraceMatt Corallo
2017-04-07Make ConnectTrace::blocksConnected private, hide behind accessorsMatt Corallo
2017-04-07Add pblock to connectTrace at the end of ConnectTip, not startMatt Corallo
This makes ConnectTip responsible for the ConnectTrace instead of splitting the logic between ActivateBestChainStep and ConnectTip
2017-04-06MOVEONLY: tx functions to consensus/tx_verify.oJorge Timón
Functions related to transaction verification.
2017-04-06Merge #9902: Lightweight abstraction of boost::filesystemWladimir J. van der Laan
f110272 Remove `namespace fs=fs` (Wladimir J. van der Laan) 75594bd torcontrol: Use fs::path instead of std::string for private key path (Wladimir J. van der Laan) 2a5f574 Use fsbridge for fopen and freopen (Wladimir J. van der Laan) bac5c9c Replace uses of boost::filesystem with fs (Wladimir J. van der Laan) 7d5172d Replace includes of boost/filesystem.h with fs.h (Wladimir J. van der Laan) 19e36bb Add fs.cpp/h (Wladimir J. van der Laan) Tree-SHA512: 2c34f059dfa6850b9323f3389e9090a6b5f839a457a2960d182c2ecfafd9883c956f5928bb796613402d3aad68ebc78259796a7a313f4a6cfa98aaf507a66842
2017-04-05Merge #10133: Clean up calculations of pcoinsTip memory usageWladimir J. van der Laan
1b55e07 Make threshold for flushing more conservative. (Alex Morcos) f33afd3 Lower default memory footprint slightly (Alex Morcos) 5b95a19 Make pcoinsTip memory calculations consistent (Alex Morcos) Tree-SHA512: d0061138596cf89008397b8729d9b25293938b1ad454cc99a6fe2f6210e94f76dfa78a8f0fce4c1ba3efec4e742a9c1a3ab26676a4a8346d3e7c3055d032669b
2017-04-03Use fsbridge for fopen and freopenWladimir J. van der Laan
Abstracts away how a path is opened to a `FILE*`. Reduces the number of places where path is converted to a string for anything else but printing.
2017-04-03Replace uses of boost::filesystem with fsWladimir J. van der Laan
Step two in abstracting away boost::filesystem. To repeat this, simply run: ``` git ls-files \*.cpp \*.h | xargs sed -i 's/boost::filesystem/fs/g' ```
2017-04-03Replace includes of boost/filesystem.h with fs.hWladimir J. van der Laan
This is step one in abstracting the use of boost::filesystem.
2017-04-02Make GetWitnessCommitmentIndex callable on blocks without a coinbase txn.Gregory Maxwell
This isn't actually needed anywhere, but it's less brittle.
2017-04-01Change LogAcceptCategory to use uint32_t rather than sets of strings.Gregory Maxwell
This changes the logging categories to boolean flags instead of strings. This simplifies the acceptance testing by avoiding accessing a scoped static thread local pointer to a thread local set of strings. It eliminates the only use of boost::thread_specific_ptr outside of lockorder debugging. This change allows log entries to be directed to multiple categories and makes it easy to change the logging flags at runtime (e.g. via an RPC, though that isn't done by this commit.) It also eliminates the fDebug global. Configuration of unknown logging categories now produces a warning.
2017-03-31Make threshold for flushing more conservative.Alex Morcos
Always leave a reasonable buffer of 50MB for usage from newly connected block (once over 50%) and increase the high water mark buffer to 200MB.
2017-03-31Send the correct error code in reject messagesJohn Newbery
2017-03-31Make pcoinsTip memory calculations consistentAlex Morcos
Since we are more accurately measuring pcoinsTip peak usage at twice the current in dynamic usage, it makes sense to double the default (this will lead to the same effective usage and peak usage as previously). We should also double the buffer used to avoid flushing if above 90% but still sufficient space remaining.
2017-03-30Compensate for memory peak at flush timePieter Wuille