mirror of
https://github.com/0glabs/0g-storage-node.git
synced 2024-11-20 15:05:19 +00:00
Allow reverting the last tx with no flow data update. (#51)
* Allow reverting the last tx with no flow data update. * Add details for panic.
This commit is contained in:
parent
8cff5dabe7
commit
f5a71375be
@ -188,7 +188,10 @@ impl<E: HashElement, A: Algorithm<E>> AppendMerkleTree<E, A> {
|
||||
self.layers[0][index] = leaf;
|
||||
self.recompute_after_fill_leaves(index, index + 1);
|
||||
} else if self.layers[0][index] != leaf {
|
||||
panic!("Fill with invalid leaf")
|
||||
panic!(
|
||||
"Fill with invalid leaf, index={} was={:?} get={:?}",
|
||||
index, self.layers[0][index], leaf
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -535,12 +535,19 @@ impl LogManager {
|
||||
+ previous_tx.num_entries() as u64)
|
||||
/ PORA_CHUNK_SIZE as u64)
|
||||
as usize;
|
||||
assert!(current_len > expected_len);
|
||||
while let Some((subtree_depth, _)) = initial_data.subtree_list.pop() {
|
||||
current_len -= 1 << (subtree_depth - 1);
|
||||
if current_len == expected_len {
|
||||
break;
|
||||
if current_len > expected_len {
|
||||
while let Some((subtree_depth, _)) = initial_data.subtree_list.pop()
|
||||
{
|
||||
current_len -= 1 << (subtree_depth - 1);
|
||||
if current_len == expected_len {
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
warn!(
|
||||
"revert last tx with no-op: {} {}",
|
||||
current_len, expected_len
|
||||
);
|
||||
}
|
||||
assert_eq!(current_len, expected_len);
|
||||
while let Some((index, h)) = initial_data.known_leaves.pop() {
|
||||
|
Loading…
Reference in New Issue
Block a user