The getBlockProduction RPC method provides information about block production in the current epoch or a specified slot range. It can be used to retrieve data for all validators or for a specific validator identity. This is valuable for monitoring validator performance and understanding block production patterns on the network.

Common Use Cases

  • Monitoring Validator Performance: Track the number of blocks produced and leader slots for a specific validator.
  • Analyzing Epoch Performance: Get an overview of block production across all validators in the current or a past epoch.
  • Identifying Missed Slots: See if validators are missing their assigned leader slots.
  • Network Health Checks: Gather data on overall block production efficiency.

Request Parameters

The getBlockProduction method accepts an optional configuration object with the following parameters:

  1. commitment (string, optional): Specifies the commitment level to use for the query. If omitted, the default commitment of the node is used.
  2. range (object, optional): Defines a slot range to query.
    • firstSlot (u64): The first slot to fetch block production information for (inclusive).
    • lastSlot (u64, optional): The last slot to fetch block production information for (inclusive). If omitted, the current epoch’s block production up to the current slot will be returned.
  3. identity (string, optional): A base58-encoded public key of a validator identity. If provided, the response will only include block production information for this specific validator. If omitted, information for all validators in the specified range (or current epoch) is returned.

Note: At least one of identity or range.firstSlot must be provided. If identity is not provided, the range parameter is required.

Response Structure

The result field of the JSON-RPC response will be an object containing:

  • context (object):
    • slot (u64): The slot at which the information was retrieved.
  • value (object):
    • byIdentity (object): An object where keys are validator identity strings (base58-encoded public keys), and values are objects containing:
      • leaderSlots (u64): The number of leader slots assigned to this validator in the queried range/epoch.
      • blocksProduced (u64): The number of blocks produced by this validator in the queried range/epoch.
    • range (object):
      • firstSlot (u64): The first slot of the queried range.
      • lastSlot (u64): The last slot of the queried range.

Developer Tips

  • Understand Epoch Boundaries: When querying by identity without a range, the data returned is for the current epoch up to the latest processed slot by the node. If you need data for a full past epoch for a specific validator, you’ll need to determine the firstSlot and lastSlot for that epoch.
  • Node Data Availability: The range of historical block production data can vary between RPC nodes. Very old slot ranges might not be available on all nodes.
  • Performance Monitoring: getBlockProduction is key for building dashboards or alerts related to validator uptime and block production success rates.
  • Combining with getLeaderSchedule: For deeper analysis, you can correlate getBlockProduction data with the output of getLeaderSchedule to see which specific leader slots were made or missed.
  • Identity vs. All Validators: Querying without an identity can return a large amount of data, especially if no range or a wide range is specified. Be mindful of response sizes and processing requirements.

Examples

1. Get Block Production for the Current Epoch (All Validators)

This example fetches block production data for all validators in the current epoch.

curl https://mainnet.helius-rpc.com/?api-key=<api-key> -X POST -H "Content-Type: application/json" -d \\
  '{
    "jsonrpc": "2.0",
    "id": 1,
    "method": "getBlockProduction"
  }'

2. Get Block Production for a Specific Validator in the Current Epoch

This example fetches block production for a specific validator identity in the current epoch.

# Replace YOUR_VALIDATOR_IDENTITY_PUBKEY with the actual validator's base58 public key.
curl https://mainnet.helius-rpc.com/?api-key=<api-key> -X POST -H "Content-Type: application/json" -d \\
  '{
    "jsonrpc": "2.0",
    "id": 1,
    "method": "getBlockProduction",
    "params": [
      {
        "identity": "YOUR_VALIDATOR_IDENTITY_PUBKEY"
      }
    ]
  }'

3. Get Block Production for a Specific Slot Range and Validator

This example fetches block production data for a specific validator within a defined slot range.

# Replace YOUR_VALIDATOR_IDENTITY_PUBKEY, START_SLOT, and END_SLOT.
curl https://mainnet.helius-rpc.com/?api-key=<api-key> -X POST -H "Content-Type: application/json" -d \\
  '{
    "jsonrpc": "2.0",
    "id": 1,
    "method": "getBlockProduction",
    "params": [
      {
        "identity": "YOUR_VALIDATOR_IDENTITY_PUBKEY",
        "range": {
          "firstSlot": START_SLOT, # e.g., 200000000
          "lastSlot": END_SLOT    # e.g., 200010000
        }
      }
    ]
  }'

This guide should give you a solid understanding of how to use the getBlockProduction RPC method to analyze block production on Solana.