Is it safe to do a mutation from within a SignedExtension for some pallet-specific storage items while validating a transaction? If not, what could go wrong, and why?

One thing that could go wrong is if pre_dispatch / validate are called separately, it could trigger the mutation multiple times

1 Answer 1


Yes it is safe to mutate storage items from pre_dispatch. Mutating storage items from validate doesn't make that much sense as it is only called in an offchain context. However, as the docs say you should ensure that pre_dispatch and validate are doing the exact same validity checks as otherwise your chain is attackable. Whatever you are doing, you just need to take into account that the dispatchable is maybe "failing" and didn't do what you expected in your pre_dispatch. So, you may need to use post_dispatch to do some corrections.

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.