backport: Merge bitcoin#28486, 28969, 27921, 27177, 26331#7187
backport: Merge bitcoin#28486, 28969, 27921, 27177, 26331#7187vijaydasmp wants to merge 5 commits intodashpay:developfrom
Conversation
✅ No Merge Conflicts DetectedThis PR currently has no conflicts with other open PRs. |
cc2dde1 to
07a7223
Compare
ef69fcc to
0d94597
Compare
24aa142 to
3cb315d
Compare
5a494d7 to
6378033
Compare
…sock properly fd4c6a1 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 bitcoin#28940. ACKs for top commit: maflcko: lgtm ACK fd4c6a1 Tree-SHA512: d360eaf776943f7f7a35ed5a5f9f3228d9e3d18eb824e5997cdc8eadddf466abe9f2da4910ee3bb86bf5411061e758259f7e1ec344f234ef7996f1bf8781dcda
…tifications fuzz target fab164f fuzz: Avoid signed-integer-overflow in wallet_notifications fuzz target (MarcoFalke) Pull request description: Should avoid ``` policy/feerate.cpp:29:63: runtime error: signed integer overflow: 77600710321911316 * 149 cannot be represented in type 'int64_t' (aka 'long') #0 0x563a1775ed66 in CFeeRate::GetFee(unsigned int) const src/policy/feerate.cpp:29:63 #1 0x563a15913a69 in wallet::COutput::COutput(COutPoint const&, CTxOut const&, int, int, bool, bool, bool, long, bool, std::optional<CFeeRate>) src/./wallet/coinselection.h:91:57 #2 0x563a16fa6a6d in wallet::FetchSelectedInputs(wallet::CWallet const&, wallet::CCoinControl const&, wallet::CoinSelectionParams const&) src/wallet/spend.cpp:297:17 #3 0x563a16fc4512 in wallet::CreateTransactionInternal(wallet::CWallet&, std::vector<wallet::CRecipient, std::allocator<wallet::CRecipient>> const&, int, wallet::CCoinControl const&, bool) src/wallet/spend.cpp:1105:33 #4 0x563a16fbec74 in wallet::CreateTransaction(wallet::CWallet&, std::vector<wallet::CRecipient, std::allocator<wallet::CRecipient>> const&, int, wallet::CCoinControl const&, bool) src/wallet/spend.cpp:1291:16 #5 0x563a16fcf6df in wallet::FundTransaction(wallet::CWallet&, CMutableTransaction&, long&, int&, bilingual_str&, bool, std::set<int, std::less<int>, std::allocator<int>> const&, wallet::CCoinControl) src/wallet/spend.cpp:1361:16 #6 0x563a1597b7b9 in wallet::(anonymous namespace)::FuzzedWallet::FundTx(FuzzedDataProvider&, CMutableTransaction) src/wallet/test/fuzz/notifications.cpp:162:15 #7 0x563a15958240 in wallet::(anonymous namespace)::wallet_notifications_fuzz_target(Span<unsigned char const>)::$_0::operator()() const src/wallet/test/fuzz/notifications.cpp:228:23 #8 0x563a15958240 in unsigned long CallOneOf<wallet::(anonymous namespace)::wallet_notifications_fuzz_target(Span<unsigned char const>)::$_0, wallet::(anonymous namespace)::wallet_notifications_fuzz_target(Span<unsigned char const>)::$_1>(FuzzedDataProvider&, wallet::(anonymous namespace)::wallet_notifications_fuzz_target(Span<unsigned char const>)::$_0, wallet::(anonymous namespace)::wallet_notifications_fuzz_target(Span<unsigned char const>)::$_1) src/./test/fuzz/util.h:43:27 #9 0x563a15958240 in wallet::(anonymous namespace)::wallet_notifications_fuzz_target(Span<unsigned char const>) src/wallet/test/fuzz/notifications.cpp:196:9 #10 0x563a15fdef0c in std::function<void (Span<unsigned char const>)>::operator()(Span<unsigned char const>) const /usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/std_function.h:591:9 dashpay#11 0x563a15fdef0c in LLVMFuzzerTestOneInput src/test/fuzz/fuzz.cpp:178:5 dashpay#12 0x563a158032a4 in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) (/ci_container_base/ci/scratch/build/bitcoin-x86_64-pc-linux-gnu/src/test/fuzz/fuzz+0x19822a4) (BuildId: 8acb42ad599d7f6d25b6f93e18fd564d80df7c06) dashpay#13 0x563a15802999 in fuzzer::Fuzzer::RunOne(unsigned char const*, unsigned long, bool, fuzzer::InputInfo*, bool, bool*) (/ci_container_base/ci/scratch/build/bitcoin-x86_64-pc-linux-gnu/src/test/fuzz/fuzz+0x1981999) (BuildId: 8acb42ad599d7f6d25b6f93e18fd564d80df7c06) dashpay#14 0x563a15804586 in fuzzer::Fuzzer::ReadAndExecuteSeedCorpora(std::vector<fuzzer::SizedFile, std::allocator<fuzzer::SizedFile>>&) (/ci_container_base/ci/scratch/build/bitcoin-x86_64-pc-linux-gnu/src/test/fuzz/fuzz+0x1983586) (BuildId: 8acb42ad599d7f6d25b6f93e18fd564d80df7c06) dashpay#15 0x563a15804aa7 in fuzzer::Fuzzer::Loop(std::vector<fuzzer::SizedFile, std::allocator<fuzzer::SizedFile>>&) (/ci_container_base/ci/scratch/build/bitcoin-x86_64-pc-linux-gnu/src/test/fuzz/fuzz+0x1983aa7) (BuildId: 8acb42ad599d7f6d25b6f93e18fd564d80df7c06) dashpay#16 0x563a157f21fb in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) (/ci_container_base/ci/scratch/build/bitcoin-x86_64-pc-linux-gnu/src/test/fuzz/fuzz+0x19711fb) (BuildId: 8acb42ad599d7f6d25b6f93e18fd564d80df7c06) dashpay#17 0x563a1581c766 in main (/ci_container_base/ci/scratch/build/bitcoin-x86_64-pc-linux-gnu/src/test/fuzz/fuzz+0x199b766) (BuildId: 8acb42ad599d7f6d25b6f93e18fd564d80df7c06) dashpay#18 0x7f499e17b0cf (/lib/x86_64-linux-gnu/libc.so.6+0x280cf) (BuildId: 96ab1a8f3b2c9a2ed37c7388615e6a726d037e89) dashpay#19 0x7f499e17b188 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x28188) (BuildId: 96ab1a8f3b2c9a2ed37c7388615e6a726d037e89) dashpay#20 0x563a157e70c4 in _start (/ci_container_base/ci/scratch/build/bitcoin-x86_64-pc-linux-gnu/src/test/fuzz/fuzz+0x19660c4) (BuildId: 8acb42ad599d7f6d25b6f93e18fd564d80df7c06) SUMMARY: UndefinedBehaviorSanitizer: signed-integer-overflow policy/feerate.cpp:29:63 in MS: 0 ; base unit: 0000000000000000000000000000000000000000 0x3f,0x0,0x2f,0x5f,0x5f,0x5f,0x7d,0x7d,0x7d,0x7d,0x7d,0x7d,0x7d,0x7d,0x7d,0x7d,0x7d,0x7d,0x7d,0x7d,0x7d,0x7d,0x7d,0x7d,0x7d,0x7d,0xff,0xff,0xff,0xff,0xff,0x53,0xff,0xff,0xff,0xff,0xff,0x0,0x0,0x0,0x0,0x0,0x0,0x13,0x5e,0x5f,0x5f,0x8,0x25,0x0,0x5f,0x5f,0x5f,0x5f,0x5f,0x5f,0x8,0x25,0xca,0x7f,0x5f,0x5f,0x5f,0x13,0x13,0x5f,0x5f,0x5f,0x2,0xdb,0xca,0x0,0x0,0xe7,0xe6,0x66,0x65,0x0,0x0,0x0,0x0,0x44,0x3f,0xa,0xa,0xff,0xff,0xff,0xff,0xff,0x61,0x76,0x6f,0x69,0x0,0xb5,0x15, ?\000/___}}}}}}}}}}}}}}}}}}}}\377\377\377\377\377S\377\377\377\377\377\000\000\000\000\000\000\023^__\010%\000______\010%\312\177___\023\023___\002\333\312\000\000\347\346fe\000\000\000\000D?\012\012\377\377\377\377\377avoi\000\265\025 artifact_prefix='./'; Test unit written to ./crash-4d3bac8a64d4e58b2f0943e6d28e6e1f16328d7d Base64: PwAvX19ffX19fX19fX19fX19fX19fX19fX3//////1P//////wAAAAAAABNeX18IJQBfX19fX18IJcp/X19fExNfX18C28oAAOfmZmUAAAAARD8KCv//////YXZvaQC1FQ== ACKs for top commit: dergoegge: ACK fab164f brunoerg: ACK fab164f Tree-SHA512: f416828f4394aa7303ee437f141e9bbd23c0e0f1b830e4ef3932338858249ba68a811b9837c5b7ad8c6ab871b6354996434183597c1a910a8d8e8d829693e4b2
fa31c4d fuzz: Avoid OOM in transaction fuzz target (MarcoFalke) Pull request description: To test: `FUZZ=transaction /usr/bin/time -f '%Us %MkB' ./src/test/fuzz/fuzz ../btc_qa_assets/fuzz_seed_corpus/transaction/9dc22b51df0af05ee5a595beefb0ce291feb6b99` Before: `0.72s 249636kB` After: `0.30s 92128kB` ACKs for top commit: dergoegge: utACK fa31c4d Tree-SHA512: 958fc54e7af31af7db3e3e1fb37553ae24de251c7fdeea3d68ec168f03db48de6aa54a96bf971f9cc804e94ff8a02fda9c56d7e85869d62962f6f020568e3a7b
…equence` 272eb55 test: fix `include_immature_coinbase` logic in `get_utxos` (brunoerg) a951c34 test: fix `interface_usdt_mempool` by mining a block after each test (brunoerg) 1557bf1 test: fix mature utxos addition to wallet in `mempool_package_limits` (brunoerg) 60ced90 test: fix intermittent issue in `feature_bip68_sequence` (brunoerg) Pull request description: Fixes bitcoin#27129 To avoid `bad-txns-premature-spend-of-coinbase` error, when getting a utxo (using `get_utxo`) to create a new transaction `get_utxo` shouldn't return (if possible) by default immature coinbase. ACKs for top commit: achow101: ACK 272eb55 pinheadmz: re-ACK 272eb55 Tree-SHA512: eae821c7833bf084d8b907c94876ed010a7925d2177c3013a0c61b69d9571df006da83397a19487d93b0d1fa415951152f0b8ad0de2a55d86c39f6917934f050
… check disk space periodically ed52e71 Periodically check disk space to avoid corruption (Aurèle Oulès) 7fe537f Implement CCoinsViewErrorCatcher::HaveCoin (Aurèle Oulès) Pull request description: Attempt to fix bitcoin#26112. As suggested by sipa in bitcoin#26112 (comment): > CCoinsViewErrorCatcher, the wrapper class used around CCoinsViewDB that's supposed to detect these problems and forcefully exit the application, has an override for GetCoins. But in CheckTxInputs, HaveInputs is first invoked, which on its turn calls HaveCoin. HaveCoin is implemented in CCoinsViewDB, but not in CCoinsViewErrorCatcher, and thus the disk read exception escapes. > A solution may be to just add an override for HaveCoin in CCoinsViewErrorCatcher. I implemented `CCoinsViewErrorCatcher::HaveCoin` and also added a periodic disk space check that shutdowns the node if there is not enough space left on disk, the minimum here is 50MB. For reviewers, it's possible to saturate disk space to test the PR by creating large files with `fallocate -l 50G test.bin` ACKs for top commit: achow101: ACK ed52e71 w0xlt: Code Review ACK bitcoin@ed52e71 sipa: utACK ed52e71 Tree-SHA512: 456aa7b996023df42b4fbb5158ee429d9abf7374b7b1ec129b21aea1188ad19be8da4ae8e0edd90b85b7a3042b8e44e17d3742e33808a4234d5ddbe9bcef1b78
6378033 to
94e4d3f
Compare
WalkthroughThis pull request introduces several independent enhancements across different components: adds a Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes 🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment Tip CodeRabbit can use Clang for C/C++ static analysis and code quality checks.Clang provides comprehensive static analysis for C and C++ code, including syntax checking, type checking, and various warning diagnostics. |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/init.cpp`:
- Around line 1554-1555: The code sets min_disk_space = 50 << 20 and then calls
CheckDiskSpace(args.GetBlocksDirPath(), min_disk_space), but CheckDiskSpace
already enforces a 50 MiB minimum, effectively doubling the threshold; fix by
calling CheckDiskSpace with zero additional bytes (or remove the extra
min_disk_space) so only the built-in 50 MiB minimum applies—update the call site
that uses CheckDiskSpace(args.GetBlocksDirPath(), ...) and remove or replace the
min_disk_space argument accordingly.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 02873299-f29c-48b9-ac4f-09100b36a1e8
📒 Files selected for processing (9)
src/coins.cppsrc/coins.hsrc/init.cppsrc/test/fuzz/transaction.cppsrc/test/util/setup_common.cppsrc/test/util_tests.cppsrc/util/system.hsrc/wallet/test/fuzz/notifications.cpptest/functional/mempool_package_limits.py
| constexpr uint64_t min_disk_space = 50 << 20; // 50 MB | ||
| if (!CheckDiskSpace(args.GetBlocksDirPath(), min_disk_space)) { |
There was a problem hiding this comment.
Disk-space threshold is effectively doubled.
At Line 1555, CheckDiskSpace() already applies a built-in 50 MiB minimum. Passing min_disk_space from Line 1554 as additional_bytes raises the effective shutdown threshold to ~100 MiB.
💡 Proposed fix
- constexpr uint64_t min_disk_space = 50 << 20; // 50 MB
- if (!CheckDiskSpace(args.GetBlocksDirPath(), min_disk_space)) {
+ if (!CheckDiskSpace(args.GetBlocksDirPath())) {
LogPrintf("Shutting down due to lack of disk space!\n");
StartShutdown();
}🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@src/init.cpp` around lines 1554 - 1555, The code sets min_disk_space = 50 <<
20 and then calls CheckDiskSpace(args.GetBlocksDirPath(), min_disk_space), but
CheckDiskSpace already enforces a 50 MiB minimum, effectively doubling the
threshold; fix by calling CheckDiskSpace with zero additional bytes (or remove
the extra min_disk_space) so only the built-in 50 MiB minimum applies—update the
call site that uses CheckDiskSpace(args.GetBlocksDirPath(), ...) and remove or
replace the min_disk_space argument accordingly.
thepastaclaw
left a comment
There was a problem hiding this comment.
Code Review
This backport PR cleanly includes 5 of the 7 upstream Bitcoin Core PRs listed in the title (bitcoin#28486, bitcoin#28969, bitcoin#27921, bitcoin#27177, bitcoin#26331). All included backports are faithfully adapted to the Dash codebase. However, bitcoin#26118 and bitcoin#28035 are absent from the branch despite being listed in the PR title — the PR title should be corrected or the missing backports added.
Reviewed commit: 94e4d3f
🟡 1 suggestion(s)
1 additional finding
🟡 suggestion: PR title lists 7 upstream backports but only 5 are included
The PR title references bitcoin#26118 (log: Use steady clock for bench logging) and bitcoin#28035 (test: Ignore UTF-8 errors in assert_debug_log), but neither has a corresponding merge commit on this branch. Verified: src/validation.cpp still defines MICRO/MILLI macros and uses GetTimeMicros() for benchmark logging (unchanged from pre-bitcoin#26118 state), src/util/time.h lacks the MillisecondsDouble alias introduced by bitcoin#26118, and test_node.py:assert_debug_log still opens debug.log in text mode without errors='replace' (unchanged from pre-bitcoin#28035 state). The 5 included backports (bitcoin#28486, bitcoin#28969, bitcoin#27921, bitcoin#27177, bitcoin#26331) are all clean. Either update the PR title to list only the 5 included PRs, or add the missing two backports.
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify each finding against the current code and only fix it if needed.
In `None`:
- [SUGGESTION] line None: PR title lists 7 upstream backports but only 5 are included
The PR title references bitcoin#26118 (log: Use steady clock for bench logging) and bitcoin#28035 (test: Ignore UTF-8 errors in assert_debug_log), but neither has a corresponding merge commit on this branch. Verified: `src/validation.cpp` still defines `MICRO`/`MILLI` macros and uses `GetTimeMicros()` for benchmark logging (unchanged from pre-#26118 state), `src/util/time.h` lacks the `MillisecondsDouble` alias introduced by #26118, and `test_node.py:assert_debug_log` still opens debug.log in text mode without `errors='replace'` (unchanged from pre-#28035 state). The 5 included backports (#28486, #28969, #27921, #27177, #26331) are all clean. Either update the PR title to list only the 5 included PRs, or add the missing two backports.
What was done?
Backports from Bitcoin Core
How Has This Been Tested?
Run unit & functional tests