Skip to content

fix: validate response staleness before returning to users#1157

Closed
MoonBoi9001 wants to merge 1 commit intomainfrom
fix/stale-indexer-response-validation
Closed

fix: validate response staleness before returning to users#1157
MoonBoi9001 wants to merge 1 commit intomainfrom
fix/stale-indexer-response-validation

Conversation

@MoonBoi9001
Copy link
Copy Markdown
Member

@MoonBoi9001 MoonBoi9001 commented Feb 3, 2026

Motivation

The gateway extracts probe_block from indexer responses (containing actual block timestamp) but never validates freshness before returning to users. Indexers can self-report being "fresh" via status endpoint while serving data that is months or even years old. This creates a gap where stale data reaches users despite the gateway having the information needed to detect it.

Summary

  • Adds post-response validation of probe_block.timestamp against current time
  • Stale responses are rejected and the retry loop continues with other candidates
  • Stale blocks are excluded from the chain tracker to avoid polluting block rate estimates
  • Configurable staleness threshold (default: 30 minutes)

Changes

  • Add ResponseTooStale { seconds_behind: u64 } error variant
  • Add max_response_staleness_seconds config option (default: 1800 / 30 min)
  • Add gw_stale_responses_rejected counter metric (labeled by deployment)
  • Add validate_response_staleness() function that checks probe_block timestamp
  • Integrate validation into response handling loop with logging
  • Treat staleness rejections as failures in performance feedback
  • Skip chain.notify for stale-rejected responses to prevent stale blocks from distorting chain head and blocks_per_minute estimates

🤖 Generated with Claude Code

@MoonBoi9001 MoonBoi9001 force-pushed the fix/stale-indexer-response-validation branch 4 times, most recently from 6211938 to 8e01362 Compare February 4, 2026 01:47
Indexers can self-report being "fresh" via status endpoint while serving
stale data. This adds post-response validation of probe_block.timestamp
against current time.

Changes:
- Add ResponseTooStale error variant to UnavailableReason
- Add max_response_staleness_seconds config (default: 30 min)
- Add gw_stale_responses_rejected metric counter
- Add validate_response_staleness() function in client_query
- Integrate validation into response handling loop
- Treat staleness rejections as failures in performance feedback

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@MoonBoi9001 MoonBoi9001 force-pushed the fix/stale-indexer-response-validation branch from 8e01362 to dc805e8 Compare February 4, 2026 01:49
@MoonBoi9001 MoonBoi9001 marked this pull request as ready for review February 4, 2026 01:53
@Theodus
Copy link
Copy Markdown
Member

Theodus commented Feb 4, 2026

We cannot make such assumptions about user preferences for freshness across the board, unfortunately. Luckily, the root cause of the issues this is trying to mitigate is resolved in #1158

@Theodus Theodus closed this Feb 4, 2026
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