Skip to content

Commit

Permalink
fix: quick workaround for flat storage memtrie comparison (#12592)
Browse files Browse the repository at this point in the history
Quick fix to allow state comparison between flat storage and memtries
only when the view over key value pairs is at the same height, for both
of them.
  • Loading branch information
Trisfald authored Dec 10, 2024
1 parent c425289 commit 6bc4f56
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions integration-tests/src/test_loop/tests/resharding_v3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ use near_primitives::test_utils::create_user_test_signer;
use near_primitives::transaction::SignedTransaction;
use near_primitives::trie_key::TrieKey;
use near_primitives::views::FinalExecutionStatus;
use near_store::flat::FlatStorageStatus;
use std::cell::Cell;
use std::u64;

Expand Down Expand Up @@ -661,11 +662,25 @@ fn assert_state_sanity(
trie.lock_for_iter().iter().unwrap().collect::<Result<HashSet<_>, _>>().unwrap();
assert_state_equal(&memtrie_state, &trie_state, shard_uid, "memtrie and trie");

let Some(flat_store_chunk_view) = client
.chain
.runtime_adapter
.get_flat_storage_manager()
.chunk_view(shard_uid, final_head.last_block_hash)
let flat_storage_manager = client.chain.runtime_adapter.get_flat_storage_manager();
// FlatStorageChunkView::iter_range() used below to retrieve all key-value pairs in Flat
// Storage only looks at the data committed into the DB. For this reasons comparing Flat
// Storage and Memtries makes sense only if we can retrieve a view at the same height from
// both.
if let FlatStorageStatus::Ready(status) =
flat_storage_manager.get_flat_storage_status(shard_uid)
{
if status.flat_head.hash != final_head.prev_block_hash {
tracing::warn!(target: "test", "skipping flat storage - memtrie state check");
continue;
} else {
tracing::debug!(target: "test", "checking flat storage - memtrie state");
}
} else {
continue;
};
let Some(flat_store_chunk_view) =
flat_storage_manager.chunk_view(shard_uid, final_head.last_block_hash)
else {
continue;
};
Expand Down

0 comments on commit 6bc4f56

Please sign in to comment.