Skip to content

feat(service): allow overriding discovery polling interval via env - #417

Merged
nahimterrazas merged 3 commits into
mainfrom
discovery-polling-env-override
Aug 24, 2026
Merged

feat(service): allow overriding discovery polling interval via env#417
nahimterrazas merged 3 commits into
mainfrom
discovery-polling-env-override

Conversation

@nahimterrazas

@nahimterrazas nahimterrazas commented Aug 24, 2026

Copy link
Copy Markdown
Collaborator

Motivation

Discovery polling is the dominant passive RPC cost of a running solver: the boot-time config merge hardcodes polling_interval_secs = 5 for onchain_eip7683, i.e. ~3-4 RPC calls every 5s per chain (~60k calls/day/chain), 24/7, regardless of traffic. Because OperatorConfig has no discovery section and the merge re-runs on every boot, this value could not be changed by bootstrap config, admin API, or storage edits — only by rebuilding.

This is needed to run the hosted solvers in a temporary low-RPC-usage mode (Alchemy CU reduction) while keeping them online.

Change

  • New optional env var SOLVER_DISCOVERY_POLLING_INTERVAL_SECS, read during the config merge (same pattern as SOLVER_API_PORT / AUTH_PUBLIC_REGISTER_ENABLED).
  • Unset → falls back to COMMON_DEFAULTS.polling_interval_secs (5) — behavior is bit-for-bit unchanged.
  • Validated to 1..=300 at merge time: the upper bound mirrors MAX_POLLING_INTERVAL_SECS in the onchain_eip7683 discovery schema (out-of-range values would otherwise pass the merge and abort startup at factory validation); 0 is rejected because the implementation treats it as the currently-disabled WebSocket mode.
  • One tracing::info! logs the effective interval at boot for operational verification.
  • Documented in AGENTS.md, crates/solver-service/AGENTS.md, and .env.example.

Testing

  • test_validate_discovery_polling_interval_bounds — pure range validation (0 / 1 / 5 / 300 / 301), no env access.
  • test_discovery_polling_interval_env_override — env var propagates into the generated onchain_eip7683 config.
  • test_discovery_polling_interval_defaults_to_seed_default_when_unset — unset falls back through COMMON_DEFAULTS and pins the current default at 5.
  • test_parse_u64_env_var_* — new helper parity with the existing parse_u16_env_var tests.
  • Env-touching tests use #[serial] + EnvVarGuard and only ever set valid values, so concurrently running non-serial tests can never observe an env state that fails the merge.
  • Full cargo test -p solver-service: 724 + 5 passed. cargo fmt --all -- --check and cargo clippy --all-features --all-targets -- -D warnings --allow deprecated clean.

Summary by CodeRabbit

  • New Features

    • Added an optional setting to control how frequently on-chain discovery runs.
    • The interval defaults to 5 seconds and accepts values from 1 to 300 seconds.
    • Invalid values are rejected with configuration feedback.
    • Changes take effect after restarting the service.
  • Documentation

    • Added configuration guidance, including the default value, valid range, startup behavior, and restart requirement.

@coderabbitai

coderabbitai Bot commented Aug 24, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: e506aefd-80f7-458a-a993-40a70e60d2ea

📥 Commits

Reviewing files that changed from the base of the PR and between 2ae1829 and 049582f.

📒 Files selected for processing (4)
  • .env.example
  • AGENTS.md
  • crates/solver-service/AGENTS.md
  • crates/solver-service/src/config_merge.rs

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

The solver service now reads SOLVER_DISCOVERY_POLLING_INTERVAL_SECS, validates values from 1 through 300 seconds, defaults to the common seed value, and applies the resolved interval to on-chain discovery. Tests and environment documentation cover the configuration.

Changes

Discovery polling interval

Layer / File(s) Summary
Parse, validate, and apply polling interval
crates/solver-service/src/config_merge.rs
The configuration loader parses and validates the polling interval, logs the resolved value, and replaces the fixed five-second discovery interval.
Validate defaults and document configuration
crates/solver-service/src/config_merge.rs, AGENTS.md, crates/solver-service/AGENTS.md, .env.example
Tests cover parsing, bounds, overrides, and defaults. Documentation describes the variable, valid range, default, and restart requirement.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to 04958

The change adds a bounded environment override for discovery polling while preserving the existing default behavior. No actionable merge-blocking risk remains beyond normal checks and review.

Suggested reviewers: shahnami, pepebndc, tirumerla

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the primary change: an environment variable override for the discovery polling interval.
Description check ✅ Passed The description clearly explains the motivation, implementation, validation, documentation, and tests, but it does not use the template headings or include a related-issue reference.
Docstring Coverage ✅ Passed Docstring coverage is 81.25% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 16 functions across 1 files. (3 skipped: 3 unsupported.)
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch discovery-polling-env-override

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Aug 24, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 94.11765% with 5 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
crates/solver-service/src/config_merge.rs 94.1% 5 Missing ⚠️

📢 Thoughts on this report? Let us know!

@nahimterrazas
nahimterrazas merged commit e6cf9f9 into main Aug 24, 2026
20 checks passed
@nahimterrazas
nahimterrazas deleted the discovery-polling-env-override branch August 24, 2026 20:54
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.

3 participants