fix(cli): implement CHARON_PRICE_MAX_AGE_SECS env override (closes #413)#416
Merged
fix(cli): implement CHARON_PRICE_MAX_AGE_SECS env override (closes #413)#416
Conversation
The docstring on `BotConfig::chainlink_max_age_secs` and the operator-facing comment in scripts/anvil_fork.sh both reference `CHARON_PRICE_MAX_AGE_SECS` as a global staleness override, but no call site ever read the env var — both `PriceCache::with_per_symbol_max_age` sites in charon-cli (listen + replay) hardcoded `DEFAULT_MAX_AGE`. Fix: add `resolve_default_price_max_age` helper that reads `CHARON_PRICE_MAX_AGE_SECS` (u64 seconds), logs once on success, warns on parse failure, and falls back to `DEFAULT_MAX_AGE`. Use it in place of the hardcoded constant at both call sites. Per-symbol overrides in `[chainlink_max_age_secs.<chain>]` continue to win. Updated the BotConfig docstring to describe the actual behaviour (env var anchors the floor for symbols without per-symbol overrides, not the headline value) so the docs stop misrepresenting the wiring.
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
The docstring on `BotConfig::chainlink_max_age_secs` and the operator-facing comment in `scripts/anvil_fork.sh` both reference `CHARON_PRICE_MAX_AGE_SECS` as a documented escape hatch for the Chainlink freshness gate. The env var was never implemented — `grep -rn CHARON_PRICE_MAX_AGE_SECS crates/` returned only the docstring. Both `PriceCache::with_per_symbol_max_age` call sites in charon-cli (listen + replay) hardcoded `DEFAULT_MAX_AGE`. Operators following the documented recovery flow on a stale fork hit `feed 'BNB' missing or stale ... max_age 3600 s` regardless of the env var.
Fix
Test plan
Do NOT merge until #412 + #414 land and the local fork-test passes end-to-end.