-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Get rid of junk in storage proofs. #9170
Description
Currently block execution storage proofs contain nodes that are not actually necessary to validate the block.
There's a common pattern in the runtime that we use to store intermediate values. Values that need to be passed around between extrinsics. Such values are put in the storage and are removed at the end of block execution with take. Here's one example:
substrate/frame/system/src/lib.rs
Line 1361 in df4a588
| let extrinsics = (0..ExtrinsicCount::<T>::take().unwrap_or_default()) |
The problem here is that take attempts to delete the value from the trie, even if it is not there. This attempted deletion query ends up being part of the proof.
A proposed solution would be to use revert rather than take. revert would simply delete the key from the state overlay.
Alternatively we could use static memory instead of storage API for intermediate values. This would also be a significant performance win, although some additional work would be needed to implement transactional semantics with this method.