substrate icon indicating copy to clipboard operation
substrate copied to clipboard

Add `#[without_storage_layer]` tag which explicitly allows an extrinsic to not have a storage layer

Open shawntabrizi opened this issue 3 years ago • 5 comments

Left over from: https://github.com/paritytech/substrate/issues/10806

Now that: https://github.com/paritytech/substrate/pull/11431 is merged, all extrinsics will have a transactional layer by default.

However, there may be situations you explicitly do not want a transactional layer, for example when you know that there is no need for it, or if you may even want to abuse this behavior(?)

We need to introduce a new attribute tag which can allow a user to note that an extrinsic should not have a storage layer, and then we skip adding the layer to the extrinsic.

This should be an easy task for anyone who is familiar with writing Rust macros.

shawntabrizi avatar May 26 '22 19:05 shawntabrizi

I would like to work on this.

Szegoo avatar Jun 04 '22 14:06 Szegoo

@Szegoo yup all yours! Presumably you are familiar with writing Rust macros?

Let me know if you need any help with finding the appropriate parts of code.

shawntabrizi avatar Jun 05 '22 07:06 shawntabrizi

@shawntabrizi Yes, I am familiar with writing rust macros, I will let you know if I need any help 😀.

Szegoo avatar Jun 05 '22 07:06 Szegoo

@shawntabrizi I have added a mode tag, that shows whether an extrinsic is gonna have a storage layer. So AFAIU I need now to write code that checks whether transactional is being used in the with_transaction and with_transaction_unchecked functions. Is this correct? If this is correct, what should I return when transactional is not being used?

Szegoo avatar Jun 05 '22 18:06 Szegoo

I think we should not do this. The point here being that Pallet developers should be aware of what is the standard, aka either always transactional or not transactional. As we want transactional, I would vote for transactional as the default and this default should not be configurable. Otherwise we may open some attack vectors/bugs when it comes to nested calls where a developer needs to do some assumptions about the nested calls and their transactional behavior.

bkchr avatar Jul 28 '22 14:07 bkchr

agreed with basti here, best to have only one behavior

shawntabrizi avatar Sep 10 '22 16:09 shawntabrizi