Fix false-positive 'Incorrect source epoch' in --validate_blocks - #5100
Open
clemahieu wants to merge 1 commit into
Open
Fix false-positive 'Incorrect source epoch' in --validate_blocks#5100clemahieu wants to merge 1 commit into
clemahieu wants to merge 1 commit into
Conversation
The check compared sideband.source_epoch to the receiving block's own epoch with equality. But a receiving block's own epoch is max(account's prior epoch, source_epoch) at write time (ledger_processor.cpp), so source_epoch < block epoch is expected whenever the receiving account had already epoch-upgraded past the sender -- a common, valid case, not a corruption. Replace the equality check with the correct monotonic invariant: only flag when the block's epoch is less than its source_epoch.
Test Results for Commit ddb349ePull Request 5100: Results Test Case Results
Last updated: 2026-07-02 21:21:39 UTC |
pwojcikdev
approved these changes
Jul 3, 2026
pwojcikdev
reviewed
Jul 3, 2026
| } | ||
| // Check link epoch version | ||
| // A receiving block's own epoch is max(account's prior epoch, source_epoch) | ||
| // (see ledger_processor.cpp), so source_epoch <= block epoch is expected and |
Contributor
There was a problem hiding this comment.
Referring to ledger_processor.cpp will get out of sync over time. Opus models like this overly verbose comment style, unless explicitly corrected in claude.md.
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.
Summary
--validate_blocksflags every receive block where the receiving account had already epoch-upgraded past the sender's epoch, even though this is normal, valid ledger state.Problem
The check in
entry.cppcomparessideband.source_epochto the receiving block's own epoch with equality:if (sideband.source_epoch != node->ledger.version (*block))At write time (
ledger_processor.cpp), a receiving block's own epoch is set tomax(account's prior epoch, source_epoch). So whenever a receiving account is already on a higher epoch than the send it's receiving,source_epoch < block epochby design — not an error. The equality check produces a false positive on every such block.Fix
Replace the equality check with the correct monotonic invariant: a block's epoch should never be less than the epoch of a send it received.
if (node->ledger.version (*block) < sideband.source_epoch)Test plan
--validate_blocksagainst a full live-network ledger copy before the fix: 219 blocks flagged, all receives wheresource_epoch=epoch_0and block epoch wasepoch_1/epoch_2Validation status: Ok