Document how block template construction interacts with the block sigop limit.

Co-authored-by: Teor <teor@zfnd.org>
Signed-off-by: Daira Hopwood <daira@jacaranda.org>
This commit is contained in:
Daira Hopwood 2022-11-10 00:50:52 +00:00 committed by Deirdre Connolly
parent 97c2e17f5b
commit f255fc5106
2 changed files with 24 additions and 13 deletions

View File

@ -31,7 +31,7 @@ Pull-Request: &lt;<a href="https://github.com/zcash/zips/pull/631">https://githu
<p>The goal of this ZIP is to change the conventional fees for transactions by making them dependent on the number of inputs and outputs in a transaction, and to get buy-in for this change from wallet developers, miners and Zcash users.</p>
</section>
<section id="motivation"><h2><span class="section-heading">Motivation</span><span class="section-anchor"> <a rel="bookmark" href="#motivation"><img width="24" height="24" class="section-anchor" src="assets/images/section-anchor.png" alt=""></a></span></h2>
<p>In light of recent Mainnet network activity, it is time to review and update the standard 1,000 zatoshi transaction fee set in ZIP 313 <a id="footnote-reference-3" class="footnote_reference" href="#zip-0313">5</a>.</p>
<p>In light of recent Mainnet network activity, it is time to review and update the standard 1,000 zatoshi transaction fee set in ZIP 313 <a id="footnote-reference-3" class="footnote_reference" href="#zip-0313">6</a>.</p>
<p>The conventional transaction fee presently is 0.00001 ZEC or 1,000 zatoshis, as specified in ZIP 313. This allowed exploration of novel use cases of the Zcash blockchain. The Zcash network has operated for almost 2 years at a conventional transaction fee of 1,000 zatoshis, without consideration for the total number of inputs and outputs in each transaction. Under this conventional fee, some usage of the chain has been characterized by high-output transactions with 1,100 outputs, paying the same conventional fee as a transaction with 2 outputs.</p>
<p>The objective of the new fee policy, once it is enforced, is for fees paid by transactions to fairly reflect the processing costs that their inputs and outputs impose on various participants in the network. This will tend to discourage usage patterns that cause either intentional or unintentional denial of service, while still allowing low fees for regular transaction use cases.</p>
</section>
@ -247,7 +247,7 @@ Pull-Request: &lt;<a href="https://github.com/zcash/zips/pull/631">https://githu
<p>P2SH outputs are smaller than P2PKH outputs, but P2SH inputs may be larger than P2PKH inputs. For example a 2-of-3 multisig input is around 70% larger, and is counted as such when computing the number of logical actions.</p>
</section>
<section id="marginal-fee"><h5><span class="section-heading">Marginal Fee</span><span class="section-anchor"> <a rel="bookmark" href="#marginal-fee"><img width="24" height="24" class="section-anchor" src="assets/images/section-anchor.png" alt=""></a></span></h5>
<p>This returns the conventional fee for a minimal transaction (as described above) to the original conventional fee of 10000 zatoshis specified in <a id="footnote-reference-5" class="footnote_reference" href="#zip-0313">5</a>, and imposes a non-trivial cost for potential denial-of-service attacks.</p>
<p>This returns the conventional fee for a minimal transaction (as described above) to the original conventional fee of 10000 zatoshis specified in <a id="footnote-reference-5" class="footnote_reference" href="#zip-0313">6</a>, and imposes a non-trivial cost for potential denial-of-service attacks.</p>
</section>
</section>
</section>
@ -255,7 +255,7 @@ Pull-Request: &lt;<a href="https://github.com/zcash/zips/pull/631">https://githu
<p>zcashd, zebrad, and potentially other node implementations, implement fee-based restrictions on relaying of mempool transactions. Nodes that normally relay transactions are expected to do so for transactions that pay at least the conventional fee as specified in this ZIP, unless there are other reasons not to do so for robustness or denial-of-service mitigation.</p>
</section>
<section id="mempool-size-limiting"><h3><span class="section-heading">Mempool size limiting</span><span class="section-anchor"> <a rel="bookmark" href="#mempool-size-limiting"><img width="24" height="24" class="section-anchor" src="assets/images/section-anchor.png" alt=""></a></span></h3>
<p>zcashd and zebrad limit the size of the mempool as described in <a id="footnote-reference-6" class="footnote_reference" href="#zip-0401">6</a>. This specifies a
<p>zcashd and zebrad limit the size of the mempool as described in <a id="footnote-reference-6" class="footnote_reference" href="#zip-0401">7</a>. This specifies a
<span class="math">\(low\_fee\_penalty\)</span>
that is added to the "eviction weight" if the transaction pays a fee less than the conventional transaction fee. This threshold is modified to use the new conventional fee formula.</p>
</section>
@ -277,7 +277,7 @@ Pull-Request: &lt;<a href="https://github.com/zcash/zips/pull/631">https://githu
in the mempool, calculate
<span class="math">\(tx.\!weight = \mathsf{min}\!\left(\frac{tx.fee}{conventional\_fee(tx)}, weight\_cap\right)\!\)</span>
.</li>
<li>Repeat while there is any mempool transaction that pays at least the conventional fee and fits in the block:
<li>Repeat while there is any mempool transaction that pays at least the conventional fee, is within the block sigop limit <a id="footnote-reference-7" class="footnote_reference" href="#sigop-limit">4</a>, and fits in the block:
<ol type="a">
<li>Pick one of those transactions at random with probability in direct proportion to its weight, and add it to the block.</li>
</ol>
@ -296,7 +296,7 @@ Pull-Request: &lt;<a href="https://github.com/zcash/zips/pull/631">https://githu
<ol type="a">
<li>Pick a transaction with probability in direct proportion to its weight and add it to the block. If that transaction would exceed the
<span class="math">\(size\_target\!\)</span>
, stop without adding it.</li>
or the block sigop limit <a id="footnote-reference-8" class="footnote_reference" href="#sigop-limit">4</a>, stop without adding it.</li>
</ol>
</li>
</ol>
@ -308,7 +308,7 @@ Pull-Request: &lt;<a href="https://github.com/zcash/zips/pull/631">https://githu
</section>
<section id="rationale-for-block-template-construction-algorithm"><h4><span class="section-heading">Rationale for block template construction algorithm</span><span class="section-anchor"> <a rel="bookmark" href="#rationale-for-block-template-construction-algorithm"><img width="24" height="24" class="section-anchor" src="assets/images/section-anchor.png" alt=""></a></span></h4>
<ul>
<li>Regardless of how full the mempool is (according to the ZIP 401 <a id="footnote-reference-7" class="footnote_reference" href="#zip-0401">6</a> cost limiting), a denial-of-service adversary can only fill a block if
<li>Regardless of how full the mempool is (according to the ZIP 401 <a id="footnote-reference-9" class="footnote_reference" href="#zip-0401">7</a> cost limiting), a denial-of-service adversary can only fill a block if
<span class="math">\(\frac{remaining\_weight}{N}\)</span>
is nearly
<span class="math">\(1\!\)</span>
@ -363,7 +363,7 @@ Pull-Request: &lt;<a href="https://github.com/zcash/zips/pull/631">https://githu
<p>Possible alternatives for the parameters:</p>
<ul>
<li>marginal_fee = 250 in @nuttycom's proposal.</li>
<li>marginal_fee = 1000 adapted from @madars' proposal <a id="footnote-reference-8" class="footnote_reference" href="#madars-1">4</a>.</li>
<li>marginal_fee = 1000 adapted from @madars' proposal <a id="footnote-reference-10" class="footnote_reference" href="#madars-1">5</a>.</li>
<li>marginal_fee = 2500 in @daira's proposal.</li>
<li>marginal_fee = 1000 for Shielded, Shielding and De-shielding transactions, and marginal_fee = 10000 for Transparent transactions adapted from @nighthawk24's proposal.</li>
</ul>
@ -384,7 +384,7 @@ Pull-Request: &lt;<a href="https://github.com/zcash/zips/pull/631">https://githu
<p>TODO: Endorsements may depend on specific parameter choices. The ZIP Editors should ensure that the endorsements are accurate before marking this ZIP as Active.</p>
</section>
<section id="acknowledgements"><h2><span class="section-heading">Acknowledgements</span><span class="section-anchor"> <a rel="bookmark" href="#acknowledgements"><img width="24" height="24" class="section-anchor" src="assets/images/section-anchor.png" alt=""></a></span></h2>
<p>Thanks to Madars Virza for initially proposing a fee mechanism similar to that proposed in this ZIP <a id="footnote-reference-9" class="footnote_reference" href="#madars-1">4</a>, and to Kris Nuttycombe, Jack Grigg, Daira Hopwood, Francisco Gindre, Greg Pfeil, and Teor for suggested improvements.</p>
<p>Thanks to Madars Virza for initially proposing a fee mechanism similar to that proposed in this ZIP <a id="footnote-reference-11" class="footnote_reference" href="#madars-1">5</a>, and to Kris Nuttycombe, Jack Grigg, Daira Hopwood, Francisco Gindre, Greg Pfeil, and Teor for suggested improvements.</p>
</section>
<section id="references"><h2><span class="section-heading">References</span><span class="section-anchor"> <a rel="bookmark" href="#references"><img width="24" height="24" class="section-anchor" src="assets/images/section-anchor.png" alt=""></a></span></h2>
<table id="rfc2119" class="footnote">
@ -411,10 +411,18 @@ Pull-Request: &lt;<a href="https://github.com/zcash/zips/pull/631">https://githu
</tr>
</tbody>
</table>
<table id="madars-1" class="footnote">
<table id="sigop-limit" class="footnote">
<tbody>
<tr>
<th>4</th>
<td><a href="https://github.com/zcash/zips/issues/568">zcash/zips issue #568 - Document block transparent sigops limit consensus rule</a></td>
</tr>
</tbody>
</table>
<table id="madars-1" class="footnote">
<tbody>
<tr>
<th>5</th>
<td><a href="https://forum.zcashcommunity.com/t/zip-reduce-default-shielded-transaction-fee-to-1000-zats/37566/89">Madars concrete soft-fork proposal</a></td>
</tr>
</tbody>
@ -422,7 +430,7 @@ Pull-Request: &lt;<a href="https://github.com/zcash/zips/pull/631">https://githu
<table id="zip-0313" class="footnote">
<tbody>
<tr>
<th>5</th>
<th>6</th>
<td><a href="zip-0313">ZIP 313: Reduce Conventional Transaction Fee to 1000 zatoshis</a></td>
</tr>
</tbody>
@ -430,7 +438,7 @@ Pull-Request: &lt;<a href="https://github.com/zcash/zips/pull/631">https://githu
<table id="zip-0401" class="footnote">
<tbody>
<tr>
<th>6</th>
<th>7</th>
<td><a href="zip-0401">ZIP 401: Addressing Mempool Denial-of-Service</a></td>
</tr>
</tbody>

