aboutsummaryrefslogtreecommitdiff
path: root/src
AgeCommit message (Collapse)Author
2022-03-09style-only: Various blockstorage.cpp cleanupsCarl Dong
2022-03-09refactor: more const annotations for uses of CBlockIndex*Anthony Towns
2022-03-09Merge bitcoin/bitcoin#24498: qt: Avoid crash on startup if int specified in ↵Andrew Chow
settings.json 5b1aae12ca4a99c6b09349981a4902717a6a5d3e qt: Avoid crash on startup if int specified in settings.json (Ryan Ofsky) 84b0973e35dae63cd1b60199b481e24d54e58c97 test: Add tests for GetArg methods / settings.json type coercion (Ryan Ofsky) Pull request description: Should probably add this change to 23.x as suggested by Luke https://github.com/bitcoin/bitcoin/issues/24457#issuecomment-1059825678. If settings like `prune` are added to `settings.json` in the future, it would be preferable for 23.x releases to respect the setting instead of crash. --- Fix GUI startup crash reported by Rspigler in https://github.com/bitcoin/bitcoin/issues/24457 that happens if `settings.json` contains an integer value for any of the configuration options which GUI settings can currently clash with (-dbcache, -par, -spendzeroconfchange, -signer, -upnp, -natpmp, -listen, -server, -proxy, -proxy, -onion, -onion, -lang, and -prune). The fix is a one-line change in `ArgsManager::GetArg`. The rest of the PR just adds a regression test for the GUI and unit tests for ArgsManager::GetArg methods. ACKs for top commit: laanwj: Code review ACK 5b1aae12ca4a99c6b09349981a4902717a6a5d3e achow101: ACK 5b1aae12ca4a99c6b09349981a4902717a6a5d3e jonatack: Code review ACK 5b1aae12ca4a99c6b09349981a4902717a6a5d3e Tree-SHA512: 958991b4bead9b82a3879fdca0f8d6405e2a212b7c46cf356f078843a4f156e27fd75fc46e2013aa5159582ead06d343c1ed248d678b3e5bbd312f247e37894c
2022-03-09Merge bitcoin/bitcoin#24138: index: Commit MuHash and best block together ↵MarcoFalke
for coinstatsindex 691d45fdc83ec14f87a400f548553168ac70263f Add coinstatsindex_unclean_shutdown test (Ryan Ofsky) eb6cc05da32c5bde122725a0bc907d3767a791cd index: Commit DB_MUHASH and DB_BEST_BLOCK to disk together (Martin Zumsande) Pull request description: Fixes #24076 Coinstatsindex currently writes the MuHash (`DB_MUHASH`) to disk in `CoinStatsIndex::WriteBlock()` and `CoinStatsIndex::ReverseBlock()`, but the best synced block is written in `BaseIndex::Commit()`. These are called at different points in time, both during the ThreadSync phase, and also after the initial sync is finished and validation callbacks (`BlockConnected()` vs `ChainStateFlushed()`) perform the syncing. As a result, the index DB is temporarily in an inconsistent state, and if bitcoind is terminated uncleanly (so that there is no time to call `Commit()` by receiving an interrupt or by flushing the chainstate) this leads to problems: On the next startup, `Init()` will read the best block and a MuHash that corresponds to a different (higher) block. Indexing will be picked up at the the best block processing some blocks again, but since MuHash is a rolling hash, it will process some utxos twice and the muhashes for all future blocks will be wrong, as was observed in #24076. Fix this by always committing `DB_MUHASH` together with `DB_BEST_BLOCK`. Note that the block data for the index is still written at different times, but this does not corrupt the index - at worst, these entries will be processed another time and overwritten after an unclean shutdown and restart. ACKs for top commit: ryanofsky: Code review ACK 691d45fdc83ec14f87a400f548553168ac70263f. Only change since last review is adding test fjahr: ACK 691d45fdc83ec14f87a400f548553168ac70263f Tree-SHA512: e1c3b5f06fa4baacd1b070abb0f8111fe2ea4a001ca8b8bf892e96597cf8b5d5ea10fa8fb837cfbf46648f052c742d912add4ce26d4406294fc5fc20809a0e1b
2022-03-09Merge bitcoin/bitcoin#24507: fix CI: bitcoin-chainstate: Lock `cs_main` to ↵laanwj
`UnloadBlockIndex` 7a68fe4831787a66986a76306180c7876ecba37f bitcoin-chainstate: Lock cs_main to UnloadBlockIndex (Carl Dong) Pull request description: This was introduced because of a silent merge conflict. ACKs for top commit: promag: ACK 7a68fe4831787a66986a76306180c7876ecba37f jonatack: ACK 7a68fe4831787a66986a76306180c7876ecba37f Tree-SHA512: 4c135efd68604452485a129e731675ff5917c157a70c77dd702211d9902c21b3b29380a881723f43ecba4762bc864b036881bb502b3b792e581565dcaa7a7ed4
2022-03-08bitcoin-chainstate: Lock cs_main to UnloadBlockIndexCarl Dong
This was introduced because of a silent merge conflict.
2022-03-08Merge bitcoin/bitcoin#24198: wallet, rpc: add wtxid in WalletTxToJSONAndrew Chow
7abd8b21ba34f6a42db2cd2d59a4c0e08561f609 doc: include wtxid in TransactionDescriptionString (brunoerg) 2d596bce6fefeff6033b21b391e81f1dda846937 doc: add wtxid info in release-notes (brunoerg) a5b66738f19a0ad46d7bc287e0db08552c5a1fec test: add wtxid in expected_fields for wallet_basic (brunoerg) e8c659a2970ec8855de3e1dbf91c6b614b8e5644 wallet: add wtxid in WalletTxToJSON (brunoerg) 7482b6f89500d9783cc6af0dccab7a08d0128206 wallet: add GetWitnessHash() (brunoerg) Pull request description: This PR add `wtxid` in `WalletTxToJSON` which allows to return this field in `listsinceblock`, `listtransactions` and `gettransaction` (RPCs). ACKs for top commit: achow101: re-ACK 7abd8b21ba34f6a42db2cd2d59a4c0e08561f609 w0xlt: crACK 7abd8b2 luke-jr: re-utACK 7abd8b21ba34f6a42db2cd2d59a4c0e08561f609 Tree-SHA512: f86f2dbb5e38e7b19932006121802f47b759d31bdbffe3263d1db464f6a3a30fddd68416f886a44f6d3a9fd570f7bd4f8d999737ad95c189e7ae5e8ec1ffbdaa
2022-03-08Merge bitcoin/bitcoin#24312: addrman: Log too low compat valueMarcoFalke
fa097d074bc1afcc2a52976796bb618f7c6a68b3 addrman: Log too low compat value (MarcoFalke) Pull request description: Before this patch, when writing a negative `lowest_compatible` value, it would be read as a positive value. For example `-32` will be read as `224`. There is generally nothing wrong with that. Though, similarly there shouldn't be anything wrong with refusing to read a negative value. I find the code after this patch more logical than before. Also, this allows dropping a file-wide sanitizer suppression. In practice none of this should ever happen. Bitcoin Core would never write a negative `lowest_compatible` in normal operation, unless the file storage is later corrupted by external influence. ACKs for top commit: mzumsande: re-ACK fa097d074bc1afcc2a52976796bb618f7c6a68b3 Tree-SHA512: 9aae7b8fe666f52f667f149667025e0160cef1a793cc4d392e36608f65c2bee8096da429235118f40a3368f327aabe30f3732ae78c5874648ea6f423f2687b65
2022-03-07qt: Avoid crash on startup if int specified in settings.jsonRyan Ofsky
Fix GUI startup crash reported by Rspigler in https://github.com/bitcoin/bitcoin/issues/24457 that happens if settings.json contains an integer value for any of the configuration options which GUI settings can currently clash with (-dbcache, -par, -spendzeroconfchange, -signer, -upnp, -natpmp, -listen, -server, -proxy, -proxy, -onion, -onion, -lang, and -prune). Fix is a one-line change in ArgsManager::GetArg.
2022-03-07test: Add tests for GetArg methods / settings.json type coercionRyan Ofsky
Just add tests. No changes to application behavior. Tests will be updated in the next commit changing & improving current behavior. Include a Qt test for GUI startup crash reported by Rspigler in https://github.com/bitcoin/bitcoin/issues/24457 caused by GetArg behavior that happens if settings.json contains an integer value for any of the configuration options which GUI settings can currently clash with (-dbcache, -par, -spendzeroconfchange, -signer, -upnp, -natpmp, -listen, -server, -proxy, -proxy, -onion, -onion, -lang, and -prune).
2022-03-07Merge bitcoin/bitcoin#24132: build: Bump minimum Qt version to 5.11.3fanquake
956f7322f60db7b8be551c9074b4c633e514079d build: Bump minimum Qt version to 5.11.3 (Hennadii Stepanov) e22d10b936eb7563b2b6611332d9e4c73a2f59d4 ci: Switch from bionic to buster (Hennadii Stepanov) Pull request description: The current minimum Qt version is 5.9.5 which has been set in bitcoin/bitcoin#21286. Distro support: - centos 7 -- unsupported since bitcoin/bitcoin#23511 - centos 8 -- [5.15.2](http://mirror.centos.org/centos/8/AppStream/x86_64/os/Packages/qt5-qtbase-5.15.2-3.el8.x86_64.rpm) - buster -- [5.11.3](https://packages.debian.org/buster/libqt5core5a) - bullseye -- [5.15.2](https://packages.debian.org/bullseye/libqt5core5a) - _bionic_ -- [5.9.5](https://packages.ubuntu.com/bionic/libqt5core5a) - focal -- [5.12.8](https://packages.ubuntu.com/focal/libqt5core5a) As another Ubuntu LTS is coming soon, it seems unreasonable to stick to Qt 5.9 which support [ended](https://www.qt.io/blog/2017/06/07/renewed-qt-support-services) on 2020-05-31. Anyway, it's still possible to build Bitcoin Core GUI with depends on bionic system. Bumping the minimum Qt version allows to make code safer and more reliable, e.g.: - functor-parameter overload of [`QMetaObject::invokeMethod`](https://doc.qt.io/qt-5/qmetaobject.html#invokeMethod-4) - fixed https://bugreports.qt.io/browse/QTBUG-10907 An example of the patch using the functor-overload of `QMetaObject::invokeMethod`: ```diff --- a/src/qt/walletmodel.cpp +++ b/src/qt/walletmodel.cpp @@ -349,7 +349,7 @@ bool WalletModel::changePassphrase(const SecureString &oldPass, const SecureStri static void NotifyUnload(WalletModel* walletModel) { qDebug() << "NotifyUnload"; - bool invoked = QMetaObject::invokeMethod(walletModel, "unload"); + bool invoked = QMetaObject::invokeMethod(walletModel, &WalletModel::unload); assert(invoked); } ``` It uses the same new syntax as signal-slot connection with compile-time check. Also see bitcoin/bitcoin#16348. This PR is intended to be merged early [after](https://github.com/bitcoin/bitcoin/issues/22969) branching `23.x` off. ACKs for top commit: MarcoFalke: cr ACK 956f7322f60db7b8be551c9074b4c633e514079d fanquake: ACK 956f7322f60db7b8be551c9074b4c633e514079d Tree-SHA512: 3d652bcdcd990ce785ad412ed70234d4f27743895e535a53ed44b35d4afc3052e066c4c84f417e30bc53d0a3dd9ebed62444c57b7c765cb1e9aa687fbf866877
2022-03-07Merge bitcoin/bitcoin#24050: validation: Give `m_block_index` ownership of ↵MarcoFalke
`CBlockIndex`s 6c23c415613d8b847e6f6a2f872be893da9f4384 refactor: Rewrite AddToBlockIndex with try_emplace (Carl Dong) c05cf7aa1e1c15089753897a10c14762027d4b99 style: Modernize range-based loops over m_block_index (Carl Dong) c2a1655799c5d5dab9b14bd2a6b2d2296efd6964 style-only: Use using instead of typedef for BlockMap (Carl Dong) dd79dad17545424d145e846026518d70da594380 refactor: Rewrite InsertBlockIndex with try_emplace (Carl Dong) 531dce034718523967808a89c18ba69a1e3e5a1f tests: Remove now-unnecessary manual Unload's (Carl Dong) bec86ae32683ac56b4e6ba9c9b7d21cfbdf4ac03 blockstorage: Make m_block_index own CBlockIndex's (Carl Dong) Pull request description: Part of: #24303 Split off from: #22564 ``` Instead of having CBlockIndex's live on the heap, which requires manual memory management, have them be owned by m_block_index. This means that they will live and die with BlockManager. ``` The second commit demonstrates how this makes calls to `Unload()` to satisfy the address sanitizer unnecessary. ACKs for top commit: ajtowns: ACK 6c23c415613d8b847e6f6a2f872be893da9f4384 MarcoFalke: re-ACK 6c23c415613d8b847e6f6a2f872be893da9f4384 🎨 Tree-SHA512: 81b2b5119be27cc0f8a9457b11da60cc60930315d2a5be36be89fe253d32073ffe622348ff153114b9b3212197bddbc791810913a43811b33cc58e7162bd105b
2022-03-07Merge bitcoin/bitcoin#24461: build: Minor leveldb subtree updatefanquake
1b20109b04061304eab84cf921a030300b4f9fe3 Squashed 'src/leveldb/' changes from f8ae182c1e..330dd6235f (MarcoFalke) Pull request description: A minor change to: * Consistently use the same symbol names in the whole project. * Fix compiling with C++20. ACKs for top commit: fanquake: ACK fa0c32eb74f448c67d0ff9d91dfdd66e2f1e4c48 Tree-SHA512: b5d4540dd621cf4aa8caac811bae03bb74e502a31dbdda9354182e4caa39905550e62ad3cf8ea7d7f9bfc3e5120d119d34ab0f1e633716ec8089876037cbf192
2022-03-07Merge bitcoin/bitcoin#24299: validation, refactor: UnloadBlockIndex and ↵laanwj
ChainstateManager::Reset thread safety cleanups ae9ceed3e23288b163b7d7b1840b06b8d332f4ce validation, refactoring: remove ChainstateManager::Reset() (Jon Atack) daad0093e3d1466789d0ce687902636c80cd74a1 validation: replace lock with annotation in UnloadBlockIndex() (Jon Atack) Pull request description: Thread safety refactoring seen in #24177: - replace re-acquiring lock cs_main with a thread safety annotation in UnloadBlockIndex() - remove ChainstateManager::Reset(), as it is currently unused (can be reintroduced in the test utilities if needed for unit testing) ACKs for top commit: laanwj: Code review ACK ae9ceed3e23288b163b7d7b1840b06b8d332f4ce vasild: ACK ae9ceed3e23288b163b7d7b1840b06b8d332f4ce klementtan: crACK ae9ceed3e23288b163b7d7b1840b06b8d332f4ce Tree-SHA512: cebb782572997cc2dda01590d6bb6c5e479e8202324d8b6ff459b814ce09e818b996c881736bfebd1b8bf4b6d7a0f79faf3ffea176a4699dd7d7429de2db2d13
2022-03-07Merge bitcoin/bitcoin#24468: init, doc: improve -onlynet help and related ↵laanwj
tor/i2p documentation a1db99adea36dbee1ec97ca1851edad12137feea init, doc: improve -onlynet help and tor/i2p documentation (Jon Atack) Pull request description: including review feedback from https://github.com/bitcoin/bitcoin/pull/22834#discussion_r795253056 and https://github.com/bitcoin/bitcoin/pull/24205#discussion_r818629106 concerning `src/init.cpp`, `doc/tor.md` and `doc/i2p.md` - s/outgoing/automatic outbound/ - s/Incoming/Inbound and manual/ (are not affected by this option.) - s/only through network/only to network/ - s/this option. This option/this option. It/ - s/network types/networks/ and pick up a few nits in `doc/p2p-bad-ports.md` from https://github.com/bitcoin/bitcoin/pull/23542#pullrequestreview-881415043. ACKs for top commit: laanwj: ACK a1db99adea36dbee1ec97ca1851edad12137feea w0xlt: ACK a1db99a theStack: ACK a1db99adea36dbee1ec97ca1851edad12137feea Tree-SHA512: dd727904b9b3dadb16053e2b0350e6c0814ef68fb0cca7d34880b883123cfe3aa03b15813b40a863f6367d596d17ee4517eab55281cfe35cd00767b8a39593ca
2022-03-07Merge bitcoin/bitcoin#24306: util: Make ArgsManager::GetPathArg more widely ↵MarcoFalke
usable 60aa179d8f9a675efa2d78eaadc09e3ba450f50f Use GetPathArg where possible (Pavol Rusnak) 5b946edd73640c6ecdfb4cbac1d4351e634678dc util, refactor: Use GetPathArg to read "-settings" value (Ryan Ofsky) 687e655ae2970f2f13aca0267c7de86dc69be763 util: Add GetPathArg default path argument (Ryan Ofsky) Pull request description: Improve `ArgsManager::GetPathArg` method added in recent PR #24265, so it is usable more places. This PR starts to use it for the `-settings` option. This can also be helpful for #24274 which is parsing more path options. - Add `GetPathArg` default argument so it is less awkward to use to parse options that have default values. - Fix `GetPathArg` negated argument handling. Return path{} not path{"0"} when path argument is negated. - Add unit tests for default and negated cases - Move `GetPathArg` method declaration next to `GetArg` declaration. The two methods are close substitutes for each, so this should help keep them consistent and make them more discoverable. ACKs for top commit: w0xlt: Tested ACK 60aa179 on Ubuntu 21.10 hebasto: re-ACK 60aa179d8f9a675efa2d78eaadc09e3ba450f50f Tree-SHA512: 3d24b885d8bbeef39ea5d0556e2f09b9e5f4a21179cef11cbbbc1b84da29c8fb66ba698889054ce28d80bc25926687654c8532ed46054bf5b2dd1837866bd1cd
2022-03-07Merge bitcoin/bitcoin#24427: refactor: Release cs_main before MaybeSendFeefilterMarcoFalke
faa329fd46b4d688a5aa728b8b22a8d098987588 refactor: Release cs_main before MaybeSendFeefilter (MarcoFalke) Pull request description: There is no need for any lock to be held, because net processing is single threaded. So holding the validation lock cs_main for sending a feefilter is confusing and might even degrade blockchain-related RPC performance minimally. ACKs for top commit: ajtowns: ACK faa329fd46b4d688a5aa728b8b22a8d098987588 ; code review only vasild: ACK faa329fd46b4d688a5aa728b8b22a8d098987588 Tree-SHA512: 3e7f9faff1631cc64c86fc1a354ada67617ad1e7a046625cc741f4711854eb41ca8aad5a51ef0d94ff65947b68dba8345c9f786b20ee0a8b7a2e8741cfced21f
2022-03-05Merge bitcoin-core/gui#549: refactor: use std::chrono for ↵Hennadii Stepanov
formatDurationStr() helper 6f2593dc23565abaa3d176595cba6e07883f512e gui, refactor: use std::chrono for formatDurationStr() helper (Jon Atack) Pull request description: Updates `formatDurationStr()` to use the `chrono` standard lib. No change in behavior. ACKs for top commit: RandyMcMillan: tACK 6f2593dc23565abaa3d176595cba6e07883f512e shaavan: ACK 6f2593dc23565abaa3d176595cba6e07883f512e w0xlt: tACK 6f2593d on Ubuntu 21.10 Qt 5.15.2 promag: Code review ACK 6f2593dc23565abaa3d176595cba6e07883f512e. Tree-SHA512: 61e9afdb1db779150df338e6af08727c34f69639add465c2f7003ff775d97dce3e78e78d325bc6dea5bc13f0fce9ef1c3506d13f1661a5e083e52bba8a32ba44
2022-03-04Merge bitcoin/bitcoin#24043: Add (sorted)multi_a descriptor for k-of-n ↵Andrew Chow
multisig inside tr 4828d53eccd52a67631c64cef0ba7df90dff138d Add (sorted)multi_a descriptors to doc/descriptors.md (Pieter Wuille) b5f33ac1f82aea290b4653af36ac2ad1bf1cce7b Simplify wallet_taproot.py functional test (Pieter Wuille) eb0667ea96d52db9135514a5e95ab943f6abd8a6 Add tests for (sorted)multi_a derivation/signing (Pieter Wuille) c17c6aa08df81aa0086d80b50187c8cd60ecc222 Add signing support for (sorted)multi_a scripts (Pieter Wuille) 3eed6fca57d1fa7544f372e6e7de0a9ae1b5715a Add multi_a descriptor inference (Pieter Wuille) 79728c4a3d8a74f276daf1e72abbdecdab85a5d8 Add (sorted)multi_a descriptor and script derivation (Pieter Wuille) 25e95f9ff89a97b87ce218f28274c3c821b2d54d Merge/generalize IsValidMultisigKeyCount/GetMultisigKeyCount (Pieter Wuille) Pull request description: This adds a new `multi_a(k,key_1,key_2,...,key_n)` (and corresponding `sortedmulti_a`) descriptor for k-of-n policies inside `tr()`. Semantically it is very similar to the existing `multi()` descriptor, but with the following changes: * The corresponding script is `<key1> OP_CHECKSIG <key2> OP_CHECKSIGADD <key3> OP_CHECKSIGADD ... <key_n> OP_CHECKSIGADD <k> OP_NUMEQUAL`, rather than the traditional `OP_CHECKMULTISIG`-based script, making it usable inside the `tr()` descriptor. * The keys can optionally be specified in x-only notation. * Both the number of keys and the threshold can be as high as 999; this is the limit due to the consensus stacksize=1000 limit I expect that this functionality will later be replaced with a miniscript-based implementation, but I don't think it's necessary to wait for that. Limitations: * The wallet code will for not estimate witness size incorrectly for script path spends, which may result in a (dramatic) fee underpayment with large multi_a scripts. * The multi_a script construction is (slightly) suboptimal for n-of-n (where a `<key1> OP_CHECKSIGVERIFY ... <key_n-1> OP_CHECKSIGVERIFY <key_n> OP_CHECKSIG` would be better). Such a construction is not included here. ACKs for top commit: achow101: ACK 4828d53eccd52a67631c64cef0ba7df90dff138d gruve-p: ACK https://github.com/bitcoin/bitcoin/pull/24043/commits/4828d53eccd52a67631c64cef0ba7df90dff138d sanket1729: code review ACK 4828d53eccd52a67631c64cef0ba7df90dff138d darosior: Code review ACK 4828d53eccd52a67631c64cef0ba7df90dff138d Tree-SHA512: 5dcd434b79585f0ff830f7d501d27df5e346f5749f47a3109ec309ebf2cbbad0e1da541eec654026d911ab67fd7cf7793fab0f765628d68d81b96ef2a4d234ce
2022-03-04Merge bitcoin/bitcoin#24441: fuzz: Limit script_format to 100kBfanquake
bbbbeaf9c87030eb6b033b6a22002ca8d6635d51 fuzz: Limit script_format to 100kB (MarcoFalke) Pull request description: The target is still one of the slowest ones, but doesn't seem incredibly important. Especially for sizes larger than the standard tx size. Fix that by limiting the script size. ACKs for top commit: fanquake: ACK bbbbeaf9c87030eb6b033b6a22002ca8d6635d51 Tree-SHA512: b6cf7248753909ef2f21d8824f187e7c05732dd3b99619c0067f862f3c2b0f9a87779d4ddbbd3a7a4bae5c794280e2f0a223bf835d6bc6ccaba01817d69479a2
2022-03-03Merge bitcoin/bitcoin#24304: [kernel 0/n] Introduce `bitcoin-chainstate`MarcoFalke
2c03cec2ff8cdbfd5da92bfb507d218e5c6435b0 ci: Build bitcoin-chainstate (Carl Dong) 095aa6ca37bf0bd5c5e221bab779978a99b2a34c build: Add example bitcoin-chainstate executable (Carl Dong) Pull request description: Part of: #24303 This PR introduces an example/demo `bitcoin-chainstate` executable using said library which can print out information about a datadir and take in new blocks on stdin. Please read the commit messages for more details. ----- #### You may ask: WTF?! Why is `index/*.cpp`, etc. being linked in? This PR is meant only to capture the state of dependencies in our consensus engine as of right now. There are many things to decouple from consensus, which will be done in subsequent PRs. Listing the files out right now in `bitcoin_chainstate_SOURCES` is purely to give us a clear picture of the task at hand, it is **not** to say that these dependencies _belongs_ there in any way. ### TODO 1. Clean up `bitcoin-chainstate.cpp` It is quite ugly, with a lot of comments I've left for myself, I should clean it up to the best of my abilities (the ugliness of our init/shutdown might be the upper bound on cleanliness here...) ACKs for top commit: ajtowns: ACK 2c03cec2ff8cdbfd5da92bfb507d218e5c6435b0 ryanofsky: Code review ACK 2c03cec2ff8cdbfd5da92bfb507d218e5c6435b0. Just rebase, comments, formatting change since last review MarcoFalke: re-ACK 2c03cec2ff8cdbfd5da92bfb507d218e5c6435b0 🏔 Tree-SHA512: 86e7fb5718caa577df8abc8288c754f4a590650d974df9d2f6476c87ed25c70f923c4db651c6963f33498fc7a3a31f6692b9a75cbc996bf4888c5dac2f34a13b
2022-03-03init, doc: improve -onlynet help and tor/i2p documentationJon Atack
and harmonize them as follows - s/outgoing/automatic outbound/ - s/Incoming/Inbound and manual/ (are not affected by this option.) - s/only through network/only to network/ - s/this option. This option/this option. It/ - s/network types/networks/ and also pick up a few nits in doc/p2p-bad-ports.md
2022-03-02net: only assume all local addresses if listening on anyVasil Dimov
If `-bind=` is provided then we would bind only to a particular address and should not add all the other addresses of the machine to the list of local addresses. Fixes https://github.com/bitcoin/bitcoin/issues/20184 (case 4.)
2022-03-02net: fix GetListenPort() to derive the proper portVasil Dimov
`GetListenPort()` uses a simple logic: "if `-port=P` is given, then we must be listening on `P`, otherwise we must be listening on `8333`". This is however not true if `-bind=` has been provided with `:port` part or if `-whitebind=` has been provided. Thus, extend `GetListenPort()` to return the port from `-bind=` or `-whitebind=`, if any. Fixes https://github.com/bitcoin/bitcoin/issues/20184 (cases 1. 2. 3. 5.)
2022-03-02net: pass Span by value to CaptureMessage()Vasil Dimov
Span is lightweight and need not be passed by const reference.
2022-03-02net: make CaptureMessage() mockableVasil Dimov
Rename `CaptureMessage()` to `CaptureMessageToFile()` and introduce a `std::function` variable called `CaptureMessage` whose value can be changed by unit tests, should they need to inspect message contents.
2022-03-02timedata: rename variables to match the coding styleVasil Dimov
Rename the local variables in `src/timedata.cpp`: `setKnown` -> `g_sources` `vTimeOffsets` -> `g_time_offsets` `fDone` -> `g_warning_emitted`
2022-03-02timedata: make it possible to reset the stateVasil Dimov
Add a new function `TestOnlyResetTimeData()` which would reset the internal state used by `GetTimeOffset()`, `GetAdjustedTime()` and `AddTimeData()`. This is needed so that unit tests that call `AddTimeData()` can restore the state in order not to confuse other tests that rely on it. Currently `timedata_tests/addtimedata` is the only test that modifies the state (via `AddTimeData()`) and also the only test that relies on that state.
2022-03-02build: Minor leveldb subtree updateMarcoFalke
2022-03-02Use GetPathArg where possiblePavol Rusnak
Co-authored-by: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com>
2022-03-02Merge bitcoin/bitcoin#24375: Do not use `LocalTestingSetup` in getarg_tests ↵MarcoFalke
test file. 5d7f22595ff2de9b9883e468e3ce7182fc3f183b Do not use `LocalTestingSetup` in getarg_tests test file. (Kiminuo) Pull request description: Avoid using a test fixture in getarg_tests for better readability. Change was implemented by _kiminuo_ and posted https://github.com/bitcoin/bitcoin/pull/24306#issuecomment-1036643216 ACKs for top commit: kiminuo: ACK 5d7f22595ff2de9b9883e468e3ce7182fc3f183b Tree-SHA512: 0fd98622010e6923e91c66447a1d0861bf344a65d86a313dff7d428c089b1740a25f699327f6ed4c163255f270bcbd4f7be962bb551862214f9b9e395d40df04
2022-03-02util, refactor: Use GetPathArg to read "-settings" valueRyan Ofsky
Take advantage of GetPathArg to simplify code slightly.
2022-03-02util: Add GetPathArg default path argumentRyan Ofsky
Let GetPathArg method be used more places for path arguments that have default values, like "-settings" and BITCOIN_SETTINGS_FILENAME in the next commit. Also: - Fix negated argument handling. Return path{} not path{"0"} when path argument is negated. - Add new tests for default and negated cases - Move GetPathArg() method declaration next to GetArg() declarations. The two methods are close substitutes for each other, so this should help keep them consistent and make them more discoverable.
2022-03-02Merge bitcoin/bitcoin#24165: p2p: extend inbound eviction protection by ↵laanwj
network to CJDNS peers b7be28cac50046b9f2ddfe63ecafccc80649a36c test: add combined CJDNS/I2P/localhost/onion eviction protection tests (Jon Atack) 0a1bb84770b403ab5cbd9d5474c76f91ce58e8f6 test: add tests for inbound eviction protection of CJDNS peers (Jon Atack) 0c00c0c981fc0b6cec101e68e8c1aeda1ccf33bb test: fix off-by-one logic in an eviction protection test (Jon Atack) f7b8094d611531c6b41a94715dbc01f56257ccd2 p2p: extend inbound eviction protection by network to CJDNS peers (Jon Atack) Pull request description: Extend inbound eviction protection for peers connected over CJDNS, as is the case for peers connected via onion, localhost, and I2P since #21261 and #20197. CJDNS peers seem to have better min ping latency than onion and I2P peers but still higher than that of unencrypted IPv4/6 peers and can be disadvantaged under our eviction criteria. They are also very few in number, which is a further reason to protect them, as the goal of this logic is to favorise the diversity of our peer connections. CJDNS support was added in #23077 for the upcoming v23 release. ACKs for top commit: laanwj: Concept and code review ACK b7be28cac50046b9f2ddfe63ecafccc80649a36c w0xlt: tACK b7be28c Tree-SHA512: 89ebdd217602e16ae14b9bd0d5a25fc09f9b2384c951f820bc0f5a6d8452bbc9042065db817d5d5296c0ad22988491a83fc5b9a611e660c40ebd4f03448c4061
2022-03-02Merge bitcoin/bitcoin#23304: wallet: Derive inactive HD chains in additional ↵laanwj
places c4d76c6faa3adf06f192649e169ca860ce420d30 tests: Tests for inactive HD chains (Andrew Chow) 8077862c5e8a3ed501f0baabc33536eb16922ceb wallet: Refactor TopUp to be able to top up inactive chains too (Andrew Chow) 70134eb34f58f0c572e7c3775e292d408f03b5ab wallet: Properly set hd chain counters when loading (Andrew Chow) 961b9e4e40019a87eaa11c8a9c3305870f7a6d75 wallet: Parse hdKeypath if key_origin is not available (Andrew Chow) 0652ee73ec880a66ec88bde007ee03c0b9d1b074 Add size check on meta.key_origin.path (Rob Fielding) Pull request description: Currently inactive HD chains are only derived from at the time a key in that chain is found to have been used. However, at that time, the wallet may not be able to derive keys (e.g. it is locked). Currently we would just move on and not derive any new keys, however this could result in missing funds. This PR resolves this problem by adding memory only variables to `CHDChain` which track the highest known index. `TopUp` is modified to always try to top up the inactive HD chains, and this process will use the new variables to determine how much to top up. In this way, after an encrypted wallet is unlocked, the inactive HD chains will be topped up and hopefully funds will not be missed. Note that because these variables are not persisted to disk (because `CHDChain`s for inactive HD chains are not written to disk), if an encrypted wallet is not unlocked in the same session as a key from an inactive chain is found to be used, then it will not be topped up later unless more keys are found. Additionally, wallets which do not have upgraded key metadata will not derive any keys from inactive HD chains. This is resolved by using the derivation path string in `CKeyMetadata.hdKeypath` to determine what indexes to derive. ACKs for top commit: laanwj: Code review ACK c4d76c6faa3adf06f192649e169ca860ce420d30 Tree-SHA512: b2b572ad7f1b1b2847edece09f7583543d63997e18ae32764e5a27ad608dd64b9bdb2d84ea27137894e986a8e82f047a3dba9c8015b74f5f179961911f0c4095
2022-03-02Merge bitcoin/bitcoin#23542: net: open p2p connections to nodes that listen ↵laanwj
on non-default ports 36ee76d1afbb278500fc8aa01606ec933b52c17d net: remove unused CNetAddr::GetHash() (Vasil Dimov) d0abce9a50dd4f507e3a30348eabffb7552471d5 net: include the port when deciding a relay destination (Vasil Dimov) 2e38a0e6865187d1f0d0f016d3df7cce414a7c4f net: add CServiceHash constructor so the caller can provide the salts (Vasil Dimov) 97208634b96f2d9a55f2ead7b0ef407da729d7bd net: open p2p connections to nodes that listen on non-default ports (Vasil Dimov) Pull request description: By default, for mainnet, the p2p listening port is 8333. Bitcoin Core has a strong preference for only connecting to nodes that listen on that port. Remove that preference because connections over clearnet that involve port 8333 make it easy to detect, analyze, block or divert Bitcoin p2p traffic before the connection is even established (at TCP SYN time). For further justification see the OP of: https://github.com/bitcoin/bitcoin/pull/23306 ACKs for top commit: laanwj: Concept and light code review ACK 36ee76d1afbb278500fc8aa01606ec933b52c17d prayank23: ACK https://github.com/bitcoin/bitcoin/pull/23542/commits/36ee76d1afbb278500fc8aa01606ec933b52c17d stickies-v: tACK 36ee76d1a jonatack: ACK 36ee76d1afbb278500fc8aa01606ec933b52c17d glozow: utACK 36ee76d1afbb278500fc8aa01606ec933b52c17d Tree-SHA512: 7f45ab7567c51c19fc50fabbaf84f0cc8883a8eef84272b76435c014c31d89144271d70dd387212cc1114213165d76b4d20a5ddb8dbc958fe7e74e6ddbd56d11
2022-03-01Merge bitcoin/bitcoin#22834: net: respect -onlynet= when making outbound ↵laanwj
connections 0eea83a85ec6b215d44facc2b16ee1b035275a6b scripted-diff: rename `proxyType` to `Proxy` (Vasil Dimov) e53a8505dbb6f9deaae8ac82793a4fb760a1e0a6 net: respect -onlynet= when making outbound connections (Vasil Dimov) Pull request description: Do not make outbound connections to hosts which belong to a network which is restricted by `-onlynet`. This applies to hosts that are automatically chosen to connect to and to anchors. This does not apply to hosts given to `-connect`, `-addnode`, `addnode` RPC, dns seeds, `-seednode`. Fixes https://github.com/bitcoin/bitcoin/issues/13378 Fixes https://github.com/bitcoin/bitcoin/issues/22647 Supersedes https://github.com/bitcoin/bitcoin/pull/22651 ACKs for top commit: naumenkogs: utACK 0eea83a85ec6b215d44facc2b16ee1b035275a6b prayank23: reACK https://github.com/bitcoin/bitcoin/pull/22834/commits/0eea83a85ec6b215d44facc2b16ee1b035275a6b jonatack: ACK 0eea83a85ec6b215d44facc2b16ee1b035275a6b code review, rebased to master, debug built, and did some manual testing with various config options on signet Tree-SHA512: 37d68b449dd6d2715843fc84d85f48fa2508be40ea105a7f4a28443b318d0b6bd39e3b2ca2a6186f2913836adf08d91038a8b142928e1282130f39ac81aa741b
2022-02-28qt: Pre-branch translation updates for 23.xlaanwj
Pull the translations from transifex once before the 23.x branch-off, so that master has at least somewhat-relevant translations.
2022-02-28Merge bitcoin/bitcoin#24365: wallet: Don't generate keys for wallets with ↵laanwj
private keys disabled during upgradewallet c7376cc8d728f3a7c40f79bd57e7cef685def723 tests: Test upgrading wallet with privkeys disabled (Andrew Chow) 3d985d4f43b5344f998bcf6db22d02782e647a2a wallet: Don't generate keys when privkeys disabled when upgrading (Andrew Chow) Pull request description: When we're upgrading a wallet, we shouldn't be trying to generate new keys for wallets where private keys are disabled. Fixes #23610 ACKs for top commit: laanwj: Code review ACK c7376cc8d728f3a7c40f79bd57e7cef685def723 benthecarman: tACK c7376cc8d728f3a7c40f79bd57e7cef685def723 this fixed the issue for me Tree-SHA512: fa07cf37df9196ff98671bb1ce5c9aa0bab46495066b4dab796d7e8e5d5c7adb414ff56adae4fd3e15658a610995bd19a9e1edb00c46144b0df635c5b343f3a6
2022-02-28Merge bitcoin/bitcoin#24403: Avoid implicit-integer-sign-change in ↵MarcoFalke
VerifyLoadedChainstate fa7991601c93761bc12ef33b672a927d48a95569 Fixup style of VerifyDB (MarcoFalke) fa462ea787d124c56d6ba7ef79a9b5b23f0411c5 Avoid implicit-integer-sign-change in VerifyLoadedChainstate (MarcoFalke) Pull request description: This happens when checking all blocks (`-1`). To test: ``` ./configure CC=clang CXX=clang++ --with-sanitizers=undefined,integer make UBSAN_OPTIONS="suppressions=$(pwd)/test/sanitizer_suppressions/ubsan:print_stacktrace=1:halt_on_error=1:report_error_type=1" ./test/functional/rpc_blockchain.py ACKs for top commit: theStack: Code-review ACK fa7991601c93761bc12ef33b672a927d48a95569 brunoerg: crACK fa7991601c93761bc12ef33b672a927d48a95569 Tree-SHA512: bcbe6becf2fbedd21bbde83a544122e79465937346802039532143b2e4165784905a8852c0ccb088b964874df5e5550931fdde3629cbcee3ae237f2f63c43a8e
2022-02-28Merge bitcoin/bitcoin#24417: net: Update hardcoded seeds for 23.xfanquake
d80dc12097ee2f16e3edfcf39363cc4d240e5c57 net: Update hardcoded seeds for 23.x (laanwj) 9f27157894ee689736d0d0936d1af1620fd8f7d8 contrib: make-seeds updates for 23.x (laanwj) Pull request description: Update hardcoded P2P network seeds for 23.x, and update the generation script and documentation as necessary Tool output: ``` IPv4 IPv6 Onion Pass 469910 72944 0 Initial 469910 72944 0 Skip entries with invalid address 469910 72944 0 After removing duplicates 469909 72944 0 Skip entries from suspicious hosts 165760 65113 0 Enforce minimal number of blocks 160668 63183 0 Require service bit 1 4951 1376 0 Require minimum uptime 4406 1051 0 Require a known and recent user agent 4307 1031 0 Filter out hosts with multiple bitcoin ports ERR: Could not resolve ASN for "2001:678:7dc:8::2": The DNS query name does not exist: 8.0.0.0.c.d.7.0.8.7.6.0.1.0.0.2.origin6.asn.cymru.com. 512 134 0 Look up ASNs and limit results per ASN and per net ```. ACKs for top commit: achow101: ACK d80dc12097ee2f16e3edfcf39363cc4d240e5c57 jonatack: ACK d80dc12097ee2f16e3edfcf39363cc4d240e5c57 reviewed the changes and ran the README steps Tree-SHA512: c651b0501cc28d397cc0778eff6aed4273669082d6ef207ce58ce198b443be66532bf1e8d618ccae3ba671ae4cccfd9b4dd2dfebacc97f3c3bd4e9fa58a3d7a3
2022-02-28Merge bitcoin/bitcoin#24418: Chainparams update for 23.xMarcoFalke
dca693e08e66279c5497cb3d30285ed41ae6983c Update nMinimumChainWork, defaultAssumeValid for 23.x (laanwj) 85e71a3baab613eab059c99485bf04c2ab2ce621 Update chainTxData for 23.x (laanwj) 37282dcf789fac0bcc4c3445ac9deec33797bb93 Update m_assumed_* chain parameters for 23.x (laanwj) Pull request description: Update chain parameters for upcoming major release. See [doc/release-process.md](https://github.com/bitcoin/bitcoin/blob/master/doc/release-process.md) for review instructions. - `m_assumed_blockchain_size`, `m_assumed_chain_state_size`: ``` bitcoin$ du -h . 105M ./blocks/index 415G ./blocks 4.5G ./chainstate 420G . bitcoin$ python3 Python 3.9.10 (main, Jan 16 2022, 17:12:18) [GCC 11.2.0] on linux Type "help", "copyright", "credits" or "license" for more information. >>> 420 * 1.1 462.00000000000006 >>> 5 * 1.1 5.5 ``` - `chainTxData`: ``` cli getchaintxstats 4096 000000000000000000052d314a259755ca65944e68df6b12a067ea8f1f5a7091 { "time": 1645542140, "txcount": 712531200, "window_final_block_hash": "000000000000000000052d314a259755ca65944e68df6b12a067ea8f1f5a7091", "window_final_block_height": 724466, "window_block_count": 4096, "window_tx_count": 6950257, "window_interval": 2404071, "txrate": 2.891036496010309 } ``` - `nMinimumChainWork`, `defaultAssumeValid`: ``` $ cli getblockhash 724466 # was two from the tip at the time 000000000000000000052d314a259755ca65944e68df6b12a067ea8f1f5a7091 $ cli getblockheader 000000000000000000052d314a259755ca65944e68df6b12a067ea8f1f5a7091 { "hash": "000000000000000000052d314a259755ca65944e68df6b12a067ea8f1f5a7091", "confirmations": 3, "height": 724466, "version": 939515908, "versionHex": "37ffe004", "merkleroot": "35a08d9647972e7c3ec39ee7f4ab434f03445de7c446a4d1acc1254b4546bbbe", "time": 1645542140, "mediantime": 1645539567, "nonce": 188699556, "bits": "170a1078", "difficulty": 27967152532434.23, "chainwork": "00000000000000000000000000000000000000002927cdceccbd5209e81e80db", "nTx": 1948, "previousblockhash": "000000000000000000075e26c23c2ecec4e34699411ccd712ff6f2d252f65a78", "nextblockhash": "0000000000000000000905369cd69f68323e3e8da2933a78bea0b2cdb8baa89f" } ``` ACKs for top commit: Sjors: ACK dca693e08e66279c5497cb3d30285ed41ae6983c achow101: ACK dca693e08e66279c5497cb3d30285ed41ae6983c prayank23: ACK https://github.com/bitcoin/bitcoin/pull/24418/commits/dca693e08e66279c5497cb3d30285ed41ae6983c darosior: ACK dca693e08e66279c5497cb3d30285ed41ae6983c -- only checked mainnet (on muliple nodes). Didn't do a reindex. Tree-SHA512: 6d5d59f00717fce5f7ce10ec8d59f806ef11b0af21440cec112f70c8e13ebb884ba6c70e744e691fcc31fe7aec7aae968268c9207ccc820d64fdf7e7f98f0cff
2022-02-27fuzz: FuzzedFileProvider::write should not return negative valueeugene
Doing so can lead to a glibc crash. Also the manpage for fopencookie warns against this: https://man7.org/linux/man-pages/man3/fopencookie.3.html
2022-02-25Add coinstatsindex_unclean_shutdown testRyan Ofsky
2022-02-25fuzz: Limit script_format to 100kBMarcoFalke
2022-02-25addrman: Log too low compat valueMarcoFalke
Also remove uint8_t{} casts from values that are already of the same type.
2022-02-25Avoid implicit-integer-sign-change in bech32.cppMarcoFalke
2022-02-25Merge bitcoin/bitcoin#24201: p2p: Avoid InitError when downgrading peers.datMarcoFalke
d41ed3215355582879c8eb6c99c2da33852f6cb1 p2p: Avoid InitError when downgrading peers.dat (junderw) Pull request description: fixes #24188 (also see https://github.com/bitcoin/bitcoin/pull/22762#issuecomment-951063826) When downgrading, a peers.dat with a future version that has a minimum required version larger than the downgraded Bitcoin Core version would cause an InitError. This commit changes this behavior to overwrite the existing peers.dat with a new empty one. ACKs for top commit: prayank23: reACK https://github.com/bitcoin/bitcoin/pull/24201/commits/d41ed3215355582879c8eb6c99c2da33852f6cb1 kallewoof: reACK d41ed3215355582879c8eb6c99c2da33852f6cb1 Tree-SHA512: c8e625fe36ce0b1aab6c8ef7241c8954038bb856f2de27bdc4814dc9a60e51be28815c7d77d0f96eace49687a0cea02deb713978bbd3a5add742f50a675f2a40
2022-02-25p2p: Avoid InitError when downgrading peers.datjunderw
fixes #24188 When downgrading, a peers.dat with a future version that has a minimum required version larger than the downgraded version would cause an InitError. This commit changes this behavior to overwrite the existing peers.dat with a new empty one, while creating a backup in peers.dat.bak.
2022-02-24Update nMinimumChainWork, defaultAssumeValid for 23.xlaanwj
Co-authored-by: Suhas Daftuar <sdaftuar@gmail.com>