mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 19:21:13 +00:00
Move sc-client into sc-service (#5502)
* Drop client from sc-network and sc-client-db, move LongestChain to sc-client-api * move leaves, cht, in_mem to sc-client-api, drop client from sc-finality-grandpa * drop sc-service from sc-rpc * drop sc-service from sc-consensus-aura * drop sc-client from manual-seal and babe * drop sc-client from utils/frame/rpc/system and utils/frame/benchmarking-cli * drop sc-client from bin/node and bin/node-template * drop sc-client * fix tests * remove check -p sc-client from gitlab.yml * fix warnings * fixes ui test * fix light client tests * adds associated Client type to AbstractService * adds UsageProvider to Client * fixed ui test, again * tried and failed to get node-cli to compile for wasm * thanks to tomaka for helping me get node-cli to compile for wasmm * ui test pls pas 🙏🏾 * all tests passing 🪄 * no_run documentation code * rm -f documentation code * ClientProvider * fix mega trait * move LongestChain to sc-consensus, use adds minimal bounds to AbstractService::Client * adds license to sc-consensus Co-authored-by: Benjamin Kampmann <ben@parity.io>
This commit is contained in:
@@ -17,12 +17,10 @@ sp-application-crypto = { version = "2.0.0-dev", default-features = false, path
|
||||
sp-consensus-aura = { version = "0.8.0-dev", default-features = false, path = "../../primitives/consensus/aura" }
|
||||
sp-consensus-babe = { version = "0.8.0-dev", default-features = false, path = "../../primitives/consensus/babe" }
|
||||
sp-block-builder = { version = "2.0.0-dev", default-features = false, path = "../../primitives/block-builder" }
|
||||
cfg-if = "0.1.10"
|
||||
codec = { package = "parity-scale-codec", version = "1.3.0", default-features = false, features = ["derive"] }
|
||||
frame-executive = { version = "2.0.0-dev", default-features = false, path = "../../frame/executive" }
|
||||
sp-inherents = { version = "2.0.0-dev", default-features = false, path = "../../primitives/inherents" }
|
||||
sp-keyring = { version = "2.0.0-dev", optional = true, path = "../../primitives/keyring" }
|
||||
log = { version = "0.4.8", optional = true }
|
||||
memory-db = { version = "0.20.0", default-features = false }
|
||||
sp-offchain = { path = "../../primitives/offchain", default-features = false, version = "2.0.0-dev"}
|
||||
sp-core = { version = "2.0.0-dev", default-features = false, path = "../../primitives/core" }
|
||||
@@ -31,7 +29,6 @@ sp-runtime-interface = { path = "../../primitives/runtime-interface", default-fe
|
||||
sp-io = { version = "2.0.0-dev", default-features = false, path = "../../primitives/io" }
|
||||
frame-support = { version = "2.0.0-dev", default-features = false, path = "../../frame/support" }
|
||||
sp-version = { version = "2.0.0-dev", default-features = false, path = "../../primitives/version" }
|
||||
serde = { version = "1.0.101", optional = true, features = ["derive"] }
|
||||
sp-session = { version = "2.0.0-dev", default-features = false, path = "../../primitives/session" }
|
||||
sp-api = { version = "2.0.0-dev", default-features = false, path = "../../primitives/api" }
|
||||
sp-runtime = { version = "2.0.0-dev", default-features = false, path = "../../primitives/runtime" }
|
||||
@@ -39,11 +36,16 @@ pallet-babe = { version = "2.0.0-dev", default-features = false, path = "../../f
|
||||
frame-system = { version = "2.0.0-dev", default-features = false, path = "../../frame/system" }
|
||||
frame-system-rpc-runtime-api = { version = "2.0.0-dev", default-features = false, path = "../../frame/system/rpc/runtime-api" }
|
||||
pallet-timestamp = { version = "2.0.0-dev", default-features = false, path = "../../frame/timestamp" }
|
||||
sc-client = { version = "0.8.0-dev", optional = true, path = "../../client" }
|
||||
sp-trie = { version = "2.0.0-dev", default-features = false, path = "../../primitives/trie" }
|
||||
sp-transaction-pool = { version = "2.0.0-dev", default-features = false, path = "../../primitives/transaction-pool" }
|
||||
trie-db = { version = "0.20.1", default-features = false }
|
||||
parity-util-mem = { version = "0.6.1", default-features = false, features = ["primitive-types"] }
|
||||
sc-service = { version = "0.8.0-dev", default-features = false, optional = true, features = ["test-helpers"], path = "../../client/service" }
|
||||
|
||||
# 3rd party
|
||||
cfg-if = "0.1.10"
|
||||
log = { version = "0.4.8", optional = true }
|
||||
serde = { version = "1.0.101", optional = true, features = ["derive"] }
|
||||
|
||||
[dev-dependencies]
|
||||
sc-block-builder = { version = "0.8.0-dev", path = "../../client/block-builder" }
|
||||
@@ -85,7 +87,7 @@ std = [
|
||||
"frame-system-rpc-runtime-api/std",
|
||||
"frame-system/std",
|
||||
"pallet-timestamp/std",
|
||||
"sc-client",
|
||||
"sc-service",
|
||||
"sp-trie/std",
|
||||
"sp-transaction-pool/std",
|
||||
"trie-db/std",
|
||||
|
||||
@@ -12,6 +12,7 @@ publish = false
|
||||
targets = ["x86_64-unknown-linux-gnu"]
|
||||
|
||||
[dependencies]
|
||||
sp-consensus = { version = "0.8.0-dev", path = "../../../primitives/consensus/common" }
|
||||
sc-block-builder = { version = "0.8.0-dev", path = "../../../client/block-builder" }
|
||||
substrate-test-client = { version = "2.0.0-dev", path = "../../client" }
|
||||
sp-core = { version = "2.0.0-dev", path = "../../../primitives/core" }
|
||||
@@ -21,5 +22,6 @@ sp-api = { version = "2.0.0-dev", path = "../../../primitives/api" }
|
||||
sp-blockchain = { version = "2.0.0-dev", path = "../../../primitives/blockchain" }
|
||||
codec = { package = "parity-scale-codec", version = "1.3.0" }
|
||||
sc-client-api = { version = "2.0.0-dev", path = "../../../client/api" }
|
||||
sc-client = { version = "0.8.0-dev", path = "../../../client/" }
|
||||
sc-consensus = { version = "0.8.0-dev", path = "../../../client/consensus/common" }
|
||||
sc-service = { version = "0.8.0-dev", default-features = false, path = "../../../client/service" }
|
||||
futures = "0.3.4"
|
||||
|
||||
@@ -26,7 +26,7 @@ use std::sync::Arc;
|
||||
use std::collections::HashMap;
|
||||
pub use substrate_test_client::*;
|
||||
pub use substrate_test_runtime as runtime;
|
||||
pub use sc_client::LongestChain;
|
||||
pub use sc_consensus::LongestChain;
|
||||
|
||||
pub use self::block_builder_ext::BlockBuilderExt;
|
||||
|
||||
@@ -34,7 +34,7 @@ use sp_core::{sr25519, ChangesTrieConfiguration};
|
||||
use sp_core::storage::{ChildInfo, Storage, StorageChild};
|
||||
use substrate_test_runtime::genesismap::{GenesisConfig, additional_storage_with_genesis};
|
||||
use sp_runtime::traits::{Block as BlockT, Header as HeaderT, Hash as HashT, NumberFor, HashFor};
|
||||
use sc_client::{
|
||||
use sc_service::client::{
|
||||
light::fetcher::{
|
||||
Fetcher,
|
||||
RemoteHeaderRequest, RemoteReadRequest, RemoteReadChildRequest,
|
||||
@@ -68,7 +68,7 @@ sc_executor::native_executor_instance! {
|
||||
pub type Backend = substrate_test_client::Backend<substrate_test_runtime::Block>;
|
||||
|
||||
/// Test client executor.
|
||||
pub type Executor = sc_client::LocalCallExecutor<
|
||||
pub type Executor = client::LocalCallExecutor<
|
||||
Backend,
|
||||
NativeExecutor<LocalExecutor>,
|
||||
>;
|
||||
@@ -77,10 +77,10 @@ pub type Executor = sc_client::LocalCallExecutor<
|
||||
pub type LightBackend = substrate_test_client::LightBackend<substrate_test_runtime::Block>;
|
||||
|
||||
/// Test client light executor.
|
||||
pub type LightExecutor = sc_client::light::call_executor::GenesisCallExecutor<
|
||||
pub type LightExecutor = client::light::call_executor::GenesisCallExecutor<
|
||||
LightBackend,
|
||||
sc_client::LocalCallExecutor<
|
||||
sc_client::light::backend::Backend<
|
||||
client::LocalCallExecutor<
|
||||
client::light::backend::Backend<
|
||||
sc_client_db::light::LightStorage<substrate_test_runtime::Block>,
|
||||
HashFor<substrate_test_runtime::Block>
|
||||
>,
|
||||
@@ -133,7 +133,7 @@ impl substrate_test_client::GenesisInit for GenesisParameters {
|
||||
let state_root = <<<runtime::Block as BlockT>::Header as HeaderT>::Hashing as HashT>::trie_root(
|
||||
storage.top.clone().into_iter().chain(child_roots).collect()
|
||||
);
|
||||
let block: runtime::Block = sc_client::genesis::construct_genesis_block(state_root);
|
||||
let block: runtime::Block = client::genesis::construct_genesis_block(state_root);
|
||||
storage.top.extend(additional_storage_with_genesis(&block));
|
||||
|
||||
storage
|
||||
@@ -149,9 +149,9 @@ pub type TestClientBuilder<E, B> = substrate_test_client::TestClientBuilder<
|
||||
>;
|
||||
|
||||
/// Test client type with `LocalExecutor` and generic Backend.
|
||||
pub type Client<B> = sc_client::Client<
|
||||
pub type Client<B> = client::Client<
|
||||
B,
|
||||
sc_client::LocalCallExecutor<B, sc_executor::NativeExecutor<LocalExecutor>>,
|
||||
client::LocalCallExecutor<B, sc_executor::NativeExecutor<LocalExecutor>>,
|
||||
substrate_test_runtime::Block,
|
||||
substrate_test_runtime::RuntimeApi,
|
||||
>;
|
||||
@@ -230,14 +230,14 @@ pub trait TestClientBuilderExt<B>: Sized {
|
||||
}
|
||||
|
||||
/// Build the test client and longest chain selector.
|
||||
fn build_with_longest_chain(self) -> (Client<B>, sc_client::LongestChain<B, substrate_test_runtime::Block>);
|
||||
fn build_with_longest_chain(self) -> (Client<B>, sc_consensus::LongestChain<B, substrate_test_runtime::Block>);
|
||||
|
||||
/// Build the test client and the backend.
|
||||
fn build_with_backend(self) -> (Client<B>, Arc<B>);
|
||||
}
|
||||
|
||||
impl<B> TestClientBuilderExt<B> for TestClientBuilder<
|
||||
sc_client::LocalCallExecutor<B, sc_executor::NativeExecutor<LocalExecutor>>,
|
||||
client::LocalCallExecutor<B, sc_executor::NativeExecutor<LocalExecutor>>,
|
||||
B
|
||||
> where
|
||||
B: sc_client_api::backend::Backend<substrate_test_runtime::Block> + 'static,
|
||||
@@ -249,7 +249,7 @@ impl<B> TestClientBuilderExt<B> for TestClientBuilder<
|
||||
Self::genesis_init_mut(self)
|
||||
}
|
||||
|
||||
fn build_with_longest_chain(self) -> (Client<B>, sc_client::LongestChain<B, substrate_test_runtime::Block>) {
|
||||
fn build_with_longest_chain(self) -> (Client<B>, sc_consensus::LongestChain<B, substrate_test_runtime::Block>) {
|
||||
self.build_with_native_executor(None)
|
||||
}
|
||||
|
||||
@@ -344,15 +344,15 @@ pub fn new() -> Client<Backend> {
|
||||
|
||||
/// Creates new light client instance used for tests.
|
||||
pub fn new_light() -> (
|
||||
sc_client::Client<LightBackend, LightExecutor, substrate_test_runtime::Block, substrate_test_runtime::RuntimeApi>,
|
||||
client::Client<LightBackend, LightExecutor, substrate_test_runtime::Block, substrate_test_runtime::RuntimeApi>,
|
||||
Arc<LightBackend>,
|
||||
) {
|
||||
|
||||
let storage = sc_client_db::light::LightStorage::new_test();
|
||||
let blockchain = Arc::new(sc_client::light::blockchain::Blockchain::new(storage));
|
||||
let blockchain = Arc::new(client::light::blockchain::Blockchain::new(storage));
|
||||
let backend = Arc::new(LightBackend::new(blockchain.clone()));
|
||||
let executor = new_native_executor();
|
||||
let local_call_executor = sc_client::LocalCallExecutor::new(backend.clone(), executor, sp_core::tasks::executor(), Default::default());
|
||||
let local_call_executor = client::LocalCallExecutor::new(backend.clone(), executor, sp_core::tasks::executor(), Default::default());
|
||||
let call_executor = LightExecutor::new(
|
||||
backend.clone(),
|
||||
local_call_executor,
|
||||
|
||||
@@ -26,7 +26,7 @@ use crate::{
|
||||
};
|
||||
use sc_client_api::backend;
|
||||
use sc_client_api::blockchain::{Backend as BlockChainBackendT, HeaderBackend};
|
||||
use substrate_test_client::sp_consensus::BlockOrigin;
|
||||
use sp_consensus::BlockOrigin;
|
||||
use substrate_test_runtime::{self, Transfer};
|
||||
use sp_runtime::generic::BlockId;
|
||||
use sp_runtime::traits::{Block as BlockT, HashFor};
|
||||
|
||||
@@ -23,6 +23,7 @@ use codec::{Encode, KeyedVec, Joiner};
|
||||
use sp_core::{ChangesTrieConfiguration, map};
|
||||
use sp_core::storage::{well_known_keys, Storage};
|
||||
use sp_runtime::traits::{Block as BlockT, Hash as HashT, Header as HeaderT};
|
||||
use sc_service::client::genesis;
|
||||
|
||||
/// Configuration of a general Substrate test genesis block.
|
||||
pub struct GenesisConfig {
|
||||
@@ -96,7 +97,7 @@ pub fn insert_genesis_block(
|
||||
let state_root = <<<crate::Block as BlockT>::Header as HeaderT>::Hashing as HashT>::trie_root(
|
||||
storage.top.clone().into_iter().collect()
|
||||
);
|
||||
let block: crate::Block = sc_client::genesis::construct_genesis_block(state_root);
|
||||
let block: crate::Block = genesis::construct_genesis_block(state_root);
|
||||
let genesis_hash = block.header.hash();
|
||||
storage.top.extend(additional_storage_with_genesis(&block));
|
||||
genesis_hash
|
||||
|
||||
Reference in New Issue
Block a user