From 0717b42d832003a543ec9bec5f291cfd30faa81a Mon Sep 17 00:00:00 2001 From: Parth Desai Date: Wed, 29 Nov 2023 22:31:09 +0400 Subject: [PATCH 1/3] add function to get recorded keys from proof recorder instance --- substrate/primitives/trie/src/recorder.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/substrate/primitives/trie/src/recorder.rs b/substrate/primitives/trie/src/recorder.rs index 154cee3f37dc..6d620e451fe8 100644 --- a/substrate/primitives/trie/src/recorder.rs +++ b/substrate/primitives/trie/src/recorder.rs @@ -105,6 +105,15 @@ impl Clone for Recorder { } impl Recorder { + /// Keys for which we have recorded the trie nodes till now. + /// Note that this does not modify the internals, rather returns snapshot of the recorded keys. + /// There can be multiple storage root in case we are tracking more than one tries. + pub fn recorded_keys(&self) -> HashMap<::Out, HashMap, RecordedForKey>> { + let inner = self.inner.lock(); + inner.recorded_keys.clone() + } + + /// Returns the recorder as [`TrieRecorder`](trie_db::TrieRecorder) compatible type. /// /// - `storage_root`: The storage root of the trie for which accesses are recorded. This is From c7603026eeba906749e3f05754e09dbac18283f3 Mon Sep 17 00:00:00 2001 From: Parth Desai Date: Fri, 1 Dec 2023 12:27:18 +0400 Subject: [PATCH 2/3] update comment to match upstream diff --- substrate/primitives/trie/src/recorder.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/substrate/primitives/trie/src/recorder.rs b/substrate/primitives/trie/src/recorder.rs index 6d620e451fe8..a10ba59583c3 100644 --- a/substrate/primitives/trie/src/recorder.rs +++ b/substrate/primitives/trie/src/recorder.rs @@ -105,15 +105,14 @@ impl Clone for Recorder { } impl Recorder { - /// Keys for which we have recorded the trie nodes till now. - /// Note that this does not modify the internals, rather returns snapshot of the recorded keys. - /// There can be multiple storage root in case we are tracking more than one tries. + /// Returns [`RecordedForKey`] per recorded key per trie. + /// + /// There are multiple tries when working with e.g. child tries. pub fn recorded_keys(&self) -> HashMap<::Out, HashMap, RecordedForKey>> { let inner = self.inner.lock(); inner.recorded_keys.clone() } - /// Returns the recorder as [`TrieRecorder`](trie_db::TrieRecorder) compatible type. /// /// - `storage_root`: The storage root of the trie for which accesses are recorded. This is From a54f2df06679f55e647862db8f44a81fc9b33c4f Mon Sep 17 00:00:00 2001 From: Parth Date: Fri, 1 Dec 2023 12:36:01 +0400 Subject: [PATCH 3/3] apply review suggestion Co-authored-by: Nazar Mokrynskyi --- substrate/primitives/trie/src/recorder.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/substrate/primitives/trie/src/recorder.rs b/substrate/primitives/trie/src/recorder.rs index a10ba59583c3..4dc45819732e 100644 --- a/substrate/primitives/trie/src/recorder.rs +++ b/substrate/primitives/trie/src/recorder.rs @@ -109,8 +109,7 @@ impl Recorder { /// /// There are multiple tries when working with e.g. child tries. pub fn recorded_keys(&self) -> HashMap<::Out, HashMap, RecordedForKey>> { - let inner = self.inner.lock(); - inner.recorded_keys.clone() + self.inner.lock().recorded_keys.clone() } /// Returns the recorder as [`TrieRecorder`](trie_db::TrieRecorder) compatible type.