RPC
Older blocks on the RPC
bittensor.ai's RPC serves recent chain state. A call that needs state from an older block returns an error that links here.
What the RPC keeps
The RPC is at https://rpc.bittensor.ai and wss://rpc.bittensor.ai. Counted back from the newest block:
- Chain state (storage reads, runtime calls, balances at a block): the latest 256 blocks, about 51 minutes at 12 seconds a block.
- Block headers and bodies: about the latest 4,096 blocks, about 13.6 hours.
chain_getBlockHashandchain_getBlockwork for those blocks; a state read at one older than 256 blocks doesn't. - EVM history: about the latest 250 blocks, counted from
eth_blockNumber. This covers a call that names a block number:eth_getBlockByNumber, andeth_getBalance,eth_call,eth_getCode,eth_getStorageAt,eth_getTransactionCountoreth_getLogsat an older block. Calls atlatest,pending,safeorfinalized, and lookups by block hash or transaction hash, are not refused by this check.
The errors
A request made with an API key gets one of these two errors when it reaches past what the RPC keeps. Both carry data.hint and a data.docs link to this page.
Chain state older than 256 blocks
The node's own error, code 4003, with data added. The block hash at the end of the message changes with the request.
{
"jsonrpc": "2.0",
"error": {
"code": 4003,
"message": "Client error: UnknownBlock: State already discarded for 0x0cd451e57b41214737afd2b6ac5f28af79a24953d6a9f5aae017a4da8110c81b",
"data": {
"hint": "historical state needs the archive add-on",
"docs": "https://bittensor.ai/docs/rpc/archive"
}
},
"id": 1
}EVM history older than about 250 blocks
Code -32000. The message says about 256 blocks; the RPC refuses a little before that, from about 250, so a call never comes back with an empty answer instead of an error.
{
"error": {
"code": -32000,
"data": {
"docs": "https://bittensor.ai/docs/rpc/archive",
"hint": "historical state needs the archive add-on"
},
"message": "EVM history beyond ~256 blocks needs the archive add-on"
},
"id": 1,
"jsonrpc": "2.0"
}The archive add-on
The archive add-on gives a key chain state and EVM history for every block. It is not available yet: the error text names it, but it is not on sale.
Today, if you need state older than these limits, run your own archive node: a subtensor node that keeps all state (Substrate's --state-pruning archive).
eth_getLogs ranges
One eth_getLogs call covers at most 10,000 blocks, with or without archive access. A wider range returns code -32602; split it into ranges of at most 10,000 blocks. The numbers in the message change with the request.
{
"error": {
"code": -32602,
"data": {
"docs": null,
"hint": "split the query into block ranges of at most 10000 blocks"
},
"message": "eth_getLogs block range of 19996 blocks exceeds the limit of 10000 blocks"
},
"id": 1,
"jsonrpc": "2.0"
}