You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 7c37319
Browse filesBrowse the repository at this point in the historyBrowse files
Hardens historical rewards pricing so wrong numbers never land in the
block-keyed cache for a year.
Three changes layered together:
1. Retry on CoinGecko 429 with backoff
----------------------------------
Free tier throttles ~10-30/min. New coingeckoFetch helper wraps each
CoinGecko request with:
• up to 5 attempts
• honors Retry-After header when present
• exponential backoff (2^attempt seconds, capped at 60s) otherwise
Applies to both current-price (fetchLavaUsdPrice) and historical-price
(fetchTokenUsdPriceAt) paths.
2. Fail loud on rate-limit exhaustion
----------------------------------
Before: fetchTokenUsdPriceAt caught all errors and returned 0 →
processRewardTokens fell back to current price cache → USD figure in
response was WRONG but cached as if historical → wrong for a year.
Now: fetchTokenUsdPriceAt throws on transient failures (rate limit,
network error) and only returns 0 for legitimate "no data" (unknown
denom, 404, empty market_data). Zeros cache indefinitely (permanent
facts), throws don't cache (next caller retries).
buildHistoricalPriceMap makes LAVA required (virtually all reward value
is LAVA), other denoms best-effort. If LAVA throws, the route returns
503 with a clear "please retry" message. Cache plugin skips 4xx/5xx so
no bad response gets written to Redis.
3. 1-year cache for immutable past-block snapshots
-----------------------------------------------
New CACHE_TTL.IMMUTABLE = 31_536_000. Applied to:
• /provider-estimated-rewards?block=N (response fully determined by
past chain state + block-time prices, both unchangeable)
• /provider-estimated-rewards/blocks (monthly 17th heights permanent)
• /provider-rewards?from=&to= when `to` is older than today - 1 day
Kept on HISTORICAL (1 day):
• /providers/:addr/avatar (Keybase avatars can change)
• /burn-rate (mixes immutable blocks with a "latest" field)
Tests updated: 113/113. Added a case asserting that when
buildHistoricalPriceMap throws, the route returns 503 AND does not call
fetchRewardsBySpec — i.e. we refuse to ship a response rather than
silently shipping one with the wrong price.
0 commit comments