Chain Work

Total proof-of-work accumulated in a chain, used to decide which version is authoritative. More work wins, not more blocks.

Basically

Chain work is the total computing work behind a blockchain. Bitcoin uses it to choose the chain with the most work.

Key Takeaways

  • Chain work is the total computing effort behind a blockchain. It adds the difficulty of every block from the genesis block to the current tip.
  • Bitcoin uses the most-work chain rule, not the longest chain rule. Nodes follow the chain with the highest total chain work, even if it has fewer blocks.
  • Chain work measures network security. Higher cumulative work means an attacker needs more energy to rewrite the chain's history.

What Is Chain Work?

Chain work, also written as "chainwork", is the total expected number of hash operations needed to reproduce a blockchain from the genesis block to the current chain tip. Each block adds a measurable amount of work based on its difficulty, and chain work is the running total.

Bitcoin Core tracks chain work as a 256-bit integer instead of simply counting blocks. This total grows with every new block and forms the basis of Bitcoin's Nakamoto consensus: when forks compete, nodes select the chain with the most total work, not the most blocks.

How It Works

Each Bitcoin block has a difficulty target encoded in its header. A valid block must have a hash below this target. A lower target makes a qualifying hash harder to find, so the block represents more work.

The Formula

A single block contributes work according to a formula. The formula gives the expected number of hash operations for that block.

The formula gives the expected number of hash attempts a miner needs to produce a hash below the target. The probability of any single hash being valid is (target + 1) / 2^256, so the expected number of attempts is the inverse. A lower target means fewer valid hashes and more attempts on average, and the cumulative chain work at any block N is the sum of all individual block work values from genesis.

Bitcoin Core cannot fit 2^256 in a 256-bit integer. The GetBlockProof() function in src/chain.cpp uses an equivalent expression instead.

The expression uses ~bnTarget, the bitwise NOT of the target. For a 256-bit unsigned integer, this equals 2^256 - target - 1, making the result mathematically identical to the original formula.

Most-Work vs. Longest-Chain

The original Bitcoin whitepaper used "longest chain" to describe the valid chain, and early Bitcoin code used block count as the deciding metric. Bitcoin changed this early in its history because attackers can manipulate block count: they could produce many low-difficulty blocks faster than honest miners produce high-difficulty blocks. Under a simple block-count rule, the attacker's easy blocks could look "longer" despite representing far less computing effort.

Bitcoin now uses the most-work chain rule, sometimes called the "heaviest chain" rule. Full nodes compare cumulative chain work rather than block height when they encounter competing forks. The fork with the most total proof of work wins, so the selected chain reflects the greatest real-world energy expenditure.

Chain Work in Bitcoin Core

Bitcoin Core stores chain work in the nChainWork field of the CBlockIndex class, defined in src/chain.h. This 256-bit unsigned integer, arith_uint256, holds the total expected hashes for the chain ending at that block. Bitcoin Core computes the field during block validation and keeps it in memory rather than serialising it to disk: when it loads its block index from LevelDB, it recomputes nChainWork for every block.

You can query chain work through the getblockchaininfo or getblockheader RPCs. Bitcoin Core displays it as a zero-padded, 64-character hexadecimal string.

Initial Block Download

Chain work has a key role during initial block download (IBD). Bitcoin Core defines nMinimumChainWork, a hard-coded chain work threshold that a node's chain must exceed before the node considers itself fully synced. This stops an attacker from feeding a new node a fabricated chain with less cumulative work than the real Bitcoin blockchain.

Gregory Maxwell introduced nMinimumChainWork in PR #9053. It replaced the older checkpoint-based approach for IBD detection and, unlike checkpoints, requires no trust in specific block hashes: it verifies that the chain represents enough aggregate computation. Bitcoin Core updates the value with each release.

The companion assume valid feature works alongside minimum chain work. If a block belongs to a chain meeting the minimum work threshold and is an ancestor of the assume-valid block, Bitcoin Core skips script validation during sync, which significantly speeds up IBD. For more on this mechanism, see Bitcoin Core assume valid fast sync.

Chain Reorganizations

Nodes resolve chain reorganisations, or reorgs, by comparing chain work. A node triggers a reorg when it discovers a competing branch with higher cumulative work than its current tip.

The probability of a reorg falls exponentially with each confirmation. This is why six confirmations is the common threshold for considering a transaction final. For a deeper look at how Bitcoin handles reorganisations, see Bitcoin reorg protection mechanisms.

Why It Matters

Chain work is the fundamental measure of a proof-of-work blockchain's security. Higher cumulative work means an attacker must expend more energy to produce a competing chain. In December 2025, Bitcoin's chain work surpassed the 2^96 milestone, approximately 7.92 × 10^28 expected hash operations, and reproducing that computation from scratch would require extraordinary resources.

This makes a 51% attack against Bitcoin economically impractical. With network hashrate exceeding 900 exahashes per second, sustaining a majority for even a short period would cost billions of dollars in hardware and electricity. Smaller proof-of-work networks with less chain work have suffered successful majority attacks, showing that cumulative work is the primary determinant of practical security. For current figures on the economics of mining, see Bitcoin mining economics.

Layer-2 protocols built on Bitcoin use chain work as their security anchor. Solutions like the Lightning Network and Spark inherit Bitcoin's security guarantees because cumulative work across the entire chain protects their on-chain settlements. More accumulated chain work means stronger finality guarantees for every transaction settled on Bitcoin's base layer.

Chain Work Is Not Block Count

Chain work is not the same as block height, despite a common misconception equating them. Two chains can have the same number of blocks but vastly different chain work if their difficulty levels differ. A chain of 1,000 high-difficulty blocks represents far more security than a chain of 10,000 low-difficulty blocks, so developers should always reference chain work rather than block count when evaluating chain security.

Difficulty Adjustment Lag

Bitcoin adjusts its difficulty target every 2,016 blocks, approximately two weeks. If hashrate drops significantly between adjustments, new blocks temporarily contribute less chain work per unit of wall-clock time. The difficulty adjustment mechanism eventually corrects this, but the lag creates brief windows where chain work growth slows relative to block production.

Minimum Chain Work Staleness

Bitcoin Core updates nMinimumChainWork only with software releases. Between releases, the threshold falls progressively further behind the actual chain work. This does not create a security vulnerability because the threshold is a floor, not a ceiling, but a very stale value offers weaker protection against fake chains during IBD. Running up-to-date node software mitigates this concern.

Quantum Computing

Chain work measures the difficulty of finding valid hashes under current cryptographic assumptions. Quantum computers capable of running Grover's algorithm at scale could theoretically produce hashes faster than classical hardware, potentially reducing the effective security represented by accumulated chain work. This remains a long-term theoretical concern: for practical implications, see the research on post-quantum cryptography and Bitcoin.

The glossary entry is for informational purposes only and does not constitute financial or investment advice. Always do your own research before using any protocol or technology.

0

← All 1876 glossary terms