Modify the conventional_fee formula to take into account

that transparent inputs and outputs are variable-length.

Signed-off-by: Daira Hopwood <daira@jacaranda.org>
This commit is contained in:
Daira Hopwood 2022-10-10 22:03:17 +01:00
parent f1924784f0
commit cb3e842bba
2 changed files with 46 additions and 16 deletions

View File

@ -194,13 +194,18 @@ span.math {
} }
div.math { div.math {
transform: scale(1.3, 1.339);
-moz-transform: scale(1.3, 1.339);
-ms-transform: scale(1.3, 1.339);
-webkit-transform: scale(1.3, 1.339);
-o-transform: scale(1.3, 1.339);
display: block; display: block;
overflow-x: auto; overflow-x: auto;
overflow-y: hidden; overflow-y: hidden;
margin: 0 1rem 1rem 1rem; margin: 2.6rem 1rem 2.6rem 1rem;
text-align: center; text-align: center;
padding: 0; padding: 0;
font-size: 0.75rem; font-size: 0.97rem;
} }
a, a:visited { a, a:visited {

View File

@ -78,18 +78,26 @@ Requirements
Specification Specification
============= =============
Notation
--------
Let :math:`\mathsf{max}(a, b)` be the greater of :math:`a` and :math:`b`.
Let :math:`\mathsf{ceiling}(x)` be the smallest integer :math:`\geq x`.
Fee calculation Fee calculation
--------------- ---------------
This specification defines two parameters that are used to calculate the This specification defines several parameters that are used to calculate the
conventional fee: conventional fee:
====================== ============================================== ===================================== ==============================================
Parameter Units Parameter Units
====================== ============================================== ===================================== ==============================================
:math:`marginal\_fee` zatoshis per logical action (as defined below) :math:`marginal\_fee` zatoshis per logical action (as defined below)
:math:`grace\_actions` logical actions :math:`grace\_actions` logical actions
====================== ============================================== :math:`p2pkh\_standard\_input\_size` bytes
:math:`p2pkh\_standard\_output\_size` bytes
===================================== ==============================================
Wallets implementing this specification SHOULD use a conventional fee Wallets implementing this specification SHOULD use a conventional fee
calculated in zatoshis per the following formula: calculated in zatoshis per the following formula:
@ -97,17 +105,34 @@ calculated in zatoshis per the following formula:
.. math:: .. math::
\begin{array}{rcl} \begin{array}{rcl}
logical\_actions &=& \max(transparent\_inputs, transparent\_outputs) \;+ \\ logical\_actions &=& \mathsf{max}\big(\mathsf{ceiling}\big(\frac{tx\_in\_total\_size}{p2pkh\_standard\_input\_size}\big),
& & 2 \cdot sprout\_joinsplits \;+ \\ \mathsf{ceiling}\big(\frac{tx\_out\_total\_size}{p2pkh\_standard\_output\_size}\big)\big) \;+ \\
& & \max(sapling\_inputs, sapling\_outputs) \;+ \\ & & 2 \cdot nJoinSplits \;+ \\
& & orchard\_actions \\ & & \mathsf{max}(nSpendsSapling, nOutputsSapling) \;+ \\
conventional\_fee &=& marginal\_fee \cdot \max(grace\_actions, logical\_actions) & & nActionsOrchard \\
conventional\_fee &=& marginal\_fee \cdot \mathsf{max}(grace\_actions, logical\_actions)
\end{array} \end{array}
The inputs to this formula are taken from transaction fields defined in the Zcash protocol
specification [#protocol-txnencoding]:
============================ ====== ===========================================
Input Units Description
============================ ====== ===========================================
:math:`tx\_in\_total\_size` bytes total size in bytes of the ``tx_in`` field
:math:`tx\_out\_total\_size` bytes total size in bytes of the ``tx_out`` field
:math:`nJoinSplit` number the number of Sprout JoinSplits
:math:`nSpendsSapling` number the number of Sapling spends
:math:`nOutputsSapling` number the number of Sapling outputs
:math:`nActionsOrchard` number the number of Orchard actions
============================ ====== ===========================================
The parameters are set to the following values: The parameters are set to the following values:
* :math:`marginal\_fee = 5000`; * :math:`marginal\_fee = 5000`;
* :math:`grace\_actions = 2`. * :math:`grace\_actions = 2`;
* :math:`p2pkh\_standard\_input\_size = TODO` bytes;
* :math:`p2pkh\_standard\_output\_size = TODO` bytes.
It is not a consensus requirement that fees follow this formula; however, It is not a consensus requirement that fees follow this formula; however,
wallets SHOULD create transactions that pay this fee, in order to reduce wallets SHOULD create transactions that pay this fee, in order to reduce
@ -273,7 +298,6 @@ of inputs/outputs to be non-proportional above the `grace_window_size`. This
is no longer expressible with the formula specified above.) is no longer expressible with the formula specified above.)
Endorsements Endorsements
============ ============
@ -312,6 +336,7 @@ References
.. [#RFC2119] `RFC 2119: Key words for use in RFCs to Indicate Requirement Levels <https://www.rfc-editor.org/rfc/rfc2119.html>`_ .. [#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-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>`_
.. [#madars-1] `Madars concrete soft-fork proposal <https://forum.zcashcommunity.com/t/zip-reduce-default-shielded-transaction-fee-to-1000-zats/37566/89>`_ .. [#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-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>`_ .. [#zip-0401] `ZIP 401: Addressing Mempool Denial-of-Service <zip-0401.rst>`_