As the title mention, I would like to know what would be the best way to ensure that an extrinsic can be executed only if it's the first call in the block (ignoring timestamp). It also need to work with batches, scheduler or any governance body.
Is there an idiomatic way to do that ?
Edit :
Initially I had to lead to solve this :
- The first one is kinda similar to what you are proposing : Having a storage that gets flipped when the extrinsic is called and the call would be applied in the
on_initialize
of the next block. (This is kinda overload since we'll do a storage read on every block for a quite rare call) - The second was to use the extrinsic count or event count in the extrinsic itself to ensure a good position (since it's ok to refuse the extrinsic if it does not respect the rule). But it's not safe since the ordering of events will change in case of batches, or governance calls and also reading the events in runtime is, I guess too heavy.