-
Notifications
You must be signed in to change notification settings - Fork 35
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
Optimized azks #189
Optimized azks #189
Conversation
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.
Some nits to consider. @eozturk1 are we waiting on @Jasleen1 or @kevinlewi to give it a process pass to see if you're on the right track? There's obviously some clippy and rustfmt
issues, but functionally it makes sense to me I think.
akd/src/history_tree_node.rs
Outdated
use async_recursion::async_recursion; | ||
use log::debug; | ||
use std::convert::TryInto; | ||
use std::marker::{Send, Sync}; | ||
use winter_crypto::Hasher; | ||
use winter_crypto::{Hasher}; |
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.
nit ::Hasher
Err(AkdError::HistoryTreeNode(HistoryTreeNodeError::NoChildAtEpoch(epoch, dir_leaf.unwrap()))) | ||
} | ||
}; | ||
result |
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.
nit: if you're just returning result, can you just remove the variable assignment? I.e.
match child_node {
...
}
without the let result = match child_node {...}; result
akd/src/history_tree_node.rs
Outdated
self.get_value::<_, H>(storage).await?, | ||
let mut leaf_hash = H::hash(&self.hash); | ||
leaf_hash = H::merge(&[ | ||
leaf_hash, |
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.
nit: instead of a mut, with multiple assignments can we just do
let leaf_hash = H::merge(&[
H::hash(&self.hash),
hash_label::<H>(self.label),
]);
akd/src/history_tree_node.rs
Outdated
} | ||
Err(e) => Err(AkdError::Storage(e)), | ||
} else { | ||
panic!("Unknown child index or None."); |
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.
hmmm. I think we're trying to avoid Panic's. Is this something that can never happen? We should then not pass in an optional, or if it could happen return Err
akd/src/history_tree_node.rs
Outdated
for child in children.iter().take(ARITY) { | ||
let hash_val = optional_history_child_state_to_hash::<H>(child); | ||
new_hash = H::merge(&[new_hash, to_digest::<H>(&hash_val)?]); | ||
// pub(crate) async fn get_value_without_label_at_epoch<S: Storage + Sync + Send, H: Hasher>( |
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.
nit: is this to be resurrected at some point or just no longer needed? delete it if the latter?
} else if dir == Some(1) { | ||
child_label_to_ret = self.right_child; | ||
} else { | ||
panic!("No child with that index!"); |
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.
nit: as before in another spot, are there better options than panic's?
SummaryThis PR so far has removed the need for storing states-per-epoch and revised the Important Changes
Next Steps:
Improvements
|
I have disabled the failing tests and updated the next steps to list those tests. |
* Optimized azks (#189) * Add left and right child for tree node * Add hash to HistoryTreeNode * Update set/get child * Update hash at parent * Update hashes in the tree * Add epoch to set_child for updating last updated epoch * Remove unnecessary last epoch update (already done in set_child) * Enable higher level tests * Update and pass leaf insertion tests * Pass tree insertion tests * Remove commented out HistoryTreeNode tests * Remove commented out unused functions * Remove printlns * Remove printlns from AZKS * Remove storage from function when not needed * Fix warnings for cargo build and test * Remove HistoryNodeState and HistoryChildState * Remove get_epoch_lte_epoch * Remove HistoryNodeState and HistoryChildState from storage layer * Remove get_epoch_lte_epoch usage * Format * Fix clippy warnings * Remove birth_epoch * Disable tests to merge * Remove needless question mark * Disable mysql tests * Disable test_mysql_db test * Fixed membership and intermediate membership tests * Fixed non membership tests * WIP: Fixed key history for optimization * WIP: Minor bug fixes in key history and updated client to match * WIP: removed epochs from leaf stored hash * WIP: Updated audit to match ozks, all but read during publish tests passing * Minor cleanup * Added more testing for #144 * Changed HistoryTreeNode to TreeNode * Uncommented previously commented tests * Addressed nits * Removed allow dead code from passing tests * Removed HistoryTreeNode references, replaced with TreeNode * Re-ran linting * Re-ran linting * Re-ran linting * Removed birth ep from being read for mysql TreeNode * Removed birth ep from being read for mysql TreeNode everywhere * mysql error due to possibly null children for a TreeNode * Allowing nul for children in mysql -- not working * Fixing the MySQL db layer * All tests passing + ran linting * Fixed descendent spelling * Reran linting * Addressing review comments Co-authored-by: Ercan Ozturk <eoz@fb.com> Co-authored-by: Harjasleen Malvai <hmalvai@fb.com> Co-authored-by: Sean Lawlor <seanlawlor@fb.com>
See Issue #186.
With the removal of previous states of
HistoryTreeNode
, we don't have a need for keeping states for multiple epochs. In result,HistoryTreeNode
,HistoryNodeState
andHistoryChildState
can simply be replaced withTreeNode
.This diff starts this conversion by adding the labels of its (1) left and right children, and (2) its hash to the
HistoryTreeNode
(not yet re-named). Actual hash updates will be added in the next diffs. Rather than keeping the node hashes at the parent, I will keep them at the node itself.NOTE: The PR builds with
cargo build
but not ready for testing. The purpose of the PR is to "get it out there" to get feedback rather than merging it.