services
Get a key

library / Blockchain ideas / Dashboards and explorers / BI0128

Block compute usage gauge

The answer to how big a Solana block can get is a compute unit cap, and a gauge can show how close each block comes. You get the spec for summing units per block, plus a runnable main.ts that prints it.

By Carbium · Dashboards and explorers · BI0128 · updated 2026-11-23

01

What fills a block

People who ask for the maximum size of a block usually expect a byte count. What fills a block in practice is compute units, the meter a program spends while it runs. A block closes for new work when the sum of the units its transactions use reaches the protocol's block cap, so that sum is the number a gauge should chart.

Four limits sit at different levels, and a gauge reads best when it labels each one correctly.

LevelLimit
Instruction200,000 units of default budget each, when the transaction sets no limit of its own
Transaction1,400,000 units at most
Blocka protocol cap on the sum over all its transactions
One writable accountits own share of the block, set by the cost model

The block cap is a protocol parameter, and it has been raised more than once. The script takes it as its first argument and defaults to 100,000,000. Confirm the figure for the cluster you read before you put a label on a gauge, and keep it as one constant so a later change is a one-line edit.

$Compute units are the limit that counts for a block's capacity. The scheduler also charges for signatures, write locks and instruction data, so a block can close a little under the compute cap you chart.
02

Reading used units from getBlock

Ask getBlock for a slot with transactionDetails: "full". Each transaction in the answer carries a meta object, and meta.computeUnitsConsumed holds the units it used. Add them up for the block total, divide by the cap, and you have the fill percentage. Along the way the same loop gives you the transaction count, how many failed, and the single heaviest transaction.

Mainnet carries v1 transactions, so the call needs maxSupportedTransactionVersion: 1. Leave it out, or send 0, and a block holding one answers -32015 with no charge. The script passes 1 inline, which the kit types accept without a cast. Setting rewards: false keeps the reward list out of the answer, since a gauge has no use for it.

Find the slot to read with getSlot. It sits in the cheap cached read class at 1 cell a call, which is 5 req/s on Free, 30 on Dev, 100 on Business and 500 on Pro. The script reads both at confirmed and sets it in each call.

The head block can still be arriving when you ask, and some slots hold no block at all. The script starts two slots back from the head and steps further back past any slot that answers null or fails.

03

What one reading means

Since the Alpenglow switch on mainnet (2026-10-21) a slot lasts about 200 ms, so a block is a fifth of a second of work, and five of them pass every second. A single block's fill percentage swings widely from one block to the next, because the leader packs whatever is waiting when its slot opens. One reading says little. A handful of consecutive blocks says much more.

Show three numbers per window: the latest block's fill, the mean over the window and the maximum. The mean tells you how busy the chain is, and the maximum tells you whether any block touched the cap. A mean of 30% with a maximum near 100% points to bursts. A mean of 30% with a maximum of 45% points to steady load.

Blocks on mainnet carry no vote transactions since the switch, so the units you sum belong to user and program transactions. A series you stored from before 2026-10-21 has vote units inside it, and a chart that spans the switch needs a marker on that date. The same split sits behind the Non-vote TPS meter, which counts transactions where this gauge counts compute.

04

Turning readings into a gauge

A gauge needs a stored series and a few display rules. Key every reading by slot, so two overlapping polls never draw one block twice and a missed poll shows as a gap you can fill.

  • Draw fill as a share of the cap, with bands you pick, for example green under 50%, amber to 80% and red above.
  • Plot the mean and the maximum of the last 25 blocks as two lines, since that window covers about five seconds.
  • Print the heaviest transaction's units beside each block, so a reader sees whether one program filled it.
  • Mark failed transactions separately. They still spend units and still take room in the block.
  • Link a block that hit a high fill to a view of its busiest writable accounts.

A program author reads the same gauge from the other side. If your transaction fails to land during a busy stretch, the gauge shows whether blocks were full or whether the cause lies elsewhere. Compute budget audit covers the per-transaction side, where the figure you set for your own limit decides what the scheduler reserves.

05

The build

The script needs @solana/kit and what Node 24 ships. It never signs or sends.

  1. Read the cap from the first argument, 100,000,000 by default, and the block count from the second, 3 by default and at most 5.
  2. Build one RPC client with the key in the x-api-key header and keep it for the run.
  3. Read the head slot at confirmed, then step back from it one slot at a time.
  4. For each slot that has a block, sum computeUnitsConsumed, count failed transactions and keep the heaviest one.
  5. Print a bar per block, then the mean and maximum fill. A slot that fails prints its error and the loop moves on.
