getBlockProduction
Overview
The getBlockProduction JSON-RPC method provides comprehensive statistics on block production by validators within a specified slot range or for the entire current epoch. It leverages the leader schedule to determine which validators were assigned slots and then reports how many blocks they actually produced within those assignments. This method is crucial for deeply understanding the operational performance and reliability of the Solana validator set.
Expert users and applications utilize getBlockProduction to monitor validator health, assess network decentralization, and evaluate the effectiveness of stake delegation. By comparing scheduled slots against actual blocks produced, one can identify validators that are frequently missing blocks, which could indicate network connectivity issues, node instability, or other operational problems. This granularity is vital for stakers to make informed decisions about their delegations and for node operators to diagnose and optimize their validator infrastructure.
The data returned by this method provides critical insights into the real-time liveness of the network, showing how efficiently the leader schedule is being executed. It's an indispensable tool for network analytics, performance auditing, and ensuring the robust operation of the Solana blockchain by holding validators accountable for their scheduled duties.
Parameters
| Name | Type | Required/Optional | Description |
|---|---|---|---|
config | object | Optional | An optional configuration object to customize the query. |
config.identity | string | Optional | A Base58 encoded Pubkey string representing a specific validator's identity. If provided, the results will be filtered to include block production statistics exclusively for this validator. This is particularly useful for focused monitoring of individual node performance. |
config.range | object | Optional | An object that defines the specific slot range for which to retrieve block production statistics. If this parameter is omitted, the method will default to providing statistics for the entire current epoch. |
config.range.firstSlot | u64 (integer) | Required (if range is present) | The first slot (inclusive) to be included in the block production statistics calculation. The firstSlot must be a valid slot number present in the node's historical data. If firstSlot is earlier than the node's firstAvailableBlock, the query will be implicitly clamped to firstAvailableBlock. |
config.range.lastSlot | u64 (integer) | Required (if range is present) | The last slot (inclusive) to be included in the block production statistics calculation. lastSlot must be greater than or equal to firstSlot. If lastSlot extends beyond the current epoch or the highest finalized slot (depending on commitment), the statistics will only cover up to the available block data. If lastSlot is in the future relative to the node's current finalized slot, the statistics will only extend up to that point. |
config.commitment | string ("processed", "confirmed", "finalized", "unconfirmed") | Optional (Default: "finalized") | Specifies the commitment level for the block data queried. This affects the highest slot considered for the query (especially if config.range is not provided) and implicitly the context.slot and currentSlot in the response. A higher commitment level ensures more stable data but might lead to slightly older currentSlot values. processed: The node has received the block and is processing it. confirmed: The node has voted on and seen the block voted on by a supermajority of the cluster. finalized: The node has voted on and seen the block voted on by an overwhelming supermajority of the cluster (typically irreversible). unconfirmed: Similar to processed, but may include blocks not yet processed by the full validation pipeline. |
Expected Response
The getBlockProduction method returns a JSON object with a standard RPC context and a value field containing the detailed production statistics.
1{
2 "jsonrpc": "2.0",
3 "result": {
4 "context": {
5 "apiVersion": "1.x.x",
6 "slot": 123456789
7 },
8 "value": {
9 "byIdentity": {
10 "ValidatorPublicKey1_Base58": [100, 95],
11 "ValidatorPublicKey2_Base58": [50, 48],
12 "ValidatorPublicKey3_Base58": [150, 150]
13 },
14 "range": {
15 "firstSlot": 123400000,
16 "lastSlot": 123456789
17 },
18 "currentSlot": 123456790,
19 "firstAvailableBlock": 123000000
20 }
21 },
22 "id": 1
23}The result field contains the following properties:
-
context: An object providing metadata about the RPC request's execution.apiVersion:string- The API version of the Solana RPC endpoint serving the request (e.g., "1.18.15").slot:u64(integer) - The highest block slot processed by the RPC node at the time the request was evaluated, respecting the specifiedcommitmentlevel. This indicates the freshness of the data in the context of the requestedcommitment.
-
value: An object containing the core block production statistics.-
byIdentity:object(Map ofstringtoarrayofu64) This is a key-value map where each key is a Base58 encodedPubkeystring representing a validator's identity. The corresponding value is an array of twou64integers:[0]:numberOfSlotsScheduled- The total number of slots this validator was assigned in the leader schedule within the effectiverangeof the query. This value is derived from the network's deterministic leader schedule.[1]:numberOfBlocksProduced- The actual number of blocks successfully produced and confirmed by this validator within their scheduled slots, within the effectiverange. A block is considered produced if it was propagated to the network and reached the requiredcommitmentlevel. The discrepancy betweennumberOfSlotsScheduledandnumberOfBlocksProducedindicates missed slots, which can be due to validator downtime, network partitioning, insufficient stake, or other operational issues. Ifconfig.identitywas specified in the request, this map will contain only one entry for that specific validator. If a validator did not produce any blocks or was not scheduled within the range, they might be omitted from this map.
-
range:objectThis object explicitly defines the actual slot range for which the block production statistics were calculated. This is particularly important when the requestedfirstSlotorlastSlotare outside the node's available data or current epoch, as the actual range might be truncated.firstSlot:u64(integer) - The lowest slot (inclusive) covered by thebyIdentitystatistics.lastSlot:u64(integer) - The highest slot (inclusive) covered by thebyIdentitystatistics.
-
currentSlot:u64(integer) - The highest slot that the RPC node has processed and is aware of at the time the query was made, regardless of thecommitmentlevel or therangerequested for production data. This serves as a general indicator of the node's current progress through the blockchain. -
firstAvailableBlock:u64(integer) - The lowest slot for which the RPC node retains historical block data. Queries forfirstSlotvalues earlier than this will be clamped tofirstAvailableBlock, as the node cannot provide data for slots before this point.
-
Usage Examples
TypeScript (Fetch)
1const response = await fetch("http://[IP_ADDRESS]:[PORT]", {
2 method: "POST",
3 headers: {
4 "Content-Type": "application/json",
5 },
6 body: JSON.stringify({
7 jsonrpc: "2.0",
8 id: 1,
9 method: "getBlockProduction",
10 params: [] // Add relevant parameters here
11 }),
12});
13
14const data = await response.json();
15console.log(data);Python (Requests)
1import requests
2import json
3
4url = "http://[IP_ADDRESS]:[PORT]"
5payload = json.dumps({
6 "jsonrpc": "2.0",
7 "id": 1,
8 "method": "getBlockProduction",
9 "params": [] # Add relevant parameters here
10})
11headers = {
12 'Content-Type': 'application/json'
13}
14
15response = requests.request("POST", url, headers=headers, data=payload)
16print(response.text)Rust (reqwest)
1use reqwest::Client;
2use serde_json::json;
3
4#[tokio::main]
5async fn main() -> Result<(), Box<dyn std::error::Error>> {
6 let client = Client::new();
7 let res = client.post("http://[IP_ADDRESS]:[PORT]")
8 .json(&json!({
9 "jsonrpc": "2.0",
10 "id": 1,
11 "method": "getBlockProduction",
12 "params": [] // Add relevant parameters here
13 }))
14 .send()
15 .await?
16 .text()
17 .await?;
18
19 println!("{}", res);
20 Ok(())
21}