This page is the Simplified Technical English version of ZIP 208. The source ZIP is the normative text. Read the writing rules to understand the marked words.
ZIP 208: Shorter Block Target Spacing
ZIP: 208 Title: Shorter Block Target Spacing Owners: Daira-Emma Hopwood <daira@jacaranda.org> Original-Authors: Simon Liu Status: Final Category: Consensus Created: 2019-01-10 License: MIT Pull-Request: <https://github.com/zcash/zips/pull/237>
Terminology
On this page, STE words are in the place of the BCP 14 key words of the source. Refer to the key word table.
In this document, these terms have the definitions in [zip-0200]:
- "block chain"
- "consensus rule change"
- "consensus branch"
- "network upgrade"
The "target block spacing" is the time interval between blocks that is the target of the difficulty adjustment algorithm in a given consensus branch. It is usually measured in seconds. (Sometimes this interval also has the name "target block time". But the term in the Zcash Protocol Specification [protocol-diffadjustment] is "block target spacing".)
In this document, the terms "Testnet" and "Mainnet" have the definitions in section 3.12 of the Zcash Protocol Specification [protocol-networks].
Abstract
This ZIP contains the specification of a change in the target block spacing. The change applies from the Blossom network upgrade [zip-0206].
In terms of time, the emission schedule of mined ZEC stays approximately the same. For this result, it is necessary to adjust the emission for each block for the new target block spacing.
Motivation
A decrease in the target block spacing has these motivations:
- Less latency before a transaction is sufficiently confirmed.
- A larger throughput of transactions in unit time.
A larger block size limit is a different method to increase the throughput. But with that method, the latency does not decrease.
The number of necessary confirmations for a given security requirement increases more slowly than the block time decreases. (The measure of the security requirement is the expected cost distribution of a rollback attack.) Thus, up to a point, the trade-off between latency and security can be better with a smaller target block spacing. The assumption of this argument is that the validation and propagation time for a block stay small compared to the target block spacing. Refer to [slowfastblocks] for more analysis in different attack models.
Specification
The changes in this section apply to the Zcash Protocol Specification [protocol]. They are changes from the pre-Blossom specification in [preblossom-protocol].
Consensus changes
In all of the specification, rename \(\mathsf{HalvingInterval}\) to \(\mathsf{PreBlossomHalvingInterval}\). Also rename \(\mathsf{PoWTargetSpacing}\) to \(\mathsf{PreBlossomTargetSpacing}\). These constants have the same values as in [preblossom-protocol]. The values are \(840000\) (blocks) and \(150\) (seconds) respectively.
In section 2 (Notation), add \(\mathsf{BlossomActivationHeight}\) and \(\mathsf{PostBlossomPoWTargetSpacing}\) to the list of integer constants.
In section 5.3 (Constants), define \(\mathsf{PostBlossomPoWTargetSpacing} := 75\) seconds.
For a given network (production or test), define \(\mathsf{BlossomActivationHeight}\) as the activation height of Blossom on that network. This height is specified in [zip-0206].
Section 7.6.3 (Difficulty adjustment) was later moved to section 7.7.3. In that section, make the changes that follow.
Define \(\mathsf{IsBlossomActivated}(\mathsf{height})\) to be true if \(\mathsf{height} \geq \mathsf{BlossomActivationHeight}\), and false if not.
An assumption of this specification is that \(\mathsf{BlossomActivationHeight} \geq \mathsf{SlowStartInterval}\).
Define:
- \(\mathsf{BlossomPoWTargetSpacingRatio} := \mathsf{PreBlossomPoWTargetSpacing} / \mathsf{PostBlossomPoWTargetSpacing}\)
- \(\mathsf{PostBlossomHalvingInterval} := \mathsf{floor}(\mathsf{PreBlossomHalvingInterval} \cdot \mathsf{BlossomPoWTargetSpacingRatio})\).
In the same section, change the definition of \(\mathsf{PoWTargetSpacing}\) to a function that has a \(\mathsf{height}\) parameter, as follows:
\[ \mathsf{PoWTargetSpacing}(\mathsf{height}) := \begin{cases} \mathsf{PreBlossomPoWTargetSpacing}, &\!\!\textsf{if not } \mathsf{IsBlossomActivated}(\mathsf{height}) \\ \mathsf{PostBlossomPoWTargetSpacing} &\!\!\textsf{otherwise} \end{cases} \]
Also change the definitions of these functions:
- \(\mathsf{AveragingWindowTimespan}\)
- \(\mathsf{MinActualTimespan}\)
- \(\mathsf{MaxActualTimespan}\)
- \(\mathsf{ActualTimespanDamped}\)
- \(\mathsf{ActualTimespanBounded}\)
- \(\mathsf{Threshold}\)
Change them as follows:
- Add a \(\mathsf{height}\) parameter to each of these functions that does not already have one.
- Replace each reference to one of these values, or to \(\mathsf{PoWTargetSpacing}\), with a function call that includes the \(\mathsf{height}\) parameter.
Section 7.7 (Calculation of Block Subsidy and Founders’ Reward) was later moved to section 7.8. In that section, change the definitions of the \(\mathsf{Halving}\) and \(\mathsf{BlockSubsidy}\) functions as follows:
\[ \mathsf{Halving}(\mathsf{height}) := \begin{cases} \mathsf{floor}((\mathsf{height} - \mathsf{SlowStartShift}) / \mathsf{PreBlossomHalvingInterval}), &\!\!\textsf{if not } \mathsf{IsBlossomActivated}(\mathsf{height}) \\ \mathsf{floor}((\mathsf{BlossomActivationHeight} - \mathsf{SlowStartShift}) / \mathsf{PreBlossomHalvingInterval} & \\ \hspace{1em}+\; (\mathsf{height} - \mathsf{BlossomActivationHeight}) / \mathsf{PostBlossomHalvingInterval}) &\!\!\textsf{otherwise} \end{cases} \]
\[ \mathsf{BlockSubsidy}(\mathsf{height}) := \begin{cases} \mathsf{SlowStartRate} \cdot \mathsf{height}, &\!\!\textsf{if } \mathsf{height} < \mathsf{SlowStartInterval} / 2 \\ \mathsf{SlowStartRate} \cdot (\mathsf{height} + 1), &\!\!\textsf{if } \mathsf{SlowStartInterval} / 2 \leq \mathsf{height} \textsf{ and } \mathsf{height} < \mathsf{SlowStartInterval} \\ \mathsf{floor}(\mathsf{MaxBlockSubsidy} / 2^{\mathsf{Halving}(\mathsf{height})}), &\!\!\textsf{if } \mathsf{SlowStartInterval} \leq \mathsf{height} \textsf{ and not } \mathsf{IsBlossomActivated}(\mathsf{height}) \\ \mathsf{floor}(\mathsf{MaxBlockSubsidy} / & \\ \hspace{1em}(\mathsf{BlossomPoWTargetSpacingRatio} \cdot 2^{\mathsf{Halving}(\mathsf{height})})) &\!\!\textsf{otherwise} \end{cases} \]
Note: The values of the three constants below are selected to give two properties:
- \(\mathsf{BlossomActivationHeight}\)
- \(\mathsf{PostBlossomHalvingInterval}\)
- \(\mathsf{PostBlossomTargetSpacing}\)
The two properties are:
- \((\mathsf{BlossomActivationHeight} - \mathsf{SlowStartShift}) / \mathsf{PreBlossomHalvingInterval}\hspace{-3em}\) \(\hspace{3em}+\; (\mathsf{height} - \mathsf{BlossomActivationHeight}) / \mathsf{PostBlossomHalvingInterval}\) is exactly \(1\) for some integer \(\mathsf{height}\).
- \(\mathsf{MaxBlockSubsidy} / (\mathsf{BlossomPoWTargetSpacingRatio} \cdot 2^{\mathsf{Halving}(\mathsf{height})})\) is an integer for the next few periods.
Section 7.8 (Payment of Founders’ Reward) was later moved to section 7.9. In that section, define:
\[ \mathsf{FounderAddressAdjustedHeight}(\mathsf{height}) := \begin{cases} \mathsf{height}, &\!\!\textsf{if not } \mathsf{IsBlossomActivated}(\mathsf{height}) \\ \mathsf{BlossomActivationHeight} + \mathsf{floor}((\mathsf{height} - \mathsf{BlossomActivationHeight}) / \\ \hspace{1em}\mathsf{BlossomPoWTargetSpacingRatio}) &\!\!\textsf{otherwise} \end{cases} \]
In the definition of \(\mathsf{FounderAddressIndex}\), replace the use of \(\mathsf{height}\) with \(\mathsf{FounderAddressAdjustedHeight}(\mathsf{height})\).
Also define:
- \(\mathsf{FoundersRewardLastBlockHeight} := \mathsf{max}(\{ \mathsf{height} \;{\small ⦂}\; \mathbb{N} | \mathsf{Halving}(\mathsf{height}) < 1 \})\)
Replace the first note in that section with the text below. The text applies to \(\mathsf{height} > \mathsf{FoundersRewardLastBlockHeight}\) and to \(\mathsf{height} = 0\):
- No Founders’ Reward is required to be paid for \(\mathsf{height} > \mathsf{FoundersRewardLastBlockHeight}\) (i.e. after the first halving), or for \(\mathsf{height} = 0\) (i.e. the genesis block).
Also, in the second note, replace \(\mathsf{SlowStartShift} + \mathsf{PreBlossomHalvingInterval} - 1\) with \(\mathsf{FoundersRewardLastBlockHeight}\).
Effect on difficulty adjustment
The difficulty adjustment parameters \(\mathsf{PoWAveragingWindow}\) and \(\mathsf{PoWMedianBlockSpan}\) are numbers of blocks. But they do not change at Blossom activation. The reason is the necessary quantity of damping/averaging, in terms of the number of blocks. This quantity is expected to be approximately the same after the change in target block spacing.
Because of the change in the effective value of \(\mathsf{PoWTargetSpacing}\), the block spacing adjusts to the new target. The adjustment occurs at the usual rate for a difficulty adjustment. The results of simulations agree with this expected behaviour.
The change in \(\mathsf{AveragingWindowTimespan}(\mathsf{height})\) applies immediately in the calculation of the target difficulty, from the block at the Blossom activation height. But the difficulty of the \(\mathsf{PoWAveragingWindow}\) blocks before that block was adjusted with the pre-Blossom target block spacing. Thus it is likely that the difficulty adjustment for the first few blocks after activation is limited by \(\mathsf{PoWMaxAdjustDown}\). This is not expected to cause a problem.
Minimum difficulty blocks on Testnet
On Testnet from block height 299188, the difficulty adjustment algorithm [protocol-diffadjustment] has a rule for minimum-difficulty blocks, as described in [zip-0205]. These blocks can occur when the block time is greater than a given threshold. With this specification, this threshold is proportional to the target block spacing.
That is, this rule applies to a block at height \(\mathsf{height} \geq 299188\). Such a block is a minimum-difficulty block if its block time is greater than \(6 \cdot \mathsf{PoWTargetSpacing}(\mathsf{height})\) seconds after the block time of the previous block. In that case, the nBits field of the block must be set to \(\mathsf{ToCompact}(\mathsf{PoWLimit})\). \(\mathsf{PoWLimit}\) is the value that is defined for Testnet in section 5.3 of the Zcash Protocol Specification [protocol-constants]. \(\mathsf{ToCompact}\) is as defined in section 7.7.4 of that specification [protocol-nbits].
Note: A previous revision of this ZIP (and [zip-0205]) contained an incorrect statement. The statement was that there is an effect only on the target threshold of minimum-difficulty blocks. In fact, the nBits field also changes, and this has an effect on difficulty adjustment for later blocks.
This change has no effect on Mainnet.
At the Testnet NU7 activation height, the minimum-difficulty threshold changes to 18 times the target block spacing, as specified in ZIP 218 [zip-0218]. Before NU7, the six-spacing threshold of this specification continues to apply.
Non-consensus node behaviour
End-of-Service halt
zcashd has an "End-of-Service halt" behaviour. For this behaviour, zcashd stops the node at a block height that is approximately equivalent to a given time after release. We recommend that this interval is adjusted in releases where the End-of-Service halt time is after Blossom activation.
Default expiry delta
For RPC calls that create transactions, zcashd uses a default value for the number of blocks until a transaction expires. This default applies when the -txexpirydelta option is not set. In recent versions of zcashd, the default is 20 blocks. At the pre-Blossom target block spacing, this is approximately 50 minutes.
We recommend that this default changes to BlossomPoWTargetSpacingRatio · 20 blocks after Blossom activation, to keep the approximate expiry time of 50 minutes.
If the -txexpirydelta option is set, we recommend that the set value is used both before and after Blossom activation.
Sprout to Sapling migration
ZIP 308 [zip-0308] contains a procedure to migrate funds from Sprout to Sapling z-addresses. In that procedure, migration transactions are sent every 500 blocks. Before Blossom, 500 blocks was approximately 20.83 hours.
The 500-block constant was not changed. Thus, after Blossom activation, migration transactions are now sent approximately every 10.42 hours. This was noted in ZIP 308. A table with the expected time to complete migration was also updated for this change.
Fingerprinting mitigation
A "fingerprinting attack" is a network analysis technique. With this technique, nodes are identified across network sessions. An example is the use of information about the blocks that the nodes request or send.
zcashd has a behaviour that it got from Bitcoin Core. This behaviour is intended as a fingerprinting mitigation. It is described in this comment in main.cpp:
// To prevent fingerprinting attacks, only send blocks outside of the active // chain if they are valid, and no more than a month older (both in time, and in // best equivalent proof of work) than the best header chain we know about.
We make no statement about the importance of fingerprinting for Zcash. The comment above has the word "prevent", but we also make no claim about the effectiveness of this mitigation.
In any case, we use this procedure to estimate the "best equivalent proof of work" of a given block chain, in units of time:
- Take the total work of the chain, as defined in section 7.7.5 of the Zcash Protocol Specification [protocol-workdef].
- Divide by the work of the block at the active tip.
- Multiply by the target block spacing of that block.
It is not a requirement of the Zcash protocol that nodes use this fingerprinting mitigation. If a node uses the mitigation, we recommend that it uses the target block spacing at the same block height as the current work estimate.
Monitoring for quicker- or slower-than-expected blocks
Before, zcashd did this monitoring every 150 seconds. Now zcashd does it every 60 seconds.
Block timeout
The timeout for a requested block is calculated as the target block spacing, multiplied by 2 + (the number of queued validated headers)/2.
Latency optimization when requesting blocks
When zcashd sees an announced block that chains from headers that it does not already have, it first asks for the headers. Then it asks for the block itself. zcashd does a latency optimization only if the chain is "nearly synced":
// First request the headers preceding the announced block. In the normal fully-synced // case where a new block is announced that succeeds the current tip (no reorganization), // there are no such headers. // Secondly, and only when we are close to being synced, we request the announced block directly, // to avoid an extra round-trip. Note that we must *first* ask for the headers, so by the // time the block arrives, the header chain leading up to it is already validated. Not // doing this will result in the received block being rejected as an orphan in case it is // not a direct successor.
The heuristic for "nearly synced" is this condition: the timestamp of the block at the active tip is a maximum of 20 block times before the current "adjusted time". For this calculation, zcashd uses the target block spacing as of the best known header. Near Blossom activation, the target block spacing changes. Thus the heuristic can be based on the pre-Blossom target block spacing until the node syncs headers past the activation block. But this is not expected to cause a problem.
Response to getblocks message when pruning
If pruning is on, zcashd includes only some blocks when it responds to a "getblocks" peer-to-peer message. It includes only blocks that it has on disk and is likely to still have on disk an hour after its response to the message:
// 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.
For each block, we estimate if the block is still on disk after an hour. For this estimate, we take MIN_BLOCKS_TO_KEEP = \(288\) blocks, minus approximately the number of blocks expected in one hour. This expected number is for the target block spacing as of that block. Near Blossom activation, this number can be less than the number of blocks in the next hour. But because of the value of MIN_BLOCKS_TO_KEEP, this is not expected to cause a problem.
Estimation of fully synced chain height
zcashd uses the EstimateNetHeight function to estimate the approximate height of the fully synced chain. With this estimate, zcashd can show the progress of block download to the node operator. This function was written again and made simpler. It was also changed to take account of cases where the time period to estimate includes Blossom activation.
Deployment
This ZIP is deployed with the Blossom network upgrade [zip-0206].
Backward compatibility
The change in this ZIP is intentionally a "bilateral consensus rule change". For this mechanism, it is necessary that all network participants upgrade their implementations to a compatible version in the upgrade window. Older implementations treat post-upgrade blocks as invalid. They follow any pre-upgrade consensus branch that continues.
Reference Implementation
Source errata
The source has these typos. This page has the repaired forms.
- Line 68:
[#preblossom-protocol]is a citation that has no underscore at its end. - Line 98:
$\mathsf{PoWTargetSpacing}has no dollar sign at its end. - Line 184:
\mathsf{AveragingWindowTimespan(\mathsf{height})has a brace in the incorrect position.
References
- [BCP14]
- Information on BCP 14 — "RFC 2119: Key words for use in RFCs to Indicate Requirement Levels" and "RFC 8174: Ambiguity of Uppercase vs Lowercase in RFC 2119 Key Words"
- [preblossom-protocol]
- Zcash Protocol Specification, Version 2018.0-beta-37 (exactly)
- [protocol]
- Zcash Protocol Specification, Version 2021.2.16 or later
- [protocol-networks]
- Zcash Protocol Specification, Version 2021.2.16. Section 3.12: Mainnet and Testnet
- [protocol-constants]
- Zcash Protocol Specification, Version 2021.2.16. Section 5.3: Constants
- [protocol-diffadjustment]
- Zcash Protocol Specification, Version 2021.2.16. Section 7.7.3: Difficulty adjustment
- [protocol-nbits]
- Zcash Protocol Specification, Version 2021.2.16. Section 7.7.4: nBits conversion
- [protocol-workdef]
- Zcash Protocol Specification, Version 2021.2.16. Section 7.7.5: Definition of Work
- [zip-0200]
- ZIP 200: Network Upgrade Mechanism
- [zip-0205]
- ZIP 205: Deployment of the Sapling Network Upgrade
- [zip-0206]
- ZIP 206: Deployment of the Blossom Network Upgrade
- [zip-0218]
- ZIP 218: 25-second Block Target Spacing
- [zip-0308]
- ZIP 308: Sprout to Sapling Migration
- [slowfastblocks]
- On Slow and Fast Block Times