main.ts
// BI0128 · Block compute usage gauge// https://carbium.sh/library/blockchainideas/block-compute-usage-gauge// Copyright (c) Carbium Corporation. MIT License (LICENSE). Keep this notice.// SPDX-License-Identifier: MITimport { createDefaultRpcTransport, createSolanaRpcFromTransport } from "@solana/kit";const key = process.env.CARBIUM_KEY;if (!key) {  console.error("Set CARBIUM_KEY to your Carbium API key.");  process.exit(1);}const rpc = createSolanaRpcFromTransport(  createDefaultRpcTransport({    url: process.env.CARBIUM_RPC_URL ?? "https://services.carbium.sh",    headers: { "x-api-key": key },  }),);// The block compute cap is a protocol setting that has changed over time.// Pass the figure your cluster enforces; this default is only a starting point.const LIMIT = Number(process.argv[2]) || 100_000_000;const COUNT = Math.min(Math.max(Number(process.argv[3]) || 3, 1), 5);const why = (e: unknown) => (e instanceof Error ? e.message : String(e));const bar = (pct: number) => "#".repeat(Math.round(Math.min(pct, 100) / 2.5)).padEnd(40, ".");let head;try {  head = await rpc.getSlot({ commitment: "confirmed" }).send();} catch (e) {  console.error(`getSlot failed: ${why(e)}`);  process.exit(1);}const fills: number[] = [];for (let back = 2n; fills.length < COUNT && back < 20n; back++) {  const slot = (head - back) as typeof head;  try {    const block = await rpc      .getBlock(slot, {        commitment: "confirmed",        encoding: "json",        transactionDetails: "full",        rewards: false,        maxSupportedTransactionVersion: 1,      })      .send();    if (!block) {      console.log(`slot ${slot} has no block`);      continue;    }    let used = 0;    let heaviest = 0;    let failed = 0;    for (const tx of block.transactions) {      const units = Number(tx.meta?.computeUnitsConsumed ?? 0);      used += units;      heaviest = Math.max(heaviest, units);      if (tx.meta?.err) failed++;    }    const pct = (used / LIMIT) * 100;    fills.push(pct);    console.log(      `slot ${slot} [${bar(pct)}] ${pct.toFixed(1)}% | ${used} units | ${block.transactions.length} txs, ${failed} failed | heaviest ${heaviest}`,    );  } catch (e) {    console.error(`getBlock ${slot} failed: ${why(e)}`);  }}if (fills.length > 0) {  const mean = fills.reduce((a, b) => a + b, 0) / fills.length;  console.log(    `window of ${fills.length}: mean ${mean.toFixed(1)}% | max ${Math.max(...fills).toFixed(1)}% of a ${LIMIT} unit cap`,  );}

run: CARBIUM_KEY=<YOUR_KEY> node main.ts 100000000 3

06

Where it ends

  • The cap is an input you supply. The script cannot read it from the chain, and a wrong value gives a confident but wrong percentage.
  • The sum covers units consumed. Signature, write-lock and data costs also count toward a block's closing, so the true fill can sit slightly above what the gauge shows.
  • Three blocks span about 600 ms. A dashboard that wants a stable picture polls on a schedule and keeps a rolling window.
  • A full block read is a large answer. Read a few blocks at a time and keep the sums, never the transaction bodies.
  • The head block may still be arriving, and a skipped slot has no block. The loop steps back past both, so the slots printed can skip numbers.
  • A series from before the Alpenglow switch has vote units inside it. Mark the switch date on any chart that crosses it.
07

When it goes wrong

what goes wrongwhat to do
getBlock answers -32015.The block holds a v1 transaction and the call left out maxSupportedTransactionVersion. Pass 1 in the config object. The failed call is uncharged.
Every block shows 0% fill.The transactions came back without meta, or the call asked for signatures only. Ask for transactionDetails: "full" so each transaction carries computeUnitsConsumed.
Fill reads above 100%.The cap you passed is lower than the cluster's current cap. Pass the figure the cluster enforces as the first argument.
No block prints and every slot reports an error.The slots tried had no block yet or were skipped. Run again a few seconds later, or widen the step back from the head.
A call answers 429.Wait for the retry-after hint and lower the poll rate. Limits belong to the account, so other tools on the same keys draw on the same budget.
08

Questions

Is the maximum block size measured in bytes?

The limit that decides how much work fits in a block is a compute unit cap on the sum over its transactions. Bytes matter for single transactions and network packets, and a block's capacity is read in compute units.

Why is the cap an argument?

It is a protocol setting that has been raised more than once, and getBlock does not return it. Keep it in one constant and update it when the cluster changes it.

Which commitment does the gauge read at?

Both getSlot and getBlock run at confirmed, set in each call. A confirmed block can still be dropped in rare cases, so a gauge that must never show a dropped fork reads at finalized.

Why do vote transactions not show up in the sums?

Since the Alpenglow switch on 2026-10-21, mainnet blocks carry no vote transactions. Blocks from before that date include them, and their units add to the total.