fix(census): improve on-chain census retry robustness#468
Open
altergui wants to merge 1 commit into
Open
Conversation
- Exponential backoff between attempts (5s, 10s, 20s, 40s, 60s...) instead of fixed 5s cooldown, extending the effective retry window from ~20s to ~4.3min - Increase default attempts from 5 to 8 and Expiration from 2min to 10min - OnCensusDownloaded no longer exits early on attempt exhaustion; only Terminal errors (true 404s) trigger an immediate failure callback - checkOnchainCensuses re-queues exhausted non-terminal on-chain censuses after MaxCooldown (60s), giving the indexer a second round without needing a root change Fixes the race where a slow indexer (e.g. Sepolia at 12s blocks) would exhaust all retries before catching up with newly mined weight-change events. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves robustness of on-chain dynamic census downloads in davinci-node by extending the retry window and adding exponential backoff to better tolerate GraphQL/indexer lag before census data becomes available.
Changes:
- Added
MaxCooldownand implemented exponential backoff (doubling cooldown per retry, capped) for census download retries. - Increased default retry attempts (5 → 8) and expiration window (2min → 10min) to align with longer on-chain/indexer delays.
- Updated on-chain census re-check logic to re-queue exhausted (non-terminal) downloads after
MaxCooldowneven when the on-chain root hasn’t changed.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
269
to
273
| case status.Terminal && status.LastErr != nil: | ||
| // Return the last error if the downloader has reached a | ||
| // terminal error. | ||
| callback(status.LastErr) | ||
| return |
Comment on lines
399
to
+401
| // 1s (to cover the 1s OnCensusDownloaded polling tick) + | ||
| // Attempts * AttemptTimeout + | ||
| // (Attempts - 1) * Cooldown (when Attempts > 1). | ||
| // | ||
| // Note that the per-attempt timeout does not increase between attempts; each | ||
| // attempt uses the same AttemptTimeout value. | ||
| // sum of per-attempt cooldowns: Cooldown<<0, Cooldown<<1, ..., capped at MaxCooldown |
Comment on lines
+534
to
+538
| // Attempts exhausted but root unchanged — wait MaxCooldown before | ||
| // giving the indexer another chance. | ||
| if cd.config.MaxCooldown <= 0 || time.Since(status.lastUpdated) < cd.config.MaxCooldown { | ||
| return true | ||
| } |
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
OnCensusDownloadedno longer exits early when attempts are exhausted — only true Terminal errors (HTTP 404) trigger an immediate failure; indexer-lag failures keep waiting for the context deadlinecheckOnchainCensusesre-queues failed on-chain censuses afterMaxCooldown(60s) without requiring the on-chain root to have changed, giving the indexer a second round of retriesContext
On-chain dynamic censuses fail when davinci-node reads the census root from the contract before the GraphQL indexer has processed the corresponding weight-change event. On Sepolia (12s blocks, 12 confirmations), the indexer can take ~5 minutes to catch up — far beyond the previous ~20s retry window.
Test plan
servicetests pass (go test ./service/...)🤖 Generated with Claude Code