Skip to content

Fix incorrect-reset bug in tx fuzz target (broken with bucketlistDB)#5292

Open
graydon wants to merge 1 commit into
stellar:masterfrom
graydon:fix-tx-fuzz-setup-bug
Open

Fix incorrect-reset bug in tx fuzz target (broken with bucketlistDB)#5292
graydon wants to merge 1 commit into
stellar:masterfrom
graydon:fix-tx-fuzz-setup-bug

Conversation

@graydon
Copy link
Copy Markdown
Contributor

@graydon graydon commented May 26, 2026

The fuzz_tx target was broken a while ago when we moved most LEs to the BucketlistDB: it sets up some state, and commits it (at the ltx level), and then resets the state assuming that the committed state will be reloaded/recovered from SQL. but it won't -- because only offers land in SQL anymore.

This bug was causing fairly early and constant internal errors when running the tx fuzz target, because the ledger state it was seeing was corrupt: offers made by nonexistent accounts mainly. This isn't a bug in the tx subsystem or anything, just in the fuzz target.

There are a few ways to fix this (including making a miniature copy of the BucketlistDB ledger-close / commit path just for the fuzz target) but the simplest is just to not write anything to disk and fuzz against an in-memory ltx: add 1 more level of nested ltx that we keep open in the fuzz target, and roll back to its state on each fuzzed tx. Works fine, actually runs faster, and is totally sufficient for fuzzing the tx subsystem.

Copilot AI review requested due to automatic review settings May 26, 2026 04:13
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes the tx fuzz target’s ledger-reset behavior after the BucketListDB migration by keeping fuzz iterations scoped to a long-lived, in-memory LedgerTxn (rolling back a nested txn per iteration) rather than relying on SQL reloading of ledger state.

Changes:

  • Introduces a persistent setup LedgerTxn (mSetupLedgerTxn) that serves as an in-memory baseline for all fuzz iterations.
  • Refactors setup logic into applySetupLedgerState(...) to apply the deterministic ledger setup to different txn parents.
  • Adds a Catch2 regression test to ensure a known input runs without triggering internal errors.

Reviewed changes

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

File Description
src/test/fuzz/targets/TxFuzzTarget.h Adds an out-of-line destructor and stores a long-lived LedgerTxn used as the fuzz baseline.
src/test/fuzz/targets/TxFuzzTarget.cpp Refactors setup into a helper, switches per-run txn parent to mSetupLedgerTxn, and adds a regression test.

}
resetTxInternalState(*mApp);

mSetupLedgerTxn = std::make_unique<LedgerTxn>(mApp->getLedgerTxnRoot());
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