From 9ac5984f547c88e310d194f50b2768582ac7b97d Mon Sep 17 00:00:00 2001 From: Daira Hopwood Date: Tue, 17 Mar 2020 18:43:15 +0000 Subject: [PATCH] ZIP 207: reference fix and HTML. Signed-off-by: Daira Hopwood --- zip-0207.html | 72 ++++++++++++++++++++++++++++++++------------------- zip-0207.rst | 2 +- 2 files changed, 47 insertions(+), 27 deletions(-) diff --git a/zip-0207.html b/zip-0207.html index 68091bab..077dd7a2 100644 --- a/zip-0207.html +++ b/zip-0207.html @@ -3,6 +3,7 @@ ZIP 207: Funding Streams +
@@ -37,43 +38,61 @@ License: MIT

This ZIP 207 was originally proposed for the Blossom network upgrade, as a means of splitting the original Founders' Reward into several streams. It was then withdrawn when such splitting was judged to be unnecessary at the consensus level. Since the capabilities of the funding stream mechanism match the requirements for the Zcash Development Fund, the ZIP is being reintroduced for that purpose in order to reuse specification, analysis, and implementation effort.

Requirements

-

The primary requirement of this ZIP is to provide a mechanism for specifying the funding streams that are used in ZIP 214 [#zip-0214] to implement the Zcash Development Fund. It should be sufficiently expressive to handle both the main three "slices" (ECC, ZF, and MG) defined in ZIP 1014 13, and also (with additional funding stream definitions) the "direct grant option" described in that ZIP.

+

The primary requirement of this ZIP is to provide a mechanism for specifying the funding streams that are used in ZIP 214 11 to implement the Zcash Development Fund. It should be sufficiently expressive to handle both the main three "slices" (ECC, ZF, and MG) defined in ZIP 1014 13, and also (with additional funding stream definitions) the "direct grant option" described in that ZIP.

As for the original Founders' Reward, addresses for a given funding stream are changed on a roughly-monthly basis, so that keys that are not yet needed may be kept off-line as a security measure.

Specification

Definitions

-

We use the following constants and functions defined in 4, 5, and 6:

+

We use the following constants and functions defined in 4, 5, and 6:

    -
  • BlossomActivationHeight
  • -
  • PostBlossomHalvingInterval
  • -
  • Halving(height)
  • -
  • BlockSubsidy(height)
  • -
  • RedeemScriptHash(height).
  • +
  • + \(\mathsf{BlossomActivationHeight}\) +
  • +
  • + \(\mathsf{PostBlossomHalvingInterval}\) +
  • +
  • + \(\mathsf{Halving}(\mathsf{height})\) +
  • +
  • + \(\mathsf{BlockSubsidy}(\mathsf{height})\) +
  • +
  • + \(\mathsf{RedeemScriptHash}(\mathsf{height})\) + .

We also define the following function:

    -
  • HeightForHalving(halving): Smallest height such that Halving(height) = halving
  • +
  • + \(\mathsf{HeightForHalving}(\mathsf{halving})\) + : Smallest + \(\mathsf{height}\) + such that + \(\mathsf{Halving}(\mathsf{height}) = \mathsf{halving}\) +

Funding streams

A funding stream is defined by a block subsidy fraction (represented as a numerator and a denominator), a start height (inclusive), and an end height (exclusive).

-

By defining the issuance as a proportion of the total block subsidy, rather than absolute zatoshis, this ZIP dovetails with any changes to both block target spacing and issuance-per-block rates, while maintaining an unchanged target-time-based issuance schedule. Such a target-time / issuance rate change occurred at the Blossom network upgrade, for example. 9

+

By defining the issuance as a proportion of the total block subsidy, rather than absolute zatoshis, this ZIP dovetails with any changes to both block target spacing and issuance-per-block rates. Such a change occurred at the Blossom network upgrade, for example. 9

The value of a funding stream at a given block height is defined as:

-
FundingStream[FUND].Value(height) =
-    floor((
-        BlockSubsidy(height) * FundingStream[FUND].ValueNumerator
-    ) / FundingStream[FUND].ValueDenominator)
+
\(\mathsf{FundingStream[FUND].Value}(\mathsf{height}) = + \mathsf{floor}\left( + \frac{\mathsf{BlockSubsidy}(\mathsf{height}) \,\cdot\, \mathsf{FundingStream[FUND].ValueNumerator}}{\mathsf{FundingStream[FUND].ValueDenominator}} + \right)\)

An active funding stream at a given block height is defined as a funding stream for which the block height is less than its end height, but not less than its start height.

Each funding stream has an associated sequence of recipient addresses, each of which MUST be either a transparent P2SH address or a Sapling address.

Each address is used for at most 1/48th of a halving interval, creating a roughly-monthly sequence of funding periods. The address to be used for a given block height is defined as follows:

-
AddressChangeInterval = PostBlossomHalvingInterval / 48
-AddressPeriod(height) =
-    floor((
-        height + PostBlossomHalvingInterval - HeightForHalving(1)
-    ) / AddressChangeInterval)
-FundingStream[FUND].AddressIndex(height) =
-    AddressPeriod(height) - AddressPeriod(FundingStream[FUND].StartHeight)
-Address(height) = FundingStream[FUND].Addresses[FundingStream[FUND].AddressIndex(height)]
+
\(\begin{eqnarray*} + \mathsf{AddressChangeInterval} &=& \mathsf{PostBlossomHalvingInterval} / 48 \\ + \mathsf{AddressPeriod}(\mathsf{height}) &=& + \mathsf{floor}\left( + {\small\frac{\mathsf{height} + \mathsf{PostBlossomHalvingInterval} - \mathsf{HeightForHalving}(1)}{\mathsf{AddressChangeInterval}}} + \right) \\ + \mathsf{FundingStream[FUND].AddressIndex}(\mathsf{height}) &=& + \mathsf{AddressPeriod}(\mathsf{height}) - \\&&\hspace{2em} \mathsf{AddressPeriod}(\mathsf{FundingStream[FUND].StartHeight}) \\ + \mathsf{Address}(\mathsf{height}) &=& \mathsf{FundingStream[FUND].Addresses[} \\&&\hspace{2em} \mathsf{FundingStream[FUND].AddressIndex}(\mathsf{height})\mathsf{]} +\end{eqnarray*}\)

This has the property that all active funding streams change the address they are using on the same block height schedule, aligned to the height of the first halving so that 48 funding periods fit cleanly within a halving interval. This can be leveraged to simplify implementations, by batching the necessary outputs for each funding period.

Below is a visual representation of how stream addresses align with funding periods:

@@ -177,15 +196,15 @@ Address(height) = FundingStream[FUND].Addresses[FundingStream[FUND].AddressIndex

On Mainnet, ${NU4} is planned to activate exactly at the point when the Founders' Reward expires, at block height 1046400. On Testnet, there will be a shortened Founders' Reward address period prior to ${NU4} activation.

Consensus rules

-

Prior to activation of the ${NU4} network upgrade, the existing consensus rule for payment of the original Founders' Reward is enforced. 6

+

Prior to activation of the ${NU4} network upgrade, the existing consensus rule for payment of the original Founders' Reward is enforced. 6

Once the ${NU4} network upgrade activates:

    -
  • The existing consensus rule 6 is no longer active. (This would be the case under the preexisting consensus rules for Mainnet, but not for Testnet.)
  • +
  • The existing consensus rule for payment of the Founders' Reward 6 is no longer active. (This would be the case under the preexisting consensus rules for Mainnet, but not for Testnet.)
  • The coinbase transaction in each block MUST contain at least one output per active funding stream that pays the stream's value in the prescribed way to the stream's recipient address for the block's height.
  • The "prescribed way" to pay a transparent P2SH address is to use a standard P2SH script of the form OP_HASH160 RedeemScriptHash(height) OP_EQUAL as the scriptPubKey.
  • -
  • The "prescribed way" to pay a Sapling address is as defined in 10. That is, all Sapling outputs in coinbase transactions (including, but not limited to, outputs for funding streams) MUST have valid note commitments when recovered using a 32-byte array of zeroes as the outgoing viewing key.
  • +
  • The "prescribed way" to pay a Sapling address is as defined in 10. That is, all Sapling outputs in coinbase transactions (including, but not limited to, outputs for funding streams) MUST have valid note commitments when recovered using a 32-byte array of zeroes as the outgoing viewing key.
-

For the funding stream definitions to be activated at ${NU4}, see ZIP 214. 11 Funding stream definitions can be added, changed, or deleted in ZIPs associated with subsequent network upgrades, subject to the ZIP process. 7

+

For the funding stream definitions to be activated at ${NU4}, see ZIP 214. 11 Funding stream definitions can be added, changed, or deleted in ZIPs associated with subsequent network upgrades, subject to the ZIP process. 7

Example implementation

struct FundingPeriod {
@@ -218,6 +237,7 @@ Address(height) = FundingStream[FUND].Addresses[FundingStream[FUND].AddressIndex
     uint64_t valueDenominator)
 {
     assert(valueNumerator < valueDenominator);
+    assert(valueNumerator < INT64_MAX / MAX_MONEY);
     params.vFundingPeriods[idx].addresses = addresses;
     params.vFundingPeriods[idx].valueNumerator = valueNumerator;
     params.vFundingPeriods[idx].valueDenominator = valueDenominator;
@@ -338,7 +358,7 @@ Address(height) = FundingStream[FUND].Addresses[FundingStream[FUND].AddressIndex
             

Deployment

-

This proposal is intended to be deployed with ${NU4}. 12

+

This proposal is intended to be deployed with ${NU4}. 12

Backward compatibility

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.

diff --git a/zip-0207.rst b/zip-0207.rst index 25f1d7d3..36603514 100644 --- a/zip-0207.rst +++ b/zip-0207.rst @@ -63,7 +63,7 @@ Requirements ============ The primary requirement of this ZIP is to provide a mechanism for specifying -the funding streams that are used in ZIP 214 [#zip-0214] to implement the Zcash +the funding streams that are used in ZIP 214 [#zip-0214]_ to implement the Zcash Development Fund. It should be sufficiently expressive to handle both the main three "slices" (ECC, ZF, and MG) defined in ZIP 1014 [#zip-1014]_, and also (with additional funding stream definitions) the "direct grant option" described