Skip to content

validator: forward-loop redundancies (epoch-gate registration, throttle prune, in-memory busy, cache source verify)#256

Merged
LandynDev merged 4 commits into
testfrom
perf/validator-loop-tier1-redundancies
May 1, 2026
Merged

validator: forward-loop redundancies (epoch-gate registration, throttle prune, in-memory busy, cache source verify)#256
LandynDev merged 4 commits into
testfrom
perf/validator-loop-tier1-redundancies

Conversation

@LandynDev

@LandynDev LandynDev commented May 1, 2026

Copy link
Copy Markdown
Collaborator

What

Four independent forward-loop optimizations, each a single commit. Built on top of #255.

7217738 validator: gate check_registered behind should_sync_metagraph
8d77fe1 validator: throttle event_watcher.prune_old_events to every 100 blocks
02304d0 validator: gate has-active-swap RPC behind in-memory busy counter
7363690 validator: cache source-tx verification per swap_id

Per-step impact

Hot-path call Before After
is_hotkey_registered 1/step 1/epoch
prune_old_events walk 1/step 1/100 blocks
get_miner_has_active_swap per pending row 1 0 in steady state, 1 only when watcher reports busy
Source-tx verify per FULFILLED swap 1+/step 1 lifetime, then cached

Correctness notes

Commit 3 uses the in-memory event_watcher.open_swap_count as a fast path but still verifies with the contract before dropping a pending row. The watcher can lag the chain after a sync_to failure; dropping a pending_confirms row on a stale "busy" report would burn the user's reserved TAO. The contract verify is only paid when the watcher reports busy (rare in steady state).

Commit 4's source_verified_ids set grows by one entry per FULFILLED swap. No eviction — the source tx is final once confirmed, so the cache is correct for the lifetime of the validator process. Memory is bounded by total swap count (negligible at any realistic scale).

Held back from this PR

Test plan

  • pytest tests/ — 387 passed
  • ruff check + ruff format --check — clean
  • Manual: testnet step-duration before/after under multi-row load.

@LandynDev LandynDev force-pushed the perf/validator-loop-tier1-redundancies branch from a1ded38 to 7363690 Compare May 1, 2026 17:54
@LandynDev LandynDev changed the title validator: tier-1 forward-loop redundancies (check_registered, prune throttle, in-memory busy lookup) validator: forward-loop redundancies (epoch-gate registration, throttle prune, in-memory busy, cache source verify) May 1, 2026
@LandynDev LandynDev merged commit 597816c into test May 1, 2026
3 checks passed
@anderdc anderdc deleted the perf/validator-loop-tier1-redundancies branch June 8, 2026 21:55
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.

1 participant