-
Notifications
You must be signed in to change notification settings - Fork 0
feat: move leaf fetching logic to leaf data trait #160
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
feat: move leaf fetching logic to leaf data trait #160
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #160 +/- ##
==========================================
- Coverage 60.44% 60.44% -0.01%
==========================================
Files 35 35
Lines 1603 1613 +10
Branches 1603 1613 +10
==========================================
+ Hits 969 975 +6
- Misses 589 590 +1
- Partials 45 48 +3 ☔ View full report in Codecov by Sentry. |
db0254b
to
ee674c4
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 2 of 2 files at r3, all commit messages.
Reviewable status: all files reviewed, 4 unresolved discussions (waiting on @aner-starkware and @dorimedini-starkware)
crates/committer/src/patricia_merkle_tree/node_data/leaf.rs
line 22 at r3 (raw file):
// Use explicit desugaring of `async fn` to allow adding trait bounds to the return type, see // https://blog.rust-lang.org/2023/12/21/async-fn-rpit-in-traits.html#async-fn-in-public-traits // for details.
Suggestion:
/// Returns / computes the NodeData.
/// Use explicit desugaring of `async fn` to allow adding trait bounds to the return type, see
/// https://blog.rust-lang.org/2023/12/21/async-fn-rpit-in-traits.html#async-fn-in-public-traits
/// for details.
crates/committer/src/patricia_merkle_tree/node_data/leaf.rs
line 63 at r3 (raw file):
index: &NodeIndex, leaf_modifications: &LeafModifications<Self>, ) -> FilledTreeResult<NodeData<Self>, Self> {
Remove
Code quote:
FilledTreeResult
crates/committer/src/patricia_merkle_tree/node_data/leaf.rs
line 66 at r3 (raw file):
let leaf_data = leaf_modifications .get(index) .ok_or(FilledTreeError::<Self>::MissingDataForUpdate(*index))?
Need new errors and possible wrap them in the caller.
Suggestion:
LeafError::<Self>::MissingDataForUpdate(*index))?
crates/committer/src/patricia_merkle_tree/node_data/leaf.rs
line 69 at r3 (raw file):
.clone(); if leaf_data.is_empty() { return Err(FilledTreeError::<Self>::DeletedLeafInSkeleton(*index));
Suggestion:
(LeafError::<Self>::DeletedLeafInSkeleton(*index)
ee674c4
to
5a4a5e3
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: 0 of 4 files reviewed, 4 unresolved discussions (waiting on @aner-starkware and @TzahiTaub)
crates/committer/src/patricia_merkle_tree/node_data/leaf.rs
line 22 at r3 (raw file):
// Use explicit desugaring of `async fn` to allow adding trait bounds to the return type, see // https://blog.rust-lang.org/2023/12/21/async-fn-rpit-in-traits.html#async-fn-in-public-traits // for details.
this is not part of the docstring; it doesn't describe API, only explains an implementation detail
crates/committer/src/patricia_merkle_tree/node_data/leaf.rs
line 63 at r3 (raw file):
Previously, TzahiTaub (Tzahi) wrote…
Remove
Done.
crates/committer/src/patricia_merkle_tree/node_data/leaf.rs
line 66 at r3 (raw file):
Previously, TzahiTaub (Tzahi) wrote…
Need new errors and possible wrap them in the caller.
Done.
crates/committer/src/patricia_merkle_tree/node_data/leaf.rs
line 69 at r3 (raw file):
.clone(); if leaf_data.is_empty() { return Err(FilledTreeError::<Self>::DeletedLeafInSkeleton(*index));
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: all files reviewed, 2 unresolved discussions (waiting on @aner-starkware and @dorimedini-starkware)
crates/committer/src/patricia_merkle_tree/node_data/leaf.rs
line 66 at r3 (raw file):
Previously, dorimedini-starkware wrote…
Done.
Sorry, actually the name of the variants are still in the context of the fileedTree (what update? what skeleton? We are in a LeafData struct). Maybe switch to MissingLeafModificationData
and EmptyLeafInModifications
? You can keep the same name for the fileedTree transparency IMO.
crates/committer/src/patricia_merkle_tree/node_data/leaf.rs
line 16 at r4 (raw file):
fn is_empty(&self) -> bool; /// Creates a leaf.
Is this because of the possible future computations? Because get
seems better here (as if the index is missing in the map we'll get an error)
Code quote:
Creates a leaf.
5a4a5e3
to
052503f
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: all files reviewed, 1 unresolved discussion (waiting on @aner-starkware and @TzahiTaub)
crates/committer/src/patricia_merkle_tree/node_data/leaf.rs
line 66 at r3 (raw file):
Previously, TzahiTaub (Tzahi) wrote…
Sorry, actually the name of the variants are still in the context of the fileedTree (what update? what skeleton? We are in a LeafData struct). Maybe switch to
MissingLeafModificationData
andEmptyLeafInModifications
? You can keep the same name for the fileedTree transparency IMO.
Done.
crates/committer/src/patricia_merkle_tree/node_data/leaf.rs
line 16 at r4 (raw file):
Previously, TzahiTaub (Tzahi) wrote…
Is this because of the possible future computations? Because
get
seems better here (as if the index is missing in the map we'll get an error)
it's for the future, yes; IMO it's better that the API is clear from the start. create
sounds more like "this operation may be non-trivial" to me
052503f
to
28a4e66
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 4 of 4 files at r5, all commit messages.
Reviewable status: all files reviewed, 4 unresolved discussions (waiting on @aner-starkware and @dorimedini-starkware)
crates/committer/src/patricia_merkle_tree/filled_tree/errors.rs
line 10 at r5 (raw file):
pub enum FilledTreeError<L: LeafData> { #[error("Deleted leaf at index {0:?} appears in the updated skeleton tree.")] DeletedLeafInSkeleton(NodeIndex),
Revive error
Code quote:
#[error("Deleted leaf at index {0:?} appears in the updated skeleton tree.")]
DeletedLeafInSkeleton(NodeIndex),
crates/committer/src/patricia_merkle_tree/filled_tree/tree.rs
line 176 at r5 (raw file):
UpdatedSkeletonNode::Leaf => { let node_data = NodeData::Leaf(LeafDataImpl::create(&index, leaf_modifications).await?);
Return the previous code block
Suggestion:
let node_data =
NodeData::Leaf(LeafDataImpl::create(&index, leaf_modifications).await?);
if node_data.is_empty() {...FilledTreeError...
crates/committer/src/patricia_merkle_tree/node_data/errors.rs
line 19 at r5 (raw file):
pub enum LeafError { #[error("Deleted leaf at index {0:?} appears in the updated skeleton tree.")] EmptyLeafInModifications(NodeIndex),
See the below comments.
crates/committer/src/patricia_merkle_tree/node_data/leaf.rs
line 68 at r5 (raw file):
if leaf_data.is_empty() { return Err(LeafError::EmptyLeafInModifications(*index)); }
This isn't an error in this function, only in the context of appearing in as Leaf in the updated skeleton.
Signed-off-by: Dori Medini <dori@starkware.co>
28a4e66
to
8d36711
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: all files reviewed, 4 unresolved discussions (waiting on @aner-starkware and @TzahiTaub)
crates/committer/src/patricia_merkle_tree/filled_tree/errors.rs
line 10 at r5 (raw file):
Previously, TzahiTaub (Tzahi) wrote…
Revive error
Done.
crates/committer/src/patricia_merkle_tree/filled_tree/tree.rs
line 176 at r5 (raw file):
Previously, TzahiTaub (Tzahi) wrote…
Return the previous code block
Done.
crates/committer/src/patricia_merkle_tree/node_data/errors.rs
line 19 at r5 (raw file):
Previously, TzahiTaub (Tzahi) wrote…
See the below comments.
Done.
crates/committer/src/patricia_merkle_tree/node_data/leaf.rs
line 68 at r5 (raw file):
Previously, TzahiTaub (Tzahi) wrote…
This isn't an error in this function, only in the context of appearing in as Leaf in the updated skeleton.
ah, right you are, good catch!
moved things back a bit
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 r6, all commit messages.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on @aner-starkware)
This change is