Skip to content

feat(nodectl): refresh past_elections cache periodically#176

Open
Keshoid wants to merge 1 commit into
release/nodectl/v0.5.1from
feature/sma-98-refresh-past_elections-cache-periodically-instead-of-once
Open

feat(nodectl): refresh past_elections cache periodically#176
Keshoid wants to merge 1 commit into
release/nodectl/v0.5.1from
feature/sma-98-refresh-past_elections-cache-periodically-instead-of-once

Conversation

@Keshoid
Copy link
Copy Markdown
Contributor

@Keshoid Keshoid commented May 22, 2026

Summary

  • Adds a TTL-based refresh for the elections runner's past_elections and pool-address caches (currently invalidated only on election_id change, i.e. once per ~9h round).
  • Defends against the SMA-98 incident where a stale snapshot from a lagging RPC endpoint persisted for the whole round and inflated frozen_stake to 2× the real value.
  • New config field elections.cache_refresh_secs (default 300, set 0 to disable). Hot-reloaded via the 10s config-file watch.
  • Logs past_elections cache refreshed (reason=election_id|ttl, ...) on each refresh so the trigger is visible in the daemon log.
  • Clock trait introduced in common (production SystemClock, deterministic MockClock) so the TTL logic is unit-testable without real-time sleeps.
  • Singlehost e2e (run_singlehost_nodectl.py) sets cache_refresh_secs=60 after config generate so the periodic refresh is exercised in the e2e log.

Closes SMA-98.

Copilot AI review requested due to automatic review settings May 22, 2026 19:16
@linear
Copy link
Copy Markdown

linear Bot commented May 22, 2026

SMA-98

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

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.

2 participants