BlockId removal: refactor: StorageProvider (#12510)

* BlockId removal: refactor: StorageProvider

It changes the arguments of `Backend::StorageProvider` trait from:
block: `BlockId<Block>` to: hash: `&Block::Hash`

This PR is part of BlockId::Number refactoring analysis (paritytech/substrate#11292)

* Apply suggestions from code review

Co-authored-by: Bastian Köcher <git@kchr.de>

* Update client/api/src/backend.rs

Co-authored-by: Dmitrii Markin <dmitry@markin.tech>

* GrandpaBlockImport::current_set_id reworked

* ExportStateCmd reworked

* trigger CI job

* trigger CI job

Co-authored-by: Bastian Köcher <git@kchr.de>
Co-authored-by: Dmitrii Markin <dmitry@markin.tech>
This commit is contained in:
Michal Kucharczyk
2022-10-18 14:52:04 +02:00
committed by GitHub
parent 2f341fcf15
commit b16135f602
12 changed files with 112 additions and 120 deletions
@@ -57,12 +57,12 @@ impl StorageCmd {
// Store the time that it took to write each value.
let mut record = BenchRecord::default();
let block = BlockId::Hash(client.usage_info().chain.best_hash);
let header = client.header(block)?.ok_or("Header not found")?;
let best_hash = client.usage_info().chain.best_hash;
let header = client.header(BlockId::Hash(best_hash))?.ok_or("Header not found")?;
let original_root = *header.state_root();
let trie = DbStateBuilder::<Block>::new(storage.clone(), original_root).build();
info!("Preparing keys from block {}", block);
info!("Preparing keys from block {}", best_hash);
// Load all KV pairs and randomly shuffle them.
let mut kvs = trie.pairs();
let (mut rng, _) = new_rng(None);
@@ -77,7 +77,7 @@ impl StorageCmd {
match (self.params.include_child_trees, self.is_child_key(k.to_vec())) {
(true, Some(info)) => {
let child_keys =
client.child_storage_keys_iter(&block, info.clone(), None, None)?;
client.child_storage_keys_iter(&best_hash, info.clone(), None, None)?;
for ck in child_keys {
child_nodes.push((ck.clone(), info.clone()));
}
@@ -124,7 +124,7 @@ impl StorageCmd {
for (key, info) in child_nodes {
if let Some(original_v) = client
.child_storage(&block, &info.clone(), &key)
.child_storage(&best_hash, &info.clone(), &key)
.expect("Checked above to exist")
{
let mut new_v = vec![0; original_v.0.len()];