mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-17 14:51:07 +00:00
Partial fix for transaction priority (#7034)
* Partial fix for priority stuff. * Small fix * Fix tests. * Update frame/transaction-payment/src/lib.rs Co-authored-by: Tomasz Drwięga <tomusdrw@users.noreply.github.com> * Better doc Co-authored-by: Tomasz Drwięga <tomusdrw@users.noreply.github.com>
This commit is contained in:
@@ -27,7 +27,7 @@ use sp_runtime::{
|
||||
};
|
||||
use frame_support::{
|
||||
traits::{Get},
|
||||
weights::{PostDispatchInfo, DispatchInfo, DispatchClass},
|
||||
weights::{PostDispatchInfo, DispatchInfo, DispatchClass, priority::FrameTransactionPriority},
|
||||
StorageValue,
|
||||
};
|
||||
|
||||
@@ -157,12 +157,18 @@ impl<T: Trait + Send + Sync> CheckWeight<T> where
|
||||
}
|
||||
|
||||
/// get the priority of an extrinsic denoted by `info`.
|
||||
///
|
||||
/// Operational transaction will be given a fixed initial amount to be fairly distinguished from
|
||||
/// the normal ones.
|
||||
fn get_priority(info: &DispatchInfoOf<T::Call>) -> TransactionPriority {
|
||||
match info.class {
|
||||
DispatchClass::Normal => info.weight.into(),
|
||||
// Don't use up the whole priority space, to allow things like `tip`
|
||||
// to be taken into account as well.
|
||||
DispatchClass::Operational => TransactionPriority::max_value() / 2,
|
||||
// Normal transaction.
|
||||
DispatchClass::Normal =>
|
||||
FrameTransactionPriority::Normal(info.weight.into()).into(),
|
||||
// Don't use up the whole priority space, to allow things like `tip` to be taken into
|
||||
// account as well.
|
||||
DispatchClass::Operational =>
|
||||
FrameTransactionPriority::Operational(info.weight.into()).into(),
|
||||
// Mandatory extrinsics are only for inherents; never transactions.
|
||||
DispatchClass::Mandatory => TransactionPriority::min_value(),
|
||||
}
|
||||
@@ -496,7 +502,7 @@ mod tests {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn signed_ext() {
|
||||
fn signed_ext_check_weight_works() {
|
||||
new_test_ext().execute_with(|| {
|
||||
let normal = DispatchInfo { weight: 100, class: DispatchClass::Normal, pays_fee: Pays::Yes };
|
||||
let op = DispatchInfo { weight: 100, class: DispatchClass::Operational, pays_fee: Pays::Yes };
|
||||
@@ -512,7 +518,7 @@ mod tests {
|
||||
.validate(&1, CALL, &op, len)
|
||||
.unwrap()
|
||||
.priority;
|
||||
assert_eq!(priority, u64::max_value() / 2);
|
||||
assert_eq!(priority, frame_support::weights::priority::LIMIT + 100);
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user