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

draft: exclude deleted values from proof #12390

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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
6 changes: 1 addition & 5 deletions core/store/src/trie/mem/mem_trie_update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,6 @@ impl UpdatedMemTrieNodeWithSize {
pub struct TrieAccesses {
/// Hashes and encoded trie nodes.
pub nodes: HashMap<CryptoHash, Arc<[u8]>>,
/// Hashes of accessed values - because values themselves are not
/// necessarily present in memtrie.
pub values: HashMap<CryptoHash, FlatStateValue>,
}

/// Tracks intermediate trie changes, final version of which is to be committed
Expand Down Expand Up @@ -181,7 +178,6 @@ impl<'a, M: ArenaMemory> GenericTrieUpdate<'a, MemTrieNodeId, FlatStateValue>
fn delete_value(&mut self, value: FlatStateValue) -> Result<(), StorageError> {
if let Some(tracked_node_changes) = self.tracked_trie_changes.as_mut() {
let hash = value.to_value_ref().hash;
tracked_node_changes.accesses.values.insert(hash, value);
tracked_node_changes
.refcount_deleted_hashes
.entry(hash)
Expand Down Expand Up @@ -209,7 +205,7 @@ impl<'a, M: ArenaMemory> MemTrieUpdate<'a, M> {
Some(TrieChangesTracker {
refcount_inserted_values: BTreeMap::new(),
refcount_deleted_hashes: BTreeMap::new(),
accesses: TrieAccesses { nodes: HashMap::new(), values: HashMap::new() },
accesses: TrieAccesses { nodes: HashMap::new() },
})
} else {
None
Expand Down
33 changes: 9 additions & 24 deletions core/store/src/trie/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1650,21 +1650,6 @@ impl Trie {
}
let (trie_changes, trie_accesses) = trie_update.to_trie_changes();

// Sanity check for tests: all modified trie items must be
// present in ever accessed trie items.
#[cfg(test)]
{
for t in trie_changes.deletions.iter() {
let hash = t.trie_node_or_value_hash;
assert!(
trie_accesses.values.contains_key(&hash)
|| trie_accesses.nodes.contains_key(&hash),
"Hash {} is not present in trie accesses",
hash
);
}
}

// Retroactively record all accessed trie items which are
// required to process trie update but were not recorded at
// processing lookups.
Expand All @@ -1675,15 +1660,15 @@ impl Trie {
for (node_hash, serialized_node) in trie_accesses.nodes {
recorder.borrow_mut().record(&node_hash, serialized_node);
}
for (value_hash, value) in trie_accesses.values {
let value = match value {
FlatStateValue::Ref(_) => {
self.storage.retrieve_raw_bytes(&value_hash)?
}
FlatStateValue::Inlined(value) => value.into(),
};
recorder.borrow_mut().record(&value_hash, value);
}
// for (value_hash, value) in trie_accesses.values {
// let value = match value {
// FlatStateValue::Ref(_) => {
// self.storage.retrieve_raw_bytes(&value_hash)?
// }
// FlatStateValue::Inlined(value) => value.into(),
// };
// recorder.borrow_mut().record(&value_hash, value);
// }
}
Ok(trie_changes)
}
Expand Down
Loading