I have an Extrinsic which modifies some storage variables and then returns either
Will it revert the changes when I return
How can I make sure that it only commits to changes when I return
Update: All storage changes are now reverted when an error from a call is returned. This makes writing code much easier.
Currently you need to make sure to never return an error after you modified storage.
In your case you need to do all checks that can error before modifying something.
Err after a modification will most likely put your pallet in an undefined state.
This is not the most ergonomic and will gladly change in the future.
An annotation à la
#[storage_layer] or something similar will be added.
This would allow to write code more easily as it would revert all changes upon error.
Will update this post once its done.
Extrinsic marked as
#[transactional] will get discarded if it returns
But there're some issues about
transactional annotation, see paritytech/substrate#10806