-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Rework Transaction Priority calculation #9834
Conversation
Co-authored-by: Alexander Popiak <alexander.popiak@parity.io>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The PR seems fine. The prioritization makes sense.
I'm just worried that this will have weird unintended consequences for downstream chains using it.
Any way we can mitigate that? Any tests we could run to see whether the behavior is sane? Could we run a few validator nodes of e.g. Kusama with this changed priority? (I know that these are runtime-level changes and thus hard to test with a canary node.)
@apopiak Please take a look once again, I've reworked the calculation after audit feedback.
This is a runtime change, so it will be intentional to upgrade to a new version. Note that
We would need to define "sane" first :) Block authors are free to put transactions into blocks in whatever order they want, the |
/// range (might simply end up being zero). Hence we use a scaling factor: | ||
/// `tip * (max_block_{weight|length} / bounded_{weight|length})`, since given current | ||
/// state of-the-art blockchains, number of per-block transactions is expected to be in a | ||
/// range reasonable enough to not saturate the `Balance` type while multiplying by the tip. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about adding some assert
in a code to ensure assumptions? (i.e. that values are in expected ranges, preventing saturation)
Co-authored-by: Alexander Popiak <alexander.popiak@parity.io>
Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
bot merge |
Trying merge. |
* Add transaction validity docs. * Re-work priority calculation. * Fix tests. * Update frame/transaction-payment/src/lib.rs Co-authored-by: Alexander Popiak <alexander.popiak@parity.io> * cargo +nightly fmt --all * Fix an obvious mistake :) * Re-work again. * Fix test. * cargo +nightly fmt --all * Make VirtualTip dependent on the transaction size. * cargo +nightly fmt --all * Update frame/transaction-payment/src/lib.rs Co-authored-by: Alexander Popiak <alexander.popiak@parity.io> * Fix compilation. * Update bin/node/runtime/src/lib.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> Co-authored-by: Alexander Popiak <alexander.popiak@parity.io> Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
* master: (125 commits) Update multiple dependencies (#9936) Speed up timestamp generation when logging (#9933) First word should be Substrate not Polkadot (#9935) Improved file not found error message (#9931) don't read events in elections anymore. (#9898) Remove incorrect sanity check (#9924) Require crypto scheme for `insert-key` (#9909) chore: refresh of the substrate_builder image (#9808) Introduce block authorship soft deadline (#9663) Rework Transaction Priority calculation (#9834) Do not propagate host RUSTFLAGS when checking for WASM toolchain (#9926) Small quoting comment fix (#9927) add clippy to CI (#9694) Ensure BeforeBestBlockBy voting rule accounts for base (#9920) rm `.maintain` lock (#9919) Downstream `node-template` pull (#9915) Implement core::fmt::Debug for BoundedVec (#9914) Quickly skip invalid transactions during block authorship. (#9789) Add SS58 prefix for Automata (#9805) Clean up sc-peerset (#9806) ...
Closes #5672
Closes #9317
Alternative take on #9596
(we can leave the adjuster from previous PR, but I don't think it is going to be useful at all, given no extensions change
priority
).This PR changes the way Transaction Priority is calculated by following
SignedExtensions
:CheckWeight
ChargeTransactionPayment
For
CheckWeight
it removes thepriority
calculation completely, leaving the priority as0
for all dispatch classes. Please note that this might cause a bit of an havoc on existing chains without any extra signed extension that would alterpriority
(which is discouraged anyway) - all transactions would end up having the same priority (0
) and the inclusion might be done at random (i.e. depending on the transaction pool ordering - currently based on the insertion time), note that the requirements (i.e. nonce) would still be respected though.ChargeTransactionPayment
is completely reworked and is now a single place responsible for calculating the overallpriority
(all otherSignedExtensions
in this repo do not alter it).The priority depends on the dispatch class and the amount of tip-per-weight or tip-per-length (whatever is more limiting) the sender is willing to pay.
Transactions without a
tip
are using a minimal tip value of1
forpriority
calculations to make sure we don't end up with all transactions with0
priority. The consequence of this is that "smaller" transactions are more preferred than the "large" ones (note the behavior used to be similar withCheckWeight
's prioriy).Operational
transactions are getting additional priority bump - not as high as previously (3/4 * u64::max), because that prevents other transactions from getting in front of them in the pool, but now equal to theOperationalVirtualTip
amount configurable by a rutnime developer.Companion PR: paritytech/polkadot#3901