<h2>Bitcoin DAA</h2>
<p>Bitcoin's original difficulty adjustment algorithm (DAA) uses a very simple method:</p>
<p>If <code>(height + 1) % 2016 != 0</code> then the next block's target will have the exact same target.<br />
Else, the next block's target will be adjusted by a <a href="https://github.com/bitcoin/bitcoin/blob/master/src/pow.cpp#L77" rel="nofollow noreferrer">factor of <code>time_difference / expected_time_difference</code></a> of the 2016-block period, where <code>time_difference</code> is established simply by subtracting the beginning and ending timestamps, and <a href="https://github.com/bitcoin/bitcoin/blob/master/src/pow.cpp#L54" rel="nofollow noreferrer">max. adjustment is limited to -75% or +300% (a factor of 4)</a>.</p>
<h2>Bitcoin Cash DAAs</h2>
<p>Since then, Bitcoin Cash fork happened and it went through 3 DAAs:</p>
<ul>
<li>Emergency DAA (2017), initial fork DAA, which was gameable by miners to accelerate block production and had to be changed soon after,</li>
<li>CW-144 DAA (2017-2020), which managed to maintain block time average but had a problem of difficulty oscillations due to miners just following their immediate incentives and switch-mining BCH/BTC with some of their hash-rate.</li>
<li>ASERT DAA (2020-now), which is stable and has performed well since 2020.</li>
</ul>
<p>We will below discuss them all in more detail.</p>
<p>The <a href="https://documentation.cash/protocol/forks/bch-uahf.html" rel="nofollow noreferrer">Bitcoin Cash fork</a> started with the Emergency DAA (EDAA), which was <a href="https://documentation.cash/protocol/blockchain/proof-of-work/difficulty-adjustment-algorithm.html#emergency-daa" rel="nofollow noreferrer">a simple modification</a> to the original DAA:</p>
<blockquote>
<p>In case the MTP of the tip of the chain is 12h or more after the MTP 6 block before the tip, the proof of work target is increased by a quarter, or 25%, which corresponds to a difficulty reduction of 20%.</p>
</blockquote>
<p>done to enable a <a href="https://www.reddit.com/r/btc/comments/bvj08f/an_incomplete_history_of_the_bitcoin_cashs_origin/" rel="nofollow noreferrer">minimum viable fork</a>. However, it performed horribly because miners could game it to speed up block production rate, which they did, and consequence was faster blocks on average, which resulted in BCH blockchain height getting ahead of BTC for about 2k blocks during the 6 months period of that DAA being active.</p>
<p>To fix this, the (now former) <a href="https://github.com/Bitcoin-ABC" rel="nofollow noreferrer">Bitcoin ABC team</a> implemented CW-144 DAA and activated it in <a href="https://documentation.cash/protocol/forks/hf-20171113.html" rel="nofollow noreferrer">November 2017 network upgrade</a>, and it was successfully maintaining average block time, but it had a problem of oscillations from miners switching some hash-rate back and forth between BTC and BCH to maximize their profitability. The problem was present because it was based on a simple moving average (SMA) where samples that &quot;fall out&quot; of the sampling window have as much impact as samples that get added, as discussed in <a href="https://read.cash/@jtoomim/bch-upgrade-proposal-use-asert-as-the-new-daa-1d875696" rel="nofollow noreferrer">this write-up</a>:</p>
<blockquote>
<p>In brief, the oscillation is due to cw-144 using a simple moving average (SMA) over the last 144 blocks to estimate hashrate. When e.g. a high-hashrate block leaves the SMA window, it reduces the difficulty by the same magnitude as a new block entering the window would increase it. Blocks leaving the window therefore sharply change the difficulty in a direction that incentivizes miners to repeat the hashrate of the departing block. I call this effect &quot;hashrate echoes.&quot; Notably, these echoes do not require any malicious miner behavior to occur. They are merely the result of miners following the direct short-term incentives that the DAA gives them.</p>
</blockquote>
<p><a href="https://i.sstatic.net/MMDrbxpB.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/MMDrbxpB.png" alt="cw-144 oscillations" /></a></p>
<p>Finally, as a result of further research, <a href="http://toom.im/files/da-asert.pdf" rel="nofollow noreferrer">&quot;absolutely
scheduled exponentially rising targets&quot; (ASERT) DAA</a> was developed.
Led by <a href="https://bitcoincashnode.org/en/team" rel="nofollow noreferrer">BCHN team</a>, BCH activated it in <a href="https://documentation.cash/protocol/forks/hf-20201115.html" rel="nofollow noreferrer">November 2020 network upgrade</a>.</p>
<p>The ASERT DAA has performed well ever since and is the currently active BCH DAA. It belongs to exponentially-weighted moving average (EWMA) family, which independent DAA researcher known as <a href="https://github.com/zawy12" rel="nofollow noreferrer">zawy12</a> regards as <a href="https://github.com/zawy12/difficulty-algorithms/issues/76" rel="nofollow noreferrer">&quot;the only difficulty algorithm people should use&quot;</a>:</p>
<blockquote>
<p>WTEMA is an &quot;infinite impulse response filters of 1st order&quot;. It's ideal in many situations. It very closely approximates relative ASERT by replacing e^x with 1+x which is very accurate for small x. Absolute ASERT is slightly better than relative ASERT because it prevents error caused by e^x function being imperfectly estimated and nBits imprecision. The error is linearly worse with larger N.</p>
</blockquote>
<p>Note: WTEMA stands for <strong>w</strong>eighted <strong>t</strong>arget <strong>e</strong>xponentially <strong>m</strong>oving <strong>a</strong>verage.</p>
<p>Later, an academic paper:</p>
<ul>
<li><a href="https://papers.ssrn.com/sol3/papers.cfm?abstract_id=3974376" rel="nofollow noreferrer">Kawaguchi, K., Komiyama, J., Noda, S., &quot;Miners' Reward Elasticity and Stability of Competing Proof-of-Work Cryptocurrencies&quot; (August 27, 2022)</a></li>
</ul>
<p>further confirmed that the design is solid, and in fact beneficial to BTC as well since BCH can serve as a shock absorber for BTC:</p>
<blockquote>
<p>Our results indicate that Bitcoin's stability heavily relies on external factors such as historical low hash-supply elasticity and interactions with other cryptocurrencies. Interestingly, despite their smaller size, Bitcoin's forks and their efficient difficulty adjustments significantly contribute to Bitcoin's stability. These findings imply that an algorithm upgrade to stabilize Bitcoin is highly recommended.</p>
</blockquote>
<p>We can observe properties of all 4 DAAs by plotting historical blockchain data:</p>
<p><a href="https://i.sstatic.net/2fwPasVM.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/2fwPasVM.png" alt="BCH historical block times" /></a></p>
<p>It is easy to spot the Emergency DAA anomaly.
Also, we can observe the oscillation effect of CW-144 in anomalous daily medians.</p>
<p>BCH now attracts only about 0.5% of available sha256d hash-rate, and increased variance is a consequence of that, and it is noticeable in the above plot.</p>
<p>I is interesting to examine the impact of BTC and BCH halvings on BCH block time:</p>
<p><a href="https://i.sstatic.net/JpdJrlx2.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/JpdJrlx2.png" alt="Impact of BCH and BTC halvings on BCH block times" /></a></p>
<p>where we can observe impact of sharp change in profitability causing miners to move some hash-rate from one chain to the other.</p>
<h2><a href="https://web.archive.org/web/20221115084207/https://dgbwiki.com/index.php?title=DigiShield" rel="nofollow noreferrer">DigiShield DAA</a></h2>
<p>We can again refer to zawy12's research, where he states <a href="https://github.com/zawy12/difficulty-algorithms/issues/7" rel="nofollow noreferrer">the following</a> about DigiShield v3:</p>
<blockquote>
<p>This discusses the start-up and MTP delay problems in Digishield (e.g. Zcash). It works good, but it has two problems that arguably make it not a lot better than an SMA with N=75. &quot;Better&quot; means that for a given level of stability during constant hashrate, it responds faster to sudden increases in hashrate. With MTP and 16%/32% removed, and safe timestamp handling in place, it easily beats SMAs. With N=17 and a tempering factor of 4x in the normal Digishield, an SMA with N=17x4=68 has the same stabilit but slower response.</p>
</blockquote>

