`sp_trie::Recorder`: Fix recording the same key for different tries (#12636)
With `StateVersion::V1` values over a certain size are not inlined and being put into the backend with their own hash. When accessing a value in the trie with a recorder, we check if the value is maybe already recorded and thus, we can check the cache. To check if a value is already recorded, we use the key of the value to differentiate them. The problem is when there are multiple tries, like multiple child tries that all have different values under the same key. Before this pull request we didn't have differentiated for which trie we already had recorded a (key, value) pair. This is now done by also taking the storage root into account in the recorder to differentiate the different (key, value) pair in the tries.
Showing
- substrate/primitives/state-machine/src/trie_backend.rs 91 additions, 0 deletionssubstrate/primitives/state-machine/src/trie_backend.rs
- substrate/primitives/state-machine/src/trie_backend_essence.rs 38 additions, 33 deletions...rate/primitives/state-machine/src/trie_backend_essence.rs
- substrate/primitives/trie/src/cache/mod.rs 2 additions, 2 deletionssubstrate/primitives/trie/src/cache/mod.rs
- substrate/primitives/trie/src/recorder.rs 22 additions, 4 deletionssubstrate/primitives/trie/src/recorder.rs
Please register or sign in to comment