Skip to content

Fix fastdev divergence bug - #5420

Merged
graydon merged 3 commits into
stellar:masterfrom
graydon:fix-fuzz-targets-induced-fastdev-divergence
Sep 9, 2026
Merged

graydon merged 3 commits into
stellar:masterfrom
graydon:fix-fuzz-targets-induced-fastdev-divergence

Conversation

@graydon

@graydon graydon commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Fastdev mode had unanticipated consequences:

  1. The soroban-fuzz-targets dependency in rust_stellar_core actually pulls in its own specific copy of soroban-env-host, which is the one it fuzzes. We can debate whether this is ideal (it's probably not, since it can fall behind the production host in master, but .. it's what it does currently).
  2. In order to fuzz that host, it enables soroban-env-host/testutils, specifically to use recording mode and set up transactions that have a chance of making it somewhat deep into the auth system. This is also probably not ideal -- it would be nice to fuzz with recording turned off -- but at the moment this is sort of hard to change.
  3. We have soroban-fuzz-targets turned on basically "by default": currently (on master) when you do a tests-enabled build of core, it enables rust_stellar_core/testutils which turns on soroban-fuzz-targets. This is intentional and I want to keep doing that! It's to make sure we notice if we break the fuzz targets. The fuzz targets get smoke-tested as part of normal core unit testing.
  4. Unfortunately fastdev mode makes a mess of this: since it's a unified build driven by cargo (not just linking separately-compiled crates), whatever version of soroban-env-host the soroban-fuzz-targets dependency pulls in gets feature unified with the corresponding version of soroban-env-host we're using for production transaction-processing. So like if the fuzz target is pulling in p27, the production p27 gets soroban-env-host/testutils turned on!
  5. This, of course, causes recording to be enabled in the production host, which perturbs costs, which makes that host fairly likely to diverge from mainnet when attached to it. Which makes fastdev fairly useless for development! And also scary. Nobody likes seeing divergence while working on a change.

So the fix in this patch is a slight degradation in the above arrangement: we split out rust_stellar_core/fuzz_targets as a separate feature from rust_stellar_core/testutils, and only turn it on when not in fastdev. This way we still get smoketest coverage of the fuzz targets in the non-fastdev builds. We just get a warning that the fuzz target is disabled in a fastdev build.

@graydon
graydon requested review from sisuresh and a balanced review from Copilot August 19, 2026 06:10

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Separates Soroban fuzz targets from Rust test utilities to prevent fastdev builds from enabling production-host recording behavior.

Changes:

  • Adds a dedicated fuzz_targets Cargo feature.
  • Disables fuzz targets in fastdev builds.
  • Retains fuzz smoke tests in normal test builds.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
src/rust/src/soroban_fuzz.rs Gates fuzz implementations on fuzz_targets.
src/rust/Cargo.toml Defines the separate fuzz-target feature.
src/Makefile.am Enables fuzz targets only for non-fastdev test builds.
Suppressed comments (1)

src/rust/src/soroban_fuzz.rs:30

  • The preceding comment is stale after splitting the features: these implementations are enabled by fuzz_targets, not testutils. Please update the comment accordingly.
#[cfg(feature = "fuzz_targets")]

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/rust/src/soroban_fuzz.rs Resolved
Comment thread src/Makefile.am Resolved
@sisuresh

Copy link
Copy Markdown
Contributor

@graydon two things -

  1. This is an existing issue, but build-fuzz.sh uses --enable-unified-rust-unsafe-for-production, which doesn't exist anymore.
  2. I believe it's still possible to enable both the fastdev and fuzzing configure flags at the same time. Should we instead error in configure?

@graydon

graydon commented Aug 19, 2026 •

Copy link
Copy Markdown
Contributor Author

@graydon two things -

  1. This is an existing issue, but build-fuzz.sh uses --enable-unified-rust-unsafe-for-production, which doesn't exist anymore.
  2. I believe it's still possible to enable both the fastdev and fuzzing configure flags at the same time. Should we instead error in configure?

Oh, interesting! Hmm. This further complicates matters.

That flag doesn't exist but re: point 2, we actually need to replace it, to pass fastdev -- for the build to be a unified build -- because fuzz instrumentation (or at least asan instrumentation, which the fuzzers usually want to have turned on) doesn't like separate .a files, it winds up with multiple asan runtimes linked in.

Unfortunately if I do that, with this patch, the soroban fuzzers are disabled. Which is not what we want. Like the fuzz target binaries get built but they all just say "warning: target disabled" over and over while they loop.

