Companion for new trie cache (#1361)

* Update branch

* Make it compile

* Update Substrate

* Revert "Update branch"

This reverts commit 7b0278160a09312fc6501e0a31923c5a8d8f8c56.

* FMT

* update lockfile for {"polkadot", "substrate"}

Co-authored-by: parity-processbot <>
This commit is contained in:
Bastian Köcher
2022-08-19 00:02:08 +02:00
committed by GitHub
parent 807db6ff0d
commit baa1c3600c
8 changed files with 275 additions and 268 deletions
+264 -256
View File
File diff suppressed because it is too large Load Diff
@@ -20,7 +20,7 @@ use cumulus_primitives_core::{
}; };
use scale_info::TypeInfo; use scale_info::TypeInfo;
use sp_runtime::traits::HashFor; use sp_runtime::traits::HashFor;
use sp_state_machine::{Backend, TrieBackend}; use sp_state_machine::{Backend, TrieBackend, TrieBackendBuilder};
use sp_std::vec::Vec; use sp_std::vec::Vec;
use sp_trie::{HashDBT, MemoryDB, StorageProof, EMPTY_PREFIX}; use sp_trie::{HashDBT, MemoryDB, StorageProof, EMPTY_PREFIX};
@@ -156,7 +156,7 @@ impl RelayChainStateProof {
if !db.contains(&relay_parent_storage_root, EMPTY_PREFIX) { if !db.contains(&relay_parent_storage_root, EMPTY_PREFIX) {
return Err(Error::RootMismatch) return Err(Error::RootMismatch)
} }
let trie_backend = TrieBackend::new(db, relay_parent_storage_root); let trie_backend = TrieBackendBuilder::new(db, relay_parent_storage_root).build();
Ok(Self { para_id, trie_backend }) Ok(Self { para_id, trie_backend })
} }
@@ -74,7 +74,7 @@ where
sp_std::mem::drop(storage_proof); sp_std::mem::drop(storage_proof);
let backend = sp_state_machine::TrieBackend::new(db, *parent_head.state_root()); let backend = sp_state_machine::TrieBackendBuilder::new(db, *parent_head.state_root()).build();
let _guard = ( let _guard = (
// Replace storage calls with our own implementations // Replace storage calls with our own implementations
@@ -399,8 +399,8 @@ impl CliConfiguration<Self> for RelayChainCli {
self.base.base.transaction_pool(is_dev) self.base.base.transaction_pool(is_dev)
} }
fn state_cache_child_ratio(&self) -> Result<Option<usize>> { fn trie_cache_maximum_size(&self) -> Result<Option<usize>> {
self.base.base.state_cache_child_ratio() self.base.base.trie_cache_maximum_size()
} }
fn rpc_methods(&self) -> Result<sc_service::config::RpcMethods> { fn rpc_methods(&self) -> Result<sc_service::config::RpcMethods> {
+2 -2
View File
@@ -832,8 +832,8 @@ impl CliConfiguration<Self> for RelayChainCli {
self.base.base.transaction_pool(is_dev) self.base.base.transaction_pool(is_dev)
} }
fn state_cache_child_ratio(&self) -> Result<Option<usize>> { fn trie_cache_maximum_size(&self) -> Result<Option<usize>> {
self.base.base.state_cache_child_ratio() self.base.base.trie_cache_maximum_size()
} }
fn rpc_methods(&self) -> Result<sc_service::config::RpcMethods> { fn rpc_methods(&self) -> Result<sc_service::config::RpcMethods> {
+1 -1
View File
@@ -102,7 +102,7 @@ impl RelayStateSproofBuilder {
) -> (polkadot_primitives::v2::Hash, sp_state_machine::StorageProof) { ) -> (polkadot_primitives::v2::Hash, sp_state_machine::StorageProof) {
let (db, root) = MemoryDB::<HashFor<polkadot_primitives::v2::Block>>::default_with_root(); let (db, root) = MemoryDB::<HashFor<polkadot_primitives::v2::Block>>::default_with_root();
let state_version = Default::default(); // for test using default. let state_version = Default::default(); // for test using default.
let mut backend = sp_state_machine::TrieBackend::new(db, root); let mut backend = sp_state_machine::TrieBackendBuilder::new(db, root).build();
let mut relevant_keys = Vec::new(); let mut relevant_keys = Vec::new();
{ {
+2 -2
View File
@@ -191,8 +191,8 @@ impl CliConfiguration<Self> for RelayChainCli {
self.base.base.transaction_pool(is_dev) self.base.base.transaction_pool(is_dev)
} }
fn state_cache_child_ratio(&self) -> CliResult<Option<usize>> { fn trie_cache_maximum_size(&self) -> CliResult<Option<usize>> {
self.base.base.state_cache_child_ratio() self.base.base.trie_cache_maximum_size()
} }
fn rpc_methods(&self) -> CliResult<sc_service::config::RpcMethods> { fn rpc_methods(&self) -> CliResult<sc_service::config::RpcMethods> {
+1 -2
View File
@@ -650,8 +650,7 @@ pub fn node_config(
keystore: KeystoreConfig::InMemory, keystore: KeystoreConfig::InMemory,
keystore_remote: Default::default(), keystore_remote: Default::default(),
database: DatabaseSource::RocksDb { path: root.join("db"), cache_size: 128 }, database: DatabaseSource::RocksDb { path: root.join("db"), cache_size: 128 },
state_cache_size: 67108864, trie_cache_maximum_size: Some(64 * 1024 * 1024),
state_cache_child_ratio: None,
state_pruning: Some(PruningMode::ArchiveAll), state_pruning: Some(PruningMode::ArchiveAll),
blocks_pruning: BlocksPruning::All, blocks_pruning: BlocksPruning::All,
chain_spec: spec, chain_spec: spec,