Apply suggestions from ZIP sync meeting.

With thanks to @sellout, @conradoplg, @upbqdn, @nuttycom, @teor2345, @str4d.

Signed-off-by: Daira Hopwood <daira@jacaranda.org>
This commit is contained in:
Daira Hopwood 2022-10-12 23:01:51 +01:00
parent 1d0b4f3820
commit ad1aace0e8
2 changed files with 35 additions and 21 deletions

View File

@ -97,12 +97,12 @@ Pull-Request: &lt;<a href="https://github.com/zcash/zips/pull/631">https://githu
<div class="math">\(\begin{array}{rcl}
logical\_actions &amp;=&amp; \mathsf{max}\big(\mathsf{ceiling}\big(\frac{tx\_in\_total\_size}{p2pkh\_standard\_input\_size}\big),
\mathsf{ceiling}\big(\frac{tx\_out\_total\_size}{p2pkh\_standard\_output\_size}\big)\big) \;+ \\
&amp; &amp; 2 \cdot nJoinSplits \;+ \\
&amp; &amp; 2 \cdot nJoinSplit \;+ \\
&amp; &amp; \mathsf{max}(nSpendsSapling, nOutputsSapling) \;+ \\
&amp; &amp; nActionsOrchard \\
conventional\_fee &amp;=&amp; marginal\_fee \cdot \mathsf{max}(grace\_actions, logical\_actions)
\end{array}\)</div>
<p>The inputs to this formula are taken from transaction fields defined in the Zcash protocol specification [#protocol-txnencoding]:</p>
<p>The inputs to this formula are taken from transaction fields defined in the Zcash protocol specification <a id="footnote-reference-4" class="footnote_reference" href="#protocol-txnencoding">3</a>:</p>
<table>
<thead>
<tr>
@ -218,14 +218,17 @@ Pull-Request: &lt;<a href="https://github.com/zcash/zips/pull/631">https://githu
<span class="math">\(p2pkh\_standard\_input\_size\)</span>
and
<span class="math">\(p2pkh\_standard\_output\_size\)</span>
are based on the maximum encoded length for simple P2PKH inputs and outputs, as follows:</p>
are based on the maximum encoded length for P2PKH inputs and outputs, as follows:</p>
<ul>
<li>
<span class="math">\(p2pkh\_standard\_input\_size\)</span>
<ul>
<li>outpoint: 36 bytes</li>
<li>stack script: 72 bytes</li>
<li>redeem script: 34 bytes</li>
<li>script: 110 bytes
<ul>
<li>1 (overall length) + 1 (signature length) + 72 (signature) + 1 (sighash type) + 1 (pubkey length) + 33 (pubkey) + 1 (margin)</li>
</ul>
</li>
<li>sequence: 4 bytes</li>
</ul>
</li>
@ -233,14 +236,18 @@ Pull-Request: &lt;<a href="https://github.com/zcash/zips/pull/631">https://githu
<span class="math">\(p2pkh\_standard\_output\_size\)</span>
<ul>
<li>value: 8 bytes</li>
<li>script: 26 bytes</li>
<li>script: 26 bytes
<ul>
<li>1 (script length) + 25 (P2PKH script)</li>
</ul>
</li>
</ul>
</li>
</ul>
<p>Simple P2SH inputs and outputs are not typically larger than this.</p>
<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-4" 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">5</a>, and imposes a non-trivial cost for potential denial-of-service attacks.</p>
</section>
</section>
</section>
@ -248,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-5" 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">6</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>
@ -283,7 +290,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.</li>
<li>marginal_fee = 1000 adapted from @madars' proposal <a id="footnote-reference-7" class="footnote_reference" href="#madars-1">4</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>
@ -301,10 +308,10 @@ Pull-Request: &lt;<a href="https://github.com/zcash/zips/pull/631">https://githu
<li>contact</li>
</ul>
<p>or, conversely e-mail the same details to the Owner of the ZIP.</p>
<p>TODO: Endorsements may depend on specific parameter choices. The ZIP Editors should ensure that the endorsements are accurate before merging this ZIP.</p>
<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-6" 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-8" 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>
</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">

View File

@ -108,14 +108,14 @@ calculated in zatoshis per the following formula:
\begin{array}{rcl}
logical\_actions &=& \mathsf{max}\big(\mathsf{ceiling}\big(\frac{tx\_in\_total\_size}{p2pkh\_standard\_input\_size}\big),
\mathsf{ceiling}\big(\frac{tx\_out\_total\_size}{p2pkh\_standard\_output\_size}\big)\big) \;+ \\
& & 2 \cdot nJoinSplits \;+ \\
& & 2 \cdot nJoinSplit \;+ \\
& & \mathsf{max}(nSpendsSapling, nOutputsSapling) \;+ \\
& & nActionsOrchard \\
conventional\_fee &=& marginal\_fee \cdot \mathsf{max}(grace\_actions, logical\_actions)
\end{array}
The inputs to this formula are taken from transaction fields defined in the Zcash protocol
specification [#protocol-txnencoding]:
specification [#protocol-txnencoding]_:
============================ ====== ===========================================
Input Units Description
@ -211,13 +211,15 @@ scripts.
The chosen values for :math:`p2pkh\_standard\_input\_size` and
:math:`p2pkh\_standard\_output\_size` are based on the maximum encoded
length for simple P2PKH inputs and outputs, as follows:
length for P2PKH inputs and outputs, as follows:
* :math:`p2pkh\_standard\_input\_size`
* outpoint: 36 bytes
* stack script: 72 bytes
* redeem script: 34 bytes
* script: 110 bytes
* 1 (overall length) + 1 (signature length) + 72 (signature) + 1 (sighash type) + 1 (pubkey length) + 33 (pubkey) + 1 (margin)
* sequence: 4 bytes
* :math:`p2pkh\_standard\_output\_size`
@ -225,7 +227,12 @@ length for simple P2PKH inputs and outputs, as follows:
* value: 8 bytes
* script: 26 bytes
Simple P2SH inputs and outputs are not typically larger than this.
* 1 (script length) + 25 (P2PKH script)
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.
Marginal Fee
~~~~~~~~~~~~
@ -329,7 +336,7 @@ below are roughly half of what they would be under the current formula.
Possible alternatives for the parameters:
* marginal_fee = 250 in @nuttycom's proposal.
* marginal_fee = 1000 adapted from @madars' proposal.
* marginal_fee = 1000 adapted from @madars' proposal [#madars-1]_.
* marginal_fee = 2500 in @daira's proposal.
* marginal_fee = 1000 for Shielded, Shielding and De-shielding
transactions, and marginal_fee = 10000 for Transparent transactions
@ -363,8 +370,8 @@ below indicating:
or, conversely e-mail the same details to the Owner of the ZIP.
TODO: Endorsements may depend on specific parameter choices. The ZIP
Editors should ensure that the endorsements are accurate before merging
this ZIP.
Editors should ensure that the endorsements are accurate before marking
this ZIP as Active.
Acknowledgements