Fix bug with bitfield tree hash caching
This commit is contained in:
parent
dddcc91ef3
commit
d3309b9f7e
@ -287,14 +287,12 @@ mod tests {
|
||||
let mut hasher = cached_tree_hash::CachedTreeHasher::new(&original).unwrap();
|
||||
|
||||
assert_eq!(hasher.tree_hash_root().unwrap(), original.tree_hash_root());
|
||||
/*
|
||||
|
||||
let modified = BooleanBitfield::from_bytes(&vec![2; 1][..]);
|
||||
|
||||
hasher.update(&modified).unwrap();
|
||||
|
||||
assert_eq!(hasher.tree_hash_root().unwrap(), modified.tree_hash_root());
|
||||
*/
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -125,7 +125,8 @@ macro_rules! cached_tree_hash_bytes_as_list {
|
||||
}
|
||||
|
||||
fn tree_hash_cache_schema(&self, depth: usize) -> cached_tree_hash::BTreeSchema {
|
||||
cached_tree_hash::impls::vec::produce_schema(&ssz::ssz_encode(self), depth)
|
||||
let bytes = self.to_bytes();
|
||||
cached_tree_hash::impls::vec::produce_schema(&bytes, depth)
|
||||
}
|
||||
|
||||
fn update_tree_hash_cache(
|
||||
@ -145,7 +146,7 @@ macro_rules! cached_tree_hash_bytes_as_list {
|
||||
cache.mix_in_length(new_overlay.chunk_range(), bytes.len())?;
|
||||
|
||||
// Skip an extra node to clear the length node.
|
||||
cache.chunk_index = new_overlay.next_node() + 1;
|
||||
cache.chunk_index += 1;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
@ -88,6 +88,7 @@ pub fn subtree_derive(input: TokenStream) -> TokenStream {
|
||||
fn update_tree_hash_cache(&self, cache: &mut cached_tree_hash::TreeHashCache) -> Result<(), cached_tree_hash::Error> {
|
||||
let overlay = cached_tree_hash::BTreeOverlay::new(self, cache.chunk_index, 0);
|
||||
|
||||
|
||||
// Skip the chunk index to the first leaf node of this struct.
|
||||
cache.chunk_index = overlay.first_leaf_node();
|
||||
// Skip the overlay index to the first leaf node of this struct.
|
||||
|
Loading…
Reference in New Issue
Block a user