Explain the use of max(1, tx.fee), and write weight_ratio as math.

Signed-off-by: Daira Hopwood <daira@jacaranda.org>
This commit is contained in:
Daira Hopwood 2022-12-01 21:07:41 +00:00
parent fc56098315
commit a9ef048527
2 changed files with 28 additions and 8 deletions

View File

@ -285,7 +285,9 @@ Pull-Request: &lt;<a href="https://github.com/zcash/zips/pull/631">https://githu
and add the transaction to the set of candidate transactions.</li> and add the transaction to the set of candidate transactions.</li>
<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 weight ratio, and remove it from the set of candidate transactions. Let <li>Pick one of those transactions at random with probability in direct proportion to its
<span class="math">\(weight\_ratio\)</span>
, 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 with this transaction included.</li>
<li>If <li>If
@ -295,7 +297,9 @@ Pull-Request: &lt;<a href="https://github.com/zcash/zips/pull/631">https://githu
</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 weight ratio, and remove it from the set of candidate transactions. Let <li>Pick one of those transactions at random with probability in direct proportion to its
<span class="math">\(weight\_ratio\)</span>
, 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 with this transaction included.</li>
<li>If <li>If
@ -330,6 +334,17 @@ Pull-Request: &lt;<a href="https://github.com/zcash/zips/pull/631">https://githu
<p>The rationale for choosing <p>The rationale for choosing
<span class="math">\(weight\_ratio\_cap = 4\)</span> <span class="math">\(weight\_ratio\_cap = 4\)</span>
is as a compromise between not allowing any prioritization of transactions relative to those that pay the conventional fee, and allowing arbitrary prioritization based on ability to pay.</p> is as a compromise between not allowing any prioritization of transactions relative to those that pay the conventional fee, and allowing arbitrary prioritization based on ability to pay.</p>
<p>Calculating
<span class="math">\(tx.\!weight\_ratio\)</span>
in terms of
<span class="math">\(\mathsf{max}(1,\, tx.\!fee)\)</span>
rather than just
<span class="math">\(tx.\!fee\)</span>
avoids needing to define "with probability in direct proportion to its
<span class="math">\(weight\_ratio\!\)</span>
" for the case where all remaining candidate transactions would have
<span class="math">\(weight\_ratio = 0\!\)</span>
.</p>
</section> </section>
<section id="incentive-compatibility-for-miners"><h4><span class="section-heading">Incentive compatibility for miners</span><span class="section-anchor"> <a rel="bookmark" href="#incentive-compatibility-for-miners"><img width="24" height="24" class="section-anchor" src="assets/images/section-anchor.png" alt=""></a></span></h4> <section id="incentive-compatibility-for-miners"><h4><span class="section-heading">Incentive compatibility for miners</span><span class="section-anchor"> <a rel="bookmark" href="#incentive-compatibility-for-miners"><img width="24" height="24" class="section-anchor" src="assets/images/section-anchor.png" alt=""></a></span></h4>
<p>Miners have an incentive to make this change because:</p> <p>Miners have an incentive to make this change because:</p>

View File

@ -283,18 +283,18 @@ from a set of transactions in a node's mempool:
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 weight ratio, and remove it from the set of candidate proportion to its :math:`weight\_ratio`, and remove it from the set of
transactions. Let :math:`B` be the block template with this transaction candidate transactions. Let :math:`B` be the block template with this
included. 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]_, add the transaction to the block template.
3. Repeat while there is any candidate transaction: 3. 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 weight ratio, and remove it from the set of candidate proportion to its :math:`weight\_ratio`, and remove it from the set of
transactions. Let :math:`B` be the block template with this transaction candidate transactions. Let :math:`B` be the block template with this
included. 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. add the transaction to the block template.
@ -338,6 +338,11 @@ between not allowing any prioritization of transactions relative to those that
pay the conventional fee, and allowing arbitrary prioritization based on ability pay the conventional fee, and allowing arbitrary prioritization based on ability
to pay. to pay.
Calculating :math:`tx.\!weight\_ratio` in terms of :math:`\mathsf{max}(1,\, tx.\!fee)`
rather than just :math:`tx.\!fee` avoids needing to define "with probability in direct
proportion to its :math:`weight\_ratio\!`" for the case where all remaining candidate
transactions would have :math:`weight\_ratio = 0\!`.
Incentive compatibility for miners Incentive compatibility for miners
'''''''''''''''''''''''''''''''''' ''''''''''''''''''''''''''''''''''