Repository navigation
fuzz: Block connection and chain reorganization fuzzing harnesses - #34651
RobinDavid wants to merge 1 commit into
Conversation
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. Code Coverage & BenchmarksFor details see: https://corecheck.dev/bitcoin/bitcoin/pulls/34651. ReviewsSee the guideline for information on the review process.
If your review is incorrectly listed, please copy-paste ConflictsReviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. LLM Linter (✨ experimental)Possible typos and grammar issues:
Possible places where named args for integral literals may be used (e.g.
2026-04-08 20:58:41 |
|
🚧 At least one of the CI tasks failed. HintsTry to run the tests locally, according to the documentation. However, a CI failure may still
Leave a comment here, if you need help tracking down a confusing failure. |
98ad4d8 to
28afc49
Compare
|
Could turn into draft while CI is red? |
4737566 to
87c6d12
Compare
|
I fixed all the CI issues. Its ready for review now. |
marcofleon
left a comment
There was a problem hiding this comment.
@dergoegge and I took a look at the connect_block harness and we think it'd be good to split that into its own PR. It's relatively straightforward, valuable on its own, and would likely get through review quicker. The other two harnesses could remain open in this PR as a draft on top of the new connect_block PR.
marcofleon
left a comment
There was a problem hiding this comment.
Base64: BAkAAAQJdwKGAAAAgBTpAACFBAk=
crash_activate_best_chain_step.txt
stack trace
===== stack trace =====
INFO: Running with entropic power schedule (0xFF, 100).
INFO: Seed: 3223231957
INFO: Loaded 1 modules (580898 inline 8-bit counters): 580898 [0x556d05d1e360, 0x556d05dac082),
INFO: Loaded 1 PC tables (580898 PCs): 580898 [0x556d05dac088,0x556d066892a8),
/workdir/out/libfuzzer_msan/fuzz: Running 1 inputs 1 time(s) each.
Running: /workdir/workspace/solutions/crash-aa5b43f99124f0e080b2b68ac94024c65fc8381b
validation.cpp:5502 double ChainstateManager::GuessVerificationProgress(const CBlockIndex *) const: Assertion `m_best_header->nHeight >= pindex->nHeight' failed.
==10489== ERROR: libFuzzer: deadly signal
#0 0x556d01ef1db9 in __sanitizer_print_stack_trace /llvm-project/compiler-rt/lib/msan/msan.cpp:790:3
#1 0x556d01e618d8 in fuzzer::PrintStackTrace() /llvm-project/compiler-rt/lib/fuzzer/FuzzerUtil.cpp:210:5
#2 0x556d01e442f3 in fuzzer::Fuzzer::CrashCallback() /llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:231:3
#3 0x556d01f50c3d in SignalAction(int, void*, void*) /llvm-project/compiler-rt/lib/msan/msan_interceptors.cpp:1166:3
#4 0x7f65ae046def (/lib/x86_64-linux-gnu/libc.so.6+0x3fdef) (BuildId: fce446c9d4ad48e2b0c90cce1a11722897805281)
#5 0x7f65ae09b95b (/lib/x86_64-linux-gnu/libc.so.6+0x9495b) (BuildId: fce446c9d4ad48e2b0c90cce1a11722897805281)
#6 0x7f65ae046cc1 in raise (/lib/x86_64-linux-gnu/libc.so.6+0x3fcc1) (BuildId: fce446c9d4ad48e2b0c90cce1a11722897805281)
#7 0x7f65ae02f4ab in abort (/lib/x86_64-linux-gnu/libc.so.6+0x284ab) (BuildId: fce446c9d4ad48e2b0c90cce1a11722897805281)
#8 0x556d03409b63 in assertion_fail(std::__1::source_location const&, std::__1::basic_string_view<char, std::__1::char_traits<char>>) /workdir/bitcoin/src/util/check.cpp:41:5
#9 0x556d05435257 in bool&& inline_assertion_check<false, bool>(bool&&, std::__1::source_location const&, std::__1::basic_string_view<char, std::__1::char_traits<char>>) /workdir/bitcoin/src/util/check.h:90:13
#10 0x556d05435257 in ChainstateManager::GuessVerificationProgress(CBlockIndex const*) const /workdir/bitcoin/src/validation.cpp:5502:10
#11 0x556d05424776 in UpdateTipLog(ChainstateManager const&, CCoinsViewCache const&, CBlockIndex const*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&) /workdir/bitcoin/src/validation.cpp:2867:5
#12 0x556d05422f9e in Chainstate::UpdateTip(CBlockIndex const*) /workdir/bitcoin/src/validation.cpp:2911:5
#13 0x556d0542a016 in Chainstate::ConnectTip(BlockValidationState&, CBlockIndex*, std::__1::shared_ptr<CBlock const>, std::__1::vector<ConnectedBlock, std::__1::allocator<ConnectedBlock>>&, DisconnectedBlockTransactions&) /workdir/bitcoin/src/validation.cpp:3076:5
#14 0x556d0543004c in Chainstate::ActivateBestChainStep(BlockValidationState&, CBlockIndex*, std::__1::shared_ptr<CBlock const> const&, bool&, std::__1::vector<ConnectedBlock, std::__1::allocator<ConnectedBlock>>&) /workdir/bitcoin/src/validation.cpp:3232:18
#15 0x556d02312811 in (anonymous namespace)::TestChainstate::CallActivateBestChainStep(BlockValidationState&, CBlockIndex*, std::__1::shared_ptr<CBlock const> const&, bool&, std::__1::vector<ConnectedBlock, std::__1::allocator<ConnectedBlock>>&) /workdir/bitcoin/src/test/fuzz/connect_block.cpp:40:16
#16 0x556d02312811 in activate_best_chain_step_fuzz_target(std::__1::span<unsigned char const, 18446744073709551615ul>) /workdir/bitcoin/src/test/fuzz/connect_block.cpp:755:32
#17 0x556d01f6a365 in std::__1::__invoke_result_impl<void, void (*&)(std::__1::span<unsigned char const, 18446744073709551615ul>), std::__1::span<unsigned char const, 18446744073709551615ul>>::type std::__1::__invoke[abi:de210108]<void (*&)(std::__1::span<unsigned char const, 18446744073709551615ul>), std::__1::span<unsigned char const, 18446744073709551615ul>>(void (*&)(std::__1::span<unsigned char const, 18446744073709551615ul>), std::__1::span<unsigned char const, 18446744073709551615ul>&&) /libcxx_msan/include/c++/v1/__type_traits/invoke.h:87:27
#18 0x556d01f6a365 in void std::__1::__invoke_void_return_wrapper<void, true>::__call[abi:de210108]<void (*&)(std::__1::span<unsigned char const, 18446744073709551615ul>), std::__1::span<unsigned char const, 18446744073709551615ul>>(void (*&)(std::__1::span<unsigned char const, 18446744073709551615ul>), std::__1::span<unsigned char const, 18446744073709551615ul>&&) /libcxx_msan/include/c++/v1/__type_traits/invoke.h:342:5
#19 0x556d01f6a365 in void std::__1::__invoke_r[abi:de210108]<void, void (*&)(std::__1::span<unsigned char const, 18446744073709551615ul>), std::__1::span<unsigned char const, 18446744073709551615ul>>(void (*&)(std::__1::span<unsigned char const, 18446744073709551615ul>), std::__1::span<unsigned char const, 18446744073709551615ul>&&) /libcxx_msan/include/c++/v1/__type_traits/invoke.h:348:10
#20 0x556d01f6a365 in std::__1::__function::__func<void (*)(std::__1::span<unsigned char const, 18446744073709551615ul>), void (std::__1::span<unsigned char const, 18446744073709551615ul>)>::operator()(std::__1::span<unsigned char const, 18446744073709551615ul>&&) /libcxx_msan/include/c++/v1/__functional/function.h:174:12
#21 0x556d02d8b8c1 in std::__1::__function::__value_func<void (std::__1::span<unsigned char const, 18446744073709551615ul>)>::operator()[abi:de210108](std::__1::span<unsigned char const, 18446744073709551615ul>&&) const /libcxx_msan/include/c++/v1/__functional/function.h:274:12
#22 0x556d02d8b8c1 in std::__1::function<void (std::__1::span<unsigned char const, 18446744073709551615ul>)>::operator()(std::__1::span<unsigned char const, 18446744073709551615ul>) const /libcxx_msan/include/c++/v1/__functional/function.h:772:10
#23 0x556d02d8b8c1 in test_one_input(std::__1::span<unsigned char const, 18446744073709551615ul>) /workdir/bitcoin/src/test/fuzz/fuzz.cpp:88:5
#24 0x556d02d8b8c1 in LLVMFuzzerTestOneInput /workdir/bitcoin/src/test/fuzz/fuzz.cpp:216:5
#25 0x556d01e45a4b in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) /llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:619:13
#26 0x556d01e2f6f2 in fuzzer::RunOneTest(fuzzer::Fuzzer*, char const*, unsigned long) /llvm-project/compiler-rt/lib/fuzzer/FuzzerDriver.cpp:329:6
#27 0x556d01e35590 in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) /llvm-project/compiler-rt/lib/fuzzer/FuzzerDriver.cpp:864:9
#28 0x556d01e62262 in main /llvm-project/compiler-rt/lib/fuzzer/FuzzerMain.cpp:20:10
#29 0x7f65ae030ca7 (/lib/x86_64-linux-gnu/libc.so.6+0x29ca7) (BuildId: fce446c9d4ad48e2b0c90cce1a11722897805281)
#30 0x7f65ae030d64 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29d64) (BuildId: fce446c9d4ad48e2b0c90cce1a11722897805281)
#31 0x556d01e286e0 in _start (/workdir/out/libfuzzer_msan/fuzz+0x13696e0)
NOTE: libFuzzer has rudimentary signal handlers.
Combine libFuzzer with AddressSanitizer or similar for better crash reports.
SUMMARY: libFuzzer: deadly signal8829b69 to
016bfd5
Compare
016bfd5 to
c14b46a
Compare
c14b46a to
673cfd3
Compare
ismaelsadeeq
left a comment
There was a problem hiding this comment.
Code review 392fac5
I have spent some time reviewing this PR and the related #34651, which includes additional fuzz harnesses. After several iterations of review, I think I have a
good understanding of what this PR is doing and what it aims to achieve.
The PR can be simplified significantly. I started inline comments but switched rather than leaving many inline comments, I think it would be cleaner to share a few fixup commits that demonstrate my suggestions.
-
ismaelsadeeq@976c605 slims down the harness file significantly, wraps the setup in a
class and performs several cleanups in line with Bitcoin Core coding style, and nits making it reusable across other fuzz harnesses and future ones. -
ismaelsadeeq@8cb0273 validation changes should live in it's own commit with a rationale
and not be baked into the test commit. -
ismaelsadeeq@297f4ac introduces the activate_best_chain and activate_best_chain_step harnesses
from #34651 along with the methods they need. As you can see, this is cleaner — there is no need for a Cleanup class or a redundant disconnect_pool; we should just
explicitly replay the chain on each iteration, I think. -
We can go further and hide the setup member variables, exposing only getters see
ismaelsadeeq@1184d67.
footnotes
-
Using the refactored setup, I was easily able to extend this and add a test_block_validity harness as previously requested done in #35000 and requested see
ismaelsadeeq@2f71bc9. -
I have built on this further and have a full branch that uses this setup to A/B fuzz
TestBlockValidityagainst a separate of work: validating blocks
with caller-supplied UTXOs. See the full branch https://github.com/ismaelsadeeq/bitcoin/tree/fixup-connect-block-harness and the original branch
https://github.com/ismaelsadeeq/bitcoin/tree/04-2026-test-block-validity-spentouts-rebased.
| // Distributed under the MIT software license, see the accompanying | ||
| // file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||
|
|
||
| #include <algorithm> |
There was a problem hiding this comment.
In 6fceab3 "Implement connect_block fuzzing harness"
nit: Standard library headers usually aren't mixed with project headers. They come after project header, with some line separation between the
| @@ -0,0 +1,498 @@ | |||
| // Copyright (c) 2025-present The Bitcoin Core developers | |||
There was a problem hiding this comment.
In 6fceab3 "Implement connect_block fuzzing harness"
| // Copyright (c) 2025-present The Bitcoin Core developers | |
| // Copyright (c) The Bitcoin Core developers |
| namespace { | ||
|
|
||
|
|
||
| /** Testing setup used by the three harnesses */ |
There was a problem hiding this comment.
In 6fceab3 "Implement connect_block fuzzing harness"
This is incorrect; there is only one harness here.
| #include <validation.h> | ||
|
|
||
|
|
||
| #define DEBUGOUTPUT(x) //(x); |
There was a problem hiding this comment.
In 6fceab3 "Implement connect_block fuzzing harness"
Why is this needed? And later the std::cout? I guess it's used for debugging; not sure whether it is ideal to merge with this.
|
|
||
| #include <algorithm> | ||
| #include <consensus/merkle.h> | ||
| #include <kernel/disconnected_transactions.h> |
There was a problem hiding this comment.
In 6fceab3 "Implement connect_block fuzzing harness"
This include is not needed.
| #include <kernel/disconnected_transactions.h> |
| if (success) { | ||
| DEBUGOUTPUT(std::cout << "Block connected successfully: " << curr_header.GetHash().ToString() << std::endl); | ||
| DEBUGOUTPUT(std::cout << "State: " << state.ToString() << std::endl); | ||
| //Assert(active_chainstate.DisconnectBlock(block, &new_index, active_coins) == DISCONNECT_OK); | ||
| } | ||
| else { | ||
| DEBUGOUTPUT(std::cout << "Block connection failed: " << state.GetRejectReason() << std::endl); | ||
| // If the connection failed, we can still try to disconnect the block | ||
| // to ensure that the disconnect logic is robust. | ||
| } |
There was a problem hiding this comment.
In 6fceab3 "Implement connect_block fuzzing harness"
This is good for debugging, but it won't help us. If you'd like to document that the goal is to test a connect/disconnect block round trip, please proceed.
A comment is ideal; why can't we do that now? Maybe link to @marcofleon's comment permalink.
Also, we can test some invariants; when valid, no reject reason should be added vis-à-vis
| if (success) { | |
| DEBUGOUTPUT(std::cout << "Block connected successfully: " << curr_header.GetHash().ToString() << std::endl); | |
| DEBUGOUTPUT(std::cout << "State: " << state.ToString() << std::endl); | |
| //Assert(active_chainstate.DisconnectBlock(block, &new_index, active_coins) == DISCONNECT_OK); | |
| } | |
| else { | |
| DEBUGOUTPUT(std::cout << "Block connection failed: " << state.GetRejectReason() << std::endl); | |
| // If the connection failed, we can still try to disconnect the block | |
| // to ensure that the disconnect logic is robust. | |
| } |
There was a problem hiding this comment.
I agree it's better to drop this whole chunk, unless there is some truly useful assertion we can make upon success/failure. Doing the connect-disconnect block roundtrip would require a refactor in validation, which I may tackle at some point.
There was a problem hiding this comment.
ACK 6fceab3
I think this test accomplishes its goal and could be merged, despite it being a bit messy. There are several clean up nits which could be addressed in a followup PR or in #34895.
style nit: Some variables throughout the test use camelCase, where snake_case would be preferred (dev notes).
| #include <validation.h> | ||
|
|
||
|
|
||
| #define DEBUGOUTPUT(x) //(x); |
There was a problem hiding this comment.
nit: We don't usually keep debug logs around in tests afaik, so this should be removed.
| static std::vector<std::shared_ptr<CBlock>> listBlocks; | ||
| /** Set of block hashes in listBlocks */ | ||
| static std::set<uint256> existingBlockHash; | ||
| /** Spending script for all UTXOs (excluding OP_RETURN) including not mature CoinBase and already spend one */ |
There was a problem hiding this comment.
nit: spent instead of spend
| * Initialize the chain for the three harnesses. | ||
| */ | ||
| static void initialize_connect_block() { | ||
| Assert(EnableFuzzDeterminism()); |
There was a problem hiding this comment.
nit: This is redundant, so it should be removed. And it would prevent (crash on) the use of the nondeterminism env that we have in our fuzzing framework
| } else { | ||
| /** Read arbitrary data in input as scriptSig */ | ||
| auto scriptSig = ConsumeRandomLengthByteVector<unsigned char>(fuzzed_data_provider, 100); | ||
| tx.vin[0].scriptSig << scriptSig; |
There was a problem hiding this comment.
nit: Could make sense to replace these two lines with the existing ConsumeScript helper.
Something like tx.vin[0].scriptSig = ConsumeScript(fuzzed_data_provider) or appending its output if that was the intent.
Same goes for the scriptSig in the else branch below and the scriptPubKey in the switch statement below.
| tx.vin[i].scriptWitness.stack.clear(); | ||
| int numWit = fuzzed_data_provider.ConsumeIntegralInRange<int>(0, 10); | ||
| for (int j = 0; j < numWit; j++) { | ||
| tx.vin[i].scriptWitness.stack.push_back(ConsumeRandomLengthByteVector<unsigned char>(fuzzed_data_provider, 100)); |
There was a problem hiding this comment.
nit: Could replace this with ConsumeScriptWitness.
|
|
||
| /** Enable fuzzer to mutate every CTxIn fields after it being taken from existing UTXOs */ | ||
| if (fuzzed_data_provider.ConsumeBool()) { | ||
| tx.vin[i].nSequence = fuzzed_data_provider.ConsumeIntegral<uint32_t>(); |
Why the rush? I would like to see my suggestions fixed or addressed. In general, all pull requests must: I tend to disagree here; I think merging a messy change lowers the bar. |
The fuzz harnesses in this PR and in #34895 were part of an external security audit and were made without all the specifics of this project in mind. I figure if the test is logically sound, adds good coverage, and does the job it's meant to do, then there isn't a need for us to stall it with style nits and refactors. A member of the project could likely more quickly and easily get those done and merged in a followup. Looking at it again, I do think, at the minimum, the I'm not looking to rush, more just trying not to stall a test-only addition of fuzz targets that overall look effective to me. Ultimately, I agree with this project's high bar and of course, am willing to go through the necessary rounds of review. |
|
That makes sense, though it wasn't clear from your ACK or the PR description. You mentioned merging despite the messiness being okay, which is what made me push back a bit. Also, thanks for the audit and this work @RobinDavid. Given that this originated from external audit work, I'd like to suggest a potentially better approach that might be more efficient for everyone:
|
I think I would prefer this, given that we have made slow progress here. @RobinDavid is that good with you? |
|
Yes I only work on this PR on my free time so I can't make it progress as fast as I'd want. So yes @sedited and @ismaelsadeeq I am fine to hand over applying these changes, I agree with all of them. I would be even better if you could hand over the second PR #34895 which would requires more significant refactoring than this one. |
@RobinDavid cool. I talked with @marcofleon a few days ago, and we concluded that I will incorporate the suggestions here and open a new PR. I expected it to be up by today, but did not because I got sucked into parallel work :(. |
I agree that there is no rush, so I don't see the need for this to be handed over (unless Robin has no interest in maintaining this, which I think he has, given that he is doing this in his spare time). These types of PRs take months or years on a regular basis (regardless of who the author is). The bottleneck is primarily review. This PR was opened in February but review started later on, and splitting the
I don't know if an LLM wrote this or if it's your opinion, but I don't think this is a fair thing to say, given that Robin has made an obviously genuine attempt at contributing and has been responsive throughout. Contributing to this project is not limited to members (GitHub org membership means nothing beyond being able to edit the wiki and restart CI jobs), and should be possible without getting paid to do so full time. Someone showing up to contribute in their spare time is great, and also how a lot of us started out (thank you Robin for contributing your time!). From what I've seen, the harness here works as intended. It should be cleaned up before merge (style, comments, etc.) but there is no need to completely re-write it (as suggested here #34651 (review)). @RobinDavid if you're still interested to work on this when you have the time, I'd be happy to ACK this once the nits have been addressed. |
I wrote this to suggest moving forward because of the eagerness to merge I see here #34651 (comment) and #34651 (review), for the reason mentioned #34651 (comment), which I believe other contributors agree with me on this.
I am happy to have this continue review as well and will ACK as well, even without a rewrite, as long as the suggestions are addressed. I am not in any rush to take over someone's work; I did almost similar work in parallel, and and @marcofleon and you suggested we close and focus on this, which is what I am doing now. I am here in good faith, wanting to move this work forward and have this harness up so that it can be used beyond this #34651 (review). |
|
Re #34651 (comment) see master...ismaelsadeeq:bitcoin:block-chain-validation-harness branch with all comments addressed and an added harness using #34651 (review). |
|
@ismaelsadeeq the branch https://github.com/ismaelsadeeq/bitcoin/tree/block-chain-validation-harness do not seems to just address the aforementioned remarks. It is significantly different than this current PR (that only contains one fuzz harness). Do we want to restore all 3 harnesses (connect_block, activate_best_chain_step, activate_best_chain) and a new one into a single PR ? I though we wanted to keep them split. I would happy to take @marcofleon and @dergoegge opinion on this. |
I think we should keep it split up, as we decided earlier. Makes it easier to review. This PR would map to the first commit of Sadiq's branch: 1a34a13 I've taken a better look at https://github.com/ismaelsadeeq/bitcoin/tree/block-chain-validation-harness and I think the refactoring of shared setup and helpers into util files makes sense. We can reuse them for future validation harnesses. If this PR were generally kept as is (all in one file) and cleaned up style-wise as reviewers have suggested above, then I would ack it and also review a refactor followup. @RobinDavid another option could be to take 1a34a13 for this PR (or re-work parts of it if something stands out to you), essentially accomplishing the refactor here, which would then be used for #34895 later on. It's up to you, either option would work fine for me. |
| if (fuzzed_data_provider.ConsumeBool()) { | ||
| block.nVersion = fuzzed_data_provider.ConsumeIntegral<int32_t>(); | ||
| } | ||
| if (fuzzed_data_provider.ConsumeBool() && !forceValidBlock) { |
There was a problem hiding this comment.
What was the intention here with forceValidBlock? Is it to create a fully valid header that would pass the contextual checks in validation.cpp? If that's the case, I think it should be applied to the other three header fields as well (nVersion, nBits, nTime).
Also, I think force_valid_header would be a clearer name.
|
This fell by the wayside. How do we want to proceed here? I really like the fuzz tests here and in #34895 so it'd be cool to get them in. |
|
For code that does not follow our style, but is otherwise correct, we have in the past merged the pull request and then followed up with improvements and style corrections. I'd be fine with doing that here too, if reviewers think it is correct. |
I understand that Robin might be busy so one of us could grab it and move on? I intend to review it by tomorrow btw. |
|
I can follow up with the small fixes / cleanups once this is merged. |
|
Yes @brunoerg and @marcofleon please go ahead. You will probably do it better that I would ever do :) |
|
@RobinDavid The meat of the tests was all your doing, we appreciate it! It's just minor stuff from here that we can get done relatively quickly. |
|
utACK 6fceab3 I'd also be fine with merging this now, and fixing up later. Thank you, Robin! |
|
This doesn't compile if I merge it into current master: This should be rebased and the following patch applied: diff --git a/src/test/fuzz/connect_block.cpp b/src/test/fuzz/connect_block.cpp
index c141fe4841..ebe473650d 100644
--- a/src/test/fuzz/connect_block.cpp
+++ b/src/test/fuzz/connect_block.cpp
@@ -161,9 +161,8 @@ void ResetChainman(TestingSetup& setup)
setup.LoadVerifyActivateChainstate();
for (int i = 0; i < 2 * COINBASE_MATURITY; i++) {
- node::BlockAssembler::Options options;
+ node::BlockCreateOptions options;
options.coinbase_output_script = P2WSH_OP_TRUE;
- options.include_dummy_extranonce = true;
MineBlock(setup.m_node, options);
}
setup.m_node.validation_signals->SyncWithValidationInterfaceQueue();
@@ -244,7 +243,7 @@ static void initialize_connect_block() {
*/
addExtraTxsInMempool(*test_setup);
/** Mine block 201 that shall contain the transactions added in the mempool */
- node::BlockAssembler::Options options;
+ node::BlockCreateOptions options;
options.coinbase_output_script = P2WSH_OP_TRUE;
MineBlock(test_setup->m_node, options);
Assert(test_setup->m_node.chainman->ActiveChainstate().GetMempool()->size() == 0); |
|
I'll open a new PR then, and take this commit as a starting point. |
|
Closing, now that #35850 is open. |
2777300 fuzz: Implement connect_block harness (Robin David) 40add91 test: Add reset to CuckooCache (Eugene Siegel) Pull request description: Adds a fuzz target that directly calls `ConnectBlock` with `fJustCheck` set to true, so it hits block/transaction validation without writing undo data or updating the chainstate. This PR is essentially #34651 with some minor tweaks and style cleanups. Additional validation harnesses (e.g. #34895) could build on this test's setup. ACKs for top commit: Crypt-iQ: ACK 2777300 nervana21: tACK 2777300 Tree-SHA512: e2dc74154a6e29e0f3eaec9caeeec53d64bcc96adb0d1739281da97712dd931c3937eaf71f977bfc9c9330f26e35b3633f72788143b76e24e17c37b0a4258ba4
2777300c68f575565dabdcef4d0498ebc91a401e fuzz: Implement connect_block harness (Robin David) 40add915be5c5d204d85474a2704362cb635ef6d test: Add reset to CuckooCache (Eugene Siegel) Pull request description: Adds a fuzz target that directly calls `ConnectBlock` with `fJustCheck` set to true, so it hits block/transaction validation without writing undo data or updating the chainstate. This PR is essentially bitcoin/bitcoin#34651 with some minor tweaks and style cleanups. Additional validation harnesses (e.g. bitcoin/bitcoin#34895) could build on this test's setup. ACKs for top commit: Crypt-iQ: ACK 2777300c68f575565dabdcef4d0498ebc91a401e nervana21: tACK 2777300c68f575565dabdcef4d0498ebc91a401e Tree-SHA512: e2dc74154a6e29e0f3eaec9caeeec53d64bcc96adb0d1739281da97712dd931c3937eaf71f977bfc9c9330f26e35b3633f72788143b76e24e17c37b0a4258ba4
Hi Bitcoin Core maintainers.
This PR is a remastered version of fuzzing harnesses developed during a Bitcoin Core audit.
It includes 1 fuzzing harnesses:
connect_block: Test the ConnectBlock() function responsible of validating the block andall its transaction with consensus rules. Thanks to
justCheckparameter no side effectis performed on the internal state enabling relatively fast fuzzing.
Besides pre-mining blocks, the harness initialization intends to bring a bit more of diversity by
introducing additional transactions in blocks (otherwise only coinbases), and put some transactions
in the mempool so that they can be 'picked' and put in a block by means of input mutation.
Note: Some additional harnesses are added in another PR: #34895
Authored by RobinDavid and nsurbay