1

Is it possible to set a different priority for the transactions other than the fee or tip sent? If so, where should I modify the substrate-node to make it work. For example let's say I want to give some account more priority over others, therefore when this account sends a transaction, I want this transaction to be prioritized over the rest.

1 Answer 1

4

You can implement a custom SignedExtension in your runtime that handles this job for you.

struct PrioritizeAccount;

impl SignedExtension for PrioritizeAccount {
    type AccountId = AccountId;
    type Call = Call;
    type AdditionalSigned = ();
    type Pre = ();

    fn validate(
        who: &Self::AccountId, 
        _call: &Self::Call, 
        _info: &DispatchInfoOf<Self::Call>, 
        _len: usize,
    ) -> TransactionValidity {
        if who == special_account {
             Ok(ValidTransaction { priority: TransactionValidity::MAX, ..Default::default() })
        } else {
             Ok(Default::default())
        }
    }
}

Something like this should do the trick. Then you need to add this to your SignedExtra in your runtime lib.rs file. But whatever logic you write there, you need to ensure that it is safe and DOS resistant. Otherwise someone could may spam your chain.

1
  • Does this SignedExtension need to be added after the transaction-payment extension so that it overrides the priority that is set by transaction-payment-pallet?
    – Yatusabes
    Commented Aug 25, 2022 at 0:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.