Skip to content

Commit

Permalink
ZIP 205 and 208: ensure that specification of minimum difficulty bloc…
Browse files Browse the repository at this point in the history
…ks matches zcashd.

Fixes ZcashFoundation/zebra#1276 .

Signed-off-by: Daira Hopwood <daira@jacaranda.org>
  • Loading branch information
daira committed Nov 10, 2020
1 parent 8b311e9 commit 806076c
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion zip-0205.html
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
</section>
<section id="change-to-difficulty-adjustment-on-testnet"><h3><span class="section-heading">Change to difficulty adjustment on testnet</span><span class="section-anchor"> <a rel="bookmark" href="#change-to-difficulty-adjustment-on-testnet"><img width="24" height="24" src="assets/images/section-anchor.png" alt=""></a></span></h3>
<p>Section 7.6.3 of <a id="id9" class="footnote_reference" href="#protocol">2</a> describes the algorithm used to adjust the difficulty of a block (defined in terms of a "target threshold") based on the <code>nTime</code> and <code>nBits</code> fields of preceding blocks.</p>
<p>This algorithm changed on testnet, starting from block 299188, to allow "minimum-difficulty" blocks. If the block time of a block from this height onward is at least 15 minutes after that of the preceding block, then the block is a minimum-difficulty block, and its target threshold is set to the value of PoWLimit for testnet (see <a id="id10" class="footnote_reference" href="#protocol">2</a> section 5.3). However, its <code>nBits</code> field is still computed according to the original difficulty adjustment algorithm.</p>
<p>This algorithm changed on testnet, starting from block 299188, to allow "minimum-difficulty" blocks. If the block time of a block from this height onward is greater than 15 minutes after that of the preceding block, then the block is a minimum-difficulty block, and its target threshold is set to the value of PoWLimit for testnet (see <a id="id10" class="footnote_reference" href="#protocol">2</a> section 5.3). However, its <code>nBits</code> field is still computed according to the original difficulty adjustment algorithm.</p>
<p>This does not affect how the minimum-difficulty block is treated for subsequent difficulty adjustments. In particular, only the <code>nBits</code> field computed by the original algorithm is used for the purpose of computing the MeanTarget values from which subsequent difficulty changes are calculated.</p>
<p>This change does not affect mainnet.</p>
</section>
Expand Down
2 changes: 1 addition & 1 deletion zip-0205.rst
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ of a block (defined in terms of a "target threshold") based on the ``nTime`` and

This algorithm changed on testnet, starting from block 299188, to allow
"minimum-difficulty" blocks. If the block time of a block from this height onward
is at least 15 minutes after that of the preceding block, then the block is a
is greater than 15 minutes after that of the preceding block, then the block is a
minimum-difficulty block, and its target threshold is set to the value of
PoWLimit for testnet (see [#protocol]_ section 5.3). However, its ``nBits`` field
is still computed according to the original difficulty adjustment algorithm.
Expand Down
2 changes: 1 addition & 1 deletion zip-0208.html
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@
<p>The change in the effective value of PoWTargetSpacing will cause the block spacing to adjust to the new target, at the normal rate for a difficulty adjustment. The results of simulations are consistent with this expected behaviour.</p>
<p>Note that the change in AveragingWindowTimespan(height) takes effect immediately when calculating the target difficulty starting from the block at the Blossom activation height, even though the difficulty of the preceding PoWAveragingWindow blocks will have been adjusted using the pre-Blossom target spacing. Therefore it is likely that the difficulty adjustment for the first few blocks after activation will be limited by PoWMaxAdjustDown. This is not anticipated to cause any problem.</p>
<section id="minimum-difficulty-blocks-on-the-test-network"><h4><span class="section-heading">Minimum difficulty blocks on the test network</span><span class="section-anchor"> <a rel="bookmark" href="#minimum-difficulty-blocks-on-the-test-network"><img width="24" height="24" src="assets/images/section-anchor.png" alt=""></a></span></h4>
<p>On the test network from block height 299188 onward, the difficulty adjustment algorithm allows minimum-difficulty blocks, as described in <a id="id9" class="footnote_reference" href="#zip-0205">8</a>, when the block time exceeds a given threshold. This specification changes this threshold to be proportional to the block target spacing.</p>
<p>On the test network from block height 299188 onward, the difficulty adjustment algorithm allows minimum-difficulty blocks, as described in <a id="id9" class="footnote_reference" href="#zip-0205">8</a>, when the block time is greater than a given threshold. This specification changes this threshold to be proportional to the block target spacing.</p>
<p>That is, if the block time of a block at height <em>height</em> ≥ 299188 is at least 6 · PoWTargetSpacing(<em>height</em>) seconds after that of the preceding block, then the block is a minimum-difficulty block, and its target threshold is set to the value of PoWLimit for testnet (see section 5.3 of the Zcash Protocol Specification <a id="id10" class="footnote_reference" href="#protocol-constants">4</a>).</p>
<p>As before, the <code>nBits</code> field of a minimum-difficulty block is still computed according to the original difficulty adjustment algorithm, and only this field is used for the purpose of computing the MeanTarget values from which subsequent difficulty changes are calculated.</p>
</section>
Expand Down
4 changes: 2 additions & 2 deletions zip-0208.rst
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,8 @@ Minimum difficulty blocks on the test network

On the test network from block height 299188 onward, the difficulty adjustment
algorithm allows minimum-difficulty blocks, as described in [#zip-0205]_, when
the block time exceeds a given threshold. This specification changes this
threshold to be proportional to the block target spacing.
the block time is greater than a given threshold. This specification changes
this threshold to be proportional to the block target spacing.

That is, if the block time of a block at height *height* ≥ 299188 is at least
6 · PoWTargetSpacing(*height*) seconds after that of the preceding block,
Expand Down

0 comments on commit 806076c

Please sign in to comment.