Skip to content

Keep the CachedWitnessesCleanIndex reorg-decrements below the chain tip - #292

Open
MorningLightMountain713 wants to merge 1 commit into
RunOnFlux:masterfrom
MorningLightMountain713:fix/cached-witnesses-clean-index-test
Open

Keep the CachedWitnessesCleanIndex reorg-decrements below the chain tip#292
MorningLightMountain713 wants to merge 1 commit into
RunOnFlux:masterfrom
MorningLightMountain713:fix/cached-witnesses-clean-index-test

Conversation

@MorningLightMountain713

Copy link
Copy Markdown
Contributor

WalletTests.CachedWitnessesCleanIndex fails on master. The test asserts that a reorg recorded in the block files leaves the witness cache and the final anchor untouched — which only holds when the decrement height is strictly below the chain tip, because DecrementNoteWitnesses touches any note whose witnessHeight is at or below the decremented height.

The test decrements at heights 5 and 50. With MAX_REORG_LENGTH = 40, the test chain is WITNESS_CACHE_SIZE + 10 = 51 blocks, so height 50 is the tip: the second decrement pops the live witness and the assertions fail.

The deeper decrement height is now derived from WITNESS_CACHE_SIZE (which scales with MAX_REORG_LENGTH) rather than a literal, so it stays below the tip regardless of the reorg-length constant.

Verified: full flux-gtest suite on this branch is green (231/231), including the previously-failing test.

🤖 Generated with Claude Code

DecrementNoteWitnesses only touches a note when its witnessHeight is at or
below the decremented height, so the test's assertion that a reorg leaves the
witness cache and final anchor untouched holds only when the decrement is
strictly below the tip. The test decremented at heights 5 and 50; with
MAX_REORG_LENGTH=40 the chain is WITNESS_CACHE_SIZE + 10 = 51 blocks, so 50 is
the tip and the decrement pops the live witness. Derive the deeper decrement
height from WITNESS_CACHE_SIZE so it stays below the tip regardless of the
reorg-length constant.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.

1 participant