BlockId removal: refactor: CallExecutor trait (#13173)

* BlockId removal: refactor: CallExecutor trait

It changes the arguments of CallExecutor methods:
-  `call`, 'contextual_call', 'runtime_version', 'prove_execution'

from: `BlockId<Block>` to: `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>

* ".git/.scripts/commands/fmt/fmt.sh"

Co-authored-by: Bastian Köcher <git@kchr.de>
Co-authored-by: command-bot <>
This commit is contained in:
Michal Kucharczyk
2023-01-24 13:52:01 +01:00
committed by GitHub
parent d2fcebef40
commit 025f9d9ba3
8 changed files with 55 additions and 56 deletions
+5 -5
View File
@@ -19,7 +19,7 @@
//! A method call executor interface.
use sc_executor::{RuntimeVersion, RuntimeVersionOf};
use sp_runtime::{generic::BlockId, traits::Block as BlockT};
use sp_runtime::traits::Block as BlockT;
use sp_state_machine::{ExecutionStrategy, OverlayedChanges, StorageProof};
use std::cell::RefCell;
@@ -54,7 +54,7 @@ pub trait CallExecutor<B: BlockT>: RuntimeVersionOf {
/// No changes are made.
fn call(
&self,
id: &BlockId<B>,
at_hash: B::Hash,
method: &str,
call_data: &[u8],
strategy: ExecutionStrategy,
@@ -67,7 +67,7 @@ pub trait CallExecutor<B: BlockT>: RuntimeVersionOf {
/// of the execution context.
fn contextual_call(
&self,
at: &BlockId<B>,
at_hash: B::Hash,
method: &str,
call_data: &[u8],
changes: &RefCell<OverlayedChanges>,
@@ -83,14 +83,14 @@ pub trait CallExecutor<B: BlockT>: RuntimeVersionOf {
/// Extract RuntimeVersion of given block
///
/// No changes are made.
fn runtime_version(&self, id: &BlockId<B>) -> Result<RuntimeVersion, sp_blockchain::Error>;
fn runtime_version(&self, at_hash: B::Hash) -> Result<RuntimeVersion, sp_blockchain::Error>;
/// Prove the execution of the given `method`.
///
/// No changes are made.
fn prove_execution(
&self,
at: &BlockId<B>,
at_hash: B::Hash,
method: &str,
call_data: &[u8],
) -> Result<(Vec<u8>, StorageProof), sp_blockchain::Error>;