-
Notifications
You must be signed in to change notification settings - Fork 0
build: impl serialize for filled tree #116
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #116 +/- ##
==========================================
- Coverage 72.03% 71.83% -0.20%
==========================================
Files 31 31
Lines 1087 1090 +3
Branches 1087 1090 +3
==========================================
Hits 783 783
- Misses 267 270 +3
Partials 37 37 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 0 of 1 files reviewed, 4 unresolved discussions (waiting on @AvivYossef-starkware and @dorimedini-starkware)
crates/committer/src/patricia_merkle_tree/filled_tree/tree.rs
line 17 at r1 (raw file):
pub(crate) trait FilledTree<L: LeafData> { /// Serializes the tree into storage. Returns hash set of keys of the serialized nodes, /// if successful.
Please add:
/// Serializes the tree and returns the resulting storage keys and values.
Code quote:
/// Serializes the tree into storage. Returns hash set of keys of the serialized nodes,
/// if successful.
crates/committer/src/patricia_merkle_tree/filled_tree/tree.rs
line 17 at r1 (raw file):
pub(crate) trait FilledTree<L: LeafData> { #[allow(dead_code)] fn serialize(&self) -> HashMap<StorageKey, StorageValue>;
Code quote (i):
fn serialize(&self) -> HashMap<StorageKey, StorageValue>;
Code snippet (ii):
fn serialize(&self) -> Result<HashMap<StorageKey, StorageValue>>;
crates/committer/src/patricia_merkle_tree/filled_tree/tree.rs
line 42 at r1 (raw file):
/// to a storage key and its serialized storage value. /// This function iterates over each node in the tree, using the node's `db_key` as the hashmap key /// and the result of the node's `serialize` method as the value.
please delete - no need to explain the implementation in the docstring.
Code quote:
/// Serializes the current state of the tree into a hashmap where each key-value pair corresponds
/// to a storage key and its serialized storage value.
/// This function iterates over each node in the tree, using the node's `db_key` as the hashmap key
/// and the result of the node's `serialize` method as the value.
crates/committer/src/patricia_merkle_tree/filled_tree/tree.rs
line 48 at r1 (raw file):
serialize_tree_map.insert(node.db_key(), node.serialize()); } serialize_tree_map
Code quote (i):
let mut serialize_tree_map: HashMap<StorageKey, StorageValue> = HashMap::new();
for (_node_index, node) in self.tree_map.iter() {
serialize_tree_map.insert(node.db_key(), node.serialize());
}
serialize_tree_map
Code snippet (ii):
self.get_all_nodes()
.iter()
.map(|(_, node)| (node.db_key(), node.serialize()))
.collect()
6413af5
to
23a959e
Compare
0184ff8
to
7a44f0d
Compare
d6f7eb9
to
8e9a49e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there is a separate PR for the first commit.
Reviewable status: 0 of 6 files reviewed, 4 unresolved discussions (waiting on @amosStarkware and @dorimedini-starkware)
crates/committer/src/patricia_merkle_tree/filled_tree/tree.rs
line 17 at r1 (raw file):
Previously, amosStarkware wrote…
Please add:
/// Serializes the tree and returns the resulting storage keys and values.
See below.
crates/committer/src/patricia_merkle_tree/filled_tree/tree.rs
line 17 at r1 (raw file):
pub(crate) trait FilledTree<L: LeafData> { #[allow(dead_code)] fn serialize(&self) -> HashMap<StorageKey, StorageValue>;
Why Result?
It's always successful.
crates/committer/src/patricia_merkle_tree/filled_tree/tree.rs
line 42 at r1 (raw file):
Previously, amosStarkware wrote…
please delete - no need to explain the implementation in the docstring.
Done.
crates/committer/src/patricia_merkle_tree/filled_tree/tree.rs
line 48 at r1 (raw file):
serialize_tree_map.insert(node.db_key(), node.serialize()); } serialize_tree_map
Done.
2aa06b9
to
d1a5e76
Compare
8e9a49e
to
55c75a9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 6 of 6 files at r4, all commit messages.
Reviewable status: all files reviewed, 6 unresolved discussions (waiting on @amosStarkware and @AvivYossef-starkware)
crates/committer/src/patricia_merkle_tree/filled_tree/tree.rs
line 190 at r4 (raw file):
} impl<L: LeafData + DBObject> FilledTree<L> for FilledTreeImpl<L> {
see comment in previous PR
Suggestion:
<L: LeafData>
crates/committer/src/patricia_merkle_tree/filled_tree/tree.rs
line 220 at r4 (raw file):
.iter() .map(|(_, node)| (node.get_db_key(&node.suffix()), node.serialize())) .collect::<HashMap<StorageKey, StorageValue>>()
are you sure you need the turbofish? compiler should know (return type)
Suggestion:
.collect()
2c6c42b
to
ddbdbce
Compare
55c75a9
to
2e06b90
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 2 of 6 files reviewed, 6 unresolved discussions (waiting on @amosStarkware and @dorimedini-starkware)
crates/committer/src/patricia_merkle_tree/filled_tree/tree.rs
line 190 at r4 (raw file):
Previously, dorimedini-starkware wrote…
see comment in previous PR
Done.
crates/committer/src/patricia_merkle_tree/filled_tree/tree.rs
line 220 at r4 (raw file):
Previously, dorimedini-starkware wrote…
are you sure you need the turbofish? compiler should know (return type)
Not needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 2 of 6 files at r4, 4 of 4 files at r5, all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @dorimedini-starkware)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed all commit messages.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on @AvivYossef-starkware)
This change is