Skip to content

Commit

Permalink
ZIP 401: allow implementations to use a different approximation of the
Browse files Browse the repository at this point in the history
memory size of a transaction than its serialized size.

fixes zcash#673

Signed-off-by: Daira Emma Hopwood <daira@jacaranda.org>
  • Loading branch information
daira committed Apr 16, 2023
1 parent aca1158 commit 6b074e1
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion zip-0401.rst
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,11 @@ potentially other implementations that have adopted this specification in full).
The mempool of a node holds a set of transactions. Each transaction has a *cost*,
which is an integer defined as:

max(serialized transaction size in bytes, 4000)
max(memory size in bytes, 4000)

The memory size is an estimate of the size that a transaction occupies in the
memory of a node. It MAY be approximated as the serialized transaction size in
bytes.

Each transaction also has an *eviction weight*, which is *cost* + *low_fee_penalty*,
where *low_fee_penalty* is 16000 if the transaction pays a fee less than the
Expand Down Expand Up @@ -135,6 +139,13 @@ be that the complexity of accounting for this overhead is unwarranted given that
the format of a transaction already imposes a minimum size. However, the proposed
cost function is almost as simple as using transaction size directly.

There is some ambiguity in the specification of "memory size", allowing
implementations to use different approximations. Currently, `zcashd` uses a size
computed by the `RecursiveDynamicUsage` function, and `zebra` uses the serialized
size. This has been changed from a previous version of this ZIP that specified
use of the serialized size, to reflect how the implementation in `zcashd` has
worked since it was first deployed [#size-ambiguity]_.

The threshold 4000 for the cost function is chosen so that the size in bytes of a
typical fully shielded Sapling transaction (with, say, 2 shielded outputs and up
to 5 shielded inputs) will fall below the threshold. This has the effect of
Expand Down Expand Up @@ -212,4 +223,5 @@ References
.. [#zip-0239] `ZIP 239: Relay of Version 5 Transactions <zip-0239.rst>`_
.. [#zip-0252] `ZIP 252: Deployment of the NU5 Network Upgrade <zip-0252.rst>`_
.. [#zip-0317] `ZIP 317: Proportional Transfer Fee Mechanism <zip-0317.rst>`_
.. [#size-ambiguity] `zcash/zips issue #673 - ZIP 401 uses serialized size to calculate cost but the zcashd implementation uses RecursiveDynamicUsage <https://github.com/zcash/zips/issues/673>`_
.. [#BitcoinCore-PR6722] `Bitcoin Core PR 6722: Limit mempool by throwing away the cheapest txn and setting min relay fee to it <https://github.com/bitcoin/bitcoin/pull/6722>`_

0 comments on commit 6b074e1

Please sign in to comment.