CC BY-SA 4.0
2024-10-08T11:30:02.720Z
2024-10-08T15:26:47.090Z
2024-10-08T15:26:47.090Z
bca-0353f40e
<p>Just because someone has made something and given it a name doesn't mean that it isn't utter garbage.  Don't trust any review or analysis from anyone that can't give you clear and well reasoned list of criteria that it is necessary and sufficient for a difficulty update algorithm to achieve.</p>

<p>Some of the fad options that altcoins blindly copy don't even achieve the basic property of achieving the target block interval when hashrate is constant.</p>

<p>Instead they seem to obsess about falling back to the nominal rate when hashrate suddenly spikes, ignoring that slow blocks are a safe failure mode and completely failing to consider the security side effects of their decision. We've seen at least a few hyped difficulty update changes lead to actual attacks, not just theoretical weaknesses.</p>

<p>I have no doubt that its possible to make something that is pareto-superior to bitcoin's non-overlapping rectangular window, but I am equally sure that essentially all the other things you see hyped fail to do so. This is unsurprising because instead of starting with a meta-analysis to understand what properties are useful, they all seem to have been created by changing things and analyzing only one or two properties (or not even analyzing things at all).</p>

<p>Keep in mind the primary purpose of most technical changes in most altcoins is to create marketing bulletpoints that can be used to convince unsophisticated speculators to pay for the altcoin.  This marketing requires a lot of hype-- far in-excess of whatever hyper a theoretical 'perfect' difficulty update would deserve-- but not a lot of substance.</p>