View File

@ -281,7 +281,8 @@ from a set of transactions in a node's mempool:
:math:`tx.\!weight = \mathsf{min}\!\left(\frac{tx.fee}{conventional\_fee(tx)}, weight\_cap\right)\!`.
2. Repeat while there is any mempool transaction that pays at least the
conventional fee and fits in the block:
conventional fee, is within the block sigop limit [#sigop-limit]_, and
fits in the block:
a. Pick one of those transactions at random with probability in direct
proportion to its weight, and add it to the block.
@ -295,7 +296,8 @@ from a set of transactions in a node's mempool:
a. Pick a transaction with probability in direct proportion to its
weight and add it to the block. If that transaction would exceed
the :math:`size\_target\!`, stop without adding it.
the :math:`size\_target\!` or the block sigop limit [#sigop-limit]_,
stop without adding it.
Note: it is sufficient to use floating point arithmetic to calculate
the argument to :math:`\mathsf{floor}` when computing :math:`size\_target\!`,
@ -460,6 +462,7 @@ References
.. [#RFC2119] `RFC 2119: Key words for use in RFCs to Indicate Requirement Levels <https://www.rfc-editor.org/rfc/rfc2119.html>`_
.. [#protocol-networks] `Zcash Protocol Specification, Version 2022.3.8. Section 3.12: Mainnet and Testnet <protocol/protocol.pdf#networks>`_
.. [#protocol-txnencoding] `Zcash Protocol Specification, Version 2022.3.8. Section 7.1: Transaction Encoding and Consensus <protocol/protocol.pdf#txnencoding>`_
.. [#sigop-limit] `zcash/zips issue #568 - Document block transparent sigops limit consensus rule <https://github.com/zcash/zips/issues/568>`_
.. [#madars-1] `Madars concrete soft-fork proposal <https://forum.zcashcommunity.com/t/zip-reduce-default-shielded-transaction-fee-to-1000-zats/37566/89>`_
.. [#zip-0313] `ZIP 313: Reduce Conventional Transaction Fee to 1000 zatoshis <zip-0313.rst>`_
.. [#zip-0401] `ZIP 401: Addressing Mempool Denial-of-Service <zip-0401.rst>`_