2024-08-31 · Ryan X. Charles

I have updated the difficulty adjustment algorithm (DAA) to be based on exponential decay. I was unhappy with both previous algorithms because they didn’t adjust quickly enough based on the current timestamp. The new DAA adjusts very quickly, up to the current moment, and also operates on only the previous two blocks. It is in production and I’m very pleased with it so far. Here’s how it works.

Consider the two previous blocks. Find the time between them, $t'$, and the desired time $T$ (ten minutes). The difficulty of the previous block was $d$, and our goal is to find $D$, the new difficulty. First, set $D_1 = \frac{T}{t'} \cdot d$. This is the difficulty that would have been set if the time between the two blocks was exactly $T$.

Next, we wish to change the difficulty to have the following properties:

- Immediately after the previous block is mined, the new difficulty should be very high.
- At ten minutes ($T$), the new difficulty should be exactly $D_1$.
- Beyond ten minutes, the difficulty should decay until it reaches a minimum.
- Blocks with a future timestamp are invalid. This incentivizes accurate timestamps because blocks from the past have a higher difficulty, which no one wants to mine. The most rational strategy is to mine blocks with the correct timestamp.

These properties ensure the block interval stays very close to ten minutes.

We can use exponential decay to achieve these properties. Let $t$ be the time since the previous block. Let $m=10$ be the maximum increase in difficulty immediately after the previous block. Let $k = \ln(m)$ and $D_2 = D_1 \cdot e^{-k \cdot (\frac{t}{T}-1)}$. The new difficulty is $D = \max(D_2, d_{\text{min}})$, where $d_{\text{min}}$ is the minimum difficulty, currently set to $2000$.

This algorithm is currently running in production and I’ve been very pleased with it so far. It adjusts quickly and it keeps the block interval very close to ten minutes, so long as someone is mining. When no one mines (often the case in development), the difficulty drops to the minimum exponentially. That makes it fast to start mining again when you’re ready.

Pre-Launch Overview of EarthBucks and the Sprint to Launch

2024-08-24 · Ryan X. Charles

Introducing the PoW Validator: A New Service to Validate EarthBucks Proof-of-Work

2024-08-15 · Ryan X. Charles

The Simplest Difficulty Adjustment Algorithm

2024-07-30 · Ryan X. Charles

Why I Renamed the “Coinbase” Transaction to “Mint” and Moved it to the End of the Block

2024-07-25 · Ryan X. Charles

EarthBucks Block Header: Independently Adjustable CPU and GPU Mining and Other Parameters

2024-07-22 · Ryan X. Charles