CC BY-SA 4.0
2019-01-14T17:51:22.883Z
2019-01-14T17:51:22.883Z
G. Maxwell
<p>They used <a href="https://github.com/kyuupichan/difficulty/blob/master/mining.py" rel="nofollow noreferrer">this simulator</a> decide on a DAA for Bitcoin Cash. Although DigiShield is not a part of the DAA collection of it, a review of it can be found <a href="https://github.com/kyuupichan/difficulty/pull/30#issuecomment-356369553" rel="nofollow noreferrer">here</a> and <a href="https://github.com/kyuupichan/difficulty/pull/30#issuecomment-356673496" rel="nofollow noreferrer">here</a>.</p>

CC BY-SA 4.0
2018-12-15T14:51:54.667Z
Thank you very much for your answer. But what you think is better DAA or Digishield ?
laizess
CC BY-SA 4.0
2018-12-15T13:16:11.077Z
2018-12-15T13:16:11.077Z
MCCCS
<p>Thinking about different difficulty adjustments for protecting new coins against attacks from big miners. 2017 when BCH forked from BTC, BCH added the EDAA (emergency difficulty adjustment algorithm) and later updated to another DAA (difficulty adjustment algorithm). Another approach of protecting the blockchain is DigiShield, the difficulty adjustment algorithm that is used by Dogecoin.
What is the difference between DigiShield and the DAA of BCH?
How do they differ from Bitcoin's original DAA?</p>

<bitcoin-cash><difficulty>
Difficulty Adjustment Algorithms Comparison
laizess
# Difficulty Adjustment Algorithms Comparison

(Asked by: username_0 on 2018-12-15)

Thinking about different difficulty adjustments for protecting new coins against attacks from big miners. 2017 when BCH forked from BTC, BCH added the EDAA (emergency difficulty adjustment algorithm) and later updated to another DAA (difficulty adjustment algorithm). Another approach of protecting the blockchain is DigiShield, the difficulty adjustment algorithm that is used by Dogecoin.
What is the difference between DigiShield and the DAA of BCH?
How do they differ from Bitcoin's original DAA?

**Tags:** bitcoin-cash, difficulty


---

## 3 answers

### Answer by username_1 on 2024-10-08. Score: 2

## Bitcoin DAA

Bitcoin's original difficulty adjustment algorithm (DAA) uses a very simple method:

