ZIP 317: address Teor's comments.

Signed-off-by: Daira Hopwood <daira@jacaranda.org>
This commit is contained in:
Daira Hopwood 2022-12-05 21:46:30 +00:00
parent 957cc57f57
commit 0d9a96050b
2 changed files with 40 additions and 22 deletions

View File

@ -274,13 +274,16 @@ Pull-Request: &lt;<a href="https://github.com/zcash/zips/pull/631">https://githu
<span class="math">\(tx\)</span>
calculated according to the section <a href="#fee-calculation">Fee calculation</a>.</p>
<p>Let
<span class="math">\(unpaid\_actions(tx) = \mathsf{max}\!\left(0,\, \mathsf{max}(grace\_actions,\, tx.\!logical\_actions) - \mathsf{floor}\!\left(\frac{tx.fee}{marginal\_fee}\right)\right)\!\)</span>
.</p>
<span class="math">\(unpaid\_actions(tx) = \begin{cases}\mathsf{max}\!\left(0,\, \mathsf{max}(grace\_actions,\, tx.\!logical\_actions) - \mathsf{floor}\!\left(\frac{tx.fee}{marginal\_fee}\right)\right),&amp;\textsf{if }tx\textsf{ is a non-coinbase transaction} \\ 0,&amp;\textsf{if }tx\textsf{ is a coinbase transaction.}\end{cases}\)</span>
</p>
<p>Let
<span class="math">\(block\_unpaid\_actions(block) = \sum_{tx \,\in\, block}\, unpaid\_actions(tx)\)</span>
.</p>
<p>The following algorithm is RECOMMENDED for constructing block templates from a set of transactions in a node's mempool:</p>
<p>The following algorithm is RECOMMENDED for constructing a block template from a set of transactions in a node's mempool:</p>
<ol type="1">
<li>Set the block template
<span class="math">\(T\)</span>
to include only the coinbase transaction.</li>
<li>For each transaction
<span class="math">\(tx\)</span>
in the mempool, calculate
@ -289,29 +292,40 @@ Pull-Request: &lt;<a href="https://github.com/zcash/zips/pull/631">https://githu
<li>Repeat while there is any candidate transaction that pays at least the conventional fee:
<ol type="a">
<li>Pick one of those transactions at random with probability in direct proportion to its
<span class="math">\(weight\_ratio\)</span>
<span class="math">\(weight\_ratio\!\)</span>
, and remove it from the set of candidate transactions. Let
<span class="math">\(B\)</span>
be the block template with this transaction included.</li>
be the block template
<span class="math">\(T\)</span>
with this transaction included.</li>
<li>If
<span class="math">\(B\)</span>
would be within the block size limit and block sigop limit <a id="footnote-reference-7" class="footnote_reference" href="#sigop-limit">4</a>, add the transaction to the block template.</li>
would be within the block size limit and block sigop limit <a id="footnote-reference-7" class="footnote_reference" href="#sigop-limit">4</a>, set
<span class="math">\(T := B\!\)</span>
.</li>
</ol>
</li>
<li>Repeat while there is any candidate transaction:
<ol type="a">
<li>Pick one of those transactions at random with probability in direct proportion to its
<span class="math">\(weight\_ratio\)</span>
<span class="math">\(weight\_ratio\!\)</span>
, and remove it from the set of candidate transactions. Let
<span class="math">\(B\)</span>
be the block template with this transaction included.</li>
be the block template
<span class="math">\(T\)</span>
with this transaction included.</li>
<li>If
<span class="math">\(B\)</span>
would be within the block size limit and block sigop limit <a id="footnote-reference-8" class="footnote_reference" href="#sigop-limit">4</a> and
<span class="math">\(block\_unpaid\_actions(B) \leq block\_unpaid\_action\_limit\!\)</span>
, add the transaction to the block template.</li>
, set
<span class="math">\(T := B\!\)</span>
.</li>
</ol>
</li>
<li>Return
<span class="math">\(T\!\)</span>
.</li>
</ol>
</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>

View File

@ -272,36 +272,40 @@ Define constants :math:`weight\_ratio\_cap = 4` and
Let :math:`conventional\_fee(tx)` be the conventional fee for transaction
:math:`tx` calculated according to the section `Fee calculation`_.
Let :math:`unpaid\_actions(tx) = \mathsf{max}\!\left(0,\, \mathsf{max}(grace\_actions,\, tx.\!logical\_actions) - \mathsf{floor}\!\left(\frac{tx.fee}{marginal\_fee}\right)\right)\!`.
Let :math:`unpaid\_actions(tx) = \begin{cases}\mathsf{max}\!\left(0,\, \mathsf{max}(grace\_actions,\, tx.\!logical\_actions) - \mathsf{floor}\!\left(\frac{tx.fee}{marginal\_fee}\right)\right),&\textsf{if }tx\textsf{ is a non-coinbase transaction} \\ 0,&\textsf{if }tx\textsf{ is a coinbase transaction.}\end{cases}`
Let :math:`block\_unpaid\_actions(block) = \sum_{tx \,\in\, block}\, unpaid\_actions(tx)`.
The following algorithm is RECOMMENDED for constructing block templates
The following algorithm is RECOMMENDED for constructing a block template
from a set of transactions in a node's mempool:
1. For each transaction :math:`tx` in the mempool, calculate
1. Set the block template :math:`T` to include only the coinbase transaction.
2. For each transaction :math:`tx` in the mempool, calculate
:math:`tx.\!weight\_ratio = \mathsf{min}\!\left(\frac{\mathsf{max}(1,\, tx.fee)}{conventional\_fee(tx)},\, weight\_ratio\_cap\right)\!`
and add the transaction to the set of candidate transactions.
2. Repeat while there is any candidate transaction that pays at least the
3. Repeat while there is any candidate transaction that pays at least the
conventional fee:
a. Pick one of those transactions at random with probability in direct
proportion to its :math:`weight\_ratio`, and remove it from the set of
candidate transactions. Let :math:`B` be the block template with this
transaction included.
proportion to its :math:`weight\_ratio\!`, and remove it from the set of
candidate transactions. Let :math:`B` be the block template :math:`T`
with this transaction included.
b. If :math:`B` would be within the block size limit and block sigop
limit [#sigop-limit]_, add the transaction to the block template.
limit [#sigop-limit]_, set :math:`T := B\!`.
3. Repeat while there is any candidate transaction:
4. Repeat while there is any candidate transaction:
a. Pick one of those transactions at random with probability in direct
proportion to its :math:`weight\_ratio`, and remove it from the set of
candidate transactions. Let :math:`B` be the block template with this
transaction included.
proportion to its :math:`weight\_ratio\!`, and remove it from the set of
candidate transactions. Let :math:`B` be the block template :math:`T`
with this transaction included.
b. If :math:`B` would be within the block size limit and block sigop
limit [#sigop-limit]_ and :math:`block\_unpaid\_actions(B) \leq block\_unpaid\_action\_limit\!`,
add the transaction to the block template.
set :math:`T := B\!`.
5. Return :math:`T\!`.
Rationale for block template construction algorithm
'''''''''''''''''''''''''''''''''''''''''''''''''''