Miners, mining pools, and other block producers, select transactions for inclusion in blocks using a variety of criteria. The algorithm in the following section is planned to be implemented by zcashd and zebrad.
Define a constant - \(weight\_cap = 4\) +
Define constants + \(weight\_ratio\_cap = 4\) + and + \(block\_unpaid\_action\_limit = 50\!\) .
Let \(conventional\_fee(tx)\) be the conventional fee for transaction \(tx\) calculated according to the section Fee calculation.
+Let + \(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 + \(block\_unpaid\_actions(block) = \sum_{tx \,\in\, block}\, unpaid\_actions(tx)\) + .
The following algorithm is RECOMMENDED for constructing block templates from a set of transactions in a node's mempool:
Note: it is sufficient to use floating point arithmetic to calculate the argument to - \(\mathsf{floor}\) - when computing - \(size\_target\!\) - , since there is no consensus requirement for this to be exactly the same between implementations.
It is likely that not all wallets will immediately update to pay the (generally higher) fees specified by this ZIP. In order to be able to deploy this block template algorithm more quickly while still giving transactions created by such wallets a reasonable chance of being mined, we allow a limited number of "unpaid" logical actions in each block. Roughly speaking, if a transaction falls short of paying the conventional transaction fee by + \(k\) + times the marginal fee, we count that as + \(k\) + unpaid logical actions.
+Regardless of how full the mempool is (according to the ZIP 401 7 cost limiting), and regardless of what strategy a denial-of-service adversary may use, the number of unpaid logical actions in each block is always limited to at most + \(block\_unpaid\_action\_limit\!\) + .
+The weighting in step 2 does not create a situation where the adversary gains a significant advantage over other users by paying more than the conventional fee, for two reasons:
+The rationale for choosing + \(weight\_ratio\_cap = 4\) + 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.
Miners have an incentive to make this change because:
@@ -352,20 +353,34 @@ Pull-Request: <https://githuWallets SHOULD deploy these changes immediately. Nodes SHOULD deploy the change to the \(low\_fee\_penalty\) threshold described in Mempool size limiting immediately.
-Miners can deploy restrictions to their policies for transaction inclusion, once a sufficient proportion of transactions in the ecosystem are observed to be paying at least the updated conventional transaction fee.
-Node developers SHOULD coordinate on schedules for deploying restrictions to their policies for transaction mempool acceptance and peer-to-peer relaying. These policy changes SHOULD NOT be deployed before the changes to transaction inclusion policy by miners described in the preceding paragraph.
+Nodes supporting block template construction SHOULD deploy the new Recommended algorithm for block template construction immediately, and miners SHOULD use nodes that have been upgraded to this algorithm.
+Node developers SHOULD coordinate on schedules for deploying restrictions to their policies for transaction mempool acceptance and peer-to-peer relaying. These policy changes SHOULD NOT be deployed before the changes to block template construction for miners described in the preceding paragraph.
This section describes alternative proposals that have not been adopted.
In previous iterations of this specification, the marginal fee was multiplied by the sum of inputs and outputs. This means that the alternatives given below are roughly half of what they would be under the current formula.
Possible alternatives for the parameters:
(In @madars' and @nighthawk24's original proposals, there was an additional base_fee parameter that caused the relationship between fee and number of inputs/outputs to be non-proportional above the grace_window_size. This is no longer expressible with the formula specified above.)
+(In @madars' and @nighthawk24's original proposals, there was an additional + \(base\_fee\) + parameter that caused the relationship between fee and number of inputs/outputs to be non-proportional above the + \(grace\_actions\) + threshold. This is no longer expressible with the formula specified above.)
The following entities/groups/individuals expressed their support for the updated fee mechanism:
@@ -382,7 +397,7 @@ Pull-Request: <https://githuTODO: Endorsements may depend on specific parameter choices. The ZIP Editors should ensure that the endorsements are accurate before marking this ZIP as Active.
Thanks to Madars Virza for initially proposing a fee mechanism similar to that proposed in this ZIP 5, and to Kris Nuttycombe, Jack Grigg, Daira Hopwood, Francisco Gindre, Greg Pfeil, and Teor for suggested improvements.
+Thanks to Madars Virza for initially proposing a fee mechanism similar to that proposed in this ZIP 5, and for finding a potential weakness in an earlier version of the block template construction algorithm. Thanks also to Kris Nuttycombe, Jack Grigg, Daira Hopwood, Francisco Gindre, Greg Pfeil, Teor, and Deirdre Connolly for reviews and suggested improvements.