From b65a4b0e491fe3c7f57f25e2be477af72db07a9a Mon Sep 17 00:00:00 2001
From: robin-near <111538878+robin-near@users.noreply.github.com>
Date: Wed, 1 Nov 2023 13:31:32 -0700
Subject: [PATCH] Revert "Split TrieRefcountChange to
TrieRefcountAddition/Subtraction. (#10006)"
This reverts commit 22716f889f58d20fd638210a52fe5ac00f9c7d2f.
---
core/store/src/cold_storage.rs | 8 +-
core/store/src/trie/insert_delete.rs | 30 ++++---
core/store/src/trie/mod.rs | 122 +++++++++++----------------
core/store/src/trie/shard_tries.rs | 17 ++--
core/store/src/trie/state_parts.rs | 37 ++++----
core/store/src/trie/trie_tests.rs | 4 +-
6 files changed, 94 insertions(+), 124 deletions(-)
diff --git a/core/store/src/cold_storage.rs b/core/store/src/cold_storage.rs
index f3d8066d1b6..3898308fae1 100644
--- a/core/store/src/cold_storage.rs
+++ b/core/store/src/cold_storage.rs
@@ -1,6 +1,6 @@
use crate::columns::DBKeyType;
use crate::db::{ColdDB, COLD_HEAD_KEY, HEAD_KEY};
-use crate::trie::TrieRefcountAddition;
+use crate::trie::TrieRefcountChange;
use crate::{metrics, DBCol, DBTransaction, Database, Store, TrieChanges};
use borsh::BorshDeserialize;
@@ -475,11 +475,7 @@ impl StoreWithCache<'_> {
option_to_not_found(self.get_ser(column, key), format_args!("{:?}: {:?}", column, key))
}
- pub fn insert_state_to_cache_from_op(
- &mut self,
- op: &TrieRefcountAddition,
- shard_uid_key: &[u8],
- ) {
+ pub fn insert_state_to_cache_from_op(&mut self, op: &TrieRefcountChange, shard_uid_key: &[u8]) {
debug_assert_eq!(
DBCol::State.key_type(),
&[DBKeyType::ShardUId, DBKeyType::TrieNodeOrValueHash]
diff --git a/core/store/src/trie/insert_delete.rs b/core/store/src/trie/insert_delete.rs
index 050d467ac3d..0d7a5ebd776 100644
--- a/core/store/src/trie/insert_delete.rs
+++ b/core/store/src/trie/insert_delete.rs
@@ -1,18 +1,21 @@
-use super::TrieRefcountDeltaMap;
+use std::collections::HashMap;
+
+use borsh::BorshSerialize;
+
+use near_primitives::hash::{hash, CryptoHash};
+use near_primitives::state::ValueRef;
+
use crate::trie::nibble_slice::NibbleSlice;
use crate::trie::{
Children, NodeHandle, RawTrieNode, RawTrieNodeWithSize, StorageHandle, StorageValueHandle,
TrieNode, TrieNodeWithSize, ValueHandle,
};
use crate::{StorageError, Trie, TrieChanges};
-use borsh::BorshSerialize;
-use near_primitives::hash::{hash, CryptoHash};
-use near_primitives::state::ValueRef;
pub(crate) struct NodesStorage {
nodes: Vec