Skip to content

Create our own SignedExtension to handle transaction priority

Today, TransactionPriority is set only by the signed extension ChargeTransactionPayment, but we can't override the priority after, because alls priorities are added (sum), see ValidTransaction::combine_with.

IMPORTANT SECURITY NOTE: all dispatch class should have the same priority, because anyone can submit a call with Operational, it's a problem even if the execution will fail with BadOrigin. I strongly recommend to not use Operational dispatch class at all. We can instead define 2 filters (origin and call), to define who "can" use a priority level.

The best way is to create a new pallet quotas_priority, something like that:

type Priority = u64;

struct PriorityQuotaData {
  max_priority: Priority, // max allowed priority in a single transaction
  remaining_quota: Priority,
}

trait Config: frame_system::Config {
  type Call;
  type PriorityQuotasStore: StoredMap<Self::AccountId, PriorityQuotaData>;
  type CallPriorityFilter: From<Priority> + InstanceFilter<Call>;
}

About providing the priority quotas, I think this should be done in a similar way than the Universal Dividend. We can add a handler OnUdClaimed in pallet universal_dividend, then impl this handler in runtime glue code to call a public function that provide priority quota.

Edited by Éloïs
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information