-
Notifications
You must be signed in to change notification settings - Fork 65
starknet_committer,starknet_os,starknet_patricia: make node data generic #10679
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
base: ariel/add_deserialization_context
Are you sure you want to change the base?
Conversation
4cc3165 to
b6aa42e
Compare
cc7d63a to
0a489d1
Compare
0a489d1 to
d780fa0
Compare
b6aa42e to
0662437
Compare
d780fa0 to
de081a6
Compare
0662437 to
c7ceea5
Compare
c7ceea5 to
f9be917
Compare
de081a6 to
6d13cf1
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 16 of 16 files at r1, all commit messages.
Reviewable status: all files reviewed, 8 unresolved discussions (waiting on @ArielElp)
crates/starknet_patricia/src/patricia_merkle_tree/filled_tree/node.rs line 8 at r1 (raw file):
#[derive(Clone, Debug, PartialEq, Eq)] /// A node in a Patricia-Merkle tree, complete with its hash and data. pub struct FilledNode<L: Leaf> {
I'm guessing that this will be the next step here, right?
Suggestion:
pub struct FilledNode<L: Leaf, HashOutput>crates/starknet_patricia/src/patricia_merkle_tree/updated_skeleton_tree/hash_function.rs line 23 at r1 (raw file):
/// Computes the hash for the given node data. fn compute_node_hash(node_data: &NodeData<L, HashOutput>) -> HashOutput;
Same question in this file.
Suggestion:
fn compute_node_hash<T>(node_data: &NodeData<L, T>) -> HashOutput;crates/starknet_patricia/src/patricia_merkle_tree/internal_test_utils.rs line 27 at r1 (raw file):
} fn compute_node_hash(node_data: &NodeData<MockLeaf, HashOutput>) -> HashOutput {
Same question
Suggestion:
fn compute_node_hash<T>(node_data: &NodeData<MockLeaf, T>) -> HashOutput {crates/starknet_committer/src/hash_function/hash.rs line 54 at r1 (raw file):
)) } fn compute_node_hash(node_data: &NodeData<ContractState, HashOutput>) -> HashOutput {
Why does it work only for HashOutput type?
Same question below.
Suggestion:
fn compute_node_hash<T>(node_data: &NodeData<ContractState, T>) -> HashOutputcrates/starknet_patricia/src/patricia_merkle_tree/node_data/inner_node.rs line 22 at r1 (raw file):
#[cfg_attr(any(test, feature = "testing"), derive(strum_macros::EnumDiscriminants))] #[cfg_attr(any(test, feature = "testing"), strum_discriminants(derive(strum_macros::EnumIter)))] // A Patricia-Merkle tree node's data, i.e., the pre-image of its hash.
Is it correct?
Code quote:
// A Patricia-Merkle tree node's data, i.e., the pre-image of its hash.crates/starknet_patricia/src/patricia_merkle_tree/node_data/inner_node.rs line 39 at r1 (raw file):
vec![self.left_data.0, self.right_data.0] } }
Are you going to move it under facts_db?
If it is not in the next PR, please add TODO.
Code quote:
impl BinaryData<HashOutput> {
pub fn flatten(&self) -> Vec<Felt> {
vec![self.left_data.0, self.right_data.0]
}
}crates/starknet_patricia/src/patricia_merkle_tree/node_data/inner_node.rs line 157 at r1 (raw file):
] } }
Same question.
Code quote:
impl EdgeData<HashOutput> {
pub fn flatten(&self) -> Vec<Felt> {
vec![
self.path_to_bottom.length.into(),
(&self.path_to_bottom.path).into(),
self.bottom_data.0,
]
}
}crates/starknet_patricia/src/patricia_merkle_tree/node_data/inner_node.rs line 204 at r1 (raw file):
#[derive(Clone, Debug, PartialEq)] pub enum Preimage {
Is it relevant for both layers?
If not, please add a TODO for moving it under facts_db.
Code quote:
pub enum Preimage {6d13cf1 to
a185e9a
Compare
00cd7a5 to
560776a
Compare
a185e9a to
743c49b
Compare
e1719c0 to
1470e1e
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.
Reviewable status: 15 of 16 files reviewed, 8 unresolved discussions (waiting on @yoavGrs)
crates/starknet_committer/src/hash_function/hash.rs line 54 at r1 (raw file):
Previously, yoavGrs wrote…
Why does it work only for
HashOutputtype?
Same question below.
The hashing logic assumes a node carries the hash of its children, otherwise it can't compute the hash of the node. Even if this were generic you'd need some way to do T --> Hash.
This isn't really layout-dependent code.
crates/starknet_patricia/src/patricia_merkle_tree/internal_test_utils.rs line 27 at r1 (raw file):
Previously, yoavGrs wrote…
Same question
See above
crates/starknet_patricia/src/patricia_merkle_tree/filled_tree/node.rs line 8 at r1 (raw file):
Previously, yoavGrs wrote…
I'm guessing that this will be the next step here, right?
Sort of, the next step is to make it generic, FilledNode<L, ChildData>
crates/starknet_patricia/src/patricia_merkle_tree/node_data/inner_node.rs line 22 at r1 (raw file):
Previously, yoavGrs wrote…
Is it correct?
The second part is no longer correct, removing
crates/starknet_patricia/src/patricia_merkle_tree/node_data/inner_node.rs line 39 at r1 (raw file):
Previously, yoavGrs wrote…
Are you going to move it under
facts_db?
If it is not in the next PR, please add TODO.
ATM it's still there. There's some issues with moving it:
- It's used in Preimage and in the starknet_os crate. That's not really a blocker since we can move the entire Preimage logic, and starknet_os already depends on the committer
- We need BinaryData next to NodeData, so we'll need to add a flatten trait in starknet_patricia and make Preimage work on things that implement this trait (we can't impl directly for the type since the type is foreign in starknet_committer)
crates/starknet_patricia/src/patricia_merkle_tree/node_data/inner_node.rs line 157 at r1 (raw file):
Previously, yoavGrs wrote…
Same question.
See above
crates/starknet_patricia/src/patricia_merkle_tree/node_data/inner_node.rs line 204 at r1 (raw file):
Previously, yoavGrs wrote…
Is it relevant for both layers?
If not, please add a TODO for moving it underfacts_db.
Nope, we can move it modulo slight refactor to preimage. Added TODO
crates/starknet_patricia/src/patricia_merkle_tree/updated_skeleton_tree/hash_function.rs line 23 at r1 (raw file):
Previously, yoavGrs wrote…
Same question in this file.
See above
b50df9d to
d41c9d5
Compare
68f6987 to
2c6a229
Compare
ae7da9d to
17c75e3
Compare
2c6a229 to
85255e6
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 of 1 files at r2, all commit messages.
Reviewable status: all files reviewed, 8 unresolved discussions (waiting on @yoavGrs)
17c75e3 to
31faa1a
Compare
8d7c15c to
fd1d090
Compare
539461a to
ba38be7
Compare
71c89a6 to
c4727df
Compare
ba38be7 to
27a9372
Compare
c4727df to
c4c6e7b
Compare
27a9372 to
71f9ce7
Compare
c4c6e7b to
db10bd7
Compare
126e08c to
76dfba8
Compare
12afbd4 to
2732847
Compare
76dfba8 to
61ce00b
Compare
2732847 to
4cc4295
Compare

No description provided.