test(p2p): add direct control fuzz harnesses - #74
Merged
Conversation
Add libFuzzer/AFL++ harnesses for the direct-P2P handshake/state/history and delta/bootstrap control parsers. Fuzzers invoke the same production parser seams as the live wire path, so coverage cannot drift from real validation. A protocol-v3 seed exercises exact-version rejection after the v4 upgrade. Bound noninteractive AFL++ campaigns with AFL_FUZZ_SECONDS and register focused fuzz-smoke tests without duplicating broad protocol/delta registrations. Clarify that peer/cycle status is local health telemetry rather than global convergence, and document the remaining decision-grade live-performance gate. Signed-off-by: trvon <git@trevon.dev>
There was a problem hiding this comment.
🟡 Changes recommended
There is at least one concrete build-hygiene issue (missing explicit standard header include) that should be fixed to avoid reliance on transitive includes.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Adds direct P2P protocol-v4 control-message fuzzing entry points and shared parser seams, plus small test/documentation updates, to strengthen bounded parsing guarantees and make fuzzing a first-class regression gate in the P2P stack.
Changes:
- Add AFL++ fuzz targets + seed corpus generation for P2P handshake/control and delta/bootstrap control parsers.
- Introduce shared internal parser-validation seams (
p2p_fuzz.h) and reuse them in focused Catch2 “fuzz-smoke” tests. - Refactor JSON frame parsing into a reusable helper and tighten several delta/bootstrap control-field bounds.
File summaries
| File | Description |
|---|---|
| tools/fuzzing/meson.build | Registers new fuzz executables for P2P protocol and delta control parsing. |
| tools/fuzzing/generate_corpus.sh | Adds deterministic seed corpora for the new P2P fuzz targets (including a protocol-v3 legacy hello). |
| tools/fuzzing/fuzz.sh | Improves fuzz runner UX (duration bounding via AFL_FUZZ_SECONDS, TTY detection) and updates examples. |
| tools/fuzzing/fuzz_p2p_protocol.cpp | New fuzzer harness invoking production handshake/state/history control validation seam. |
| tools/fuzzing/fuzz_p2p_delta.cpp | New fuzzer harness invoking bounded delta/bootstrap control validation seam. |
| tests/unit/daemon/p2p_protocol_catch2_test.cpp | Adds a focused smoke test that exercises the handshake fuzz seam and bounds/version rejection. |
| tests/unit/daemon/p2p_delta_catch2_test.cpp | Adds a focused smoke test that exercises the delta fuzz seam and key bounds. |
| tests/meson.build | Excludes [fuzz] tests from broad P2P suites and registers dedicated fuzz-smoke tests. |
| src/daemon/p2p/p2p_protocol.cpp | Adds handshake control validation seam used by fuzzing and tests. |
| src/daemon/p2p/p2p_json.h | Extracts parseJsonFrame() helper for reuse by seams/tests/fuzzers. |
| src/daemon/p2p/p2p_fuzz.h | Introduces shared internal validation seam declarations for fuzz/test harnesses. |
| src/daemon/p2p/p2p_delta.cpp | Extracts/tightens delta/bootstrap control parsing/validation and adds delta control validation seam. |
| docs/p2p.md | Documents local-telemetry semantics and how to run the new fuzz targets with bounded campaigns. |
Review details
- Files reviewed: 13/13 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
13
to
15
| #include <limits> | ||
| #include <string_view> | ||
| #include <utility> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Final blocked draft child in the #68 stack, based on #73. This change closes the disclosed operator-wording and protocol-fuzz registration blockers without marking the umbrella ready, merging, or deploying.
AFL_FUZZ_SECONDSAI disclosure
Extensive AI assistance was used for implementation, test generation, and adversarial review. All changes were locally inspected and validated; remaining gates are disclosed above.
Stack
fix/p2p-apply-serialization/ fix(p2p): serialize sync application #73 ated7b09a23cf1bfb5cb6be0bcfc769d826f9e82b4fix/p2p-operator-validationat87e298e04415fbfb2ed5f06cd40712c428186f94Do not merge or deploy this child independently.