-
Notifications
You must be signed in to change notification settings - Fork 1
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
refactor: remove dependency between storage and starknet prefix #308
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #308 +/- ##
==========================================
- Coverage 70.59% 70.54% -0.06%
==========================================
Files 38 38
Lines 2095 2091 -4
Branches 2095 2091 -4
==========================================
- Hits 1479 1475 -4
Misses 546 546
Partials 70 70 ☔ 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.
Reviewed all commit messages.
Reviewable status: 0 of 7 files reviewed, 1 unresolved discussion (waiting on @AvivYossef-starkware)
crates/committer/src/patricia_merkle_tree/node_data/leaf_serde.rs
line 40 at r1 (raw file):
StarknetPrefix::CompiledClassLeaf.to_storage_prefix() } }
I suggest you give a better return type than Vec<u8>
in get_prefix
, how about this?
(trait definition shouldn't be here, obviously, but this is my idea)
Suggestion:
#[cfg(test)]
#[path = "leaf_serde_test.rs"]
pub mod leaf_serde_test;
pub trait StoragePrefix {
fn to_bytes(&self) -> Vec<u8>;
}
impl StoragePrefix for StarknetPrefix {
...
}
impl DBObject for StarknetStorageValue {
/// Serializes the value into a 32-byte vector.
fn serialize(&self) -> StorageValue {
StorageValue(self.0.to_bytes_be().to_vec())
}
fn get_prefix(&self) -> impl StoragePrefix {
StarknetPrefix::StorageLeaf
}
}
impl DBObject for CompiledClassHash {
/// Creates a json string describing the leaf and casts it into a byte vector.
fn serialize(&self) -> StorageValue {
let json_string = format!(r#"{{"compiled_class_hash": "{}"}}"#, self.0.to_hex());
StorageValue(json_string.into_bytes())
}
fn get_prefix(&self) -> impl StoragePrefix {
StarknetPrefix::CompiledClassLeaf
}
}
e7a9884
to
64f9a1b
Compare
This stack of pull requests is managed by Graphite. Learn more about stacking. Join @AvivYossef-starkware and the rest of your teammates on Graphite |
64f9a1b
to
9658446
Compare
Benchmark movements: |
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 7 files at r1, 4 of 4 files at r2, 1 of 1 files at r3, all commit messages.
Reviewable status: all files reviewed, 5 unresolved discussions (waiting on @AvivYossef-starkware)
crates/committer/src/patricia_merkle_tree/original_skeleton_tree/create_tree.rs
line 238 at r3 (raw file):
L::prefix() } else { StarknetPrefix::InnerNode.to_storage_prefix()
is calculate_subtree_roots
part of the future patricia crate?
if so, how will this work without the StarknetPrefix (starknet implementation detail)?
please add a TODO about it if you're still unsure, out of scope of the current PR anyway
Code quote:
StarknetPrefix::InnerNode.to_storage_prefix()
crates/committer/src/storage/db_object.rs
line 9 at r3 (raw file):
/// Returns the storage key prefix of the DB object. fn get_prefix(&self) -> Vec<u8>;
Suggestion:
// TODO(Aviv, 1/8/2024): Define a trait `T` for storage prefix and return `impl T` here.
fn get_prefix(&self) -> Vec<u8>;
crates/committer/src/storage/db_object.rs
line 22 at r3 (raw file):
/// The prefix used to store in DB. fn prefix() -> Vec<u8>;
Suggestion:
/// The prefix used to store in DB.
// TODO(Aviv, 1/8/2024): Define a trait `T` for storage prefix and return `impl T` here.
fn prefix() -> Vec<u8>;
crates/committer/src/storage/errors.rs
line 33 at r3 (raw file):
PathToBottomError(#[from] PathToBottomError), #[error("Unexpected prefix ({0:?}) variant when deserializing a leaf.")] LeafPrefixError(Vec<u8>),
Suggestion:
#[error("Unexpected prefix ({0:?}) variant when deserializing a leaf.")]
// TODO(Aviv, 1/8/2024): Define a trait `T` for storage prefix and return `impl T` here.
LeafPrefixError(Vec<u8>),
crates/committer/src/storage/storage_trait.rs
line 33 at r3 (raw file):
} // TODO(Aviv, 17/07/2024); Split between Storage and node specific implementation.
Suggestion:
// TODO(Aviv, 17/07/2024); Split between Storage prefix representation (trait) and node
// specific implementation (enum).
9658446
to
0b1ec9d
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: 3 of 7 files reviewed, 5 unresolved discussions (waiting on @dorimedini-starkware)
crates/committer/src/patricia_merkle_tree/original_skeleton_tree/create_tree.rs
line 238 at r3 (raw file):
Previously, dorimedini-starkware wrote…
is
calculate_subtree_roots
part of the future patricia crate?
if so, how will this work without the StarknetPrefix (starknet implementation detail)?
please add a TODO about it if you're still unsure, out of scope of the current PR anyway
calculate_subtree_root is part of the committer logic. It uses StarknetPrefix only for the inner node. It should depend on the storage, as we discussed today.
I add TODO
Code snippet:
fn calculate_subtrees_roots<L: Leaf>(
subtrees: &[SubTree<'a>],
storage: &impl Storage,
) -> OriginalSkeletonTreeResult<Vec<FilledNode<L>>> {
crates/committer/src/storage/db_object.rs
line 9 at r3 (raw file):
/// Returns the storage key prefix of the DB object. fn get_prefix(&self) -> Vec<u8>;
Done.
crates/committer/src/storage/db_object.rs
line 22 at r3 (raw file):
/// The prefix used to store in DB. fn prefix() -> Vec<u8>;
Done.
crates/committer/src/storage/errors.rs
line 33 at r3 (raw file):
PathToBottomError(#[from] PathToBottomError), #[error("Unexpected prefix ({0:?}) variant when deserializing a leaf.")] LeafPrefixError(Vec<u8>),
Done.
crates/committer/src/storage/storage_trait.rs
line 33 at r3 (raw file):
} // TODO(Aviv, 17/07/2024); Split between Storage and node specific implementation.
Done.
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 4 of 4 files at r4, all commit messages.
Reviewable status: complete! all files reviewed, all discussions resolved (waiting on @AvivYossef-starkware)
Merge activity
|
This change is