fix: anchor scoring cadence and prune horizon to block height (#372)#374
Open
greatjourney589 wants to merge 1 commit into
Open
fix: anchor scoring cadence and prune horizon to block height (#372)#374greatjourney589 wants to merge 1 commit into
greatjourney589 wants to merge 1 commit into
Conversation
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
The validator's scoring cadence was driven by
self.step % SCORING_WINDOW_BLOCKS,a per-process counter, and every scoring pass scored a fixed trailing window
ending at
self.block. When the forward loop advances more than one block perstep (catch-up after a restart/outage, fast chain), consecutive windows leave
gaps on the block axis — so a miner holding crown across the gap is only
credited for the final window, not the full span. Validators also diverged
because
self.stepand restart history differ across processes.This change anchors the cadence and the windows to block height via a new
persisted
last_scored_blockfrontier:and a full
SCORING_WINDOW_BLOCKShas elapsed sincelast_scored_block.(last_scored, window_end], so they tile the blockaxis contiguously — no gap, no overlap.
window_endis clamped to thewatcher cursor so a window never runs ahead of loaded events.
last_scored_blockis persisted inevent_watcher_meta, so a fresh processresumes from its frontier instead of re-deriving from
self.step.(
min(current_block, last_scored_block)), so a not-yet-scored window keepsits busy/active inputs until scoring consumes them.
unreachable), falling back to the trailing window.
Two replaying validators starting from the same
last_scored_blocknow scoreidentical windows regardless of step counts.
Changes
allways/validator/scoring.py— addscoring_due()/scoring_window();derive the window from
last_scored_block; advance the frontier after scoresupdate; anchor
prune_rate_eventson the unscored frontier.allways/validator/forward.py— gate scoring onscoring_due(self)insteadof
self.step % SCORING_WINDOW_BLOCKS.allways/validator/event_watcher.py— prune cutoff trails the unscoredfrontier; cold bootstrap resets
last_scored_blockto 0.allways/validator/state_store.py—get_/set_last_scored_block().neurons/validator.py— drop theinitial_scoring_doneflag.Testing
uv run pytest tests/— passesuv run ruff check allways/ neurons/— cleanNew tests cover block-anchored cadence, contiguous window tiling, the full-span
crediting case (issue #372), prune-horizon tracking, frontier round-trip, and
cold-boot reset.
Fixes #372