fix(staker): never drop newly-activated orchs from NewRound fanout discovery - #7
Merged
Merged
Conversation
…scovery
load_known_orchestrators_before returned early with only matview-derived
addresses whenever orchestrator_profile was non-empty, skipping the raw
lifecycle-event scan. Discovery of new orchestrators is otherwise
in-memory only, so an orch whose TranscoderActivated event was consumed
in a follow iteration that ended before the next NewRound was silently
excluded from every future fanout: no orch_stake_by_round row, no
matview row, permanent 404 on /orchestrators/{address}.
Union both sources instead. The event scan is bounded by
idx_events_contract_event via the new contract_name filter (all eight
lifecycle event names are BondingManager events).
Observed in prod: 0x428989...2e93 (activated 2026-08-28) and
0xfd6fe0...8df7 (activated 2026-08-29) had full event history but no
profile row through rounds 4320-4321. Self-heals at the next NewRound
after deploy.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HPZTFAkTkMusMUe2nQBTUD
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.
Problem
GET /api/v1/orchestrators/{address}returns 404 for orchestrators that are demonstrably live on-chain. Observed in prod:0x428989211607999bc53243e25862b9a2336e2e93— TranscoderActivated 2026-08-28, earning tickets since0xfd6fe005f611bdaa195937c7b95e9c1fde118df7— TranscoderActivated 2026-08-29, earning tickets sinceBoth have full event history in
raw_protocol_eventsbut zero rows inorch_stake_by_round, so theorchestrator_profilematview (which the endpoint serves) has never heard of them.Root cause
load_known_orchestrators_beforereturns early with only matview-derived addresses wheneverorchestrator_profileis non-empty — the raw lifecycle-event fallback scan only ever ran on a cold start. Discovery of new orchestrators is otherwise in-memory only, and theProfileFollowloop rebuildsknown_orchsfrom the matview on every iteration.So at the chain tip: an iteration consumes
TranscoderActivated, adds the orch to the in-memory set, advances the checkpoint past it — but no NewRound arrives in that batch (rounds are ~21h apart). The next iteration reseeds from the matview, which lacks the orch, and its activation event is now behind the checkpoint. It is excluded from every future NewRound fanout, permanently. Any orch that first activates mid-round hits this.Fix
Union both discovery sources instead of early-returning. The event scan gains a
contract_name = 'BondingManager'filter (all eight lifecycle event names occur only on BondingManager — verified in prod) so it is served byidx_events_contract_event; it resolves ~1,958 distinct addresses, the same cardinality the fanout already handles.No API, matview, or migration changes needed: the matview is an unfiltered
DISTINCT ON (address)overorch_stake_by_roundand the daemon refreshes it every 30s, so one snapshot row suffices.Deploy behavior
Self-heals: at the first NewRound after deploy (~round 4322), the re-discovered orchs enter the fanout, get their first
orch_stake_by_roundrow, and the 404s resolve after the next matview refresh. For immediate repair, astaker_orch_profilecheckpoint replay from before block 499300750 is idempotent.🤖 Generated with Claude Code
https://claude.ai/code/session_01HPZTFAkTkMusMUe2nQBTUD