stale
How many slots is your Solana RPC behind a reference endpoint? stale measures it once a second — and says UNKNOWN when it cannot tell.
Install
go install github.com/Alarm2024/stale/cmd/stale@latest
Example output
stale check https://rpc.example.com ref=https://api.mainnet-beta.solana.com max_lag=5 for=10s
target=450106684 ref=450106712 lag=28 slots (11200 ms) advanced=no
target=450106684 ref=450106716 lag=32 slots (12800 ms) advanced=no
target=450106684 ref=450106720 lag=36 slots (14400 ms) advanced=no
verdict=STALE target_slot=450106684 ref_slot=450106720 lag=36 slots (14400 ms) target_advanced=false ref_behind=false degraded=false
Why we built it
Our own trading bot labelled every hop-1 quote it priced in half an hour "fresh" — 283 of 283. The ages it logged beside that word ran from four to eight seconds. The label was our code's, not any provider's, and it was wrong: the bot called a quote fresh because it was cached, without checking how old it was. We found it by reading the bot's own logs and judging the word by the number next to it. stale is that check, made into a tool you can point at any RPC.
stale did not produce the numbers below — they are quote ages our bot wrote to its log, in milliseconds, over half an hour of scans. A stale run reports something else: lag in slots against a reference endpoint.
Limits
- Compares against one reference — if both endpoints lag equally, stale cannot tell.
- Measures slot lag with
getSlotatprocessedcommitment. It does not measure the age of account data, quotes, or any other answer. - Lag in milliseconds is slots × 400 ms, an estimate from the nominal slot time, not a measured duration.
- The verdict judges lag on the last sample of the window. A target that trailed and then caught up by the end reads FRESH.
- The default reference,
api.mainnet-beta.solana.com, is rate-limited. A refused or slow call never produces FRESH. It can still end in STALE when at least two earlier samples, answered by both endpoints, already proved the lag; the verdict line then saysdegraded=trueand printslag=unknownif the last sample went unanswered. - An endpoint measured against itself is refused — lag against yourself is always zero.
- Read-only proxy —
sendTransactionandrequestAirdropare refused in any letter case, and a request that names its method twice or in two spellings is refused before it is forwarded. - The proxy's
X-Stale-*headers describe the latest background sample, not the response they arrive on. - WebSocket fan-out waits for v0.2.