Keep the CachedWitnessesCleanIndex reorg-decrements below the chain tip - #292
Open
MorningLightMountain713 wants to merge 1 commit into
Conversation
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>
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.
WalletTests.CachedWitnessesCleanIndexfails 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, becauseDecrementNoteWitnessestouches any note whosewitnessHeightis at or below the decremented height.The test decrements at heights 5 and 50. With
MAX_REORG_LENGTH = 40, the test chain isWITNESS_CACHE_SIZE + 10 = 51blocks, 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 withMAX_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