BitcoinSC’s Difficulty Adjustment Algorithm: A Smooth Ride for Miners

BSC
3 min readApr 24, 2020

--

As most people know, the mining difficulty for Bitcoin adjusts every 2,016 blocks, about two weeks. “Difficulty” is how difficult it is using Proof of Work to mine a block, and for Bitcoin (and most forks) difficulty is adjusted every 2,016 blocks.

The brilliant algorithm designed by Satoshi allowed difficulty to adjust over 13 orders of magnitude (so far), for example:

For any decentralized network, using difficulty with a random SHA-256 hash result (e.g., hash < target) gives some variation in block spacing (the time between two block). While the average block spacing is 600 seconds, the standard deviation for Bitcoin block spacing is also in the range of 600 seconds, with some 95% of block spacing distribution taking place in less than approximately 1,725 seconds.

Blocks 500,000–600,000 Spacing Algorithm
Spacing from header timestamp

Since BitcoinSC will support smart contract operations, and since not much has changed in regards to block spacing 11 years on, the BitcoinSC devs took a fresh look at the difficulty adjustment approach for improvements. The resulting BitcoinSC algorithm adjusts difficulty for every new block like other more recent blockchains, using an exponential moving average.

The charts below show the difficulty adjustment for Bitcoin vs. BitcoinSC for a block spacing comparison. First, here is Bitcoin navigating a recent difficulty adjustment after a “historic” drop in hash rate (1):

Bitcoin — average block spacing
Estimated daily Hash Rate from blockchain.com, Difficulty from headers with 144 block average, Average Spacing from headers with 144 block average

This chart shows a recent difficulty adjustment for Bitcoin. The chart estimated hash rate and difficulty are scaled to show timing only, but the green dashed arrow shows an estimated hash rate drop of approximately 40%. The daily average spacing for blocks 621,600 to 623,000 floats up to almost 900 seconds for some days, because the hash rate dropped significantly and difficulty couldn’t catch up until block 622,944 on March 25th.

Then there are other times when the difficulty drops before the adjustment and rebounds precipitously after, causing the blocks to be mined in less than 10 minutes.

For grins and giggles we tried a similar sized hash rate change with the blockchain simulator (using the self-same block-by-block difficulty adjustment algorithm) set for a 50% step reduction in hash rate and got these results:

BitcoinSC — Simulated Average Block Spacing
Simulations: Hash Rate, Difficulty with 144 block average, Average Spacing with 144 block average

As with the above chart, the simulated hash rate and difficulty are scaled to show timing only, but the daily average block spacing (seconds) scale is identical to the Bitcoin chart above. It should be inherently obvious to the casual observer that the BitcoinSC difficulty adjustment gives a smoother adjustment to keep average block spacing ever so much closer to 600 seconds.

As compared to the Bitcoin difficulty adjustment algorithm, BitcoinSC makes these improvements:

⦁ Rapid response to hash rate changes for difficulty (no waiting up to 2 weeks)

⦁ No concerns over miners joining, leaving or using miner arbitrage (jumping between PoW chains depending on slowly-adjusting difficulty)

⦁ More accurate average confirmation spacing for transactions, albeit with the inherent variation from the SHA-256 random number generator.

May all your difficulty adjustments be smooth and prosperous; we hope Satoshi agrees.

--

--