Skip to content

Conversation

@lnbc1QWFyb24
Copy link
Collaborator

  • Summary
    - Implement exponential backoff with full jitter when get_latest_block fails to prevent hot-looping, reduce RPC load, and cut log spam.
    Backoff resets on success and caps at 5s.
    • Changes
      • Add retry constants ERROR_RETRY_BASE_BACKOFF_MS=250 and ERROR_RETRY_MAX_BACKOFF_MS=5000 (src/agent.rs:17-19).
      • Implement jittered exponential backoff in poll_blocks:
        • On error: sleep random floor..=cap ms, double backoff_ms up to max (src/agent.rs:248-296).
        • On success: reset backoff_ms to base (src/agent.rs:255-258).
        • Log includes retry_ms for observability (src/agent.rs:292).
      • Import rand::Rng and add rand dependency (src/agent.rs:15, Cargo.toml).
      • Bump crate version to 0.1.3 (Cargo.toml).
    • Rationale
      • Avoid tight retry loops during RPC instability; align with standard backoff + jitter to minimize thundering herd behavior.
    • Behavior
      • No public API changes.
      • When RPC errors occur, retries back off between 250ms and 5s with jitter; returns to normal cadence after a successful fetch.
    • Verification
      • Induce get_latest_block errors and observe retry_ms increasing and bounded; ensure reset on success and normal block handling remains
        intact.
    • Files
      • src/agent.rs:15 — add use rand::Rng;
      • src/agent.rs:17-19 — add backoff constants
      • src/agent.rs:248-296 — backoff logic in poll_blocks
      • Cargo.toml:3 — version 0.1.3 and rand dependency
      • Cargo.lock — updated for version/deps

@lnbc1QWFyb24 lnbc1QWFyb24 merged commit be3691a into main Nov 3, 2025
6 checks passed
@lnbc1QWFyb24 lnbc1QWFyb24 deleted the fix/rpc-block-error-backoff branch November 3, 2025 21:42
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