Skip to content
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

fix non-persisted diffs #2964

Merged
merged 5 commits into from
Apr 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
- Replaced DB key-val diffs pruning of non-persisted keys that searched for the
last diffs and was degrading throughput with a separate DB column family that
is pruned on every block.
([\#2964](https://github.com/anoma/namada/pull/2964))
19 changes: 8 additions & 11 deletions crates/apps/src/lib/node/ledger/storage/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -779,10 +779,6 @@ mod tests {
Key::parse("testing2").unwrap()
}

fn merkle_tree_key_filter(key: &Key) -> bool {
key == &test_key_1()
}

#[test]
fn test_persistent_storage_writing_without_merklizing_or_diffs() {
let db_path =
Expand All @@ -793,7 +789,8 @@ mod tests {
ChainId::default(),
address::testing::nam(),
None,
merkle_tree_key_filter,
// Only merkelize and persist diffs for `test_key_1`
|key: &Key| -> bool { key == &test_key_1() },
);
// Start the first block
let first_height = BlockHeight::first();
Expand Down Expand Up @@ -869,12 +866,12 @@ mod tests {
// need to have diffs for at least 1 block for rollback purposes
let res2 = state
.db()
.read_diffs_val(&key2, first_height, true)
.read_rollback_val(&key2, first_height, true)
.unwrap();
assert!(res2.is_none());
let res2 = state
.db()
.read_diffs_val(&key2, first_height, false)
.read_rollback_val(&key2, first_height, false)
.unwrap()
.unwrap();
let res2 = u64::try_from_slice(&res2).unwrap();
Expand Down Expand Up @@ -932,27 +929,27 @@ mod tests {
// Check that key-val-2 diffs don't exist for block 0 anymore
let res2 = state
.db()
.read_diffs_val(&key2, first_height, true)
.read_rollback_val(&key2, first_height, true)
.unwrap();
assert!(res2.is_none());
let res2 = state
.db()
.read_diffs_val(&key2, first_height, false)
.read_rollback_val(&key2, first_height, false)
.unwrap();
assert!(res2.is_none());

// Check that the block 1 diffs for key-val-2 include an "old" value of
// val2 and no "new" value
let res2 = state
.db()
.read_diffs_val(&key2, second_height, true)
.read_rollback_val(&key2, second_height, true)
.unwrap()
.unwrap();
let res2 = u64::try_from_slice(&res2).unwrap();
assert_eq!(res2, val2);
let res2 = state
.db()
.read_diffs_val(&key2, second_height, false)
.read_rollback_val(&key2, second_height, false)
.unwrap();
assert!(res2.is_none());
}
Expand Down
Loading
Loading