mirror of https://github.com/zcash/zips.git
ZIP 317: address Teor's comments.
Signed-off-by: Daira Hopwood <daira@jacaranda.org>
This commit is contained in:
parent
957cc57f57
commit
0d9a96050b
|
@ -274,13 +274,16 @@ Pull-Request: <<a href="https://github.com/zcash/zips/pull/631">https://githu
|
||||||
<span class="math">\(tx\)</span>
|
<span class="math">\(tx\)</span>
|
||||||
calculated according to the section <a href="#fee-calculation">Fee calculation</a>.</p>
|
calculated according to the section <a href="#fee-calculation">Fee calculation</a>.</p>
|
||||||
<p>Let
|
<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>
|
<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),&\textsf{if }tx\textsf{ is a non-coinbase transaction} \\ 0,&\textsf{if }tx\textsf{ is a coinbase transaction.}\end{cases}\)</span>
|
||||||
.</p>
|
</p>
|
||||||
<p>Let
|
<p>Let
|
||||||
<span class="math">\(block\_unpaid\_actions(block) = \sum_{tx \,\in\, block}\, unpaid\_actions(tx)\)</span>
|
<span class="math">\(block\_unpaid\_actions(block) = \sum_{tx \,\in\, block}\, unpaid\_actions(tx)\)</span>
|
||||||
.</p>
|
.</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">
|
<ol type="1">
|
||||||
|
<li>Set the block template
|
||||||
|
<span class="math">\(T\)</span>
|
||||||
|
to include only the coinbase transaction.</li>
|
||||||
<li>For each transaction
|
<li>For each transaction
|
||||||
<span class="math">\(tx\)</span>
|
<span class="math">\(tx\)</span>
|
||||||
in the mempool, calculate
|
in the mempool, calculate
|
||||||
|
@ -289,29 +292,40 @@ Pull-Request: <<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:
|
<li>Repeat while there is any candidate transaction that pays at least the conventional fee:
|
||||||
<ol type="a">
|
<ol type="a">
|
||||||
<li>Pick one of those transactions at random with probability in direct proportion to its
|
<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
|
, and remove it from the set of candidate transactions. Let
|
||||||
<span class="math">\(B\)</span>
|
<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
|
<li>If
|
||||||
<span class="math">\(B\)</span>
|
<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>
|
</ol>
|
||||||
</li>
|
</li>
|
||||||
<li>Repeat while there is any candidate transaction:
|
<li>Repeat while there is any candidate transaction:
|
||||||
<ol type="a">
|
<ol type="a">
|
||||||
<li>Pick one of those transactions at random with probability in direct proportion to its
|
<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
|
, and remove it from the set of candidate transactions. Let
|
||||||
<span class="math">\(B\)</span>
|
<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
|
<li>If
|
||||||
<span class="math">\(B\)</span>
|
<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
|
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>
|
<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>
|
</ol>
|
||||||
</li>
|
</li>
|
||||||
|
<li>Return
|
||||||
|
<span class="math">\(T\!\)</span>
|
||||||
|
.</li>
|
||||||
</ol>
|
</ol>
|
||||||
</section>
|
</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>
|
<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>
|
||||||
|
|
30
zip-0317.rst
30
zip-0317.rst
|
@ -272,36 +272,40 @@ Define constants :math:`weight\_ratio\_cap = 4` and
|
||||||
Let :math:`conventional\_fee(tx)` be the conventional fee for transaction
|
Let :math:`conventional\_fee(tx)` be the conventional fee for transaction
|
||||||
:math:`tx` calculated according to the section `Fee calculation`_.
|
: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)`.
|
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:
|
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)\!`
|
: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.
|
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:
|
conventional fee:
|
||||||
|
|
||||||
a. Pick one of those transactions at random with probability in direct
|
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
|
proportion to its :math:`weight\_ratio\!`, and remove it from the set of
|
||||||
candidate transactions. Let :math:`B` be the block template with this
|
candidate transactions. Let :math:`B` be the block template :math:`T`
|
||||||
transaction included.
|
with this transaction included.
|
||||||
b. If :math:`B` would be within the block size limit and block sigop
|
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
|
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
|
proportion to its :math:`weight\_ratio\!`, and remove it from the set of
|
||||||
candidate transactions. Let :math:`B` be the block template with this
|
candidate transactions. Let :math:`B` be the block template :math:`T`
|
||||||
transaction included.
|
with this transaction included.
|
||||||
b. If :math:`B` would be within the block size limit and block sigop
|
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\!`,
|
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
|
Rationale for block template construction algorithm
|
||||||
'''''''''''''''''''''''''''''''''''''''''''''''''''
|
'''''''''''''''''''''''''''''''''''''''''''''''''''
|
||||||
|
|
Loading…
Reference in New Issue