mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 22:11:06 +00:00
BlockId removal: runtime-api refactor (#13255)
* BlockId removal: refactor of runtime API It changes the arguments of: - `ApiExt` methods: `has_api`, `has_api_with`, `api_version` - `CallApiAt` method: `runtime_version_at` from: `BlockId<Block>` to: `Block::Hash` It also changes the first argument of all generated runtime API calls from: `BlockId<Block>` to: `Block::Hash` This PR is part of BlockId::Number refactoring analysis (paritytech/substrate#11292) * BlockId removal: refactor of runtime API - tests - tests adjusted to new runtime API, - some tests migrated from block number to block hash * benchmarking-cli: BlockId(0) migrated to info().genesis_hash `runtime_api.call()` now requires the block hash instead of BlockId::Number. To access the genesis hash widely used in benchmarking engine the Client was constrained to satisfy `sp_blockchain::HeaderBackend<Block>` trait which provides `info().genesis_hash`. * trivial: api.call(BlockId) -> api.call(Hash) - Migrated all `runtime_api.calls` to use Hash - Noteworthy (?): -- `validate_transaction_blocking` in transaction pool, * CallApiAtParams::at changed to Block::Hash * missed doc updated * Apply suggestions from code review Co-authored-by: Bastian Köcher <git@kchr.de> * ".git/.scripts/commands/fmt/fmt.sh" * BlockId removal: Benchmark::consumed_weight Little refactor around `Benchmark::consumed_weight`: `BlockId` removed. * at_hash renamed * wrong merge fixed * beefy worker: merged with master * beefy: tests: missing block problem fixed * Apply review suggestion * fix --------- Co-authored-by: Bastian Köcher <git@kchr.de> Co-authored-by: command-bot <>
This commit is contained in:
committed by
GitHub
parent
ac13aaeb2f
commit
7a10154188
@@ -123,7 +123,7 @@ where
|
||||
let best_block_hash = self.client.info().best_hash;
|
||||
self.client
|
||||
.runtime_api()
|
||||
.generate_session_keys(&generic::BlockId::Hash(best_block_hash), None)
|
||||
.generate_session_keys(best_block_hash, None)
|
||||
.map(Into::into)
|
||||
.map_err(|api_err| Error::Client(Box::new(api_err)).into())
|
||||
}
|
||||
@@ -135,7 +135,7 @@ where
|
||||
let keys = self
|
||||
.client
|
||||
.runtime_api()
|
||||
.decode_session_keys(&generic::BlockId::Hash(best_block_hash), session_keys.to_vec())
|
||||
.decode_session_keys(best_block_hash, session_keys.to_vec())
|
||||
.map_err(|e| Error::Client(Box::new(e)))?
|
||||
.ok_or(Error::InvalidSessionKeys)?;
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ use sc_rpc_api::{dev::error::Error, DenyUnsafe};
|
||||
use sp_api::{ApiExt, Core, ProvideRuntimeApi};
|
||||
use sp_core::Encode;
|
||||
use sp_runtime::{
|
||||
generic::{BlockId, DigestItem},
|
||||
generic::DigestItem,
|
||||
traits::{Block as BlockT, Header},
|
||||
};
|
||||
use std::{
|
||||
@@ -98,7 +98,7 @@ where
|
||||
let mut runtime_api = self.client.runtime_api();
|
||||
runtime_api.record_proof();
|
||||
runtime_api
|
||||
.execute_block(&BlockId::Hash(parent_header.hash()), block)
|
||||
.execute_block(parent_header.hash(), block)
|
||||
.map_err(|_| Error::BlockExecutionFailed)?;
|
||||
let witness = runtime_api
|
||||
.extract_proof()
|
||||
|
||||
@@ -48,7 +48,7 @@ use sp_core::{
|
||||
},
|
||||
Bytes,
|
||||
};
|
||||
use sp_runtime::{generic::BlockId, traits::Block as BlockT};
|
||||
use sp_runtime::traits::Block as BlockT;
|
||||
use sp_version::RuntimeVersion;
|
||||
|
||||
/// The maximum time allowed for an RPC call when running without unsafe RPC enabled.
|
||||
@@ -321,7 +321,7 @@ where
|
||||
self.block_or_best(block).map_err(client_err).and_then(|block| {
|
||||
self.client
|
||||
.runtime_api()
|
||||
.metadata(&BlockId::Hash(block))
|
||||
.metadata(block)
|
||||
.map(Into::into)
|
||||
.map_err(|e| Error::Client(Box::new(e)))
|
||||
})
|
||||
@@ -332,9 +332,7 @@ where
|
||||
block: Option<Block::Hash>,
|
||||
) -> std::result::Result<RuntimeVersion, Error> {
|
||||
self.block_or_best(block).map_err(client_err).and_then(|block| {
|
||||
self.client
|
||||
.runtime_version_at(&BlockId::Hash(block))
|
||||
.map_err(|e| Error::Client(Box::new(e)))
|
||||
self.client.runtime_version_at(block).map_err(|e| Error::Client(Box::new(e)))
|
||||
})
|
||||
}
|
||||
|
||||
@@ -383,9 +381,7 @@ where
|
||||
|
||||
let initial = match self
|
||||
.block_or_best(None)
|
||||
.and_then(|block| {
|
||||
self.client.runtime_version_at(&BlockId::Hash(block)).map_err(Into::into)
|
||||
})
|
||||
.and_then(|block| self.client.runtime_version_at(block).map_err(Into::into))
|
||||
.map_err(|e| Error::Client(Box::new(e)))
|
||||
{
|
||||
Ok(initial) => initial,
|
||||
@@ -402,9 +398,8 @@ where
|
||||
.import_notification_stream()
|
||||
.filter(|n| future::ready(n.is_new_best))
|
||||
.filter_map(move |n| {
|
||||
let version = client
|
||||
.runtime_version_at(&BlockId::hash(n.hash))
|
||||
.map_err(|e| Error::Client(Box::new(e)));
|
||||
let version =
|
||||
client.runtime_version_at(n.hash).map_err(|e| Error::Client(Box::new(e)));
|
||||
|
||||
match version {
|
||||
Ok(version) if version != previous_version => {
|
||||
|
||||
Reference in New Issue
Block a user