-
Notifications
You must be signed in to change notification settings - Fork 65
starknet_committer,starknet_committer_and_os_cli,starknet_patricia: layout dependent fetch_nodes #10680
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
4cc3165 to
b6aa42e
Compare
021132a to
466fffe
Compare
466fffe to
b4ed9c6
Compare
b6aa42e to
0662437
Compare
b4ed9c6 to
c700f80
Compare
c7ceea5 to
f9be917
Compare
c700f80 to
745b6d9
Compare
745b6d9 to
d1214e3
Compare
00cd7a5 to
560776a
Compare
d1214e3 to
a4c64e9
Compare
560776a to
e1719c0
Compare
a4c64e9 to
ad38e50
Compare
ad38e50 to
b24fb64
Compare
e1719c0 to
68f6987
Compare
b24fb64 to
71c316b
Compare
yoavGrs
left a comment
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.
@yoavGrs reviewed 2 files and all commit messages, made 2 comments, and resolved 4 discussions.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @ArielElp and @nimrod-starkware).
crates/starknet_committer/src/db/facts_db/create_facts_tree.rs line 273 at r9 (raw file):
Previously, ArielElp wrote…
Diverged even further, ptal at handle_unmodified_subtree
I missed the meaning of the call to get_bottom_subtree.
I guess this function is non-trivial and involves heavy computation as well.
crates/starknet_committer/src/db/facts_db/create_facts_tree.rs line 262 at r12 (raw file):
if let NodeData::Edge(EdgeData { bottom_data, path_to_bottom }) = filled_root.data { // Even if a subtree rooted at an edge node is umodified, we still need an
Suggestion:
unmodified
yoavGrs
left a comment
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.
@yoavGrs made 1 comment and resolved 1 discussion.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @ArielElp and @nimrod-starkware).
crates/starknet_committer/src/db/facts_db/create_facts_tree.rs line 262 at r12 (raw file):
if let NodeData::Edge(EdgeData { bottom_data, path_to_bottom }) = filled_root.data { // Even if a subtree rooted at an edge node is umodified, we still need an
Edge case :)
nimrod-starkware
left a comment
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.
@nimrod-starkware reviewed all commit messages, made 1 comment, and resolved 1 discussion.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @ArielElp).
ca4aa2b to
f08a6b1
Compare
nimrod-starkware
left a comment
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.
please open py side
@nimrod-starkware made 1 comment.
Reviewable status: 13 of 14 files reviewed, 2 unresolved discussions (waiting on @ArielElp, @dorimedini-starkware, and @yoavGrs).
dorimedini-starkware
left a comment
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.
yes, py side please :)
@dorimedini-starkware reviewed 5 files and all commit messages, and made 8 comments.
Reviewable status: all files reviewed, 8 unresolved discussions (waiting on @ArielElp).
crates/starknet_committer/src/db/facts_db/db.rs line 46 at r13 (raw file):
use crate::patricia_merkle_tree::types::CompiledClassHash; pub struct FactsNodeLayout {}
docstring describing the storage scheme in high-level?
or is there a more natural location for this doc?
Code quote:
pub struct FactsNodeLayout {}crates/starknet_committer/src/db/facts_db/create_facts_tree.rs line 64 at r13 (raw file):
L: Leaf, Layout: NodeLayout<'a, L>, FilledNode<L, Layout::NodeData>: DBObject<DeserializeContext = Layout::DeserializationContext>,
hmmmm don't you have
impl<L: Leaf, Layout: NodeLayout> DBObject<DeserializeContext = Layout::DeserializationContext> for FilledNode<L, Layout::NodeData>
that prevents the need for this bound?
Code quote:
FilledNode<L, Layout::NodeData>: DBObject<DeserializeContext = Layout::DeserializationContext>crates/starknet_committer/src/db/facts_db/create_facts_tree.rs line 70 at r13 (raw file):
let should_fetch_modified_leaves = config.compare_modified_leaves() || previous_leaves.is_some(); while !current_subtrees.is_empty() {
this swap is technically a logic change that should be in a separate PR, because I had to scan to make sure that previous_leaves is not mutated inside the loop. I see it isn't, so ok, but try to keep this in mind when creating PRs
Code quote:
let should_fetch_modified_leaves =
config.compare_modified_leaves() || previous_leaves.is_some();
while !current_subtrees.is_empty() {crates/starknet_committer/src/db/facts_db/create_facts_tree.rs line 254 at r13 (raw file):
subtree: SubTree, ) where SubTree::NodeData: Copy,
please be explicit when a copy is needed
Suggestion:
SubTree::NodeData: Clone,crates/starknet_committer/src/db/facts_db/create_facts_tree.rs line 282 at r13 (raw file):
.nodes .insert(root_index, OriginalSkeletonNode::UnmodifiedSubTree(filled_root.hash)); }
- please use an explicit
matchon the three options offilled_root.data, instead ofif let .. else - previously, an unmodified leaf just triggered a warning; now, you seem to be pushing it to the skeleton tree. why?
Code quote:
if let NodeData::Edge(EdgeData { bottom_data, path_to_bottom }) = filled_root.data {
// Even if a subtree rooted at an edge node is unmodified, we still need an
// `OriginalSkeletonNode::Edge` node in the skeleton in case we need to manipulate it later
// (e.g. unify the edge node with an ancestor edge node).
skeleton_tree.nodes.insert(root_index, OriginalSkeletonNode::Edge(path_to_bottom));
match SubTree::should_traverse_unmodified_child(bottom_data) {
UnmodifiedChildTraversal::Traverse => {
let (bottom_subtree, _) = subtree.get_bottom_subtree(&path_to_bottom, bottom_data);
next_subtrees.push(bottom_subtree);
}
UnmodifiedChildTraversal::Skip(unmodified_child_hash) => {
skeleton_tree.nodes.insert(
path_to_bottom.bottom_index(root_index),
OriginalSkeletonNode::UnmodifiedSubTree(unmodified_child_hash),
);
}
}
} else {
skeleton_tree
.nodes
.insert(root_index, OriginalSkeletonNode::UnmodifiedSubTree(filled_root.hash));
}crates/starknet_committer/src/db/facts_db/create_facts_tree.rs line 295 at r13 (raw file):
) { let is_leaf = subtree.is_leaf(); let is_modified = !subtree.is_unmodified();
are either of these used more than once? seems like a redundant definition
Code quote:
let is_leaf = subtree.is_leaf();
let is_modified = !subtree.is_unmodified();crates/starknet_committer/src/db/facts_db/create_facts_tree.rs line 309 at r13 (raw file):
} return; }
this entire block of logic is basically equivalent to the if we had before - please revert the "unrolling" so it's easier to see the diff
Suggestion:
let is_modified = !subtree.is_unmodified();
if !subtree.is_leaf() || (should_fetch_modified_leaves && is_modified) {
next_subtrees.push(subtree);
} else if !is_modified {
match SubTree..
}
ArielElp
left a comment
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.
@ArielElp made 6 comments and resolved 2 discussions.
Reviewable status: all files reviewed, 6 unresolved discussions (waiting on @dorimedini-starkware).
crates/starknet_committer/src/db/facts_db/create_facts_tree.rs line 64 at r13 (raw file):
Previously, dorimedini-starkware wrote…
hmmmm don't you have
impl<L: Leaf, Layout: NodeLayout> DBObject<DeserializeContext = Layout::DeserializationContext> for FilledNode<L, Layout::NodeData>that prevents the need for this bound?
There is a constraint on the layout trait, hence using it requires satisfying the constraint here.
FWIW, the FilledTree part of the stack adds an associated NodeDbObject: DbObject to the layout trait, so these requirements may be unnecessary then.
crates/starknet_committer/src/db/facts_db/create_facts_tree.rs line 254 at r13 (raw file):
Previously, dorimedini-starkware wrote…
please be explicit when a copy is needed
WDYM?
Clone indeed allows more freedom, but in practice our types here are () and HashOutput, both copyable. If I require Clone, then bottom_data will need to be cloned in:
match SubTree::should_traverse_unmodified_child(bottom_data.clone()) {
crates/starknet_committer/src/db/facts_db/create_facts_tree.rs line 282 at r13 (raw file):
Previously, dorimedini-starkware wrote…
- please use an explicit
matchon the three options offilled_root.data, instead ofif let .. else- previously, an unmodified leaf just triggered a warning; now, you seem to be pushing it to the skeleton tree. why?
- Done
- This is related to the last case of handle_child_subtree.
Before: an unmodified leaf was always added to the skeleton upon encountering its parent, it was never traversed itself (hence the "unexpected" warning)
Now: when we traverse unmodified children, we will go through this leaf in the main loop, so it's no longer unexpected.
crates/starknet_committer/src/db/facts_db/create_facts_tree.rs line 295 at r13 (raw file):
Previously, dorimedini-starkware wrote…
are either of these used more than once? seems like a redundant definition
No, they're there for clarity
is_modified was Yoav's suggestion IIRC to make the control flow more clear. IMO it does make it more clear (no "not unmodified" in the if condition).
is_leaf is less important so removed
crates/starknet_committer/src/db/facts_db/create_facts_tree.rs line 309 at r13 (raw file):
Previously, dorimedini-starkware wrote…
this entire block of logic is basically equivalent to the
ifwe had before - please revert the "unrolling" so it's easier to see the diff
Slight pushback: I think the control flow is much clearer now
Internal --> traverse
Modified --> if should_fetch_modified_leaves then traverse
Unmodified --> new logic
crates/starknet_committer/src/db/facts_db/db.rs line 46 at r13 (raw file):
Previously, dorimedini-starkware wrote…
docstring describing the storage scheme in high-level?
or is there a more natural location for this doc?
Done, this is probably the most reasonable place
ArielElp
left a comment
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.
python side successful
https://github.com/starkware-industries/starkware/pull/39782
@ArielElp made 1 comment.
Reviewable status: all files reviewed, 6 unresolved discussions (waiting on @dorimedini-starkware).
f08a6b1 to
7851196
Compare
dorimedini-starkware
left a comment
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.
WOOP!
@dorimedini-starkware reviewed 2 files and all commit messages, made 3 comments, and resolved 5 discussions.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @ArielElp).
crates/starknet_committer/src/db/facts_db/create_facts_tree.rs line 254 at r13 (raw file):
Previously, ArielElp wrote…
WDYM?
Clone indeed allows more freedom, but in practice our types here are () and HashOutput, both copyable. If I require Clone, then bottom_data will need to be cloned in:
match SubTree::should_traverse_unmodified_child(bottom_data.clone()) {
that's good IMO, it's the same just explicit; when data is copied I'd like to know
crates/starknet_committer/src/db/facts_db/create_facts_tree.rs line 309 at r13 (raw file):
Previously, ArielElp wrote…
Slight pushback: I think the control flow is much clearer now
Internal --> traverse
Modified --> if should_fetch_modified_leaves then traverse
Unmodified --> new logic
kibalti
7851196 to
97e5941
Compare
ArielElp
left a comment
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.
@ArielElp made 1 comment.
Reviewable status: 12 of 14 files reviewed, 1 unresolved discussion (waiting on @dorimedini-starkware and @yoavGrs).
crates/starknet_committer/src/db/facts_db/create_facts_tree.rs line 254 at r13 (raw file):
Previously, dorimedini-starkware wrote…
that's good IMO, it's the same just explicit; when data is copied I'd like to know
Done, note that I also changed the constraint in the layout so there are a couple more clones in this file.
dorimedini-starkware
left a comment
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.
@dorimedini-starkware reviewed 2 files and all commit messages, and resolved 1 discussion.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on @ArielElp).
dorimedini-starkware
left a comment
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.
@dorimedini-starkware made 1 comment.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on @ArielElp).
97e5941 to
a49bbd1
Compare
nimrod-starkware
left a comment
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.
@nimrod-starkware reviewed 1 file and all commit messages, and made 1 comment.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on @ArielElp).
dorimedini-starkware
left a comment
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.
@dorimedini-starkware reviewed 1 file and all commit messages.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on @ArielElp).

No description provided.