Conversation
There was a problem hiding this comment.
Pull request overview
This PR implements a unified fuzzing infrastructure for stellar-core that replaces the old AFL-specific implementation. The changes enable fuzzing with multiple modern fuzz engines (libFuzzer, AFL++, honggfuzz) while integrating fuzz targets into the normal test suite for continuous regression testing.
Changes:
- Introduces
FuzzTargetinterface andFuzzTargetRegistryfor extensible fuzz target management - Migrates existing tx and overlay fuzz targets to the new framework
- Adds Soroban fuzz target integration through Rust bridge
- Updates build system to support modern fuzzer engines with proper instrumentation
- Integrates fuzz targets as unit tests with corpus-based regression testing
Reviewed changes
Copilot reviewed 35 out of 38 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/util/Math.h | Changes global state seed tracking to use optional to support fuzz initialization |
| src/util/Math.cpp | Implements reinitializeAllGlobalStateForFuzzing for safe reseeding in fuzz contexts |
| src/test/test.cpp | Updates to use optional API for seed retrieval |
| src/test/fuzz/targets/TxFuzzTarget.h | New header defining transaction fuzzing target interface |
| src/test/fuzz/targets/TxFuzzTarget.cpp | Implementation of transaction fuzzing with ledger setup |
| src/test/fuzz/targets/SorobanFuzzTargets.h | Header for Soroban fuzz target wrappers |
| src/test/fuzz/targets/SorobanFuzzTargets.cpp | C++ bridge to Rust-based Soroban fuzz targets |
| src/test/fuzz/targets/OverlayFuzzTarget.h | Header for overlay/P2P message fuzzing |
| src/test/fuzz/targets/OverlayFuzzTarget.cpp | Implementation of overlay network fuzzing |
| src/test/fuzz/FuzzUtils.h | Shared utilities for compact XDR representation used in fuzzing |
| src/test/fuzz/FuzzUtils.cpp | Implementation of fuzzing utilities and XDR compactor/unpacker |
| src/test/fuzz/FuzzTargetRegistry.h | Central registry for fuzz target management |
| src/test/fuzz/FuzzTargetRegistry.cpp | Implementation of fuzz target registry |
| src/test/fuzz/FuzzRegressionTests.cpp | Shared test helpers for corpus regression and smoke tests |
| src/test/fuzz/FuzzMain.cpp | LibFuzzer-compatible entry point for fuzz binaries |
| src/test/fuzz.h | Removed old AFL-specific fuzzing interface |
| src/test/fuzz.cpp | Removed old AFL-specific fuzzing implementation |
| src/test/FuzzerImpl.h | Updated to remove old overlay fuzzer, keep tx fuzzer reference |
| src/test/FuzzerImpl.cpp | Removed old fuzzer implementations (migrated to new structure) |
| src/simulation/ApplyLoad.h | Changed constant to constexpr for consistency |
| src/rust/src/soroban_fuzz.rs | New Rust module bridging to Soroban fuzz targets |
| src/rust/src/lib.rs | Adds soroban_fuzz module to Rust library |
| src/rust/src/bridge.rs | Adds FuzzResultCode enum and run_soroban_fuzz_target bridge function |
| src/rust/soroban/p25 | Updates Soroban submodule to version with fuzz support |
| src/rust/Cargo.toml | Adds fuzz and testutils features for fuzzing support |
| src/main/CommandLine.cpp | Replaces old fuzz commands with new fuzz-one, gen-fuzz, and fuzz-list |
| src/Makefile.am | Major build system changes to support modern fuzzing infrastructure |
| make-mks | Excludes main.cpp and FuzzMain.cpp from shared source lists |
| docs/software/commands.md | Updates command documentation for new fuzz commands |
| docs/fuzzing.md | Completely rewrites fuzzing documentation for new infrastructure |
| configure.ac | Replaces --enable-afl with --enable-fuzz supporting multiple engines |
| build-fuzz.sh | New build script for oss-fuzz integration |
| Makefile.am | Removes old AFL-specific targets |
| Builds/VisualStudio/stellar-core.vcxproj.filters | Updates Visual Studio project filters for new file structure |
| Builds/VisualStudio/stellar-core.vcxproj | Updates Visual Studio project for new fuzz files |
| .gitignore | Adds fuzz_* binaries to gitignore |
|
Warning Review the following alerts detected in dependencies. According to your organization's Security Policy, it is recommended to resolve "Warn" alerts. Learn more about Socket for GitHub.
|
Co-Authored-By: Claude Opus 4.5 <claude@anthropic.com>
9f124d8 to
e4b89e8
Compare
Description
This is an initial step towards completion of #5027 -- it doesn't cover everything but it gets a lot of the basic reorganization done. I've ticked off the items in that bug that are done in this PR. There is a Soroban side of this change that has to land first also: stellar/rs-soroban-env#1646 though it's much less involved, just moves some code around.
To summarize the changes here:
FuzzTargetthat you write a subclass of if you are writing a new fuzz target in C++.SorobanFuzzTarget, but the idea is the same. You add a target on the Rust side and you wire it into the dispatch function, by string name.FuzzTargetRegistry.--enable-fuzzcompile core with instrumentation and, separately, link one of 3 fuzz engines. You have to provide some separate env vars to specify the fuzz engine, which OSS-fuzz provides. It supports AFL++ (not old AFL), Libfuzzer, and Honggfuzz, and only supports each engine running in "persistent" mode (where the binary is observed by the fuzzer in-process).fuzz_overlayand so on.BUILD_TESTS/ Rustfeature="testutils"is turned on, because...Note: This change was written substantially by Opus 4.5 (on my direction from a fairly detailed spec) and it's made more than a few questionable choices during implementation (mostly over-complicating things). I am still in the process of reviewing, correcting, extending and minimizing its work. If you see something silly, please point it out. I'm opening this PR now for early visibility if anyone's curious and because it seems like it's close to a good initial stopping point.