-
Notifications
You must be signed in to change notification settings - Fork 16
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
Add support for tracking legacy frontiers and witnesses in ShardTree
instances.
#69
Conversation
390fa2b
to
9510fc9
Compare
d9e51bd
to
2dbdd34
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.
/// allowed depth or if the list of ommers provided is not consistent | ||
/// with the position of the leaf. | ||
/// Returns `None` if the new frontier would exceed the maximum allowed depth or if the list of | ||
/// ommers provided is not consistent with the position of the leaf. |
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.
[Non-blocking future nice-to-have:] I wish we had automated tooling for comment whitespace formatting and could then compartmentalize all such changes in a single tool-generated commit. Without that I had to spend a couple seconds squinting to see if there was a substantial change here. Not a big deal, but a tiny context switching cost.
fn from(err: InsertionError) -> Self { | ||
ShardTreeError::Insert(err) | ||
} | ||
} |
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.
In my personal code, I make heavy use of "boiler-plate removal" dependencies. In this case derive_more
crate enables #[derive(derive_more::From)]
on enums that remove this boilerplate. Do we have a policy for or against such crates?
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.
I just checked that derive_more::From
can be instructed to ignore the ::Storage
variant (which would otherwise attempt an incoherent blanket impl).
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.
utACK 4732ea6 (modulo conflicts).
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.
utACK - Reviewed the remaining commits that I didn't cover last week.
1ae6fc3
to
e57c252
Compare
ACK w/ local |
The cap is a truncated tree that can be used to cache precomputed subtree roots at tree heights greater than `SHARD_HEIGHT`. Only roots whose hashes cannot be altered by rewinds or by the addition of data to the tree may be persisted to the cap.
This introduces a `ShardTreeError` type that is used to wrap errors that arise from the undelying `ShardStore` when used in `ShardTree` methods. The previous approach that relied on `From<QueryError> + From<InsertionError>` bounds resulted in a situation where the shard store error was forced to encompass the bounds of these types, even though the methods on the `ShardStore` itself could never generate them. This resulted in a number of awkward problems for error conversion.
@daira @nathan-at-least here are the changes since your previous approvals; these are substantial enough to require a re-review if you don't mind. |
incrementalmerkletree/Cargo.toml
Outdated
legacy-api = [] | ||
# The test-depenencies feature guards types and functions that are |
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.
# The test-depenencies feature guards types and functions that are | |
# The test-dependencies feature guards types and functions that are |
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.
utACK, but I did not review new logic with any thoroughness (so this should not be merged based on my review alone).
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.
utACK accb8d7 (single commit; caveats about thoroughness of my previous review still apply).
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.
I've reviewed all of the changes not inside shardtree/src/lib.rs
. I'm partway through reading that file, and it's proving extensive enough I'm gonna break it off into its own review.
A note on terminology: The standard lingo in use here is that the root of the tree is the most-ancestral node. Each non-root node has one parent, and each non-leaf node has two children. Intuitively (from the genetic meaning of the word ancestor), the leaves would be ancestors, and two nodes would be hashed together to create a child node. Hashing two nodes together to create the ancestor of those nodes is the opposite what I expect the term 'ancestor' to mean.
I don't think this is something that could (or should) be changed, as flipping the meaning of already established terms would just cause more confusion. Maybe it could be better clarified somewhere?
Edit: The terms ancestor/child is going to get more and more baked in...but as the codebase stands, there's only a few instances of the terms. I don't think the terms have crystallized yet, and I think it would be more intuitive to flip them before they're too baked into the vocabulary.
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.
utACK, this looks great. I'm not sure to draw the line between a long review process where my end result is three sentences, but it's that or add another dozen comments saying "This bit took me a long time to grok but seems correct"
Hi! It also seems to me that this use of word I proposed some commits that would refine terminology and replace Since that proposal changes the public API I |
The reason that |
/// Returns `None` if the new frontier would exceed the maximum | ||
/// allowed depth or if the list of ommers provided is not consistent | ||
/// with the position of the leaf. | ||
/// Returns `None` if the new frontier would exceed the maximum allowed depth or if the list of |
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.
This returns Err
, not None
, in the failure case.
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.
fixed in 701d3e6
incrementalmerkletree/src/lib.rs
Outdated
/// Returns whether this address is the right-hand child of its parent | ||
pub fn is_left_child(&self) -> bool { |
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.
This should say left-hand child.
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.
Fixed in 701d3e6
incrementalmerkletree/src/witness.rs
Outdated
} | ||
}) | ||
.take(self.filled.len()) | ||
.fold(0u64, |acc, addr| acc + 2u64.pow(addr.level().into())); |
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.
nonblocking nit: acc + (1u64 << addr.level().into())
might be more consistent with the other arithmetic in these crates.
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.
Fixed in 701d3e6
Tree::leaf((right.clone(), RetentionFlags::EPHEMERAL)), | ||
); | ||
} else { | ||
break; |
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.
Tests don't appear to be exercising this scenario.
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.
Fixed in 082109d
subtree = | ||
Tree::parent(None, Tree::leaf((left, RetentionFlags::EPHEMERAL)), subtree); | ||
} else { | ||
break; |
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.
Tests don't appear to be exercising this scenario.
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.
Fixed in 082109d
Yeah, I suspected as much. I find it extremely confusing for merkle trees, but I'll accept that it's a lesser confusion than using terms opposite to everyone else. |
No description provided.