So .. sigh .. need to think more about this.

@graydon
graydon force-pushed the fix-fuzz-targets-induced-fastdev-divergence branch from 3712444 to 75009ea Compare August 22, 2026 01:54
@graydon

graydon commented Aug 22, 2026

Copy link
Copy Markdown
Contributor Author

@sisuresh Ok I think I have decided on a solution here: to turn the fuzz target back on in an ENABLE_FUZZ build and just accept that such a build can diverge if run against mainnet. not ideal, but also .. nobody's going to run such a build against mainnet. this way we can get the fuzz target when it's good for smoke testing (normal build) and when it's good for fuzzing (ENABLE_FUZZ builds) but not when doing fastdev-without-ENABLE_FUZZ. I've pushed this change along with comments to explain it.

Comment thread src/Makefile.am Resolved
Copilot AI review requested due to automatic review settings September 4, 2026 07:27

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

Suppressed comments (1)

src/Makefile.am:354

  • Correct the typo “fuzzz” to “fuzz.”
# mode (it just exits with a message to turn it off). The other fuzzz engines,

Comment thread src/Makefile.am Resolved
@stellar stellar deleted a comment Sep 4, 2026
Copilot AI review requested due to automatic review settings September 4, 2026 07:44
@graydon
graydon force-pushed the fix-fuzz-targets-induced-fastdev-divergence branch from c817732 to a7f9f85 Compare September 4, 2026 07:44

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

Suppressed comments (3)

src/Makefile.am:78

  • CARGO_FEATURE_FUZZ_TARGETS becomes empty whenever tests are disabled, even when ENABLE_FUZZ is set. Since these configure options are independent and --enable-fuzz promises to build the fuzz targets, --disable-tests --enable-fuzz currently builds the Soroban harness against the disabled stub in both fastdev and regular modes. Enable this Cargo feature when either tests or fuzzing are enabled.
CARGO_FEATURE_FUZZ_TARGETS = --features fuzz_targets

src/Makefile.am:362

  • Correct the typo in “fuzzz engines.”
# mode (it just exits with a message to turn it off). The other fuzzz engines,

src/rust/Cargo.toml:246

  • Introducing fuzz_targets as the actual gate leaves related guidance pointing at obsolete gates: src/test/fuzz/FuzzRegressionTests.cpp:86-87 says testutils, while src/rust/src/bridge.rs:458, src/test/fuzz/targets/SorobanFuzzTargets.h:22-23, and src/Makefile.am:646 say --features fuzz. These references now misdirect anyone enabling or debugging Soroban targets; update them to fuzz_targets.
fuzz_targets = ["dep:soroban-fuzz-targets"]

Comment thread src/Makefile.am Resolved
Comment thread build-fuzz.sh Resolved
@graydon
graydon force-pushed the fix-fuzz-targets-induced-fastdev-divergence branch from a7f9f85 to e5cac0b Compare September 4, 2026 08:02
Copilot AI review requested due to automatic review settings September 4, 2026 08:02
@graydon
graydon force-pushed the fix-fuzz-targets-induced-fastdev-divergence branch from e5cac0b to 7916a01 Compare September 4, 2026 08:06

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Suppressed comments (2)

src/Makefile.am:372

  • The safety-critical non-fuzz fastdev branch is not exercised by the current CI: the only fastdev build is build-fuzz.sh, which passes --enable-fuzz and takes the opposite branch. Add a non-fuzz fastdev regression build that verifies Soroban fuzz targets report FUZZ_DISABLED and that the production host remains free of recording/testutils, so feature changes cannot silently reintroduce mainnet divergence.
else
FASTDEV_CARGO_FEATURE_FUZZ_TARGETS=
RUSTFLAGS_FUZZ :=

src/Makefile.am:78

  • --enable-fuzz is independent of BUILD_TESTS, and the fuzz rules compile their own test support even under --disable-tests. Gating this feature only on BUILD_TESTS therefore makes every --enable-fuzz --disable-tests Soroban target return FUZZ_DISABLED; enable fuzz_targets when either tests or fuzzing are enabled.
CARGO_FEATURE_FUZZ_TARGETS = --features fuzz_targets

Comment thread .github/workflows/build.yml Resolved
Comment thread build-fuzz.sh Resolved
Comment thread src/Makefile.am Resolved
Copilot AI review requested due to automatic review settings September 4, 2026 08:07

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Suppressed comments (3)

.github/workflows/build.yml:233

  • The sanitizer path selects cargo +nightly -Zbuild-std, which requires rust-src, but installing the nightly toolchain does not include that component by default. Install rust-src for nightly here so this fuzz job can build the standard library.
        run: rustup toolchain add nightly

src/Makefile.am:362

  • Correct the typo “fuzzz” to “fuzz”.
# mode (it just exits with a message to turn it off). The other fuzzz engines,

src/Makefile.am:371

  • The fastdev-without-fuzz branch that implements the divergence fix is not exercised by CI: the fuzz job configures --enable-fuzz and takes the opposite branch, while the ordinary build jobs do not enable fastdev. Add a tests-enabled fastdev/no-fuzz CI case with an assertion that fuzz_targets (and the production host's unified testutils) remain disabled, so this safety-critical behavior cannot silently regress.
FASTDEV_CARGO_FEATURE_FUZZ_TARGETS=

Comment thread src/Makefile.am Resolved
Comment thread src/Makefile.am Resolved
@graydon
graydon force-pushed the fix-fuzz-targets-induced-fastdev-divergence branch from 7916a01 to c797c10 Compare September 4, 2026 08:10
Copilot AI review requested due to automatic review settings September 4, 2026 08:10

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.

Suppressed comments (3)

src/Makefile.am:357

  • CARGO_FEATURE_FUZZ_TARGETS is empty when BUILD_TESTS is disabled, so --enable-fastdev-unsafe-for-production --enable-fuzz --disable-tests still builds the Soroban fuzz executables but backs them with the FUZZ_DISABLED stub. ENABLE_FUZZ should force this feature independently of the test-suite setting.
FASTDEV_CARGO_FEATURE_FUZZ_TARGETS=$(CARGO_FEATURE_FUZZ_TARGETS)

src/Makefile.am:151

  • This TSan probe also matches the unconditional -pthread added to CXXFLAGS in configure.ac:55. Consequently, the new fuzz configuration (-fsanitize=fuzzer-no-link,address) sets both -Zsanitizer=address and -Zsanitizer=thread, even though Rust sanitizers are mutually exclusive, so the fuzz build fails. Match thread only inside a -fsanitize= value.
RUSTFLAGS_TSAN := $(if $(if $(findstring -fsanitize,$(CXXFLAGS)),$(findstring thread,$(CXXFLAGS))),-Zsanitizer=thread,)

src/rust/Cargo.toml:246

  • The feature split leaves user-facing references to the old gate: src/rust/src/bridge.rs:458 and src/test/fuzz/targets/SorobanFuzzTargets.h:22-23 say --features fuzz, while src/test/fuzz/FuzzRegressionTests.cpp:86-87 says testutils; src/Makefile.am:646 also names the nonexistent fuzz feature. Update these references to fuzz_targets so the documented build instructions and disabled-target explanation remain accurate.
fuzz_targets = ["dep:soroban-fuzz-targets"]

Copilot AI review requested due to automatic review settings September 4, 2026 08:15
@graydon
graydon force-pushed the fix-fuzz-targets-induced-fastdev-divergence branch from c797c10 to c17475e Compare September 4, 2026 08:15

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Comment thread src/Makefile.am Resolved
Comment thread src/Makefile.am Resolved
@graydon
graydon added this pull request to the merge queue Sep 9, 2026
Merged via the queue into stellar:master with commit 457f20b Sep 9, 2026
56 checks passed
@graydon
graydon deleted the fix-fuzz-targets-induced-fastdev-divergence branch September 9, 2026 18:13
sisuresh added a commit to sisuresh/stellar-core that referenced this pull request Sep 18, 2026
Master added six [tx] tests that close ledgers (stellar#5420) and fixed the test
footprint deduplication helper (stellar#5402), which had been placing read-only
keys in the read-write footprint. Both tiers gain 6 leaves and 138 rewritten
InvokeHostFunctionTests vectors whose transactions now carry the corrected
footprints and fees.

Claude-Session: https://claude.ai/code/session_01Rq9SZEScpZhaDqJpqjXu6b
sisuresh added a commit to sisuresh/stellar-core that referenced this pull request Sep 22, 2026
Master added six [tx] tests that close ledgers (stellar#5420) and fixed the test
footprint deduplication helper (stellar#5402), which had been placing read-only
keys in the read-write footprint. Both tiers gain 6 leaves and 138 rewritten
InvokeHostFunctionTests vectors whose transactions now carry the corrected
footprints and fees.

Claude-Session: https://claude.ai/code/session_01Rq9SZEScpZhaDqJpqjXu6b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants