mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 04:07: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:
@@ -18,6 +18,7 @@ substrate-test-client = { git = "https://github.com/paritytech/substrate", branc
|
||||
sc-service = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
sc-block-builder = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
sc-consensus = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
sc-offchain = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
sp-blockchain = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
sp-inherents = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
@@ -27,6 +28,8 @@ sp-timestamp = { git = "https://github.com/paritytech/substrate", branch = "mast
|
||||
sp-consensus = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
sp-consensus-babe = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
sp-state-machine = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
sp-io = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
frame-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
|
||||
[dev-dependencies]
|
||||
sp-keyring = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
|
||||
@@ -17,7 +17,8 @@
|
||||
use crate::{Client, FullBackend};
|
||||
use parity_scale_codec::{Decode, Encode};
|
||||
use polkadot_primitives::{Block, InherentData as ParachainsInherentData};
|
||||
use polkadot_test_runtime::{GetLastTimestamp, UncheckedExtrinsic};
|
||||
use polkadot_test_runtime::UncheckedExtrinsic;
|
||||
use polkadot_test_service::GetLastTimestamp;
|
||||
use sc_block_builder::{BlockBuilder, BlockBuilderProvider};
|
||||
use sp_api::ProvideRuntimeApi;
|
||||
use sp_consensus_babe::{
|
||||
|
||||
@@ -22,12 +22,12 @@ mod block_builder;
|
||||
|
||||
use polkadot_primitives::Block;
|
||||
use sp_runtime::BuildStorage;
|
||||
use std::sync::Arc;
|
||||
|
||||
pub use block_builder::*;
|
||||
pub use polkadot_test_runtime as runtime;
|
||||
pub use polkadot_test_service::{
|
||||
construct_extrinsic, construct_transfer_extrinsic, Client, FullBackend,
|
||||
PolkadotTestExecutorDispatch,
|
||||
};
|
||||
pub use substrate_test_client::*;
|
||||
|
||||
@@ -35,7 +35,7 @@ pub use substrate_test_client::*;
|
||||
pub type Executor = client::LocalCallExecutor<
|
||||
Block,
|
||||
FullBackend,
|
||||
sc_executor::NativeElseWasmExecutor<PolkadotTestExecutorDispatch>,
|
||||
WasmExecutor<(sp_io::SubstrateHostFunctions, frame_benchmarking::benchmarking::HostFunctions)>,
|
||||
>;
|
||||
|
||||
/// Test client builder for Polkadot.
|
||||
@@ -70,7 +70,21 @@ pub trait TestClientBuilderExt: Sized {
|
||||
|
||||
impl TestClientBuilderExt for TestClientBuilder {
|
||||
fn build_with_longest_chain(self) -> (Client, LongestChain) {
|
||||
self.build_with_native_executor(None)
|
||||
let executor = WasmExecutor::builder().build();
|
||||
let executor = client::LocalCallExecutor::new(
|
||||
self.backend().clone(),
|
||||
executor.clone(),
|
||||
Default::default(),
|
||||
ExecutionExtensions::new(
|
||||
Default::default(),
|
||||
None,
|
||||
sc_offchain::OffchainDb::factory_from_backend(&*self.backend()),
|
||||
Arc::new(executor),
|
||||
),
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
self.build_with_executor(executor)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user