If `(height + 1) % 2016 != 0` then the next block's target will have the exact same target.  
Else, the next block's target will be adjusted by a [factor of `time_difference / expected_time_difference`](https://github.com/bitcoin/bitcoin/blob/master/src/pow.cpp#L77) of the 2016-block period, where `time_difference` is established simply by subtracting the beginning and ending timestamps, and [max. adjustment is limited to -75% or +300% (a factor of 4)](https://github.com/bitcoin/bitcoin/blob/master/src/pow.cpp#L54).

## Bitcoin Cash DAAs

Since then, Bitcoin Cash fork happened and it went through 3 DAAs:

* Emergency DAA (2017), initial fork DAA, which was gameable by miners to accelerate block production and had to be changed soon after,
* CW-144 DAA (2017-2020), which managed to maintain block time average but had a problem of difficulty oscillations due to miners just following their immediate incentives and switch-mining BCH/BTC with some of their hash-rate.
* ASERT DAA (2020-now), which is stable and has performed well since 2020.

We will below discuss them all in more detail.

The [Bitcoin Cash fork](https://documentation.cash/protocol/forks/bch-uahf.html) started with the Emergency DAA (EDAA), which was [a simple modification](https://documentation.cash/protocol/blockchain/proof-of-work/difficulty-adjustment-algorithm.html#emergency-daa) to the original DAA:

> In case the MTP of the tip of the chain is 12h or more after the MTP 6 block before the tip, the proof of work target is increased by a quarter, or 25%, which corresponds to a difficulty reduction of 20%.

done to enable a [minimum viable fork](https://www.reddit.com/r/btc/comments/bvj08f/an_incomplete_history_of_the_bitcoin_cashs_origin/). However, it performed horribly because miners could game it to speed up block production rate, which they did, and consequence was faster blocks on average, which resulted in BCH blockchain height getting ahead of BTC for about 2k blocks during the 6 months period of that DAA being active.

To fix this, the (now former) [Bitcoin ABC team](https://github.com/Bitcoin-ABC) implemented CW-144 DAA and activated it in [November 2017 network upgrade](https://documentation.cash/protocol/forks/hf-20171113.html), and it was successfully maintaining average block time, but it had a problem of oscillations from miners switching some hash-rate back and forth between BTC and BCH to maximize their profitability. The problem was present because it was based on a simple moving average (SMA) where samples that "fall out" of the sampling window have as much impact as samples that get added, as discussed in [this write-up](https://read.cash/@jtoomim/bch-upgrade-proposal-use-asert-as-the-new-daa-1d875696):

> In brief, the oscillation is due to cw-144 using a simple moving average (SMA) over the last 144 blocks to estimate hashrate. When e.g. a high-hashrate block leaves the SMA window, it reduces the difficulty by the same magnitude as a new block entering the window would increase it. Blocks leaving the window therefore sharply change the difficulty in a direction that incentivizes miners to repeat the hashrate of the departing block. I call this effect "hashrate echoes." Notably, these echoes do not require any malicious miner behavior to occur. They are merely the result of miners following the direct short-term incentives that the DAA gives them.

[![cw-144 oscillations](https://i.sstatic.net/MMDrbxpB.png)](https://i.sstatic.net/MMDrbxpB.png)

Finally, as a result of further research, ["absolutely
scheduled exponentially rising targets" (ASERT) DAA](http://toom.im/files/da-asert.pdf) was developed.
Led by [BCHN team](https://bitcoincashnode.org/en/team), BCH activated it in [November 2020 network upgrade](https://documentation.cash/protocol/forks/hf-20201115.html).

The ASERT DAA has performed well ever since and is the currently active BCH DAA. It belongs to exponentially-weighted moving average (EWMA) family, which independent DAA researcher known as [zawy12](https://github.com/zawy12) regards as ["the only difficulty algorithm people should use"](https://github.com/zawy12/difficulty-algorithms/issues/76):

> WTEMA is an "infinite impulse response filters of 1st order". It's ideal in many situations. It very closely approximates relative ASERT by replacing e^x with 1+x which is very accurate for small x. Absolute ASERT is slightly better than relative ASERT because it prevents error caused by e^x function being imperfectly estimated and nBits imprecision. The error is linearly worse with larger N.

Note: WTEMA stands for **w**eighted **t**arget **e**xponentially **m**oving **a**verage.

Later, an academic paper:

* [Kawaguchi, K., Komiyama, J., Noda, S., "Miners' Reward Elasticity and Stability of Competing Proof-of-Work Cryptocurrencies" (August 27, 2022)](https://papers.ssrn.com/sol3/papers.cfm?abstract_id=3974376)

further confirmed that the design is solid, and in fact beneficial to BTC as well since BCH can serve as a shock absorber for BTC:

> Our results indicate that Bitcoin's stability heavily relies on external factors such as historical low hash-supply elasticity and interactions with other cryptocurrencies. Interestingly, despite their smaller size, Bitcoin's forks and their efficient difficulty adjustments significantly contribute to Bitcoin's stability. These findings imply that an algorithm upgrade to stabilize Bitcoin is highly recommended.

We can observe properties of all 4 DAAs by plotting historical blockchain data:

[![BCH historical block times](https://i.sstatic.net/2fwPasVM.png)](https://i.sstatic.net/2fwPasVM.png)

It is easy to spot the Emergency DAA anomaly.
Also, we can observe the oscillation effect of CW-144 in anomalous daily medians.

BCH now attracts only about 0.5% of available sha256d hash-rate, and increased variance is a consequence of that, and it is noticeable in the above plot.

I is interesting to examine the impact of BTC and BCH halvings on BCH block time:

[![Impact of BCH and BTC halvings on BCH block times](https://i.sstatic.net/JpdJrlx2.png)](https://i.sstatic.net/JpdJrlx2.png)

where we can observe impact of sharp change in profitability causing miners to move some hash-rate from one chain to the other.

## [DigiShield DAA](https://web.archive.org/web/20221115084207/https://dgbwiki.com/index.php?title=DigiShield)

We can again refer to zawy12's research, where he states [the following](https://github.com/zawy12/difficulty-algorithms/issues/7) about DigiShield v3:

> This discusses the start-up and MTP delay problems in Digishield (e.g. Zcash). It works good, but it has two problems that arguably make it not a lot better than an SMA with N=75. "Better" means that for a given level of stability during constant hashrate, it responds faster to sudden increases in hashrate. With MTP and 16%/32% removed, and safe timestamp handling in place, it easily beats SMAs. With N=17 and a tempering factor of 4x in the normal Digishield, an SMA with N=17x4=68 has the same stabilit but slower response.


---

### Answer by username_2 on 2019-01-14. Score: 1

Just because someone has made something and given it a name doesn't mean that it isn't utter garbage. Don't trust any review or analysis from anyone that can't give you clear and well reasoned list of criteria that it is necessary and sufficient for a difficulty update algorithm to achieve.

Some of the fad options that altcoins blindly copy don't even achieve the basic property of achieving the target block interval when hashrate is constant.

Instead they seem to obsess about falling back to the nominal rate when hashrate suddenly spikes, ignoring that slow blocks are a safe failure mode and completely failing to consider the security side effects of their decision. We've seen at least a few hyped difficulty update changes lead to actual attacks, not just theoretical weaknesses.

I have no doubt that its possible to make something that is pareto-superior to bitcoin's non-overlapping rectangular window, but I am equally sure that essentially all the other things you see hyped fail to do so. This is unsurprising because instead of starting with a meta-analysis to understand what properties are useful, they all seem to have been created by changing things and analyzing only one or two properties (or not even analyzing things at all).

Keep in mind the primary purpose of most technical changes in most altcoins is to create marketing bulletpoints that can be used to convince unsophisticated speculators to pay for the altcoin. This marketing requires a lot of hype-- far in-excess of whatever hyper a theoretical 'perfect' difficulty update would deserve-- but not a lot of substance.


---

### Answer by username_3 on 2018-12-15. Score: -1

They used [this simulator](https://github.com/kyuupichan/difficulty/blob/master/mining.py) decide on a DAA for Bitcoin Cash. Although DigiShield is not a part of the DAA collection of it, a review of it can be found [here](https://github.com/kyuupichan/difficulty/pull/30#issuecomment-356369553) and [here](https://github.com/kyuupichan/difficulty/pull/30#issuecomment-356673496).

> **Comments:**
> **username_0**: Thank you very much for your answer. But what you think is better DAA or Digishield ?  

---

