Skip to content

Fix false-positive 'Incorrect source epoch' in --validate_blocks - #5100

Open
clemahieu wants to merge 1 commit into
nanocurrency:developfrom
clemahieu:fix/validate-blocks-source-epoch-check
Open

Fix false-positive 'Incorrect source epoch' in --validate_blocks#5100
clemahieu wants to merge 1 commit into
nanocurrency:developfrom
clemahieu:fix/validate-blocks-source-epoch-check

Conversation

@clemahieu

Copy link
Copy Markdown
Contributor

Summary

--validate_blocks flags 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.cpp compares sideband.source_epoch to 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 to max(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 epoch by 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

  • Ran --validate_blocks against a full live-network ledger copy before the fix: 219 blocks flagged, all receives where source_epoch=epoch_0 and block epoch was epoch_1/epoch_2
  • Applied the fix, rebuilt, reran against the same ledger data: 0 errors, Validation status: Ok

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.
@gr0vity-dev-bot

gr0vity-dev-bot commented Jul 2, 2026

Copy link
Copy Markdown

Test Results for Commit ddb349e

Pull Request 5100: Results
Overall Status:

Test Case Results

  • 5n4pr_conf_10k_bintree: PASS (Duration: 105s)
  • 5n4pr_conf_10k_change: PASS (Duration: 139s)
  • 5n4pr_conf_change_dependant: PASS (Duration: 117s)
  • 5n4pr_conf_change_independant: PASS (Duration: 106s)
  • 5n4pr_conf_send_dependant: PASS (Duration: 110s)
  • 5n4pr_conf_send_independant: PASS (Duration: 105s)
  • 5n4pr_rocks_10k_bintree: PASS (Duration: 118s)
  • 5n4pr_rocks_10k_change: PASS (Duration: 150s)

Last updated: 2026-07-02 21:21:39 UTC

Comment thread nano/nano_node/entry.cpp
}
// 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

@pwojcikdev pwojcikdev Jul 3, 2026

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.

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.

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