Skip to content

Commit

Permalink
Fix a key format conversion bug in delete_all (#1385)
Browse files Browse the repository at this point in the history
The bug is caused by incorrect conversion of DeltaMptKey to SnapshotMptKey from SnapshotMptKey itself.

Other small fixes:
- Change assert into debug assert in CowNodeDef drop method to improve error reporting.
- A comment update in MemOptimizedTrieNode.
  • Loading branch information
yangzhe1990 authored and Peilun Li committed May 1, 2020
1 parent 3730569 commit d7437d4
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion core/src/storage/impls/delta_mpt/cow_node_ref.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ impl CowNodeRef {
impl Drop for CowNodeRef {
/// Assert that the CowNodeRef doesn't own something.
fn drop(&mut self) {
assert_eq!(false, self.owned);
debug_assert_eq!(false, self.owned);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ pub struct MemOptimizedTrieNode<CacheAlgoDataT: CacheAlgoDataTrait> {
pub(super) children_table: ChildrenTableDeltaMpt,
// Rust automatically moves the value_size field in order to minimize the
// total size of the struct.
/// We limit the maximum value length by u16. If it proves insufficient,
/// We limit the maximum value length by u32. If it proves insufficient,
/// manage the length and content separately.
value_size: u32,
value: MaybeInPlaceByteArray,
Expand Down
2 changes: 1 addition & 1 deletion core/src/storage/impls/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ impl StateTrait for State {
// No need to check v.len() because there are no tombStone values in
// snapshot.
for (k, v) in snapshot_kvs {
let storage_key = StorageKey::from_delta_mpt_key(&k);
let storage_key = StorageKey::from_key_bytes(&k);
self.delete(storage_key)?;
if !deleted_keys.contains(&k) {
result.push((k, v));
Expand Down

0 comments on commit d7437d4

Please sign in to comment.