<p>The key words "MUST" and "SHOULD" in this document are to be interpreted as described in RFC 2119. <aid="footnote-reference-1"class="footnote_reference"href="#rfc2119">1</a></p>
<p>The terms "block chain", "consensus rule change", "consensus branch", and "network upgrade" are to be interpreted as defined in <aid="footnote-reference-2"class="footnote_reference"href="#zip-0200">9</a>.</p>
<p>The term "block target spacing" means the time interval between blocks targeted by the difficulty adjustment algorithm in a given consensus branch. It is normally measured in seconds. (This is also sometimes called the "target block time", but "block target spacing" is the term used in the Zcash Protocol Specification <aid="footnote-reference-3"class="footnote_reference"href="#protocol-diffadjustment">6</a>.)</p>
<p>The terms "Testnet" and "Mainnet" are to be interpreted as described in section 3.12 of the Zcash Protocol Specification <aid="footnote-reference-4"class="footnote_reference"href="#protocol-networks">4</a>.</p>
<p>This proposal specifies a change in the block target spacing, to take effect in the Blossom network upgrade <aid="footnote-reference-5"class="footnote_reference"href="#zip-0206">11</a>.</p>
<p>The emission schedule of mined ZEC will be approximately the same in terms of time, but this requires the emission per block to be adjusted to take account of the changed block target spacing.</p>
<p>Note that, for a given security requirement (in terms of the expected cost distribution of a rollback attack), the number of confirmations needed increases more slowly than the decrease in block time, and so, up to a point, decreasing the block target spacing can provide a better trade-off between latency and security. This argument assumes that the validation and propagation time for a block remain small compared to the block target spacing. See <aid="footnote-reference-6"class="footnote_reference"href="#slowfastblocks">13</a> for further analysis in various attack models.</p>
<p>The changes described in this section are to be made in the Zcash Protocol Specification <aid="footnote-reference-7"class="footnote_reference"href="#protocol">3</a>, relative to the pre-Blossom specification in [#preblossom-protocol].</p>
<p>Throughout the specification, rename HalvingInterval to PreBlossomHalvingInterval, and rename PoWTargetSpacing to PreBlossomTargetSpacing. These constants retain their values from <aid="footnote-reference-8"class="footnote_reference"href="#preblossom-protocol">2</a> of 840000 (blocks) and 150 (seconds) respectively.</p>
<p>For a given network (production or test), define BlossomActivationHeight as the height at which Blossom activates on that network, as specified in <aid="footnote-reference-9"class="footnote_reference"href="#zip-0206">11</a>.</p>
<p>In the same section, redefine PoWTargetSpacing as a function taking a <em>height</em> parameter, as follows:</p>
<ul>
<li>PoWTargetSpacing(<em>height</em>) :=
<ul>
<li>PreBlossomPoWTargetSpacing, if not IsBlossomActivated(<em>height</em>)</li>
<li>PostBlossomPoWTargetSpacing, otherwise.</li>
</ul>
</li>
</ul>
<p>Also redefine AveragingWindowTimespan, MinActualTimespan, MaxActualTimespan, ActualTimespanDamped, ActualTimespanBounded, and Threshold as follows:</p>
<ul>
<li>add a <em>height</em> parameter to each of these functions that does not already have one;</li>
<li>ensure that each reference to any of these values, or to PoWTargetSpacing, are replaced with a function call passing the <em>height</em> parameter.</li>
<p>In section 7.7 (Calculation of Block Subsidy and Founders’ Reward) [later moved to section 7.8], redefine the Halving and BlockSubsidy functions as follows:</p>
<p>Replace the first note in that section with:</p>
<ul>
<li>No Founders’ Reward is required to be paid for <em>height</em>> FoundersRewardLastBlockHeight (i.e. after the first halving), or for <em>height</em> = 0 (i.e. the genesis block).</li>
</ul>
<p>and in the second note, replace SlowStartShift + PreBlossomHalvingInterval - 1 with FoundersRewardLastBlockHeight.</p>
<sectionid="effect-on-difficulty-adjustment"><h3><spanclass="section-heading">Effect on difficulty adjustment</span><spanclass="section-anchor"><arel="bookmark"href="#effect-on-difficulty-adjustment"><imgwidth="24"height="24"class="section-anchor"src="assets/images/section-anchor.png"alt=""></a></span></h3>
<p>The difficulty adjustment parameters PoWAveragingWindow and PoWMedianBlockSpan refer to numbers of blocks, but do <em>not</em> change at Blossom activation. This is because the amount of damping/averaging required is expected to be roughly the same, in terms of the number of blocks, after the change in block target spacing.</p>
<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>
<sectionid="minimum-difficulty-blocks-on-testnet"><h4><spanclass="section-heading">Minimum difficulty blocks on Testnet</span><spanclass="section-anchor"><arel="bookmark"href="#minimum-difficulty-blocks-on-testnet"><imgwidth="24"height="24"class="section-anchor"src="assets/images/section-anchor.png"alt=""></a></span></h4>
<p>On Testnet from block height 299188 onward, the difficulty adjustment algorithm <aid="footnote-reference-10"class="footnote_reference"href="#protocol-diffadjustment">6</a> allows minimum-difficulty blocks, as described in <aid="footnote-reference-11"class="footnote_reference"href="#zip-0205">10</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 greater than 6 · PoWTargetSpacing(<em>height</em>) seconds after that of the preceding block, then the block is a minimum-difficulty block. In that case its <code>nBits</code> field MUST be set to ToCompact(PoWLimit), where PoWLimit is the value defined for Testnet in section 5.3 of the Zcash Protocol Specification <aid="footnote-reference-12"class="footnote_reference"href="#protocol-constants">5</a>, and ToCompact is as defined in section 7.7.4 of that specification <aid="footnote-reference-13"class="footnote_reference"href="#protocol-nbits">7</a>.</p>
<p>Note: a previous revision of this ZIP (and <aid="footnote-reference-14"class="footnote_reference"href="#zip-0205">10</a>) incorrectly said that only the target threshold of minimum-difficulty blocks is affected. In fact the <code>nBits</code> field is modified as well, and this affects difficulty adjustment for subsequent blocks.</p>
<p><cite>zcashd</cite> implements an "End-of-Service halt" behaviour that halts the node at a block height that corresponds approximately to a given time after release. This interval SHOULD be adjusted in releases where the End-of-Service halt time will follow Blossom activation.</p>
<p>When not overridden by the <code>-txexpirydelta</code> option, <cite>zcashd</cite> RPC calls that create transactions use a default value for the number of blocks after which a transaction will expire. The default in recent versions of <cite>zcashd</cite> is 20 blocks, which at the pre-Blossom block target spacing corresponds to roughly 50 minutes.</p>
<p>This default SHOULD change to BlossomPoWTargetSpacingRatio · 20 blocks after Blossom activation, to maintain the approximate expiry time of 50 minutes.</p>
<sectionid="sprout-to-sapling-migration"><h4><spanclass="section-heading">Sprout to Sapling migration</span><spanclass="section-anchor"><arel="bookmark"href="#sprout-to-sapling-migration"><imgwidth="24"height="24"class="section-anchor"src="assets/images/section-anchor.png"alt=""></a></span></h4>
<p>ZIP 308 <aid="footnote-reference-15"class="footnote_reference"href="#zip-0308">12</a> defines a procedure for migrating funds from Sprout to Sapling z-addresses. In that procedure, migration transactions are sent every 500 blocks, which corresponded to roughly 20.83 hours before Blossom.</p>
<p>The 500-block constant has not been changed. Therefore, migration transactions are now sent roughly every 10.42 hours after Blossom activation. This has been noted in the ZIP, and a table showing the expected time to complete migration has been updated accordingly.</p>
<p>A "fingerprinting attack" is a network analysis technique in which nodes are identified across network sessions, for example using information about which blocks they request or send.</p>
<p><cite>zcashd</cite> inherits from Bitcoin Core the following behaviour, described in a comment in <code>main.cpp</code>, intended as a fingerprinting mitigation:</p>
// best equivalent proof of work) than the best header chain we know about.</pre>
<p>We make no assertion about the significance of fingerprinting for Zcash, and (despite the word "prevent" in the above comment) no claim about the effectiveness of this mitigation.</p>
<p>In any case, to estimate the "best equivalent proof of work" of a given block chain (measured in units of time), we take the total work of the chain as defined in section 7.7.5 of the Zcash Protocol Specification <aid="footnote-reference-16"class="footnote_reference"href="#protocol-workdef">8</a>, divide by the work of the block at the active tip, and multiply by the target block spacing of that block.</p>
<p>It is not a requirement of the Zcash protocol that this fingerprinting mitigation is used; however, if it is used, then it SHOULD use the target block spacing at the same block height that is used for the current work estimate.</p>
<sectionid="monitoring-for-quicker-or-slower-than-expected-blocks"><h4><spanclass="section-heading">Monitoring for quicker- or slower-than-expected blocks</span><spanclass="section-anchor"><arel="bookmark"href="#monitoring-for-quicker-or-slower-than-expected-blocks"><imgwidth="24"height="24"class="section-anchor"src="assets/images/section-anchor.png"alt=""></a></span></h4>
<sectionid="latency-optimization-when-requesting-blocks"><h4><spanclass="section-heading">Latency optimization when requesting blocks</span><spanclass="section-anchor"><arel="bookmark"href="#latency-optimization-when-requesting-blocks"><imgwidth="24"height="24"class="section-anchor"src="assets/images/section-anchor.png"alt=""></a></span></h4>
<p>When <cite>zcashd</cite> sees an announced block that chains from headers that it does not already have, it will first ask for the headers, and then the block itself. A latency optimization is performed only if the chain is "nearly synced":</p>
<p>The heuristic for "nearly synced" is that the timestamp of the block at the active tip is no more than 20 block times before the current "adjusted time". In <cite>zcashd</cite> this calculation uses the block target spacing as of the best known header. Around Blossom activation when the block target spacing changes, this could cause the heuristic to be based on the pre-Blossom block target spacing until the node has synced headers past the activation block, but this is not anticipated to cause any problem.</p>
<sectionid="response-to-getblocks-message-when-pruning"><h4><spanclass="section-heading">Response to getblocks message when pruning</span><spanclass="section-anchor"><arel="bookmark"href="#response-to-getblocks-message-when-pruning"><imgwidth="24"height="24"class="section-anchor"src="assets/images/section-anchor.png"alt=""></a></span></h4>
<p>If pruning is enabled, when <cite>zcashd</cite> responds to an "getblocks" peer-to-peer message, it will only include blocks that it has on disk, and is likely to still have on disk an hour after responding to the message:</p>
<pre>// If pruning, don't inv blocks unless we have on disk and are likely to still have
// for some reasonable time window (1 hour) that block relay might require.</pre>
<p>For each block, when estimating whether it will still be on disk after an hour, we take MIN_BLOCKS_TO_KEEP = 288 blocks, minus approximately the number of blocks expected in one hour at the target block spacing as of that block. Around Blossom activation, this might underestimate the number of blocks in the next hour, but given the value of MIN_BLOCKS_TO_KEEP, this is not anticipated to cause any problem.</p>
<p><cite>zcashd</cite> uses the <code>EstimateNetHeight</code> function to estimate the approximate height of the fully synced chain, so that the progress of block download can be displayed to the node operator. This function has been rewritten, simplified, and changed to take account of cases where the time period that needs to be estimated crosses Blossom activation.</p>
<p>This proposal intentionally creates what is known as a "bilateral consensus rule change". Use of this mechanism requires that all network participants upgrade their software to a compatible version within the upgrade window. Older software will treat post-upgrade blocks as invalid, and will follow any pre-upgrade consensus branch that persists.</p>