From 806076c48c9834fd9941b940a32310d737975a3a Mon Sep 17 00:00:00 2001 From: Daira Hopwood Date: Tue, 10 Nov 2020 15:32:59 +0000 Subject: [PATCH] ZIP 205 and 208: ensure that specification of minimum difficulty blocks matches zcashd. Fixes https://github.com/ZcashFoundation/zebra/issues/1276 . Signed-off-by: Daira Hopwood --- zip-0205.html | 2 +- zip-0205.rst | 2 +- zip-0208.html | 2 +- zip-0208.rst | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/zip-0205.html b/zip-0205.html index c4b0ab269..771e6878b 100644 --- a/zip-0205.html +++ b/zip-0205.html @@ -60,7 +60,7 @@

Change to difficulty adjustment on testnet

Section 7.6.3 of 2 describes the algorithm used to adjust the difficulty of a block (defined in terms of a "target threshold") based on the nTime and nBits fields of preceding blocks.

-

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 2 section 5.3). However, its nBits field is still computed according to the original difficulty adjustment algorithm.

+

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 2 section 5.3). However, its nBits field is still computed according to the original difficulty adjustment algorithm.

This does not affect how the minimum-difficulty block is treated for subsequent difficulty adjustments. In particular, only the nBits field computed by the original algorithm is used for the purpose of computing the MeanTarget values from which subsequent difficulty changes are calculated.

This change does not affect mainnet.

diff --git a/zip-0205.rst b/zip-0205.rst index b4210ef32..de191b3e3 100644 --- a/zip-0205.rst +++ b/zip-0205.rst @@ -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. diff --git a/zip-0208.html b/zip-0208.html index 547e84d11..67fcde89e 100644 --- a/zip-0208.html +++ b/zip-0208.html @@ -110,7 +110,7 @@

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.

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.

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 8, when the block time exceeds a given threshold. This specification changes this threshold to be proportional to the block target spacing.

+

On the test network from block height 299188 onward, the difficulty adjustment algorithm allows minimum-difficulty blocks, as described in 8, when 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, 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 4).

As before, the nBits 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.

diff --git a/zip-0208.rst b/zip-0208.rst index 7d1623ab1..c5669351b 100644 --- a/zip-0208.rst +++ b/zip-0208.rst @@ -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,