Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Companion for new trie cache #1361

Merged
merged 9 commits into from
Aug 18, 2022
Merged
Show file tree
Hide file tree
Changes from 7 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
4 changes: 2 additions & 2 deletions pallets/parachain-system/src/relay_state_snapshot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use cumulus_primitives_core::{
};
use scale_info::TypeInfo;
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_trie::{HashDBT, MemoryDB, StorageProof, EMPTY_PREFIX};

Expand Down Expand Up @@ -156,7 +156,7 @@ impl RelayChainStateProof {
if !db.contains(&relay_parent_storage_root, EMPTY_PREFIX) {
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 })
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ where

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 = (
// Replace storage calls with our own implementations
Expand Down
4 changes: 2 additions & 2 deletions parachain-template/node/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -399,8 +399,8 @@ impl CliConfiguration<Self> for RelayChainCli {
self.base.base.transaction_pool(is_dev)
}

fn state_cache_child_ratio(&self) -> Result<Option<usize>> {
self.base.base.state_cache_child_ratio()
fn trie_cache_maximum_size(&self) -> Result<Option<usize>> {
self.base.base.trie_cache_maximum_size()
}

fn rpc_methods(&self) -> Result<sc_service::config::RpcMethods> {
Expand Down
4 changes: 2 additions & 2 deletions polkadot-parachain/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -832,8 +832,8 @@ impl CliConfiguration<Self> for RelayChainCli {
self.base.base.transaction_pool(is_dev)
}

fn state_cache_child_ratio(&self) -> Result<Option<usize>> {
self.base.base.state_cache_child_ratio()
fn trie_cache_maximum_size(&self) -> Result<Option<usize>> {
self.base.base.trie_cache_maximum_size()
}

fn rpc_methods(&self) -> Result<sc_service::config::RpcMethods> {
Expand Down
2 changes: 1 addition & 1 deletion test/relay-sproof-builder/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ impl RelayStateSproofBuilder {
) -> (polkadot_primitives::v2::Hash, sp_state_machine::StorageProof) {
let (db, root) = MemoryDB::<HashFor<polkadot_primitives::v2::Block>>::default_with_root();
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();
{
Expand Down
4 changes: 2 additions & 2 deletions test/service/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,8 @@ impl CliConfiguration<Self> for RelayChainCli {
self.base.base.transaction_pool(is_dev)
}

fn state_cache_child_ratio(&self) -> CliResult<Option<usize>> {
self.base.base.state_cache_child_ratio()
fn trie_cache_maximum_size(&self) -> CliResult<Option<usize>> {
self.base.base.trie_cache_maximum_size()
}

fn rpc_methods(&self) -> CliResult<sc_service::config::RpcMethods> {
Expand Down
3 changes: 1 addition & 2 deletions test/service/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -650,8 +650,7 @@ pub fn node_config(
keystore: KeystoreConfig::InMemory,
keystore_remote: Default::default(),
database: DatabaseSource::RocksDb { path: root.join("db"), cache_size: 128 },
state_cache_size: 67108864,
state_cache_child_ratio: None,
trie_cache_maximum_size: Some(64 * 1024 * 1024),
state_pruning: Some(PruningMode::ArchiveAll),
blocks_pruning: BlocksPruning::All,
chain_spec: spec,
Expand Down