aboutsummaryrefslogtreecommitdiff
path: root/src/test
AgeCommit message (Collapse)Author
2023-12-18Merge bitcoin/bitcoin#29064: fuzz: Improve fuzzing stability for minisketch ↵fanquake
harness b2fc7a2eda103724ac8cbeaf99df3ce6f5b7d974 [fuzz] Improve fuzzing stability for minisketch harness (dergoegge) Pull request description: The `minisketch` harness has low stability due to: * Rng internal to minisketch * Benchmarkning for the best minisketch impl Fix this by seeding the rng and letting the fuzzer choose the impl. Also see #29018. ACKs for top commit: maflcko: review ACK b2fc7a2eda103724ac8cbeaf99df3ce6f5b7d974 Tree-SHA512: 3d81414299c6803c34e928a53bcf843722fa8c38e1d3676cde7fa80923f9058b1ad4b9a2941f718303a6641b17eeb28b4a22eda09678102e9fb7c4e31d06f8f2
2023-12-18Merge bitcoin/bitcoin#29079: fuzz: Limit p2p fuzz targets to ↵fanquake
MAX_PROTOCOL_MESSAGE_LENGTH fa769d3e41daec696452b8a0a8753ba511b0a4b5 fuzz: Limit p2p fuzz targets to MAX_PROTOCOL_MESSAGE_LENGTH (MarcoFalke) Pull request description: Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=65039 ACKs for top commit: dergoegge: utACK fa769d3e41daec696452b8a0a8753ba511b0a4b5 brunoerg: crACK fa769d3e41daec696452b8a0a8753ba511b0a4b5 Tree-SHA512: 46f70d1acf4e2f95055c70162909010c6322f8504a810906e1ab4db470dc2525f9a494b8427b254279bc68b1c8b87338c943787fd5249df7113556740701a51a
2023-12-15Merge bitcoin/bitcoin#29088: tests: Don't depend on value of ↵Ava Chow
DEFAULT_PERMIT_BAREMULTISIG 7b45744df33c6a4759eae1a3984f389cbac837c2 tests: ensure functional tests set permitbaremultisig=1 when needed (Anthony Towns) 7dfabdcf860c529772a54b0e8fa235cbb4a78b4d tests: test both settings for permitbaremultisig in p2sh tests (Anthony Towns) Pull request description: Update unit and functional tests so that they continue to work if the default for `-permitbaremultisig` is changed. ACKs for top commit: maflcko: lgtm ACK 7b45744df33c6a4759eae1a3984f389cbac837c2 instagibbs: crACK https://github.com/bitcoin/bitcoin/pull/29088/commits/7b45744df33c6a4759eae1a3984f389cbac837c2 ajtowns: > crACK [7b45744](https://github.com/bitcoin/bitcoin/commit/7b45744df33c6a4759eae1a3984f389cbac837c2) achow101: ACK 7b45744df33c6a4759eae1a3984f389cbac837c2 glozow: ACK 7b45744df33c6a4759eae1a3984f389cbac837c2, changed default locally and all tests passed Tree-SHA512: f89f9e2bb11f07662cfd57390196df9e531064e1bd662e1db7dcfc97694394ae5e8014e9d209b9405aa09195bf46fc331b7fba10378065cdb270cbd0669ae904
2023-12-15tests: test both settings for permitbaremultisig in p2sh testsAnthony Towns
2023-12-14Merge bitcoin/bitcoin#29040: refactor: Remove pre-C++20 code, fs::path cleanupAva Chow
66667130416b86208e01a0eb5541a15ea805ac26 refactor: Rename fs::path::u8string() to fs::path::utf8string() (MarcoFalke) 856c88776f8486446602476a1c9e133ac0cff510 ArgsManager: return path by value from GetBlocksDirPath() (Vasil Dimov) fa3d9304e80c214c8b073f12a7f4b08c5a94af04 refactor: Remove pre-C++20 fs code (MarcoFalke) fa00098e1a493aa3cce20335d18e7f5f2fb7a4a8 Add tests for C++20 std::u8string (MarcoFalke) fa2bac08c22182e738a8cabf1b24a9dbf3b092d2 refactor: Avoid copy/move in fs.h (MarcoFalke) faea30227ba633da5ab257d0247853e0927244bb refactor: Use C++20 std::chrono::days (MarcoFalke) Pull request description: This: * Removes dead code. * Avoids unused copies in some places. * Adds copies in other places for safety. ACKs for top commit: achow101: ACK 66667130416b86208e01a0eb5541a15ea805ac26 ryanofsky: Code review ACK 66667130416b86208e01a0eb5541a15ea805ac26. Just documentation change since last review. stickies-v: re-ACK 66667130416b86208e01a0eb5541a15ea805ac26 Tree-SHA512: 6176e44f30b310d51632ec2d3827c3819905d0ddc6a4b57acfcb6cfa1f9735176da75ee8ed4a4abd1296cb0b83bee9374cc6f91ffac87c19b63c435eeadf3f46
2023-12-14Merge bitcoin/bitcoin#28051: Get rid of shutdown.cpp/shutdown.h, use ↵Ava Chow
SignalInterrupt directly 6db04be102807ee0120981a9b8de62a55439dabb Get rid of shutdown.cpp/shutdown.h, use SignalInterrupt directly (Ryan Ofsky) 213542b625a6a4885fcbdfe236629a5f381eeb05 refactor: Add InitContext function to initialize NodeContext with global pointers (Ryan Ofsky) feeb7b816affa790e02e7ba0780c4ef33d2310ff refactor: Remove calls to StartShutdown from KernelNotifications (Ryan Ofsky) 6824eecaf1e74624cf149ed20abd9145c49d614a refactor: Remove call to StartShutdown from stop RPC (Ryan Ofsky) 1d92d89edbb1812dc353084c62772ebb1024d632 util: Get rid of uncaught exceptions thrown by SignalInterrupt class (Ryan Ofsky) ba93966368d3aaa426b97837ef475ec5aa612f5f refactor: Remove call to ShutdownRequested from IndexWaitSynced (Ryan Ofsky) 42e5829d9710ebebda5de356fab01dd7c149d5fa refactor: Remove call to ShutdownRequested from HTTPRequest (Ryan Ofsky) 73133c36aa9cc09546eabac18d0ea35274dd5d72 refactor: Add NodeContext::shutdown member (Ryan Ofsky) f4a8bd6e2f03e786a84dd7763d1c04665e6371f2 refactor: Remove call to StartShutdown from qt (Ryan Ofsky) f0c73c1336bee74fe2d58474ac36bca28c219e85 refactor: Remove call to ShutdownRequested from rpc/mining (Ryan Ofsky) 263b23f0082c60516acced1b03abb8e4d8f9ee46 refactor: Remove call to ShutdownRequested from chainstate init (Ryan Ofsky) Pull request description: This change drops `shutdown.h` and `shutdown.cpp` files, replacing them with a `NodeContext::shutdown` member which is used to trigger shutdowns directly. This gets rid of an unnecessary layer of indirection, and allows getting rid of the `kernel::g_context` global. Additionally, this PR tries to improve error handling of `SignalInterrupt` code by marking relevant methods `[[nodiscard]]` to avoid the possibility of uncaught exceptions mentioned https://github.com/bitcoin/bitcoin/pull/27861#discussion_r1255496707. Behavior is changing In a few cases which are noted in individual commit messages. Particularly: GUI code more consistently interrupts RPCs when it is shutting down, shutdown state no longer persists between unit tests, the stop RPC now returns an RPC error if requesting shutdown fails instead of aborting, and other failed shutdown calls now log errors instead of aborting. This PR is a net reduction in lines of code, but in some cases the explicit error handling and lack of global shutdown functions do make it more verbose. The verbosity can be seen as good thing if it discourages more code from directly triggering shutdowns, and instead encourages code to return errors or send notifications that could be translated into shutdowns. Probably a number of existing shutdown calls could just be replaced by better error handling. ACKs for top commit: achow101: ACK 6db04be102807ee0120981a9b8de62a55439dabb TheCharlatan: Re-ACK 6db04be102807ee0120981a9b8de62a55439dabb maflcko: ACK 6db04be102807ee0120981a9b8de62a55439dabb 👗 stickies-v: re-ACK 6db04be102807ee0120981a9b8de62a55439dabb Tree-SHA512: 7a34cb69085f37e813c43bdaded1a0cbf6c53bd95fdde96f0cb45346127fc934604c43bccd3328231ca2f1faf712a7418d047ceabd22ef2dca3c32ebb659e634
2023-12-14[fuzz] Improve fuzzing stability for minisketch harnessdergoegge
* Seed minisketch rng * Use fuzzer chosen minisketch impl instead of benchmarking for the best impl
2023-12-14refactor: Rename fs::path::u8string() to fs::path::utf8string()MarcoFalke
2023-12-14fuzz: Limit p2p fuzz targets to MAX_PROTOCOL_MESSAGE_LENGTHMarcoFalke
2023-12-13Merge bitcoin/bitcoin#28075: util: Remove DirIsWritable, GetUniquePathfanquake
fa3da629a1aebcb4500803d7417feed8e34285b0 Remove DirIsWritable, GetUniquePath (MarcoFalke) fad3a9793b71df5bb0b17cc3758cf3466d08c015 Return LockResult::ErrorWrite in LockDirectory (MarcoFalke) fa0afe740843c308f6287b923f1f4d758cf2a3f6 refactor: Return enum in LockDirectory (MarcoFalke) Pull request description: `GetUniquePath` is only used in tests and in `DirIsWritable`. The check by `DirIsWritable` is redundant with the check done in `LockDirectory`. Fix the redundancy by removing everything, except `LockDirectory`. ACKs for top commit: TheCharlatan: Re-ACK fa3da629a1aebcb4500803d7417feed8e34285b0 hebasto: ACK fa3da629a1aebcb4500803d7417feed8e34285b0, I have reviewed the code and it looks OK. Tree-SHA512: e95f18cd586de7582e9c08ac7ddb860bfcfcbc8963804f45c5784c5e4c0598dc59ae7e45dd4daf30a5020dbf8433f5db2ad06e46a8676371982003790043c6c9
2023-12-12Merge bitcoin/bitcoin#29021: refactor: rpc: Pass CBlockIndex by reference ↵fanquake
instead of pointer fa5989d514d246e56977c528b2dd2abe6dc8efcc refactor: rpc: Pass CBlockIndex by reference instead of pointer (MarcoFalke) fa604eb6cfa7f70ce11c78c1060f0823884c745b refactor: Use reference instead of pointer in IsBlockPruned (MarcoFalke) Pull request description: Follow-up to https://github.com/bitcoin/bitcoin/pull/29003#issuecomment-1841435462 ACKs for top commit: TheCharlatan: ACK fa5989d514d246e56977c528b2dd2abe6dc8efcc pablomartin4btc: tACK fa5989d514d246e56977c528b2dd2abe6dc8efcc dergoegge: Code review ACK fa5989d514d246e56977c528b2dd2abe6dc8efcc Tree-SHA512: 7449de3e3bb435dcbf438df88df343bb70f6edc3228ee7c0078f912ffb415e951ba30f8ecad916765f8cf896f0d784fe30535c5cf997e303cf5af257ade69773
2023-12-11Add tests for C++20 std::u8stringMarcoFalke
Also, add missing includes: #include <system_error> // for error_code #include <type_traits> // for is_same #include <cerrno> // for errno
2023-12-11Merge bitcoin/bitcoin#29009: fuzz: p2p: Detect peer deadlocksfanquake
9f265d88253ed464413dea5614fa13dea0d8cfd5 fuzz: Detect deadlocks in process_message (dergoegge) fae1e7e012571201fd51c547ba4fb6044be9aeb5 fuzz: p2p: Detect peer deadlocks (MarcoFalke) Pull request description: It may be possible that a peer connection will deadlock, due to software bugs such as https://github.com/bitcoin/bitcoin/pull/18808. Fix this by detecting them in the fuzz target. Can be tested by introducing a bug such as: ```diff diff --git a/src/net_processing.cpp b/src/net_processing.cpp index 1067341495..97495a13df 100644 --- a/src/net_processing.cpp +++ b/src/net_processing.cpp @@ -2436,3 +2436,3 @@ void PeerManagerImpl::ProcessGetData(CNode& pfrom, Peer& peer, const std::atomic if (it != peer.m_getdata_requests.end() && !pfrom.fPauseSend) { - const CInv &inv = *it++; + const CInv& inv = *it; if (inv.IsGenBlkMsg()) { ``` Using a fuzz input such as: ``` $ base64 ./timeout-ada0fecaba2b8c46c6e970cf637d9625b01bf7e5 kNptdNbW1tbWYghvXIpwb25vPQAA////////cwAjLv8AXAB2ZXJhY2sAQW5v/62tra3Pz/////// //////////////////////9c8GZpbHRlcmxvYWQAAAEAAwAAAABVYwC2XABmaWx0ZXJhZGQAAAAX Fxdn/////2V0F861tcqvEmAAACEAAABjYXB0dXJldmUAAH4AgAA1PNfX11x0Z2V0ZGF0YQBDACOw AQMAAAAGIm5GERoLWcqvEmBD61u/KMNPOl4zKh/HKLK3PPGIkQ9eE/////////8AAAAAAAAAAFtb WyjDTzpeMSofx7K3PNfX11x0Z2V0ZGF0YQBDACMwAQMAAAAGIm5GERoLWcqvEmBD61u/KMNPOl4z Kh/Hsrc88YiRD2/Nzc3Nzc3Nzc3NTc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3N zWWj1NTUudTU1NTU1P///0j+P/9cdHR4AAAAAAAAy/4AAHR4AAAAAAAAP8v+AAD/+P////////// AX55bJl8HWnz/////wAgXGF0YVPxY2RkAAAA ``` And running the fuzz target: ``` $ FUZZ=process_messages ./src/test/fuzz/fuzz -runs=1 -timeout=18 ./timeout-ada0fecaba2b8c46c6e970cf637d9625b01bf7e5 INFO: Running with entropic power schedule (0xFF, 100). INFO: Seed: 3436516708 INFO: Loaded 1 modules (390807 inline 8-bit counters): 390807 [0x55d0d6221e80, 0x55d0d6281517), INFO: Loaded 1 PC tables (390807 PCs): 390807 [0x55d0d6281518,0x55d0d6877e88), ./src/test/fuzz/fuzz: Running 1 inputs 1 time(s) each. Running: ./timeout-ada0fecaba2b8c46c6e970cf637d9625b01bf7e5 ALARM: working on the last Unit for 19 seconds and the timeout value is 18 (use -timeout=N to change) ==375014== ERROR: libFuzzer: timeout after 19 seconds ``` ACKs for top commit: naumenkogs: ACK 9f265d88253ed464413dea5614fa13dea0d8cfd5 dergoegge: ACK 9f265d88253ed464413dea5614fa13dea0d8cfd5 brunoerg: ACK 9f265d88253ed464413dea5614fa13dea0d8cfd5 Tree-SHA512: da83ff90962bb679aae00e8e9dba639c180b7aaba544e0c4d0978d36e28a9ff1cd7a2e13009d8ab407ef57767656aca1ebc767a7d2f1bc880284f8f57c197a50
2023-12-11Merge bitcoin/bitcoin#29031: fuzz: Improve fuzzing stability for txorphan ↵fanquake
harness 15f5a0d0c8ce6b306cdeba6a4777334b848a76aa fuzz: Improve fuzzing stability for txorphan harness (dergoegge) Pull request description: The `txorphan` harness has low stability as eviction of orphan txs is entirely random at the moment. Fix this by passing the rng to `LimitOrphans`, which can be deterministic in tests. Also see #29018. ACKs for top commit: maflcko: lgtm ACK 15f5a0d0c8ce6b306cdeba6a4777334b848a76aa brunoerg: utACK 15f5a0d0c8ce6b306cdeba6a4777334b848a76aa Tree-SHA512: 854ec34b3a0f16f26db6dc419096c6e7a380e8400119534aa278d6b1d54c253b572aa2fad13c383c796c431d8ff4263956e6f60326e99f8bf6abd16d9a280e97
2023-12-08fuzz: Improve fuzzing stability for txorphan harnessdergoegge
2023-12-08Merge bitcoin/bitcoin#28349: build: Require C++20 compilerfanquake
fa6e50d6c79633e22ad4cfc75f56aaa40112ecbb fuzz: Use C++20 starts_with in rpc.cpp (MarcoFalke) faa48388bca06df1ca7ab92461b76a6720481e45 Revert "tracepoints: Disables `-Wgnu-zero-variadic-macro-arguments` to compile without warnings" (MarcoFalke) fae3b77a87f4d799aca5907335a9dcbab3a51db6 refactor: Drop unused _Pragma to ignore -Wgnu-zero-variadic-macro-arguments (MarcoFalke) fa02fc0a86c410f907de4fee91dd045547ea4b6e refactor: modernize-use-default-member-init for bit-fields (C++20) (MarcoFalke) fa67f096bdea9db59dd20c470c9e32f3dac5be94 build: Require C++20 compiler (MarcoFalke) Pull request description: C++20 allows to write safer code, because it allows to enforce more stuff at compile time (`constinit`, `conteval`, `constexpr`, `std::span`, ...). Also, it allows to write less verbose and easier to understand code (C++ 20 Concepts). See https://github.com/bitcoin/bitcoin/issues/23363 and https://en.cppreference.com/w/cpp/compiler_support#cpp20 With g++-10 (https://github.com/bitcoin/bitcoin/pull/28348) and clang-13 (https://github.com/bitcoin/bitcoin/pull/28210), there is broad support for almost all features of C++20. It should be fine to require a C++20 compiler for Bitcoin Core 27.0 in 2024 (next year), not the soon upcoming 26.0 next month. This pull request includes three small cleanups to make use of C++20 features. If any issues are detected before or after merge, this should be easy to revert. If no issues arise, it should be fine to make use of more involved C++20 features later on. ACKs for top commit: fanquake: ACK fa6e50d6c79633e22ad4cfc75f56aaa40112ecbb Tree-SHA512: 244d79bfb0b750a4bdd713f40573b9ca33816fb84b6c84a58f027b9d7d4bb0cc4f18642959e4cf3d094808a69e5b8a327ca8521d7c0c08af27dacb5da3e78e71
2023-12-07Merge bitcoin/bitcoin#28924: refactor: Remove unused and fragile string ↵fanquake
interface from arith_uint256 fa63f16018d9468e1751d2107b5102184ac2d5ae test: Add uint256 string parse tests (MarcoFalke) facf629ce8ff1d1f6d254dde4e89b5018f8df60e refactor: Remove unused and fragile string interface from arith_uint256 (MarcoFalke) Pull request description: The string interface (`base_uint(const std::string&)`, as well as `base_uint::SetHex`) is problematic for many reasons: * It is unused (except in test-only code). * It is redundant with the `uint256` string interface: `std::string -> uint256 -> UintToArith256`. * It is brittle, because it inherits the brittle `uint256` string interface, which is brittle due to the use of `c_str()` (embedded null will be treated as end-of string), etc ... Instead of fixing the interface, remove it since it is unused and redundant with `UintToArith256`. ACKs for top commit: ajtowns: ACK fa63f16018d9468e1751d2107b5102184ac2d5ae TheCharlatan: ACK fa63f16018d9468e1751d2107b5102184ac2d5ae Tree-SHA512: a95d5b938ffd0473361336bbf6be093d01265a626c50be1345ce2c5e582c0f3f73eb11af5fd1884019f59d7ba27e670ecffdb41d2c624ffb9aa63bd52b780e62
2023-12-07refactor: rpc: Pass CBlockIndex by reference instead of pointerMarcoFalke
All functions assume that the pointer is never null, so pass by reference, to avoid accidental segfaults at runtime, or at least make them more obvious. Also, remove unused c-style casts in touched lines. Also, add CHECK_NONFATAL checks, to turn segfault crashes into an recoverable runtime error with debug information.
2023-12-07fuzz: Use C++20 starts_with in rpc.cppMarcoFalke
2023-12-07refactor: Drop unused _Pragma to ignore -Wgnu-zero-variadic-macro-argumentsMarcoFalke
2023-12-06Merge bitcoin/bitcoin#29012: fuzz: Avoid timeout in bitdequefanquake
fad1903b8a85506378101c1f857ba47b4a058fb4 fuzz: Avoid timeout in bitdeque (MarcoFalke) Pull request description: Avoid timeouts such as https://github.com/bitcoin/bitcoin/issues/28812#issuecomment-1842914664 This is done by: * Limiting the maximum number of iterations if the maximum size of the container is "large" (see the magic numbers in the code). * Check the equality only once. This should be fine, because if a crash were to happen in the equality check, but the crash doesn't happen if further iterations were run, the fuzz engine should eventually find the crash by truncating the fuzz input. ACKs for top commit: sipa: utACK fad1903b8a85506378101c1f857ba47b4a058fb4 dergoegge: utACK fad1903b8a85506378101c1f857ba47b4a058fb4 brunoerg: crACK fad1903b8a85506378101c1f857ba47b4a058fb4 Tree-SHA512: d3d83acb3e736b8fcaf5d17ce225ac82a9f9a2efea048512d2fed594ba6c76c25bae72eb0fab3276d4db37baec0752e5367cecfb18161301b921fed09693045e
2023-12-06Merge bitcoin/bitcoin#27581: net: Continuous ASMap health checkAndrew Chow
3ea54e5db7d53da5afa321e1800c29aa269dd3b3 net: Add continuous ASMap health check logging (Fabian Jahr) 28d7e55dff826a69f3f8e58139dbffb611cc5947 test: Add tests for unfiltered GetAddr usage (Fabian Jahr) b8843d37aed1276ff8527328c956c70c6e02ee13 fuzz: Let fuzzers use filter options in GetAddr/GetAddresses (Fabian Jahr) e16f420547fc72a5a2902927aa7138e43c0fb7c8 net: Optionally include terrible addresses in GetAddr results (Fabian Jahr) Pull request description: There are certain statistics we can collect by running all our known clearnet addresses against the ASMap file. This could show issues with a maliciously manipulated file or with an old file that has decayed with time. This is just a proof of concept for now. My idea currently is to run the analysis once per day and print the results to logs if an ASMap file is used. ACKs for top commit: achow101: ACK 3ea54e5db7d53da5afa321e1800c29aa269dd3b3 mzumsande: ACK 3ea54e5db7d53da5afa321e1800c29aa269dd3b3 brunoerg: crACK 3ea54e5db7d53da5afa321e1800c29aa269dd3b3 Tree-SHA512: 777acbfac43cc43ce4a0a3612434e4ddbc65f59ae8ffc9e24f21de09011bccb297f0599cbaa82bcf40ef68e5af582c4e98556379db7ceff7d9f97574a1cf8e09
2023-12-06fuzz: Detect deadlocks in process_messagedergoegge
2023-12-06Merge bitcoin/bitcoin#28989: test: Fix test by checking the actual exception ↵Andrew Chow
instance 55e3dc3e03510e97caba1547a82e3e022b0bbd42 test: Fix test by checking the actual exception instance (Hennadii Stepanov) Pull request description: The `system_tests/run_command` test is broken because it passes even with the diff as follows: ```diff --- a/src/test/system_tests.cpp +++ b/src/test/system_tests.cpp @@ -90,7 +90,7 @@ BOOST_AUTO_TEST_CASE(run_command) }); } { - BOOST_REQUIRE_THROW(RunCommandParseJSON("echo \"{\""), std::runtime_error); // Unable to parse JSON + BOOST_REQUIRE_THROW(RunCommandParseJSON("invalid_command \"{\""), std::runtime_error); // Unable to parse JSON } // Test std::in, except for Windows #ifndef WIN32 ``` The reason of such fragility is that the [`BOOST_REQUIRE_THROW`](https://www.boost.org/doc/libs/1_83_0/libs/test/doc/html/boost_test/utf_reference/testing_tool_ref/assertion_boost_level_throw.html) macro passes even if the command raises an exception in the underlying subprocess implementation, which might have a type derived from `std::runtime_error`. ACKs for top commit: maflcko: lgtm ACK 55e3dc3e03510e97caba1547a82e3e022b0bbd42 achow101: ACK 55e3dc3e03510e97caba1547a82e3e022b0bbd42 furszy: Non-Windows code ACK 55e3dc3e pablomartin4btc: ACK 55e3dc3e03510e97caba1547a82e3e022b0bbd42 Tree-SHA512: 32f49421bdcc94744c81e82dc10cfa02e3f8ed111974edf1c2a47bdaeb56d7baec1bede67301cc89464fba613029ecb131dedc6bc5948777ab52f0f12df8bfe9
2023-12-06fuzz: Avoid timeout in bitdequeMarcoFalke
2023-12-06fuzz: p2p: Detect peer deadlocksMarcoFalke
2023-12-04fuzz: txorphan check wtxids using GenTxid::Wtxid not GenTxid::TxidGreg Sanders
2023-12-04Get rid of shutdown.cpp/shutdown.h, use SignalInterrupt directlyRyan Ofsky
This change is mostly a refectoring that removes some code and gets rid of an unnecessary layer of indirection after #27861 But it is not a pure refactoring since StartShutdown, AbortShutdown, and WaitForShutdown functions used to abort on failure, and the replacement code logs or returns errors instead.
2023-12-04refactor: Remove calls to StartShutdown from KernelNotificationsRyan Ofsky
Use SignalInterrupt object instead. There is a slight change in behavior here because the previous StartShutdown code used to abort on failure and the new code logs errors instead.
2023-12-04refactor: Remove call to ShutdownRequested from IndexWaitSyncedRyan Ofsky
Use the node interrupt object instead. There is no change in behavior in this commit.
2023-12-04refactor: Remove call to ShutdownRequested from HTTPRequestRyan Ofsky
Pass HTTP server an interrupt object instead of having it depend on shutdown.h and global shutdown state. There is no change in behavior in this commit.
2023-12-04refactor: Add NodeContext::shutdown memberRyan Ofsky
Add NodeContext::shutdown variable and start using it to replace the kernel::Context::interrupt variable. The latter can't easily be removed right away but will be removed later in this PR. Moving the interrupt object from the kernel context to the node context increases flexibility of the kernel API so it is possible to use multiple interrupt objects, or avoid creating one if one is not needed. It will also allow getting rid of the kernel::g_context global later in this PR, replacing it with a private SignalInterrupt instance in init.cpp There is no change in behavior in this commit outside of unit tests. In unit tests there should be no visible change either, but internally now each test has its own interrupt variable so the variable will be automatically reset between tests.
2023-12-03test: Fix test by checking the actual exception instanceHennadii Stepanov
The BOOST_REQUIRE_THROW passes even if the command raises an exception in the underlying subprocess implementation, which might have a type derived from std::runtime_error.
2023-12-01Merge bitcoin/bitcoin#28368: Fee Estimator updates from Validation ↵Andrew Chow
Interface/CScheduler thread 91504cbe0de2b74ef1aa2709761aaf0597ec66a2 rpc: `SyncWithValidationInterfaceQueue` on fee estimation RPC's (ismaelsadeeq) 714523918ba2b853fc69bee6b04a33ba0c828bf5 tx fees, policy: CBlockPolicyEstimator update from `CValidationInterface` notifications (ismaelsadeeq) dff5ad3b9944cbb56126ba37a8da180d1327ba39 CValidationInterface: modify the parameter of `TransactionAddedToMempool` (ismaelsadeeq) 91532bd38223d7d04166e05de11d0d0b55e60f13 tx fees, policy: update `CBlockPolicyEstimator::processBlock` parameter (ismaelsadeeq) bfcd401368fc0dc43827a8969a37b7e038d5ca79 CValidationInterface, mempool: add new callback to `CValidationInterface` (ismaelsadeeq) 0889e07987294d4ef2814abfca16d8e2a0c5f541 tx fees, policy: cast with static_cast instead of C-Style cast (ismaelsadeeq) a0e3eb7549d2ba4dd3af12b9ce65e29158f59078 tx fees, policy: bugfix: move `removeTx` into reason != `BLOCK` condition (ismaelsadeeq) Pull request description: This is an attempt to #11775 This Pr will enable fee estimator to listen to ValidationInterface notifications to process new transactions added and removed from the mempool. This PR includes the following changes: - Added a new callback to the Validation Interface `MempoolTransactionsRemovedForConnectedBlock`, which notifies listeners about the transactions that have been removed due to a new block being connected, along with the height at which the transactions were removed. - Modified the `TransactionAddedToMempool` callback parameter to include additional information about the transaction needed for fee estimation. - Updated `CBlockPolicyEstimator` to process transactions using` CTransactionRef` instead of `CTxMempoolEntry.` - Implemented the `CValidationInterface` interface in `CBlockPolicyEstimater` and overridden the `TransactionAddedToMempool`, `TransactionRemovedFromMempool`, and `MempoolTransactionsRemovedForConnectedBlock` methods to receive updates from their notifications. Prior to this PR, the fee estimator updates from the mempool, i.e whenever a new block is connected all transactions in the block that are in our mempool are going to be removed using the `removeForBlock` function in `txmempool.cpp`. This removal triggered updates to the fee estimator. As a result, the fee estimator would block mempool's `cs` until it finished updating every time a new block was connected. Instead of being blocked only on mempool tx removal, we were blocking on both tx removal and fee estimator updating. If we want to further improve fee estimation, or add heavy-calulation steps to it, it is currently not viable as we would be slowing down block relay in the process This PR is smaller in terms of the changes made compared to #11775, as it focuses solely on enabling fee estimator updates from the validationInterface/cscheduler thread notifications. I have not split the validation interface because, as I understand it, the rationale behind the split in #11775 was to have `MempoolInterface` signals come from the mempool and `CValidationInterface` events come from validation. I believe this separation can be achieved in a separate refactoring PR when the need arises. Also left out some commits from #11775 - Some refactoring which are no longer needed. - Handle reorgs much better in fee estimator. - Track witness hash malleation in fee estimator I believe they are a separate change that can come in a follow-up after this. ACKs for top commit: achow101: ACK 91504cbe0de2b74ef1aa2709761aaf0597ec66a2 TheCharlatan: Re-ACK 91504cbe0de2b74ef1aa2709761aaf0597ec66a2 willcl-ark: ACK 91504cbe0de2b74ef1aa2709761aaf0597ec66a2 Tree-SHA512: 846dfb9da57a8a42458827b8975722d153907fe6302ad65748d74f311e1925557ad951c3d95fe71fb90ddcc8a3710c45abb343ab86b88780871cb9c38c72c7b1
2023-11-30Merge bitcoin/bitcoin#26762: bugfix: Make `CCheckQueue` RAII-styled (attempt 2)Andrew Chow
5b3ea5fa2e7f6dc1c9161ed8b74c9be4bd1e92dd refactor: Move `{MAX,DEFAULT}_SCRIPTCHECK_THREADS` constants (Hennadii Stepanov) 6e17b3168072ab77ed7170ab81327c017877133a refactor: Make `CCheckQueue` non-copyable and non-movable explicitly (Hennadii Stepanov) 8111e74653dc5c93cb510672d99048c3f741d8dc refactor: Drop unneeded declaration (Hennadii Stepanov) 9cf89f7a5b81197e38f58b24be0793b28fe41477 refactor: Make `CCheckQueue` constructor start worker threads (Hennadii Stepanov) d03eaacbcfb276fb638db1b423113ff43bd7ec41 Make `CCheckQueue` destructor stop worker threads (Hennadii Stepanov) be4ff3060b7b43b496dfb5a2c02b114b2b717106 Move global `scriptcheckqueue` into `ChainstateManager` class (Hennadii Stepanov) Pull request description: This PR: - makes `CCheckQueue` RAII-styled - gets rid of the global `scriptcheckqueue` - fixes https://github.com/bitcoin/bitcoin/issues/25448 The previous attempt was in https://github.com/bitcoin/bitcoin/pull/18731. ACKs for top commit: martinus: ACK 5b3ea5fa2e7 achow101: ACK 5b3ea5fa2e7f6dc1c9161ed8b74c9be4bd1e92dd TheCharlatan: ACK 5b3ea5fa2e7f6dc1c9161ed8b74c9be4bd1e92dd Tree-SHA512: 45cca846e7ed107e3930149f0b616ddbaf2648d6cde381f815331b861b5d67ab39e154883ae174b8abb1dae485bc904318c50c51e5d6b46923d89de51c5eadb0
2023-11-30Merge bitcoin/bitcoin#28451: refactor: Remove unused SER_DISK, SER_NETWORK, ↵Ryan Ofsky
CDataStream fa98a097a30bc39f2424c0efd28a7979155faae6 Rename version.h to node/protocol_version.h (MarcoFalke) fa4fbd58169a244c14017c62218e443b18a868ef Remove unused version.h include (MarcoFalke) fa0ae22ff2c608c94b26c85040c4a1c7e9f7cf90 Remove unused SER_NETWORK, SER_DISK (MarcoFalke) fae00fe9c25af80024adda33d9077962964269ea Remove unused CDataStream (MarcoFalke) fa7eb4f5c3d2438f9689cd46b22dcfd50f6bd751 fuzz: Drop unused version from fuzz input format (MarcoFalke) Pull request description: Seems odd to have code that is completely dead. Fix this by removing all of it. ACKs for top commit: sipa: utACK fa98a097a30bc39f2424c0efd28a7979155faae6 ajtowns: ACK fa98a097a30bc39f2424c0efd28a7979155faae6 ryanofsky: Seems odd to not code review ACK fa98a097a30bc39f2424c0efd28a7979155faae6 (looks good) Tree-SHA512: 9f1b9d9f92bda0512610bda6653e892756f637860362a9abfa439faab62de233cbad94b7df78ebacc160d9667aadfed4d9df08c0edefa618c040a049050fb913
2023-11-30Merge bitcoin/bitcoin#28951: fuzz: BIP324: damage ciphertext/aad in full ↵fanquake
byte range e67634ef19db310511a22f461bb1af7edb3d862b fuzz: BIP324: damage ciphertext/aad in full byte range (Sebastian Falbesoner) Pull request description: This PR is a tiny improvement for the `bip324_cipher_roundtrip` fuzz target: currently the damaging of input data for decryption (either ciphertext or aad) only ever happens in the lower nibble within the byte at the damage position, as the bit position for the `damage_val` byte was calculated with `damage_bit & 3` (corresponding to `% 4`) rather than `damage_bit & 7` (corresponding to the expected `% 8`). Noticed while reviewing #28263 which uses similar constructs. ACKs for top commit: stratospher: ACK e67634ef. dergoegge: utACK e67634ef19db310511a22f461bb1af7edb3d862b Tree-SHA512: 1bab4df28708e079874feee939beef45eff235215375c339decc696f4c9aef04e4b417322b045491c8aec6e88ec8ec2db564e27ef1b0be352b6ff4ed38bad49a
2023-11-30Rename version.h to node/protocol_version.hMarcoFalke
2023-11-30Remove unused version.h includeMarcoFalke
2023-11-30Remove unused CDataStreamMarcoFalke
2023-11-30fuzz: Drop unused version from fuzz input formatMarcoFalke
2023-11-29Merge bitcoin/bitcoin#28486: test, bench: Initialize and terminate use of ↵fanquake
Winsock properly fd4c6a10f2285f16c5d0215eb56a3060441f3ef2 test: Setup networking globally (Hennadii Stepanov) Pull request description: On the master branch, when compiling without external signer support, the `bench_bitcoin.exe` does not initialize Winsock DLL that is required, for example, here: https://github.com/bitcoin/bitcoin/blob/459272d639b9547f68000d2b9a5a0d991d477de5/src/bench/addrman.cpp#L124 Moreover, Windows docs explicitly [state](https://learn.microsoft.com/en-us/windows/win32/api/winsock/nf-winsock-wsacleanup) that `WSAStartup` and `WSACleanup` must be balanced: > There must be a call to `WSACleanup` for each successful call to `WSAStartup`. Only the final `WSACleanup` function call performs the actual cleanup. The preceding calls simply decrement an internal reference count in the WS2_32.DLL. That is not the case for our unit tests because the `SetupNetworking()` call is a part of the `BasicTestingSetup` fixture and is invoked multiple times, while `~CNetCleanup()` is invoked once only, at the end of the test binary execution. This PR fixes Winsock DLL initialization and termination. More docs: - https://learn.microsoft.com/en-us/windows/win32/winsock/initializing-winsock - https://learn.microsoft.com/en-us/windows/win32/api/winsock/nf-winsock-wsastartup - https://learn.microsoft.com/en-us/windows/win32/api/winsock/nf-winsock-wsacleanup Fix https://github.com/bitcoin/bitcoin/issues/28940. ACKs for top commit: maflcko: lgtm ACK fd4c6a10f2285f16c5d0215eb56a3060441f3ef2 Tree-SHA512: d360eaf776943f7f7a35ed5a5f9f3228d9e3d18eb824e5997cdc8eadddf466abe9f2da4910ee3bb86bf5411061e758259f7e1ec344f234ef7996f1bf8781dcda
2023-11-29fuzz: Fix nullptr deref in scriptpubkeymanMarcoFalke
Also, add missing includes to scriptpubkeyman. Also, export dependecies of the BasicTestingSetup from setup_common.h, to avoid having to include them when setup_common.h is already included.
2023-11-29Merge bitcoin/bitcoin#28958: refactor: Use Txid in CMerkleBlockfanquake
fa02c08c93e5867b7ea07d79ca1c0917dcde88e0 refactor: Use Txid in CMerkleBlock (MarcoFalke) Pull request description: This should also fix a gcc-13 compiler warning, see https://github.com/bitcoin/bitcoin/pull/28922#discussion_r1407856376 ``` rpc/txoutproof.cpp: In lambda function: rpc/txoutproof.cpp:72:33: error: possibly dangling reference to a temporary [-Werror=dangling-reference] 72 | const Coin& coin = AccessByTxid(active_chainstate.CoinsTip(), Txid::FromUint256(tx)); | ^~~~ rpc/txoutproof.cpp:72:52: note: the temporary was destroyed at the end of the full expression ‘AccessByTxid((*(const CCoinsViewCache*)(&(& active_chainstate)->Chainstate::CoinsTip())), transaction_identifier<false>::FromUint256((* & tx)))’ 72 | const Coin& coin = AccessByTxid(active_chainstate.CoinsTip(), Txid::FromUint256(tx)); | ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ cc1plus: all warnings being treated as errors ACKs for top commit: TheCharlatan: Re-ACK fa02c08c93e5867b7ea07d79ca1c0917dcde88e0 dergoegge: reACK fa02c08c93e5867b7ea07d79ca1c0917dcde88e0 Tree-SHA512: 2e6837b9d0c90bd6e9d766330e7086d68c6ec80bb27fe2cfc4702b251b00d91a79f8bfbc76d998cbcd90bee5317402cf617f61099eee96d94e7ac8f37ba7a642
2023-11-28Merge bitcoin/bitcoin#28903: refactor: Make CTxMemPoolEntry only explicitly ↵Andrew Chow
copyable 705e3f1de00bf30d728addd52a790a139d948e32 refactor: Make CTxMemPoolEntry only explicitly copyable (TheCharlatan) Pull request description: This has the goal of prohibiting users from accidentally creating runtime failures, e.g. by interacting with iterator_to with a copied entry. This was brought up here: https://github.com/bitcoin/bitcoin/pull/28886#issuecomment-1814794954. CTxMemPoolEntry is already implicitly not move-constructable. So be explicit about this and use a std::list to collect the values in the policy_estimator fuzz test instead of a std::vector. ACKs for top commit: maflcko: ACK 705e3f1de00bf30d728addd52a790a139d948e32 🌯 achow101: ACK 705e3f1de00bf30d728addd52a790a139d948e32 ajtowns: ACK 705e3f1de00bf30d728addd52a790a139d948e32 ismaelsadeeq: ACK 705e3f1de00bf30d728addd52a790a139d948e32 Tree-SHA512: 62056905c679c919d00f9ae065ed66ac986e7e7062015aea542843d8deecda57104d7a68d002f7b20afa3164f8e9215d2d2d002c167224129540e3b1bd0712cc
2023-11-28test: Setup networking globallyHennadii Stepanov
2023-11-28Merge bitcoin/bitcoin#28912: refactor: VectorWriter and SpanReader without ↵fanquake
nVersion fae76a1f2ac0b352cdd708e6d57f8605bf40112e scripted-diff: Use DataStream in most places (MarcoFalke) fac39b56b723f79ba0aa9570708a1d4a600f4e12 refactor: SpanReader without nVersion (MarcoFalke) Pull request description: The serialize version is unused, so remove it. This also allows to remove `GCS_SER_VERSION` and allows a scripted-diff to remove most of `CDataStream`. ACKs for top commit: ajtowns: ACK fae76a1f2ac0b352cdd708e6d57f8605bf40112e ryanofsky: Code review ACK fae76a1f2ac0b352cdd708e6d57f8605bf40112e Tree-SHA512: 3b487dba8ea380f1eacff9fdfb9197f025dbc30906813d3f4c3e6f1e9e4d9f2a169c6f163f51d135e18af538be78e2d2b13d694073ad25c5762980ae971a4c83
2023-11-28refactor: Use Txid in CMerkleBlockMarcoFalke
2023-11-28Merge bitcoin/bitcoin#28952: fuzz: Avoid timeout in process_messagesfanquake
fa825975b57bc5c4323e5d6f4bc8cd2b8189e238 fuzz: Avoid timeout in process_messages (MarcoFalke) Pull request description: Reduce the number of messages per fuzz input. There should be no reason to have more messages than that. This should also avoid timeouts, such as https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=64548. CC https://github.com/bitcoin/bitcoin/issues/28812 ACKs for top commit: dergoegge: utACK fa825975b57bc5c4323e5d6f4bc8cd2b8189e238 Tree-SHA512: eeff732f7b0bd9a71f23aeecbf813d31fe34d355b906fd0384a43075cbc3cebc46a26df741b0f337208d8b33b3e28210c9b9437e2eed77844f03131bb8f5f2a1
2023-11-28scripted-diff: Use DataStream in most placesMarcoFalke
The remaining places are handled easier outside a scripted-diff. -BEGIN VERIFY SCRIPT- sed --regexp-extended -i 's/CDataStream ([0-9a-zA-Z_]+)\(SER_[A-Z]+, [A-Z_]+_VERSION\);/DataStream \1{};/g' $( git grep -l CDataStream) sed -i 's/, CDataStream/, DataStream/g' src/wallet/walletdb.cpp -END VERIFY SCRIPT-