Repository navigation
fuzz: add end-to-end liveness target for opportunistic 1p1c relay - #36371
instagibbs wants to merge 10 commits into
Conversation
When a 1p1c package fails the package feerate check, the child gets a TX_RECONSIDERABLE result, and ProcessPackageResult passed it to ProcessInvalidTx, which erased the child from the orphanage for all of its announcers. The failure is a property of that pair of wtxids, which MempoolRejectedPackage already caches, not of the child. The child can still succeed with another version of the parent, such as the one an honest announcer holds, so it should stay available. Skip ProcessInvalidTx for package members with a TX_RECONSIDERABLE result. A child that is too low feerate on its own is still rejected when its parent's work set is processed.
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. External sites
ReviewsSee the guideline and AI policy for information on the review process. 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. |
29df704 to
ad56a4b
Compare
|
🚧 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. |
ad56a4b to
2aaf0ee
Compare
Check that when another announcer of the child delivers a witness-padded parent that fails the package feerate check, the child stays in the orphanage and the honest peer's package is still accepted, for both v2 and TRUC packages.
A TX_RECONSIDERABLE rejection forgets the transaction's wtxid in TxRequestTracker for all peers. For a transaction without witness data the wtxid equals the txid, which is the hash orphan resolution uses to request a missing parent. Such a rejection therefore cancelled every announcer's request for the parent, and the orphan stayed unresolved until a new announcer appeared or the parent confirmed. Keep those requests when the rejected transaction has no witness and an orphan spends it.
Check that after another peer delivers a witnessless parent that is rejected as reconsiderable, the child's announcer is still asked for the parent and the package is accepted, for both a witness-stripped and a nonsegwit parent.
Add invariants to the txdownloadman_impl target: an event about one transaction or peer must not remove other peers' transaction requests or orphan announcements beyond that transaction's own hashes and entries. Uniform random operations almost never reach the states where this matters, so bias the harness towards orphans with missing parents and towards TX_MISSING_INPUTS and TX_RECONSIDERABLE results. Without the bias, reverting the witnessless-parent fix survived 57k runs.
Orphan handling treated every input's parent as missing: each was checked against the reject filters and requested from the orphan's announcers. A confirmed parent whose txid had entered the reject filter, which a rejected witnessless copy of it can cause, made the node drop every orphan spending one of its outputs. Have validation report which parents it found missing, and use only those when storing a new orphan. Parents that are present are no longer held against the orphan or requested. Update the orphan handling functional test, which expected present parents to be requested.
Check that a child spending a zero-fee parent and a confirmed output is stored and resolved even after the confirmed transaction's txid enters the reject filter, and that only the missing parent is requested. Have the txdownloadman_impl fuzz target pass a random non-empty subset of parents as missing.
TX_CONFLICT means the transaction is already known, in the mempool or confirmed, not that it is invalid. Its wtxid still went into the reject filter, and for a witnessless copy that is also the txid. If the known parent then leaves the mempool before the next block, through eviction or replacement, a child arriving afterwards is dropped as having a rejected parent. Don't add TX_CONFLICT results to the reject filter. The entry only saved re-downloading and re-checking a transaction we already have. Update the rejection-type table for TX_CONFLICT.
Check that after a stripped copy of a mempool parent is rejected as a conflict and the parent is evicted, a child spending it is still stored as an orphan.
Add a target for the property that if an honest peer announces the child of an acceptable low-fee parent and child, the child ends up in the mempool whatever other peers do. Children also spend a confirmed output, as a child paying its own fee does, and peers may replay that confirmed transaction. It drives a real PeerManager with real messages and validation against fuzzer-controlled peers that may deliver witness-malleated versions of the transactions, stall, send notfound or reconnect. The existing targets model validation results, so they cannot check how real results are attributed across peers.
2aaf0ee to
43ee8e2
Compare
|
@marcofleon could you throw a bit of cpu at this if you have the time |
|
Haven't gotten around to looking into it much but crashFUZZ=p2p_1p1c_liveness ./fuzzbuild/bin/fuzz crash-1373b980ed285e4076457461baafe0fa1ce6d68a
INFO: Running with entropic power schedule (0xFF, 100).
INFO: Seed: 2116994025
INFO: Loaded 1 modules (417851 inline 8-bit counters): 417851 [0x560893f6f7f0, 0x560893fd582b),
INFO: Loaded 1 PC tables (417851 PCs): 417851 [0x560893fd5830,0x560894635be0),
./fuzzbuild/bin/fuzz: Running 1 inputs 1 time(s) each.
Running: crash-1373b980ed285e4076457461baafe0fa1ce6d68a
../../../../src/test/fuzz/p2p_1p1c_liveness.cpp:390 void p2p_1p1c_liveness_fuzz_target(FuzzBufferType): Assertion `child_accepted()' failed.
==2192686== ERROR: libFuzzer: deadly signal
#0 0x5608929e27b4 in __sanitizer_print_stack_trace (/root/bitcoin/fuzzbuild/bin/fuzz+0xac87b4) (BuildId: fd9e87d1176e5516d4fb5c2cec2c7e817d02e645)
#1 0x5608929b50c8 in fuzzer::PrintStackTrace() (/root/bitcoin/fuzzbuild/bin/fuzz+0xa9b0c8) (BuildId: fd9e87d1176e5516d4fb5c2cec2c7e817d02e645)
#2 0x56089299a6c3 in fuzzer::Fuzzer::CrashCallback() (/root/bitcoin/fuzzbuild/bin/fuzz+0xa806c3) (BuildId: fd9e87d1176e5516d4fb5c2cec2c7e817d02e645)
#3 0x7f075bf51a6f (/usr/lib/x86_64-linux-gnu/libc.so.6+0x40a6f) (BuildId: c9a199fd28ea54b305ea35a8b25500a79bfe684a)
#4 0x7f075bfa83bb (/usr/lib/x86_64-linux-gnu/libc.so.6+0x973bb) (BuildId: c9a199fd28ea54b305ea35a8b25500a79bfe684a)
#5 0x7f075bf51941 in raise (/usr/lib/x86_64-linux-gnu/libc.so.6+0x40941) (BuildId: c9a199fd28ea54b305ea35a8b25500a79bfe684a)
#6 0x7f075bf394ab in abort (/usr/lib/x86_64-linux-gnu/libc.so.6+0x284ab) (BuildId: c9a199fd28ea54b305ea35a8b25500a79bfe684a)
#7 0x560893047284 in assertion_fail(std::source_location const&, std::basic_string_view<char, std::char_traits<char>>) /root/bitcoin/fuzzbuild/src/util/../../../src/util/check.cpp:41:5
#8 0x560892c25cee in bool&& inline_assertion_check<true, bool>(bool&&, std::source_location const&, std::basic_string_view<char, std::char_traits<char>>) /root/bitcoin/fuzzbuild/src/test/fuzz/../../../../src/util/check.h:93:13
#9 0x560892c25cee in p2p_1p1c_liveness_fuzz_target(std::span<unsigned char const, 18446744073709551615ul>) /root/bitcoin/fuzzbuild/src/test/fuzz/../../../../src/test/fuzz/p2p_1p1c_liveness.cpp:390:5
#10 0x560892e4676c in std::function<void (std::span<unsigned char const, 18446744073709551615ul>)>::operator()(std::span<unsigned char const, 18446744073709551615ul>) const /usr/lib/gcc/x86_64-linux-gnu/14/../../../../include/c++/14/bits/std_function.h:591:9
#11 0x560892e4676c in test_one_input(std::span<unsigned char const, 18446744073709551615ul>) /root/bitcoin/fuzzbuild/src/test/fuzz/util/../../../../../src/test/fuzz/fuzz.cpp:86:5
#12 0x560892e4676c in LLVMFuzzerTestOneInput /root/bitcoin/fuzzbuild/src/test/fuzz/util/../../../../../src/test/fuzz/fuzz.cpp:214:5
#13 0x56089299bbe5 in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) (/root/bitcoin/fuzzbuild/bin/fuzz+0xa81be5) (BuildId: fd9e87d1176e5516d4fb5c2cec2c7e817d02e645)
#14 0x56089298457f in fuzzer::RunOneTest(fuzzer::Fuzzer*, char const*, unsigned long) (/root/bitcoin/fuzzbuild/bin/fuzz+0xa6a57f) (BuildId: fd9e87d1176e5516d4fb5c2cec2c7e817d02e645)
#15 0x56089298a63f in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) (/root/bitcoin/fuzzbuild/bin/fuzz+0xa7063f) (BuildId: fd9e87d1176e5516d4fb5c2cec2c7e817d02e645)
#16 0x5608929b5ae2 in main (/root/bitcoin/fuzzbuild/bin/fuzz+0xa9bae2) (BuildId: fd9e87d1176e5516d4fb5c2cec2c7e817d02e645)
#17 0x7f075bf3af74 (/usr/lib/x86_64-linux-gnu/libc.so.6+0x29f74) (BuildId: c9a199fd28ea54b305ea35a8b25500a79bfe684a)
#18 0x7f075bf3b026 in __libc_start_main (/usr/lib/x86_64-linux-gnu/libc.so.6+0x2a026) (BuildId: c9a199fd28ea54b305ea35a8b25500a79bfe684a)
#19 0x56089297f070 in _start (/root/bitcoin/fuzzbuild/bin/fuzz+0xa65070) (BuildId: fd9e87d1176e5516d4fb5c2cec2c7e817d02e645)
NOTE: libFuzzer has rudimentary signal handlers.
Combine libFuzzer with AddressSanitizer or similar for better crash reports.
SUMMARY: libFuzzer: deadly signalbase64: IwAAAAAALgAAAAAAAB8uzQBcTQAAAAAAACj+gL6sgiguAwD/dA7fFElVUSz/psEyPl9zHR0dGR0dHWxfZw1mIwLKzLblzaMZGk9TroshBo6PmfJA9YbEi91SHU4loA7LJjIAXiEA////AF8xMi0lVXM0MZFdEoFVX/E=Can look some more tomorrow. |
|
@marcofleon thanks for running this, will take a look myself soon |
|
@marcofleon Caught a known defficiency that wasn't excepted in the harness, that's a good sign I think! Bot repro: We should probably just patch it for real to make the harness correct rather than patch the harness. |
|
@marcofleon replaced by #36437 for now |
Based on #36369; only the last commit is new here.
Adds
p2p_1p1c_liveness, a fuzz target for the property that if an honest peer announces the child ofan acceptable low-fee parent and child, the child ends up in the mempool whatever other peers do.
It drives a real PeerManager, with real P2P messages and validation, against fuzzer-controlled peers that
announce by wtxid or txid, deliver witness-stripped, padded or otherwise malleated versions of the
transactions, send notfound, stall, and reconnect. The existing download-manager targets model validation
results, so they cannot check how real results are attributed across peers.
Known gaps are listed in https://gist.github.com/instagibbs/880a76535fd802fced9f9a5253cdbb40: no witnessless or honest-bump scenarios yet, no trimming
environment, and no tip changes.