Skip to content
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

Handle Extension-nodes in Iterator #430

Merged
merged 10 commits into from
Dec 15, 2023
Merged

Handle Extension-nodes in Iterator #430

merged 10 commits into from
Dec 15, 2023

Conversation

richardpringle
Copy link
Contributor

  • Move MerkleStream to submodule
  • Make MerkleStream handle branches with values
  • Stop prefetching next node in iterator

Copy link
Collaborator

@rkuris rkuris left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Partial review

firewood/src/merkle/stream.rs Outdated Show resolved Hide resolved
firewood/src/merkle/stream.rs Show resolved Hide resolved
Copy link
Collaborator

@rkuris rkuris left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still need to review the algorithm more, but I added a few questions in the meantime.

firewood/src/merkle/stream.rs Outdated Show resolved Hide resolved
firewood/src/merkle/stream.rs Outdated Show resolved Hide resolved
firewood/src/merkle/stream.rs Outdated Show resolved Hide resolved
Copy link
Collaborator

@rkuris rkuris left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Round 2 of questions

firewood/src/merkle/stream.rs Outdated Show resolved Hide resolved
firewood/src/merkle/stream.rs Outdated Show resolved Hide resolved
firewood/src/merkle/stream.rs Show resolved Hide resolved
firewood/src/merkle/stream.rs Show resolved Hide resolved
firewood/src/merkle/stream.rs Show resolved Hide resolved
firewood/src/merkle/stream.rs Show resolved Hide resolved
firewood/src/merkle/stream.rs Outdated Show resolved Hide resolved
firewood/src/merkle/stream.rs Show resolved Hide resolved
firewood/src/merkle/stream.rs Outdated Show resolved Hide resolved
firewood/src/merkle/stream.rs Outdated Show resolved Hide resolved
@richardpringle richardpringle marked this pull request as ready for review December 14, 2023 21:43
.map_err(|e| api::Error::InternalError(Box::new(e)))
start_key: Box<[u8]>,
) -> merkle::MerkleKeyValueStream<'_, S, Bincode> {
self.merkle.iter_from(self.header.kv_root, start_key)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a significant improvement to the API. It was such a pain specifying the type on the None when it could be any number of things. It's too bad there's no default generic, like with structs and enums.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, I like that.

@@ -1264,7 +1265,7 @@ impl<S: ShaleStore<Node> + Send + Sync, T> Merkle<S, T> {
.map_err(|e| api::Error::InternalError(Box::new(e)))?;
let limit = limit.map(|old_limit| old_limit - 1);

let mut middle = vec![(first_key, first_data)];
let mut middle = vec![(first_key.into_vec(), first_data)];
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wasn't sure about this, but we can change it later. into_vec does not allocate.

Copy link
Contributor

@xinifinity xinifinity left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My review was mostly focus on the algorithm and the test cases coverage and all comments are nits that can be ignored or addressed in a follow up.

.map_err(|e| api::Error::InternalError(Box::new(e)))
start_key: Box<[u8]>,
) -> merkle::MerkleKeyValueStream<'_, S, Bincode> {
self.merkle.iter_from(self.header.kv_root, start_key)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, I like that.

}

#[tokio::test]
async fn start_at_key_greater_than_all_others() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks a lot for the thorough test lists! On top of that may be start_at_key_smaller_than_all_others ? I guess this may be already covered, but just to make it explicitly covered.

}

enum NodeRef<'a> {
New(ObjRef<'a>),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❤️

Ok(next)
}

fn find_next_node_with_data<'a, S: ShaleStore<Node>, T>(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: as the core function, I feel it deserves some high level comments describe how things work.

@rkuris rkuris self-requested a review December 15, 2023 19:35
Copy link
Collaborator

@rkuris rkuris left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing "requested changes" status. Hao has completed the review here.

@richardpringle richardpringle merged commit 17e53d2 into main Dec 15, 2023
5 checks passed
@richardpringle richardpringle deleted the move-merkle-stream branch December 15, 2023 20:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants