Skip to content

Commit

Permalink
[scratchpad] bug fix: branchtracker.next was not properly initialized
Browse files Browse the repository at this point in the history
  • Loading branch information
msmouse authored and aptos-bot committed Mar 31, 2022
1 parent 624a6ae commit 97facf4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion storage/scratchpad/src/sparse_merkle/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,12 @@ impl<V> Inner<V> {
let mut links_locked = self.links.lock();

let child = if links_locked.children.is_empty() {
self.spawn_impl(child_root, links_locked.branch_tracker.clone())
let child = self.spawn_impl(child_root, links_locked.branch_tracker.clone());
let mut branch_tracker_locked = links_locked.branch_tracker.lock();
if branch_tracker_locked.next.upgrade().is_none() {
branch_tracker_locked.next = Arc::downgrade(&child);
}
child
} else {
// forking a new branch
let branch_tracker =
Expand Down
2 changes: 1 addition & 1 deletion storage/scratchpad/src/sparse_merkle/sparse_merkle_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ static VALUE: Lazy<AccountStateBlob> = Lazy::new(|| AccountStateBlob::from(b"val
static LEAF: Lazy<SparseMerkleLeafNode> =
Lazy::new(|| SparseMerkleLeafNode::new(*KEY, VALUE.hash()));
static PROOF_READER: Lazy<ProofReader<AccountStateBlob>> = Lazy::new(|| {
let proof = SparseMerkleProof::new(Some(LEAF.clone()), vec![]);
let proof = SparseMerkleProof::new(Some(*LEAF), vec![]);
ProofReader::new(vec![(*KEY, proof)])
});

Expand Down

0 comments on commit 97facf4

Please sign in to comment.