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
@@ -22,7 +22,9 @@ use frame_support::weights::constants::WEIGHT_PER_NANOS;
use frame_system::ConsumedWeight;
use sc_block_builder::{BlockBuilderApi, BlockBuilderProvider};
use sc_cli::{Error, Result};
use sc_client_api::{Backend as ClientBackend, BlockBackend, StorageProvider, UsageProvider};
use sc_client_api::{
Backend as ClientBackend, BlockBackend, HeaderBackend, StorageProvider, UsageProvider,
};
use sp_api::{ApiExt, Core, HeaderT, ProvideRuntimeApi};
use sp_blockchain::Error::RuntimeApiError;
use sp_runtime::{generic::BlockId, traits::Block as BlockT, DigestItem, OpaqueExtrinsic};
@@ -73,7 +75,8 @@ where
+ ProvideRuntimeApi<Block>
+ StorageProvider<Block, BA>
+ UsageProvider<Block>
+ BlockBackend<Block>,
+ BlockBackend<Block>
+ HeaderBackend<Block>,
C::Api: ApiExt<Block, StateBackend = BA::State> + BlockBuilderApi<Block>,
{
/// Returns a new [`Self`] from the arguments.
@@ -136,9 +139,10 @@ where
)?;
let key = StorageKey(hash);
let block_hash = self.client.expect_block_hash_from_id(block)?;
let mut raw_weight = &self
.client
.storage(&block, &key)?
.storage(&block_hash, &key)?
.ok_or(format!("Could not find System::BlockWeight for block: {}", block))?
.0[..];
@@ -22,6 +22,7 @@ use sc_block_builder::{BlockBuilderApi, BlockBuilderProvider};
use sc_cli::{CliConfiguration, ImportParams, Result, SharedParams};
use sc_client_api::{Backend as ClientBackend, BlockBackend, StorageProvider, UsageProvider};
use sp_api::{ApiExt, ProvideRuntimeApi};
use sp_blockchain::HeaderBackend;
use sp_runtime::{traits::Block as BlockT, OpaqueExtrinsic};
use clap::Parser;
@@ -87,7 +88,8 @@ impl BlockCmd {
+ BlockBackend<Block>
+ ProvideRuntimeApi<Block>
+ StorageProvider<Block, BA>
+ UsageProvider<Block>,
+ UsageProvider<Block>
+ HeaderBackend<Block>,
C::Api: ApiExt<Block, StateBackend = BA::State> + BlockBuilderApi<Block>,
{
// Put everything in the benchmark type to have the generic types handy.