aboutsummaryrefslogtreecommitdiff
path: root/src/validation.cpp
AgeCommit message (Collapse)Author
2019-04-27Merge #15778: [wallet] Move maxtxfee from node to walletMarcoFalke
5c759c73b2 [wallet] Move maxTxFee to wallet (John Newbery) Pull request description: Closes #15355 Moves the `-maxtxfee` from the node to the wallet. See discussion in issue for details. This is a cleanup. There is no change in behaviour. Completes #15620 ACKs for commit 5c759c: MarcoFalke: utACK 5c759c73b2602c7fde1c50dbafe5525904c1b64c ryanofsky: utACK 5c759c73b2602c7fde1c50dbafe5525904c1b64c. Changes since last review: updated commit message and an error message and method name. meshcollider: utACK https://github.com/bitcoin/bitcoin/pull/15778/commits/5c759c73b2602c7fde1c50dbafe5525904c1b64c Tree-SHA512: 2f9b2729da3940a5cda994d3f3bc11ee1a52fcc1c5e9842ea0ea63e4eb0300e8416853046776311298bc449ba07554aa46f0f245ce28598a5b0bd7347c12e752
2019-04-26Merge #15267: doc: explain AcceptToMemoryPoolWorker's coins_to_uncacheMarcoFalke
5d26205272 doc: explain AcceptToMemoryPoolWorker's coins_to_uncache (James O'Beirne) Pull request description: I found ATMPW's `coins_to_uncache` a little hard to understand (see #15264). This adds some doc for posterity. ACKs for commit 5d2620: jnewbery: ACK 5d262052728acdaa2d108a35ba9921a23b3d761a Tree-SHA512: 088508fa78012fab8680663c4e30f5cee29768416c2ca8b8b2abc29b6ac7067c5a589674f0254474a7ccc95477889d41719760f5796792bf492f51b3dd499c6c
2019-04-26doc: explain AcceptToMemoryPoolWorker's coins_to_uncacheJames O'Beirne
2019-04-19Merge #15655: Resolve the checkpoints <-> validation circular dependencyMarcoFalke
418d3230f8 Resolve the checkpoints <-> validation CD. (251) Pull request description: This pull request attempts to resolve the `checkpoints -> validation -> checkpoints` circular dependency. The circular dependency is resolved by moving the `CheckPoints::GetLastCheckpoint(const CCheckpointData& data)` function to `validation.cpp` where it used exclusively by the private function `ContextualCheckBlockHeader(const CBlockHeader& block, CValidationState& state, const CChainParams& params, const CBlockIndex* pindexPrev, int64_t nAdjustedTime)`. ACKs for commit 418d32: promag: utACK 418d323, only `GetLastCheckpoint` usage is in `validation.cpp` and so makes sense to move it there. practicalswift: utACK 418d3230f86f77dde6e817f502baff8a54b707fa MarcoFalke: utACK 418d3230f86f77dde6e817f502baff8a54b707fa sipa: utACK 418d3230f86f77dde6e817f502baff8a54b707fa Tree-SHA512: 03c3556bc192e65f5e3fa76fd545d4ee7d63d3fb06b132f7a1fa6131aa21ddd2e5b2d19e2222dfe524f422daaca30efde219bed188db8c74ff4b088876b5bc16
2019-04-18[wallet] Move maxTxFee to walletJohn Newbery
This commit moves the maxtxfee setting to the wallet. There is only one minor behavior change: - an error message in feebumper now refers to -maxtxfee instead of maxTxFee.
2019-04-10Merge #15638: Move-only: Pull wallet code out of libbitcoin_serverWladimir J. van der Laan
4d074e84a2cf419510e2920417799f62747f4b07 [build] Move AnalyzePSBT from psbt.cpp to node/psbt.cpp (Russell Yanofsky) fd509bd1f71df628b933ea7a135a9a957a5e0136 [docs] Document src subdirectories and different libraries (John Newbery) 9eaeb7fb8d4ab0d4493849e6c17e314fd75fea9c [build] Move wallet load functions to wallet/load unit (John Newbery) 91a25d1e711bfc0617027eee18b9777ff368d6b9 [build] Add several util units (John Newbery) 99517866b62c261f990e1f897502855afc12f2a7 [build] Move several units into common libraries (John Newbery) 0509465542d63a5bbe7296f283f44dd491e74f78 [build] Move rpc rawtransaction util functions to rpc/rawtransaction_util.cpp (John Newbery) 1acc61f8746bc6efb905e121a9f607c4f5982b35 [build] Move rpc utility methods to rpc/util (John Newbery) 4a75c9d6512a5580e60104103ea11d2cd9586354 [build] Move policy settings to new src/policy/settings unit (John Newbery) fdf8888b6f0c63e8a4cb1459752625e642d6a4dd [build] Move CheckTransaction from lib_server to lib_consensus (John Newbery) Pull request description: This is a move-only commit. No code is changing and the moves can be easily verified with: ```sh git log -p -n1 --color-moved=dimmed_zebra ``` This commit moves functions and variables that wallet code depends on out of libbitcoin_server.a, so the bitcoin-wallet tool can be built without libbitcoin_server.a in #15639, and attempting to access server state from wallet code will result in link errors instead of silently broken code. List of moves: - `CheckTransaction` moves from `consensus/tx_verify.cpp` to `consensus/tx_check.cpp` - `urlDecode` moves from `httpserver.cpp` to `util/url.cpp` - `TransactionErrorString` moves from `node/transaction.cpp` to `util/error.cpp` - `StringForFeeReason` and `FeeModeFromString` move from `policy/fees.cpp` to `util/fees.cpp` - `incrementalRelayFee` `dustRelayFee` and `nBytesPerSigOp` move from `policy/policy.cpp` to `policy/settings.cpp` - `SignalsOptInRBF` moves from `policy/rbf.cpp` to `util/rbf.cpp` - `fIsBareMultisigStd` moves from `validation.cpp` to `policy/settings.cpp` - `ConstructTransaction` `TxInErrorToJSON` and `SignTransaction` move from `rpc/rawtransaction.cpp` to `rpc/rawtransaction_util.cpp` - `RPCTypeCheck` `RPCTypeCheckArgument` `RPCTypeCheckObj` `AmountFromValue` `ParseHashV``ParseHashO` `ParseHexV` `ParseHexO` `HelpExampleCli` and `HelpExampleRpc` move from `rpc/server.cpp` to `rpc/util.cpp` - `AmountHighWarn` and `AmountErrMsg` move from `ui_interface.cpp` to `util/error.cpp` - `FormatStateMessage` and `strMessageMagic` move from `validation.cpp` to `util/validation.cpp` - `VerifyWallets` `LoadWallets` `StartWallets` `FlushWallets` `StopWallets` and `UnloadWallets` move from `wallet/init.cpp` to `wallet/node.cpp` ACKs for commit 4d074e: jnewbery: utACK 4d074e84a2cf419510e2920417799f62747f4b07 (checked by doing the rebase myself and verifying no difference between my branch and 4d074e84a2cf419510e2920417799f62747f4b07) Tree-SHA512: 5e1604a9fb06475f2b96da0de0baa8330f4dda834dc20a0183ef11e1e4c27631d1d1bbb9abf0054efc03d56945fdf9920f63366b6a4f200f665b742a479ff75c
2019-04-09Merge #15629: init: Throw error when network specific config is ignoredMarcoFalke
fae38c3dc6 doc: Fix all typos reported by codespell (MarcoFalke) fa9058f0ed doc: Add release notes for 15629 (MarcoFalke) fa4a922d78 qa: Add test for missing testnet section in conf file (MarcoFalke) dddd6f0f58 init: Throw error when network specific config is ignored (MarcoFalke) Pull request description: This should have no effect on mainnet users, but simplifies testing, where config settings are currently ignored with only a warning. Fix this by making it an error. Issues: * bitcoin client 0.17.0 ignores wallet's name (file) #14523 * Can't set custom rpcport on testnet #13777 * ... ACKs for commit fae38c: Tree-SHA512: 2e209526898eea6e444c803ec2666989cee4ca137492d32984998733c50a70056cb54657df8dc3027a6a0612738a8afce0bc35824b868c5f22281e00e0188530
2019-04-09[build] Add several util unitsJohn Newbery
Adds the following util units and adds them to libbitcoin_util: - `util/url.cpp` takes `urlDecode` from `httpserver.cpp` - `util/error.cpp` takes `TransactionErrorString` from `node/transaction.cpp` and `AmountHighWarn` and `AmountErrMsg` from `ui_interface.cpp` - `util/fees.cpp` takes `StringForFeeReason` and `FeeModeFromString` from `policy/fees.cpp` - `util/rbf.cpp` takes `SignalsOptInRBF` from `policy/rbf.cpp` - 'util/validation.cpp` takes `FormatStateMessage` and `strMessageMagic` from 'validation.cpp`
2019-04-09[build] Move policy settings to new src/policy/settings unitJohn Newbery
This moves the following policy settings functions and globals to a new src/policy/settings unit in lib_server: - `incrementalRelayFee` - `dustRelayFee` - `nBytesPerSigOp` - `fIsBareMultisigStd` These settings are only required by the node and should not be accessed by other libraries.
2019-04-09[build] Move CheckTransaction from lib_server to lib_consensusJohn Newbery
CheckTransaction is a context-free function that does not require access to the blockchain or mempool. Move it from src/consensus/tx_verify in lib_server to a new unit src/consensus/tx_check in lib_consensus so that it can be called by non-server libraries.
2019-03-23Resolve the checkpoints <-> validation CD.251
This commit resolves the checkpoints -> validation -> checkpoints cirular dependency by moving `CheckPoints::GetLastCheckpoint(const CCheckpointData& data)` from `checkpoints.cpp` to `validation.cpp`.
2019-03-22doc: Fix all typos reported by codespellMarcoFalke
2019-03-19refactor: Expose UndoReadFromDisk in headerMarcoFalke
2019-03-18Merge #15618: refactor: Remove unused functionWladimir J. van der Laan
fa5c511a832632b964617776eb6c3535bb2bd893 refactor: Remove unused function (MarcoFalke) Pull request description: Oversight of kallewoof and mine in https://github.com/bitcoin/bitcoin/pull/13541#discussion_r266555476 Tree-SHA512: 2fd3c4ecde5d3c58b113aa58d606976ceb4998358bde0547ead8e83df210722fa9821d2c88b717bdd190ef71593cd9c0154c3a5d3f2ccc3af8cbf6c36aaa6d45
2019-03-18refactor: Remove unused functionMarcoFalke
2019-03-18Merge #13541: wallet/rpc: sendrawtransaction maxfeerateMarcoFalke
7abd2e697c wallet/rpc: add maxfeerate parameter to testmempoolaccept (Karl-Johan Alm) 6c0a6f73e3 wallet/rpc: add maxfeerate parameter to sendrawtransaction (Karl-Johan Alm) e5efacb941 test: Refactor vout fetches in rpc_rawtransaction (Karl-Johan Alm) Pull request description: This adds a new `maxfeerate` parameter to `sendrawtransaction` which forces the node to reject a transaction whose feerate is above the given fee rate. This is a safety harness from shooting yourself in the foot and accidentally overpaying fees. See also #12911. Tree-SHA512: efa50134a7c17c9330cfdfd48ba400e095c0a419cc45e630618d8b44929c25d780d1bb2710c1fbbb6e687eca373505b0338cdaa7f2ff4ca22636d84c31557a2e
2019-03-14wallet/rpc: add maxfeerate parameter to sendrawtransactionKarl-Johan Alm
2019-03-07Merge #15402: Granular invalidateblock and RewindBlockIndexWladimir J. van der Laan
519b0bc5dc5155b6f7e2362c2105552bb7618ad0 Make last disconnected block BLOCK_FAILED_VALID, even when aborted (Pieter Wuille) 8d220417cd7bc34464e28a4861a885193ec091c2 Optimization: don't add txn back to mempool after 10 invalidates (Pieter Wuille) 9ce9c37004440d6a329874dbf66b51666d497dcb Prevent callback overruns in InvalidateBlock and RewindBlockIndex (Pieter Wuille) 9bb32eb571a846b66ed3bac493f55cee11a3a1b9 Release cs_main during InvalidateBlock iterations (Pieter Wuille) 9b1ff5c742dec0a6e0d6aab29b0bb771ad6d8135 Call InvalidateBlock without cs_main held (Pieter Wuille) 241b2c74ac8c4c3000e778554da1271e3f293e5d Make RewindBlockIndex interruptible (Pieter Wuille) 880ce7d46b51835c00d77a366ec28f54a05239df Call RewindBlockIndex without cs_main held (Pieter Wuille) 436f7d735f1c37e77d42ff59d4cbb1bd76d5fcfb Release cs_main during RewindBlockIndex operation (Pieter Wuille) 1d342875c21b5d0a17cf4d176063bb14b35b657e Merge the disconnection and erasing loops in RewindBlockIndex (Pieter Wuille) 32b2696ab4b079db736074b57bbc24deaee0b3d9 Move erasure of non-active blocks to a separate loop in RewindBlockIndex (Pieter Wuille) 9d6dcc52c6cb0cdcda220fddccaabb0ffd40068d Abstract EraseBlockData out of RewindBlockIndex (Pieter Wuille) Pull request description: This PR makes a number of improvements to the InvalidateBlock (`invalidateblock` RPC) and RewindBlockIndex functions, primarily around breaking up their long-term cs_main holding. In addition: * They're made safely interruptible (`bitcoind` can be shutdown, and no progress in either will be lost, though if incomplete, `invalidateblock` won't continue after restart and will need to be called again) * The validation queue is prevented from overflowing (meaning `invalidateblock` on a very old block will not drive bitcoind OOM) (see #14289). * `invalidateblock` won't bother to move transactions back into the mempool after 10 blocks (optimization). This is not an optimal solution, as we're relying on the scheduler call sites to make sure the scheduler doesn't overflow. Ideally, the scheduler would guarantee this directly, but that needs a few further changes (moving the signal emissions out of cs_main) to prevent deadlocks. I have manually tested the `invalidateblock` changes (including interrupting, and running with -checkblockindex and -checkmempool), but haven't tried the rewinding (which is probably becoming increasingly unnecessary, as very few pre-0.13.1 nodes remain that would care to upgrade). Tree-SHA512: 692e42758bd3d3efc2eb701984a8cb5db25fbeee32e7575df0183a00d0c2c30fdf72ce64c7625c32ad8c8bdc56313da72a7471658faeb0d39eefe39c4b8b8474
2019-03-03Make last disconnected block BLOCK_FAILED_VALID, even when abortedPieter Wuille
2019-03-02Merge #15118: Refactor block file logicWladimir J. van der Laan
04cca330944f859b4ed68cb8da8a79f5206fd630 Style cleanup. (Jim Posen) 4c01e4e159db82ce4b2acce75f709cac996367d7 flatfile: Unit tests for FlatFileSeq methods. (Jim Posen) 65a489e93d181d3c0f7a9cf79f7c11ff8cf2b0f0 scripted-diff: Rename CBlockDiskPos to FlatFilePos. (Jim Posen) d6d8a78f26f52fdfe43293686135e2fc6919926c Move CDiskBlockPos from chain to flatfile. (Jim Posen) e0380933e3745214331d358bda8c5e79299c84d2 validation: Refactor file flush logic into FlatFileSeq. (Jim Posen) 992404b31ed2f8cabeed59d074552f0ae10fda94 validation: Refactor block file pre-allocation into FlatFileSeq. (Jim Posen) e2d2abb99fe353ffc2ff3bc1ff578fad31065335 validation: Refactor OpenDiskFile into method on FlatFileSeq. (Jim Posen) 9183d6ef656c8f3ed406821b99827f9b5f047665 validation: Extract basic block file logic into FlatFileSeq class. (Jim Posen) 62e7addb632cad77cbd5fbccbaee51c7b32505d0 util: Move CheckDiskSpace to util. (Jim Posen) Pull request description: This cleans up and refactors block file helpers so that they may be used by the block filter indexer. Per [design discussion](https://github.com/bitcoin/bitcoin/pull/14121#issuecomment-451252591) about storing BIP 157 block filters, it has been suggested that they are stored in the same way as block and undo data. This refactor is sufficient to simplify file operations for this use case, though in the future perhaps more pruning-related logic ought to be moved into the new classes. The basic abstraction is a `FlatFileSeq` which manages access to a sequence of numbered files into which raw data is written. Tree-SHA512: b2108756777f2dad8964a1a2ef2764486e708a4a4a8cfac47b5de8bcb0625388964438eb096b10cfd9ea39212c299b5cb32fa943e768db2333cf49ea7def157e
2019-02-28Optimization: don't add txn back to mempool after 10 invalidatesPieter Wuille
2019-02-28Prevent callback overruns in InvalidateBlock and RewindBlockIndexPieter Wuille
2019-02-28Release cs_main during InvalidateBlock iterationsPieter Wuille
2019-02-25rpc/gui: Remove 'Unknown block versions being mined' warningWladimir J. van der Laan
Due to miners inserting garbage into the version numbers, the current version signalling has become completely useless. This removes the "unknown block versions" warning which has the tendency to scare users unnecessarily (and might get them to "update" to something bad). It preserves the warning in the logs. Whether this is desirable can be a point of discussion.
2019-02-24Call InvalidateBlock without cs_main heldPieter Wuille
2019-02-24Make RewindBlockIndex interruptiblePieter Wuille
2019-02-24Release cs_main during RewindBlockIndex operationPieter Wuille
2019-02-24Merge the disconnection and erasing loops in RewindBlockIndexPieter Wuille
2019-02-24Move erasure of non-active blocks to a separate loop in RewindBlockIndexPieter Wuille
This lets us simplify the iteration to just walking back in the chain, rather than looping over all of mapBlockIndex.
2019-02-24Abstract EraseBlockData out of RewindBlockIndexPieter Wuille
Note that the former 'else' branch in RewindBlockIndex is now dealt with more naturally inside the EraseBlockData call (by checking whether the parent needs to be re-added as candidate after deleting a child).
2019-02-22scripted-diff: Rename CBlockDiskPos to FlatFilePos.Jim Posen
-BEGIN VERIFY SCRIPT- sed -i 's/CDiskBlockPos/FlatFilePos/g' $(git ls-files 'src/*.h' 'src/*.cpp') -END VERIFY SCRIPT-
2019-02-22validation: Refactor file flush logic into FlatFileSeq.Jim Posen
2019-02-22validation: Refactor block file pre-allocation into FlatFileSeq.Jim Posen
2019-02-22validation: Refactor OpenDiskFile into method on FlatFileSeq.Jim Posen
2019-02-22validation: Extract basic block file logic into FlatFileSeq class.Jim Posen
2019-02-22util: Move CheckDiskSpace to util.Jim Posen
2019-02-12Remove unnecessary const_castJulian Fleischer
Signed-off-by: Julian Fleischer <julian@thirdhash.com>
2019-02-01doc: Add cs_main lock annotations for mapBlockIndexpracticalswift
2019-01-30Merge #15159: [RPC] Remove lookup to UTXO set from GetTransactionMarcoFalke
04da9f4834 [RPC] Update getrawtransaction interface (Amiti Uttarwar) Pull request description: - stop checking unspent UTXOs for a transaction when txindex is not enabled, as per conversation here: https://github.com/bitcoin/bitcoin/issues/3220#issuecomment-377458383 - code contributed by sipa Tree-SHA512: aa07353bccc14b81b7803992a25d076d6bc06d15ec7c1b85828dc10aea7e0498d9b49f71783e352ab8a14b0bb2010cfb7835de3dfd1bc6f2323f460449348e66
2019-01-26[RPC] Update getrawtransaction interfaceAmiti Uttarwar
2019-01-15Merge #14963: mempool, validation: Explain cs_main locking semanticsMarcoFalke
fa5e373365 validation: Add cs_main locking annotations (MarcoFalke) fa5c346c5a doc: Add comment to cs_main and mempool::cs (MarcoFalke) fafe941bdd test: Add missing validation locks (MarcoFalke) fac4558462 sync: Add RecursiveMutex type alias (MarcoFalke) Pull request description: Both the chain state and the transaction pool are validation specific, but access to them is protected by two locks. The two locks have the following semantics: * Writing to the chain state or adding transactions to the transaction pool -> Take both `cs_main` and `mempool::cs` * Reading either or removing transactions from the the transaction pool -> Take only the appropriate lock Tree-SHA512: 6f6e612ffc391904c6434a79a4f3f8de1b928bf0a3e3434b73561037b395e2b40a70a5a4bd8472dd230e9eacc8e5d5374c904a3c509910cf3971dd7ff59a626c
2019-01-04Merge #13910: Log progress while verifying blocks at level 4MarcoFalke
e58985c916 Log progress while verifying blocks at level 4. (Daniel Kraft) Pull request description: When verifying blocks at startup, the progress is printed in 10% increments to logs. When `-checklevel=4`, however, the second half of the verification (connecting the blocks again) does not log the progress anymore. (It is still computed and shown in the UI, but not printed to logs.) This change makes the behaviour consistent, by adding the missing progress logging also for level-4 checks. Tree-SHA512: 6a4c5914726fc1a1337de0c5130b20d4edf4e2feeb0aa0449d2ce422b2d8c41e56ede94163a02044d9a28ac4dc6624b1ad611da93ce5792ff32ad9fb1f0ea1e0
2018-12-29Merge #13743: refactor: Replace boost::bind with std::bindMarcoFalke
cb53b825c2 scripted-diff: Replace boost::bind with std::bind (Chun Kuan Lee) 2196c51821 refactor: Use boost::scoped_connection in signal/slot, also prefer range-based loop instead of std::transform (Chun Kuan Lee) Pull request description: Replace boost::bind with std::bind - In `src/rpc/server.cpp`, replace `std::transform` with simple loop. - In `src/validation.cpp`, store the `boost::signals2::connection` object and use it to disconnect. - In `src/validationinterface.cpp`, use 2 map to store the `boost::signals2::scoped_connection` object. Tree-SHA512: 6653cbe00036fecfc495340618efcba6d7be0227c752b37b81a27184433330f817e8de9257774e9b35828026cb55f11ee7f17d6c388aebe22c4a3df13b5092f0
2018-12-22Merge #13930: doc: Better explain GetAncestor check for m_failed_blocks in ↵MarcoFalke
AcceptBlockHeader 66e15e8f97 Explain GetAncestor check for m_failed_blocks in AcceptBlockHeader (Sjors Provoost) Pull request description: Salvaged (but slightly modified) from #12138, the comment there was really helpful to wrap my head around that part of the code. In addition, a naive reader like yours truly will first think `IsValid(BLOCK_VALID_SCRIPTS)` means the previous block was invalid. But IIUC that's not what it means. Instead, it means the block hasn't been checked for validity at the `BLOCK_VALID_SCRIPTS` level yet. So in that case the existing text "previous block index isn't valid" is wrong. Tree-SHA512: 442a319a83290d94697fdf51376463b70454e0f3909d4a45594ddc2e7c26cd19dc703808385a25e26d6d2dddab0aa35ca41722f2e65ee6fe57bbaf62652d3ec8
2018-12-22validation: Add cs_main locking annotationsMarcoFalke
2018-12-20doc: Add comment to cs_main and mempool::csMarcoFalke
2018-12-13Merge #14834: validation: assert that pindexPrev is non-null when requiredWladimir J. van der Laan
fbaaf782cea54dc433e72129ee1088b3169cdfd4 validation: assert that pindexPrev is non-null when required (Karl-Johan Alm) Pull request description: In `ContextualCheckBlock`, we are checking if `pindexPrev == nullptr` conditionally at the start, but then assume it is non-`null` later. This removes the latter assumption. Tree-SHA512: 95f1e9dc839b2cc0e099d155e6180634ece8c6760d00b53e7d27128762e64c92e82d98a5f4a5786b48a4851b17cdbb4b667d3b6a99adb651256e2032de67d05c
2018-12-07Merge #14480: refactor: Drop boost::this_thread::interruption_point and ↵Wladimir J. van der Laan
boost::thread_interrupted in main thread b7df96f4565064bcb7cbbf7e2507e03bdcf339f0 refactor: Drop boost::this_thread::interruption_point and boost::thread_interrupted in main thread (Chun Kuan Lee) Pull request description: This PR drops useless `boost::this_thread::interruption_point` and `boost::thread_interrupted` catch. They are only executed in main thread. Tree-SHA512: a980d098c1a8238e4f0da9493731d7e69b9ca8e010103f442722d0d4cce471cc40a1fafd5f05535ad0e18899b6cf7563ee20e4025f7c7bc15182a0058c028922
2018-12-04validation: Add and use HaveTxsDownloaded where appropriateMarcoFalke
2018-11-30Move CheckBlock() call to critical sectionHennadii Stepanov
This prevents data race for CBlock::fChecked.