mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 14:37:57 +00:00
Do not depend on native runtimes for RuntimeApi (#7451)
* Implement runtime apis for fake runtime
These runtime api implementations are only used to make the compiler
think that we have implemented all required runtime apis. They will not
be called as we switch the executor to `WasmExecutor`. In the near
future we will not require these fake implementations anymore after
Substrate has shifted away from this compile time requirement.
This brings us the advantage that the `polkadot-service` doesn't need to
depend on the runtimes for getting the `RuntimeApi` type.
It also removes around 1min of build time on my machine ;)
* Fix warning
* FMT
* ".git/.scripts/commands/fmt/fmt.sh"
* Use more descriptive id
* Fix warnings
* Adapt path
* Fix 🙈
---------
Co-authored-by: command-bot <>
This commit is contained in:
@@ -28,9 +28,7 @@ use polkadot_overseer::Handle;
|
||||
use polkadot_primitives::{Balance, CollatorPair, HeadData, Id as ParaId, ValidationCode};
|
||||
use polkadot_runtime_common::BlockHashCount;
|
||||
use polkadot_runtime_parachains::paras::{ParaGenesisArgs, ParaKind};
|
||||
use polkadot_service::{
|
||||
ClientHandle, Error, ExecuteWithClient, FullClient, IsCollator, NewFull, PrometheusConfig,
|
||||
};
|
||||
use polkadot_service::{Error, FullClient, IsCollator, NewFull, PrometheusConfig};
|
||||
use polkadot_test_runtime::{
|
||||
ParasCall, ParasSudoWrapperCall, Runtime, SignedExtra, SignedPayload, SudoCall,
|
||||
UncheckedExtrinsic, VERSION,
|
||||
@@ -63,26 +61,11 @@ use std::{
|
||||
use substrate_test_client::{
|
||||
BlockchainEventsExt, RpcHandlersExt, RpcTransactionError, RpcTransactionOutput,
|
||||
};
|
||||
/// Declare an instance of the native executor named `PolkadotTestExecutorDispatch`. Include the wasm binary as the
|
||||
/// equivalent wasm code.
|
||||
pub struct PolkadotTestExecutorDispatch;
|
||||
|
||||
impl sc_executor::NativeExecutionDispatch for PolkadotTestExecutorDispatch {
|
||||
type ExtendHostFunctions = frame_benchmarking::benchmarking::HostFunctions;
|
||||
|
||||
fn dispatch(method: &str, data: &[u8]) -> Option<Vec<u8>> {
|
||||
polkadot_test_runtime::api::dispatch(method, data)
|
||||
}
|
||||
|
||||
fn native_version() -> sc_executor::NativeVersion {
|
||||
polkadot_test_runtime::native_version()
|
||||
}
|
||||
}
|
||||
|
||||
/// The client type being used by the test service.
|
||||
pub type Client = FullClient<polkadot_test_runtime::RuntimeApi, PolkadotTestExecutorDispatch>;
|
||||
pub type Client = FullClient;
|
||||
|
||||
pub use polkadot_service::FullBackend;
|
||||
pub use polkadot_service::{FullBackend, GetLastTimestamp};
|
||||
|
||||
/// Create a new full node.
|
||||
#[sc_tracing::logging::prefix_logs_with(config.network.node_name.as_str())]
|
||||
@@ -90,8 +73,8 @@ pub fn new_full(
|
||||
config: Configuration,
|
||||
is_collator: IsCollator,
|
||||
worker_program_path: Option<PathBuf>,
|
||||
) -> Result<NewFull<Arc<Client>>, Error> {
|
||||
polkadot_service::new_full::<polkadot_test_runtime::RuntimeApi, PolkadotTestExecutorDispatch, _>(
|
||||
) -> Result<NewFull, Error> {
|
||||
polkadot_service::new_full(
|
||||
config,
|
||||
is_collator,
|
||||
None,
|
||||
@@ -107,15 +90,6 @@ pub fn new_full(
|
||||
)
|
||||
}
|
||||
|
||||
/// A wrapper for the test client that implements `ClientHandle`.
|
||||
pub struct TestClient(pub Arc<Client>);
|
||||
|
||||
impl ClientHandle for TestClient {
|
||||
fn execute_with<T: ExecuteWithClient>(&self, t: T) -> T::Output {
|
||||
T::execute_with_client::<_, _, polkadot_service::FullBackend>(t, self.0.clone())
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns a prometheus config usable for testing.
|
||||
pub fn test_prometheus_config(port: u16) -> PrometheusConfig {
|
||||
PrometheusConfig::new_with_default_registry(
|
||||
|
||||
Reference in New Issue
Block a user