aboutsummaryrefslogtreecommitdiff
path: root/src/node
AgeCommit message (Collapse)Author
2022-01-05doc: Fix typo in LoadBlockIndexbrunoerg
2022-01-05Merge bitcoin/bitcoin#23411: refactor: Avoid integer overflow in ApplyStats ↵MarcoFalke
when activating snapshot fa996c58e8a31ebe610d186cef408b6dd3b385a8 refactor: Avoid integer overflow in ApplyStats when activating snapshot (MarcoFalke) fac01888d17423d6c23a9ce15d98fc88fb34e3cc Move AdditionOverflow to util, Add CheckedAdd with unit tests (MarcoFalke) fa526d8fb6ab8f2678a30d4536aa9c45218f5269 Add dev doc to CCoinsStats::m_hash_type and make it const (MarcoFalke) faff051560552d4405896e01920a18f698155a56 style: Remove unused whitespace (MarcoFalke) Pull request description: A snapshot contains the utxo set, including the out value. To activate the snapshot, the hash needs to be calculated. As a side-effect, the total amount in the snapshot is calculated (as the sum of all out values), but never used. Instead of running into an integer overflow in an unused result, don't calculate the result in the first place. Other code paths (using the active utxo set) can not run into an integer overflow, since the active utxo set is valid. Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=39716 ACKs for top commit: shaavan: reACK fa996c58e8a31ebe610d186cef408b6dd3b385a8 vasild: ACK fa996c58e8a31ebe610d186cef408b6dd3b385a8 Tree-SHA512: 4f207f634841f6f634fd02ae1e5907e343fd767524fd0e8149aa99fa9a1834fe50167d14874834d45236e9c325d567925f28129bacb7d80be29cf22277a16a14
2022-01-02Fixup style of moved codeMarcoFalke
Can be reviewed with --word-diff-regex=. -U0 --ignore-all-space
2022-01-02Move BlockManager to node/blockstorageMarcoFalke
Can be reviewed with --color-moved=dimmed-zebra
2021-12-30scripted-diff: Bump copyright headersHennadii Stepanov
-BEGIN VERIFY SCRIPT- ./contrib/devtools/copyright_header.py update ./ -END VERIFY SCRIPT- Commits of previous years: * 2020: fa0074e2d82928016a43ca408717154a1c70a4db * 2019: aaaaad6ac95b402fe18d019d67897ced6b316ee0
2021-12-22scripted-diff: Rename interfaces::WalletClient to interfaces::WalletLoaderRussell Yanofsky
Name has been confusing since it was introduced, and it was pointed in recent review club as https://bitcoincore.reviews/10102 that it was particularly unclear how interfaces::WalletClient was different from interfaces::Wallet. -BEGIN VERIFY SCRIPT- ren() { git grep -l "$1" src | xargs sed -i "s/$1/$2/g"; } ren WalletClient WalletLoader ren walletClient walletLoader ren wallet_client wallet_loader ren "wallet clients release the wallet" "wallet pointer owners release the wallet" ren "wallet client" "wallet loader" ren "Wallet client" "Wallet loader" -END VERIFY SCRIPT-
2021-12-17refactor: Avoid integer overflow in ApplyStats when activating snapshotMarcoFalke
2021-12-17Add dev doc to CCoinsStats::m_hash_type and make it constMarcoFalke
2021-12-17style: Remove unused whitespaceMarcoFalke
2021-12-15Move FindForkInGlobalIndex from BlockManager to CChainStateMarcoFalke
The helper was moved in commit b026e318c39f59a06e29f1b25c7f577e01b25ccb, which also mentioned that it could be moved to CChainState. So do that, as the functionality is not block-storage related. This also allows to drop one function argument.
2021-12-14refactor: remove unneeded calls to strprintf()fanquake
2021-12-10Merge bitcoin/bitcoin#23280: init: Coalesce Chainstate loading sequence ↵MarcoFalke
between {,non-}unittest codepaths 7f15eff2ddd86034e84a19413e1a42883987f660 style-only: Remove redundant scope in *Chainstate (Carl Dong) 89bec827fdea1cedd560be85201f04e0a78aa48d Collapse the 2 cs_main locks in LoadChainstate (Carl Dong) 3b1584b794499158e0df07bd1bee1b803c568614 Remove all #include // for * comments (Carl Dong) 9a5a5a3d08b2c130ab9147914739ff3583b0dc84 test/setup: Use LoadChainstate (Carl Dong) c541da0d62eaf5e96eca00d7508899f98bdfc1bc node/chainstate: Add options for in-memory DBs (Carl Dong) ceb979034184345a662be4e3b327a573fbb31c63 node/caches: Remove intermediate variables (Carl Dong) ac4bf138b849a8544798f3891d6623803040c265 node/caches: Extract cache calculation logic (Carl Dong) 15f2e33bb3d1ad3bc997f6a84956337f46495091 validation: VerifyDB only needs Consensus::Params (Carl Dong) 4da9c076d1cf12728730bb1f7e8906d4e9bfaba5 node/chainstate: Decouple from ShutdownRequested (Carl Dong) 05441c2dc5f60e2025476d8ec94c9025032d118c node/chainstate: Decouple from GetTime (Carl Dong) 2414ebc18b8bebf79c47e58a4293d0fc6420a811 init: Delay RPC block notif until warmup finished (Carl Dong) 8d466a8504bfb81ce8699d650aa72ec9cc8b0a54 Move -checkblocks LogPrintf to AppInitMain (Carl Dong) aad8d597890c3707ae96fdb2b9fadc270ca574dd node/chainstate: Reduce coupling of LogPrintf (Carl Dong) b345979a2b03b671c0984edd7e48e0baec2e2f34 node/chainstate: Decouple from concept of uiInterface (Carl Dong) ca7c0b934db68acdc410e3a82f1ed898382da2e5 Split off VerifyLoadedChainstate (Carl Dong) adf4912d77496b9a243476c5944528f95641f14d node/chainstate: Remove do/while loop (Carl Dong) 975235ca0a8f5bcf9df880698b3b0d4bbde9f7fb Move init logistics message for BAD_GENESIS_BLOCK to init.cpp (Carl Dong) 8715658983a0a07c56513acd8ded8dfc59c5c169 Move mempool nullptr Assert out of LoadChainstate (Carl Dong) 9162a4f93ef5aeb57fe11a6e09f5881cf431f5e6 node/chainstate: Decouple from concept of NodeContext (Carl Dong) c7a5c46e6fd6d6ff46ca7a65fc3f0fff3cbdb24e node/chainstate: Decouple from ArgsManager (Carl Dong) ae9121f958a4124ea6238cad0c3f2acb8b9eb4bb node/chainstate: Decouple from stringy errors (Carl Dong) cbac28b72f5b831f6f84b7628f73e85627af3d94 node/chainstate: Decouple from GetTimeMillis (Carl Dong) cb64af9635a9553e335f2dc0b1cca20c6bbd0933 node: Extract chainstate loading sequence (Carl Dong) Pull request description: This PR: 1. Coalesce the Chainstate loading sequence between `AppInitMain` and `*TestingSetup` (which makes it more tested) 2. Makes the Chainstate loading sequence reusable in preparation for future work extracting out our consensus engine. Code-wise, this PR: 1. Extracts `AppInitMain`'s Chainstate loading sequence into a `::LoadChainstateSequence` function 2. Makes this `::LoadChainstateSequence` function reusable by 1. Decoupling it from various concepts (`ArgsManager`, `uiInterface`, etc) 2. Making it report errors using an `enum` rather than by setting a `bilingual_str` 3. Makes `*TestingSetup` use this new `::LoadChainstateSequence` Reviewers: Aside from commentary, I've also included `git diff` flags of interest in the commit messages which I hope will aid review! ACKs for top commit: ryanofsky: Code review ACK 7f15eff2ddd86034e84a19413e1a42883987f660. Thanks for updates! MarcoFalke: review ACK 7f15eff2ddd86034e84a19413e1a42883987f66 💳 Tree-SHA512: fb9a6cbd1c511a52b477c62a5e68e53a8be5dec2fff0e44a279966afb91efbab44bf1fe7c6b1519f8464ecc25f42dd4bae8e1efbf55ee91fc90fa0b92e3a83e2
2021-12-07style-only: Remove redundant scope in *ChainstateCarl Dong
I strongly recommend reviewing with the following git-diff flags: --ignore-space-change
2021-12-07Collapse the 2 cs_main locks in LoadChainstateCarl Dong
2021-12-07Remove all #include // for * commentsCarl Dong
2021-12-07node/chainstate: Add options for in-memory DBsCarl Dong
[META] In a future commit, these options will be used in TestingSetup to ensure that the DBs are in-memory.
2021-12-07node/caches: Remove intermediate variablesCarl Dong
2021-12-07node/caches: Extract cache calculation logicCarl Dong
I strongly recommend reviewing with the following git-diff flags: --color-moved=dimmed_zebra --color-moved-ws=allow-indentation-change [META] In a future commit, this function will be re-used in TestingSetup so that the behaviour matches across test and non-test init codepaths.
2021-12-07validation: VerifyDB only needs Consensus::ParamsCarl Dong
Previously we were passing in CChainParams, when VerifyDB only needed the Consensus::Params subset.
2021-12-07node/chainstate: Decouple from ShutdownRequestedCarl Dong
...instead allow optionally passing in a std::function<bool()>
2021-12-07node/chainstate: Decouple from GetTimeCarl Dong
...instead pass in a std::function<int64_t()> Note that the static_cast is needed (apparently) for the compiler to know which overloaded GetTime to choose.
2021-12-07init: Delay RPC block notif until warmup finishedCarl Dong
See added code comment for more details.
2021-12-07mining, refactor: add m_mempool.cs thread safety lock assertionsJon Atack
in src/node/miner to: - BlockAssembler::addPackageTxs() - BlockAssembler::SkipMapTxEntry() - BlockAssembler::UpdatePackagesForAdded() These functions have thread safety lock annotations in their declarations but are missing the corresponding run-time lock assertions in their definitions. Per doc/developer-notes.md: "Combine annotations in function declarations with run-time asserts in function definitions."
2021-12-07Merge bitcoin/bitcoin#23644: wallet: Replace confusing getAdjustedTime() ↵MarcoFalke
with GetTime() fa37e798b2660d8e44e31c944a257b55aeef5de2 wallet: Replace confusing getAdjustedTime() with GetTime() (MarcoFalke) Pull request description: Setting `nTimeReceived` to the adjusted time has several issues: * `m_best_block_time` is set to the "unadjusted" time, thus a comparison of the two times is like comparing apples to oranges. In the worst case this opens up an attack vector where remote peers can force a premature re-broadcast of wallet txs. * The RPC documentation for `"timereceived"` doesn't mention that the network adjusted time is used, possibly confusing users when the time reported by RPC is off by a few seconds compared to their local timestamp. Fix all issues by replacing the call with `GetTime()`. Also a style fix: Use non-narrowing integer conversion in the RPC method. ACKs for top commit: theStack: Code-review ACK fa37e798b2660d8e44e31c944a257b55aeef5de2 shaavan: crACK fa37e798b2660d8e44e31c944a257b55aeef5de2 Tree-SHA512: 8d020ba400521246b7aed4b6c41319fc70552e8c69e929a5994500375466a9edac02a0ae64b803dbc6695df22276489561a23bd6e030c44c97d288f7b9b2b3fa
2021-12-06Move -checkblocks LogPrintf to AppInitMainCarl Dong
2021-12-06node/chainstate: Reduce coupling of LogPrintfCarl Dong
...by moving the try/catch out of LoadChainstate I strongly recommend reviewing with the following git-diff flags: --color-moved=dimmed_zebra --color-moved-ws=allow-indentation-change
2021-12-06node/chainstate: Decouple from concept of uiInterfaceCarl Dong
...instead allow the caller to optionally pass in callbacks which are triggered for certain events. Behaviour change: The string "Verifying blocks..." was previously printed for each chainstate in chainman which did not have an effectively empty coinsview, now it will be printed once unconditionally before we call VerifyLoadedChain.
2021-12-06Split off VerifyLoadedChainstateCarl Dong
2021-12-06node/chainstate: Remove do/while loopCarl Dong
I strongly recommend reviewing with the following git-diff flags: --ignore-space-change
2021-12-06Move init logistics message for BAD_GENESIS_BLOCK to init.cppCarl Dong
2021-12-06Move mempool nullptr Assert out of LoadChainstateCarl Dong
2021-12-06node/chainstate: Decouple from concept of NodeContextCarl Dong
...instead pass in only the necessary information Also allow mempool to be a nullptr
2021-12-06node/chainstate: Decouple from ArgsManagerCarl Dong
...instead pass in only the necessary information
2021-12-06node/chainstate: Decouple from stringy errorsCarl Dong
This allows us to separate the initialization code from translations and error reporting. This change changes the caller semantics of LoadChainstate quite drastically. To see that this change doesn't change behaviour, observe that: 1. Prior to this change, LoadChainstate returned false only in the "bad genesis block" failure case (by returning InitError()), indicating that the caller should immediately bail. After this change, the corresponding ERROR_BAD_GENESIS_BLOCK handler in src/init.cpp maintains behavioue by also bailing immediately. 2. The failed_* temporary booleans were only used to break out of the outer do/while(false) loop. They can therefore be safely removed.
2021-12-06node/chainstate: Decouple from GetTimeMillisCarl Dong
...instead just move it out
2021-12-06node: Extract chainstate loading sequenceCarl Dong
I strongly recommend reviewing with the following git-diff flags: --color-moved=dimmed_zebra --color-moved-ws=allow-indentation-change [META] This commit is intended to be as close to a move-only commit as possible, and lingering ugliness will be resolved in subsequent commits. A few variables that are passed in by value instead of by reference deserve explanation: - fReset and fReindexChainstate are both local variables in AppInitMain and are not modified in the sequence - fPruneMode, despite being a global, is only modified in AppInitParameterInteraction, long before LoadChainstate is called ---- [META] This semantic will change in a future commit named "node/chainstate: Decouple from stringy errors"
2021-12-01wallet: Replace confusing getAdjustedTime() with GetTime()MarcoFalke
2021-12-01miner: Remove uncompiled MTP codeMarcoFalke
2021-12-01style: Add {} to if-bodies in node/minerMarcoFalke
Can be reviewed with --word-diff-regex=. --ignore-all-space
2021-11-26Merge bitcoin/bitcoin#23517: scripted-diff: Move miner to src/nodeMarcoFalke
fa4e09924b11b0dc94e377005f86a83c09761265 refactor: Replace validation.h include with forward-decl in miner.h (MarcoFalke) fa0739a7d398aea952a07b73ef565e7c2da75898 style: Sort file list after rename (MarcoFalke) fa53e3a58c94731a90514fe92fad365a49adb10c scripted-diff: Move miner to src/node (MarcoFalke) Pull request description: It is impossible to run the miner without a node (validation, chainstate, mempool, rpc, ...). Also, the module is in the node library. Thus, it should be moved to `src/node`. Also, replace the `validation.h` include in the header with a forward-declaration. ACKs for top commit: theStack: Code-review ACK fa4e09924b11b0dc94e377005f86a83c09761265 Tree-SHA512: 791e6caa5839d8dc83b0f58f3f49bc0a7e3c1710822e8a44dede254c87b6f7531a0586fb95e8a067c181457a3895ad6041718aa2a2fac64cfc136bf04bb851d5
2021-11-25Merge bitcoin/bitcoin#23512: policy: Treat taproot as always activeMarcoFalke
fa3e0da06b491b8c0fa2dbae37682a9112c9deb8 policy: Treat taproot as always active (MarcoFalke) Pull request description: Now that taproot is active, it can be treated as if it was always active for policy for the next major release. This simplifies the code and changes two things: * Importing `tr` descriptors can be done before the chain is fully synced. This is fine, because the wallet will already generate `tr` descriptors by default (regardless of the taproot status) after commit 47fe7445e7f54aee10ec6dbc53f1db1adbeb43de. * Valid taproot spends won't be rejected from the mempool before taproot is active. This is strictly speaking a bugfix after commit 47fe7445e7f54aee10ec6dbc53f1db1adbeb43de, since the wallet may generate taproot spends before the chain is fully synced. For example, a slow node or a purposefully offline node. Currently, the wallet needs the mempool to account for change. See https://github.com/bitcoin/bitcoin/issues/11887. A similar change was done for segwit v0 in https://github.com/bitcoin/bitcoin/pull/13120 . This effectively reverts commit c5ec0367d718544caa3a1578d6c730fc92ee4e94. ACKs for top commit: mjdietzx: Code Review ACK fa3e0da06b491b8c0fa2dbae37682a9112c9deb8 achow101: ACK fa3e0da06b491b8c0fa2dbae37682a9112c9deb8 sipa: utACK fa3e0da06b491b8c0fa2dbae37682a9112c9deb8 gruve-p: ACK https://github.com/bitcoin/bitcoin/pull/23512/commits/fa3e0da06b491b8c0fa2dbae37682a9112c9deb8 gunar: Code Review + tACK fa3e0da06 rajarshimaitra: code review + tACK https://github.com/bitcoin/bitcoin/pull/23512/commits/fa3e0da06b491b8c0fa2dbae37682a9112c9deb8 Tree-SHA512: c6dc7a4e6c345bdec33f256847dc63906ab1696aa683ab9b32a79e715613950884ac3a1a7a44e95f31bb28e58dd64679a616175f7e152b21f5550f3337c8e622
2021-11-22refactor: cast bool to int to silence compiler warningJon Atack
This fixes -Wbitwise-instead-of-logical compiler warnings: node/interfaces.cpp:544:16: warning: use of bitwise '&' with boolean operands [-Wbitwise-instead-of-logical] return FillBlock(ancestor, ancestor_out, lock, active) & FillBlock(block1, block1_out, lock, active) & FillBlock(block2, block2_out, lock, active); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ && node/interfaces.cpp:544:16: note: cast one or both operands to int to silence this warning node/interfaces.cpp:544:16: warning: use of bitwise '&' with boolean operands [-Wbitwise-instead-of-logical] return FillBlock(ancestor, ancestor_out, lock, active) & FillBlock(block1, block1_out, lock, active) & FillBlock(block2, block2_out, lock, active); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ && node/interfaces.cpp:544:16: note: cast one or both operands to int to silence this warning 2 warnings generated. A similar change was recently made to libsecp in commit 16d13221 for the same reason.
2021-11-16refactor: Replace validation.h include with forward-decl in miner.hMarcoFalke
2021-11-16scripted-diff: Move miner to src/nodeMarcoFalke
-BEGIN VERIFY SCRIPT- # Move module git mv src/miner.cpp src/node/ git mv src/miner.h src/node/ # Replacements sed -i 's:miner\.h:node/miner.h:g' $(git grep -l miner) sed -i 's:miner\.cpp:node/miner.cpp:g' $(git grep -l miner) sed -i 's:MINER_H:NODE_MINER_H:g' $(git grep -l MINER_H) -END VERIFY SCRIPT-
2021-11-16Merge bitcoin/bitcoin#23491: scripted-diff: Move minisketchwrapper to src/nodefanquake
faba1abe469833b2dad01bac4e4d8a4ebb4bc97a Sort file list after rename (MarcoFalke) fa8f60e31102e1153ad1452fbced51e54487a3d4 scripted-diff: Move minisketchwrapper to src/node (MarcoFalke) Pull request description: The newly added wrapper is currently in the node library, but not placed in the node directory. While it is possible to use the wrapper outside of a node context (for example in a utility), it seems unlikely. Either way, I think the wrapper should either be moved to the util lib+dir or the node lib+dir, not something in-between. Also, fix incorrect comment `BITCOIN_DBWRAPPER_H`. ACKs for top commit: fanquake: ACK faba1abe469833b2dad01bac4e4d8a4ebb4bc97a. I saw the comment in #21515, however given there hasn't been any new activity there, I'm going to merge this now. Tree-SHA512: fccc0cfd1fee661152a1378587b96795ffb7a7eceb6d2c27ea5401993fd8b9c0a92579fdba61203917ae6565269cb28d0973464fb6201dabf72a5143495d3e77
2021-11-16Merge bitcoin/bitcoin#23499: multiprocess: Add ↵MarcoFalke
interfaces::Node::broadCastTransaction method 0e0f4fdd892223766db4a83194b6576847b757f7 multiprocess: Add interfaces::Node::broadCastTransaction method (Russell Yanofsky) Pull request description: This fixes a null pointer crash in the bitcoin-gui PSBT dialog. The bitcoin-gui interfaces::Node object has a null NodeContext pointer, and can't broadcast transactions directly. It needs to broadcast transactions through the bitcoin-node process instead. --- This PR is part of the [process separation project](https://github.com/bitcoin/bitcoin/projects/10). ACKs for top commit: lsilva01: Code Review ACK 0e0f4fd Tree-SHA512: cd2c1fe8dc15e7cecf01a21d64319d6add1124995305a9ef9cb72f8492dc692c62d4f846182567d47a5048a533178a925419250941a47cb39932467c36bea3e1
2021-11-16policy: Treat taproot as always activeMarcoFalke
2021-11-15Merge bitcoin/bitcoin#23005: multiprocess: Delay wallet client constructionW. J. van der Laan
ad085f9ba15c131fc5cc77086a620f2e366aac7c multiprocess: Delay wallet client construction (Russell Yanofsky) Pull request description: Delay wallet client construction until after logging, thread and other init for two reasons: - More responsive multiprocess GUI startup. When bitcoin-gui is started this moves the call from bitcoin-gui to bitcoin-node that spawns bitcoin-wallet off of the GUI event thread and onto the background GUI init executor thread. - Avoids feature_logging.py test failures with bitcoin-node by making bitcoin-wallet logging start after bitcoin-node logging starts, because the tests are not written to handle the bitcoin-wallet logging init code running first. This partially reverts commit b266b3e0bf29d0f3d5deaeec62d57c5025b35525, moving wallet client creation back to the place it was located before. --- This PR is part of the [process separation project](https://github.com/bitcoin/bitcoin/projects/10). ACKs for top commit: laanwj: code review ACK ad085f9ba15c131fc5cc77086a620f2e366aac7c hebasto: ACK ad085f9ba15c131fc5cc77086a620f2e366aac7c, I have reviewed the code and it looks OK. Tree-SHA512: 74d957ce2ee096db745c517124f60800185814b06c20db676090e10dce1b90311adbab02865a69731f8c39b9365f9ee14be0830ca1368cac9b474801ea92bad5
2021-11-15Merge bitcoin/bitcoin#23004: multiprocess: add interfaces::ExternalSigner classW. J. van der Laan
a032fa30d282fa69c304e0afd1f95f67c55d22e3 multiprocess: add interfaces::ExternalSigner class (Russell Yanofsky) Pull request description: Add `interfaces::ExternalSigner` class to let signer objects be passed between processes and let signer code run in the original process where the object was created. --- This PR is part of the [process separation project](https://github.com/bitcoin/bitcoin/projects/10). ACKs for top commit: laanwj: Concept and code review ACK a032fa30d282fa69c304e0afd1f95f67c55d22e3 hebasto: re-ACK a032fa30d282fa69c304e0afd1f95f67c55d22e3 Tree-SHA512: 99a729fb3a64d010e142cc778a9f1f358e58345b77faaf2664de7d2277715d59df3352326e8f0f2a6628038670eaa4556310a549079fb28af6d2eeb05aea1460
2021-11-12multiprocess: Add interfaces::Node::broadCastTransaction methodRussell Yanofsky
This fixes a null pointer crash in the bitcoin-gui PSBT dialog. The bitcoin-gui interfaces::Node object has a null NodeContext pointer, and can't broadcast transactions directly. It needs to broadcast transactions through the bitcoin-node process instead.