4

it looks like that in version of 28 polkadot was change that extrinsics are by default transactional.

Before that we used attribute #[transactional] for specific extrinsic in order to have transactional extrinsics.

But now it looks like that all extrinsic by default are transactional and in our case we do not want to have all the extrinsics transactional.

Is there attribute in order to annotate extrinsic as non-transactional ?

2
  • Just curious. Why do you want non-transactional?
    – aurexav
    Commented Nov 11, 2022 at 9:22
  • The reason we need non-transactional is that we need to charge some special fees which be charged even if the extrinsic fails; they can't be a part of extrinsic fees because it is too heavy an operation to be done during extrinsic validation (as a part of the signed extension) for all such extrinsics. Commented Nov 12, 2022 at 20:01

1 Answer 1

6

Pasting context from #10806 itself, very well documented, please check.

Annotation for safe without storage layer

Now that the default behavior of extrinsics will be to spawn at least one transactional layer, we can introduce an opt-in optimization where a user can state that a function is safe to be executed without its own transactional layer.

For example:

    /// This function is safe to execute without an additional transactional storage layer.
    #[without_transactional]
    fn set_value(x: u32) -> DispatchResult {
        Self::check_value(x)?;
        MyStorage::set(x);
        Ok(())
    }

When this function is called directly, a transactional layer should not spawn for it.

If a user called dispatch_with_transactional to this function, a transactional layer also does not need to spawn.

3
  • Thank you Alejandro :) this will help us :) Commented Nov 12, 2022 at 20:01
  • Alejandro can you tell us in which crate is this attribute #[without_transactional] ? .. we did not find this. Commented Nov 15, 2022 at 11:16
  • The implementation of such attribute tag was halted as per the discussion on this issue: github.com/paritytech/substrate/issues/11533 Where you can find the PR with the proposal for its implementation Commented Nov 15, 2022 at 11:29

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.