mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-17 06:41:02 +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
@@ -53,10 +53,7 @@ use sp_blockchain::{
|
||||
Backend as BlockChainBackend, Error as BlockChainError, HeaderBackend, HeaderMetadata,
|
||||
};
|
||||
use sp_core::{hexdisplay::HexDisplay, storage::well_known_keys, Bytes};
|
||||
use sp_runtime::{
|
||||
generic::BlockId,
|
||||
traits::{Block as BlockT, Header},
|
||||
};
|
||||
use sp_runtime::traits::{Block as BlockT, Header};
|
||||
use std::{marker::PhantomData, sync::Arc};
|
||||
|
||||
/// An API for chain head RPC calls.
|
||||
@@ -142,12 +139,8 @@ where
|
||||
let finalized_block_hash = client.info().finalized_hash;
|
||||
handle.pin_block(finalized_block_hash)?;
|
||||
|
||||
let finalized_block_runtime = generate_runtime_event(
|
||||
&client,
|
||||
runtime_updates,
|
||||
&BlockId::Hash(finalized_block_hash),
|
||||
None,
|
||||
);
|
||||
let finalized_block_runtime =
|
||||
generate_runtime_event(&client, runtime_updates, finalized_block_hash, None);
|
||||
|
||||
let initialized_event = FollowEvent::Initialized(Initialized {
|
||||
finalized_block_hash,
|
||||
@@ -162,12 +155,7 @@ where
|
||||
for (child, parent) in initial_blocks.into_iter() {
|
||||
handle.pin_block(child)?;
|
||||
|
||||
let new_runtime = generate_runtime_event(
|
||||
&client,
|
||||
runtime_updates,
|
||||
&BlockId::Hash(child),
|
||||
Some(&BlockId::Hash(parent)),
|
||||
);
|
||||
let new_runtime = generate_runtime_event(&client, runtime_updates, child, Some(parent));
|
||||
|
||||
let event = FollowEvent::NewBlock(NewBlock {
|
||||
block_hash: child,
|
||||
@@ -214,8 +202,8 @@ fn parse_hex_param(
|
||||
fn generate_runtime_event<Client, Block>(
|
||||
client: &Arc<Client>,
|
||||
runtime_updates: bool,
|
||||
block: &BlockId<Block>,
|
||||
parent: Option<&BlockId<Block>>,
|
||||
block: Block::Hash,
|
||||
parent: Option<Block::Hash>,
|
||||
) -> Option<RuntimeEvent>
|
||||
where
|
||||
Block: BlockT + 'static,
|
||||
@@ -329,8 +317,8 @@ where
|
||||
let new_runtime = generate_runtime_event(
|
||||
&client,
|
||||
runtime_updates,
|
||||
&BlockId::Hash(notification.hash),
|
||||
Some(&BlockId::Hash(*notification.header.parent_hash())),
|
||||
notification.hash,
|
||||
Some(*notification.header.parent_hash()),
|
||||
);
|
||||
|
||||
// Note: `Block::Hash` will serialize to hexadecimal encoded string.
|
||||
|
||||
Reference in New Issue
Block a user