mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 13:31:10 +00:00
substrate test runner
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
/target
|
||||
**/*.rs.bk
|
||||
Cargo.lock
|
||||
.vscode/
|
||||
.idea/
|
||||
+10
-10
@@ -31,24 +31,24 @@ url = "2.1.1"
|
||||
codec = { package = "parity-scale-codec", version = "1.3.4", default-features = false, features = ["derive", "full"] }
|
||||
|
||||
frame-metadata = { version = "11.0.0-rc5", package = "frame-metadata" }
|
||||
frame-support = { version = "2.0.0-rc5", package = "frame-support" }
|
||||
sp-runtime = { version = "2.0.0-rc5", package = "sp-runtime" }
|
||||
sp-version = { version = "2.0.0-rc5", package = "sp-version" }
|
||||
pallet-indices = { version = "2.0.0-rc5", package = "pallet-indices" }
|
||||
frame-support = { git = "https://github.com/paritytech/substrate.git", branch = "seun-substrate-test-runner", package = "frame-support" }
|
||||
sp-runtime = { git = "https://github.com/paritytech/substrate.git", branch = "seun-substrate-test-runner", package = "sp-runtime" }
|
||||
sp-version = { git = "https://github.com/paritytech/substrate.git", branch = "seun-substrate-test-runner", package = "sp-version" }
|
||||
pallet-indices = { git = "https://github.com/paritytech/substrate.git", branch = "seun-substrate-test-runner", package = "pallet-indices" }
|
||||
hex = "0.4.2"
|
||||
sp-rpc = { version = "2.0.0-rc5", package = "sp-rpc" }
|
||||
sp-core = { version = "2.0.0-rc5", package = "sp-core" }
|
||||
sp-rpc = { git = "https://github.com/paritytech/substrate.git", branch = "seun-substrate-test-runner", package = "sp-rpc" }
|
||||
sp-core = { git = "https://github.com/paritytech/substrate.git", branch = "seun-substrate-test-runner", package = "sp-core" }
|
||||
sc-rpc-api = { version = "0.8.0-rc5", package = "sc-rpc-api" }
|
||||
sp-transaction-pool = { version = "2.0.0-rc5", package = "sp-transaction-pool" }
|
||||
sp-transaction-pool = { git = "https://github.com/paritytech/substrate.git", branch = "seun-substrate-test-runner", package = "sp-transaction-pool" }
|
||||
substrate-subxt-client = { version = "0.3.0", path = "client", optional = true }
|
||||
substrate-subxt-proc-macro = { version = "0.11.0", path = "proc-macro" }
|
||||
|
||||
[dev-dependencies]
|
||||
async-std = { version = "1.6.2", features = ["attributes"] }
|
||||
env_logger = "0.7.1"
|
||||
frame-system = { version = "2.0.0-rc5", package = "frame-system" }
|
||||
pallet-balances = { version = "2.0.0-rc5", package = "pallet-balances" }
|
||||
sp-keyring = { version = "2.0.0-rc5", package = "sp-keyring" }
|
||||
frame-system = { git = "https://github.com/paritytech/substrate.git", branch = "seun-substrate-test-runner", package = "frame-system" }
|
||||
pallet-balances = { git = "https://github.com/paritytech/substrate.git", branch = "seun-substrate-test-runner", package = "pallet-balances" }
|
||||
sp-keyring = { git = "https://github.com/paritytech/substrate.git", branch = "seun-substrate-test-runner", package = "sp-keyring" }
|
||||
substrate-subxt-client = { version = "0.3.0", path = "client" }
|
||||
tempdir = "0.3.7"
|
||||
test-node = { path = "test-node" }
|
||||
|
||||
+3
-3
@@ -17,10 +17,10 @@ futures = { version = "0.3.5", features = ["compat"] }
|
||||
futures01 = { package = "futures", version = "0.1.29" }
|
||||
jsonrpsee = "0.1.0"
|
||||
log = "0.4.11"
|
||||
sc-network = { version = "0.8.0-rc5", default-features = false }
|
||||
sc-service = { version = "0.8.0-rc5", default-features = false }
|
||||
sc-network = { git = "https://github.com/paritytech/substrate.git", branch = "seun-substrate-test-runner", default-features = false }
|
||||
sc-service = { git = "https://github.com/paritytech/substrate.git", branch = "seun-substrate-test-runner", default-features = false }
|
||||
serde_json = "1.0.56"
|
||||
sp-keyring = "2.0.0-rc5"
|
||||
sp-keyring = { git = "https://github.com/paritytech/substrate.git", branch = "seun-substrate-test-runner" }
|
||||
thiserror = "1.0.20"
|
||||
|
||||
[dev-dependencies]
|
||||
|
||||
+18
-3
@@ -314,7 +314,8 @@ mod tests {
|
||||
ClientBuilder,
|
||||
KusamaRuntime as NodeTemplateRuntime,
|
||||
PairSigner,
|
||||
};
|
||||
};
|
||||
use std::sync::Arc;
|
||||
use tempdir::TempDir;
|
||||
|
||||
#[async_std::test]
|
||||
@@ -360,7 +361,14 @@ mod tests {
|
||||
};
|
||||
let client = ClientBuilder::<NodeTemplateRuntime>::new()
|
||||
.set_client(
|
||||
SubxtClient::from_config(config, test_node::service::new_light).unwrap(),
|
||||
SubxtClient::from_config(
|
||||
config,
|
||||
|config| {
|
||||
test_node::service::new_light(config)
|
||||
.map(|(task, rpc)| (task, Arc::new(rpc)))
|
||||
},
|
||||
)
|
||||
.expect("Error creating subxt client"),
|
||||
)
|
||||
.build()
|
||||
.await
|
||||
@@ -393,7 +401,14 @@ mod tests {
|
||||
};
|
||||
let client = ClientBuilder::<NodeTemplateRuntime>::new()
|
||||
.set_client(
|
||||
SubxtClient::from_config(config, test_node::service::new_full).unwrap(),
|
||||
SubxtClient::from_config(
|
||||
config,
|
||||
|config| {
|
||||
test_node::service::new_full(config)
|
||||
.map(|(task, rpc)| (task, Arc::new(rpc)))
|
||||
},
|
||||
)
|
||||
.expect("Error creating subxt client"),
|
||||
)
|
||||
.build()
|
||||
.await
|
||||
|
||||
+10
-2
@@ -468,7 +468,9 @@ mod tests {
|
||||
SubxtClient,
|
||||
SubxtClientConfig,
|
||||
};
|
||||
use tempdir::TempDir;
|
||||
use tempdir::TempDir;
|
||||
use std::sync::Arc;
|
||||
|
||||
|
||||
pub(crate) type TestRuntime = crate::NodeTemplateRuntime;
|
||||
|
||||
@@ -496,7 +498,13 @@ mod tests {
|
||||
};
|
||||
let client = ClientBuilder::new()
|
||||
.set_client(
|
||||
SubxtClient::from_config(config, test_node::service::new_full)
|
||||
SubxtClient::from_config(
|
||||
config,
|
||||
|config| {
|
||||
test_node::service::new_full(config)
|
||||
.map(|(task, rpc)| (task, Arc::new(rpc)))
|
||||
},
|
||||
)
|
||||
.expect("Error creating subxt client"),
|
||||
)
|
||||
.build()
|
||||
|
||||
+17
-17
@@ -18,23 +18,23 @@ log = "0.4.11"
|
||||
structopt = "0.3.15"
|
||||
parking_lot = "0.11.0"
|
||||
|
||||
sc-cli = { version = "0.8.0-rc5", features = ["wasmtime"] }
|
||||
sp-core = "2.0.0-rc5"
|
||||
sc-executor = { version = "0.8.0-rc5", features = ["wasmtime"] }
|
||||
sc-service = { version = "0.8.0-rc5", features = ["wasmtime"] }
|
||||
sp-inherents = "2.0.0-rc5"
|
||||
sc-transaction-pool = "2.0.0-rc5"
|
||||
sp-transaction-pool = "2.0.0-rc5"
|
||||
sc-network = "0.8.0-rc5"
|
||||
sc-consensus-aura = "0.8.0-rc5"
|
||||
sp-consensus-aura = "0.8.0-rc5"
|
||||
sp-consensus = "0.8.0-rc5"
|
||||
sc-consensus = "0.8.0-rc5"
|
||||
sc-finality-grandpa = "0.8.0-rc5"
|
||||
sp-finality-grandpa = "2.0.0-rc5"
|
||||
sc-client-api = "2.0.0-rc5"
|
||||
sp-runtime = "2.0.0-rc5"
|
||||
sc-basic-authorship = "0.8.0-rc5"
|
||||
sc-cli = {git = "https://github.com/paritytech/substrate.git", branch = "seun-substrate-test-runner", features = ["wasmtime"] }
|
||||
sp-core = { git = "https://github.com/paritytech/substrate.git", branch = "seun-substrate-test-runner" }
|
||||
sc-executor = {git = "https://github.com/paritytech/substrate.git", branch = "seun-substrate-test-runner", features = ["wasmtime"] }
|
||||
sc-service = {git = "https://github.com/paritytech/substrate.git", branch = "seun-substrate-test-runner", features = ["wasmtime"] }
|
||||
sp-inherents = { git = "https://github.com/paritytech/substrate.git", branch = "seun-substrate-test-runner" }
|
||||
sc-transaction-pool = { git = "https://github.com/paritytech/substrate.git", branch = "seun-substrate-test-runner" }
|
||||
sp-transaction-pool = { git = "https://github.com/paritytech/substrate.git", branch = "seun-substrate-test-runner" }
|
||||
sc-network = { git = "https://github.com/paritytech/substrate.git", branch = "seun-substrate-test-runner" }
|
||||
sc-consensus-aura = { git = "https://github.com/paritytech/substrate.git", branch = "seun-substrate-test-runner" }
|
||||
sp-consensus-aura = { git = "https://github.com/paritytech/substrate.git", branch = "seun-substrate-test-runner" }
|
||||
sp-consensus = { git = "https://github.com/paritytech/substrate.git", branch = "seun-substrate-test-runner" }
|
||||
sc-consensus = { git = "https://github.com/paritytech/substrate.git", branch = "seun-substrate-test-runner" }
|
||||
sc-finality-grandpa = { git = "https://github.com/paritytech/substrate.git", branch = "seun-substrate-test-runner" }
|
||||
sp-finality-grandpa = { git = "https://github.com/paritytech/substrate.git", branch = "seun-substrate-test-runner" }
|
||||
sc-client-api = { git = "https://github.com/paritytech/substrate.git", branch = "seun-substrate-test-runner" }
|
||||
sp-runtime = { git = "https://github.com/paritytech/substrate.git", branch = "seun-substrate-test-runner" }
|
||||
sc-basic-authorship = { git = "https://github.com/paritytech/substrate.git", branch = "seun-substrate-test-runner" }
|
||||
|
||||
test-node-runtime = { version = "2.0.0-rc5", path = "runtime" }
|
||||
|
||||
|
||||
@@ -12,30 +12,30 @@ targets = ["x86_64-unknown-linux-gnu"]
|
||||
|
||||
[dependencies]
|
||||
codec = { package = "parity-scale-codec", version = "1.3.4", default-features = false, features = ["derive"] }
|
||||
|
||||
aura = { version = "2.0.0-rc5", default-features = false, package = "pallet-aura" }
|
||||
balances = { version = "2.0.0-rc5", default-features = false, package = "pallet-balances" }
|
||||
frame-support = { version = "2.0.0-rc5", default-features = false }
|
||||
grandpa = { version = "2.0.0-rc5", default-features = false, package = "pallet-grandpa" }
|
||||
randomness-collective-flip = { version = "2.0.0-rc5", default-features = false, package = "pallet-randomness-collective-flip" }
|
||||
sudo = { version = "2.0.0-rc5", default-features = false, package = "pallet-sudo" }
|
||||
system = { version = "2.0.0-rc5", default-features = false, package = "frame-system" }
|
||||
timestamp = { version = "2.0.0-rc5", default-features = false, package = "pallet-timestamp" }
|
||||
transaction-payment = { version = "2.0.0-rc5", default-features = false, package = "pallet-transaction-payment" }
|
||||
frame-executive = { version = "2.0.0-rc5", default-features = false }
|
||||
serde = { version = "1.0.114", optional = true, features = ["derive"] }
|
||||
sp-api = { version = "2.0.0-rc5", default-features = false }
|
||||
sp-block-builder = { version = "2.0.0-rc5", default-features = false }
|
||||
sp-consensus-aura = { version = "0.8.0-rc5", default-features = false }
|
||||
sp-core = { version = "2.0.0-rc5", default-features = false }
|
||||
sp-inherents = { version = "2.0.0-rc5", default-features = false }
|
||||
sp-io = { version = "2.0.0-rc5", default-features = false }
|
||||
sp-offchain = { version = "2.0.0-rc5", default-features = false }
|
||||
sp-runtime = { version = "2.0.0-rc5", default-features = false }
|
||||
sp-session = { version = "2.0.0-rc5", default-features = false }
|
||||
sp-std = { version = "2.0.0-rc5", default-features = false }
|
||||
sp-transaction-pool = { version = "2.0.0-rc5", default-features = false }
|
||||
sp-version = { version = "2.0.0-rc5", default-features = false }
|
||||
|
||||
aura = { git = "https://github.com/paritytech/substrate.git", branch = "seun-substrate-test-runner", default-features = false, package = "pallet-aura" }
|
||||
balances = { git = "https://github.com/paritytech/substrate.git", branch = "seun-substrate-test-runner", default-features = false, package = "pallet-balances" }
|
||||
frame-support = { git = "https://github.com/paritytech/substrate.git", branch = "seun-substrate-test-runner", default-features = false }
|
||||
grandpa = { git = "https://github.com/paritytech/substrate.git", branch = "seun-substrate-test-runner", default-features = false, package = "pallet-grandpa" }
|
||||
randomness-collective-flip = { git = "https://github.com/paritytech/substrate.git", branch = "seun-substrate-test-runner", default-features = false, package = "pallet-randomness-collective-flip" }
|
||||
sudo = { git = "https://github.com/paritytech/substrate.git", branch = "seun-substrate-test-runner", default-features = false, package = "pallet-sudo" }
|
||||
system = { git = "https://github.com/paritytech/substrate.git", branch = "seun-substrate-test-runner", default-features = false, package = "frame-system" }
|
||||
timestamp = { git = "https://github.com/paritytech/substrate.git", branch = "seun-substrate-test-runner", default-features = false, package = "pallet-timestamp" }
|
||||
transaction-payment = { git = "https://github.com/paritytech/substrate.git", branch = "seun-substrate-test-runner", default-features = false, package = "pallet-transaction-payment" }
|
||||
frame-executive = { git = "https://github.com/paritytech/substrate.git", branch = "seun-substrate-test-runner", default-features = false }
|
||||
sp-api = { git = "https://github.com/paritytech/substrate.git", branch = "seun-substrate-test-runner", default-features = false }
|
||||
sp-block-builder = { git = "https://github.com/paritytech/substrate.git", branch = "seun-substrate-test-runner", default-features = false }
|
||||
sp-consensus-aura = { git = "https://github.com/paritytech/substrate.git", branch = "seun-substrate-test-runner", default-features = false }
|
||||
sp-core = { git = "https://github.com/paritytech/substrate.git", branch = "seun-substrate-test-runner", default-features = false }
|
||||
sp-inherents = { git = "https://github.com/paritytech/substrate.git", branch = "seun-substrate-test-runner", default-features = false }
|
||||
sp-io = { git = "https://github.com/paritytech/substrate.git", branch = "seun-substrate-test-runner", default-features = false }
|
||||
sp-offchain = { git = "https://github.com/paritytech/substrate.git", branch = "seun-substrate-test-runner", default-features = false }
|
||||
sp-runtime = { git = "https://github.com/paritytech/substrate.git", branch = "seun-substrate-test-runner", default-features = false }
|
||||
sp-session = { git = "https://github.com/paritytech/substrate.git", branch = "seun-substrate-test-runner", default-features = false }
|
||||
sp-std = { git = "https://github.com/paritytech/substrate.git", branch = "seun-substrate-test-runner", default-features = false }
|
||||
sp-transaction-pool = { git = "https://github.com/paritytech/substrate.git", branch = "seun-substrate-test-runner", default-features = false }
|
||||
sp-version = { git = "https://github.com/paritytech/substrate.git", branch = "seun-substrate-test-runner", default-features = false }
|
||||
|
||||
[build-dependencies]
|
||||
wasm-builder-runner = { version = "1.0.5", package = "substrate-wasm-builder-runner" }
|
||||
|
||||
+35
-25
@@ -14,19 +14,11 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with substrate-subxt. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
use crate::{
|
||||
chain_spec,
|
||||
cli::Cli,
|
||||
service,
|
||||
service::new_full_params,
|
||||
};
|
||||
use sc_cli::{
|
||||
ChainSpec,
|
||||
Role,
|
||||
RuntimeVersion,
|
||||
SubstrateCli,
|
||||
};
|
||||
use sc_service::ServiceParams;
|
||||
use crate::{chain_spec, cli::Cli, service::{self, Executor}};
|
||||
use sc_cli::{ChainSpec, Role, RuntimeVersion, SubstrateCli};
|
||||
use std::sync::Arc;
|
||||
use sp_consensus_aura::sr25519::AuthorityPair as AuraPair;
|
||||
use test_node_runtime::{opaque::Block, RuntimeApi};
|
||||
|
||||
impl SubstrateCli for Cli {
|
||||
fn impl_name() -> String {
|
||||
@@ -78,18 +70,36 @@ pub fn run() -> sc_cli::Result<()> {
|
||||
Some(subcommand) => {
|
||||
let runner = cli.create_runner(subcommand)?;
|
||||
runner.run_subcommand(subcommand, |config| {
|
||||
let (
|
||||
ServiceParams {
|
||||
client,
|
||||
backend,
|
||||
task_manager,
|
||||
import_queue,
|
||||
..
|
||||
},
|
||||
..,
|
||||
) = new_full_params(config)?;
|
||||
Ok((client, backend, import_queue, task_manager))
|
||||
})
|
||||
sc_service::new_full_parts::<Block, RuntimeApi, Executor>(&config)
|
||||
.and_then(|(client, backend, _, task_manager)| {
|
||||
let client = Arc::new(client);
|
||||
let select_chain = sc_consensus::LongestChain::new(backend.clone());
|
||||
let inherent_data_providers = sp_inherents::InherentDataProviders::new();
|
||||
|
||||
let (grandpa_block_import, _) = sc_finality_grandpa::block_import(
|
||||
client.clone(),
|
||||
&(client.clone() as Arc<_>),
|
||||
select_chain.clone(),
|
||||
)?;
|
||||
|
||||
let aura_block_import = sc_consensus_aura::AuraBlockImport::<_, _, _, AuraPair>::new(
|
||||
grandpa_block_import.clone(),
|
||||
client.clone(),
|
||||
);
|
||||
|
||||
let import_queue = sc_consensus_aura::import_queue::<_, _, _, AuraPair, _>(
|
||||
sc_consensus_aura::slot_duration(&*client)?,
|
||||
aura_block_import,
|
||||
Some(Box::new(grandpa_block_import.clone())),
|
||||
None,
|
||||
client.clone(),
|
||||
inherent_data_providers.clone(),
|
||||
&task_manager.spawn_handle(),
|
||||
config.prometheus_registry(),
|
||||
)?;
|
||||
Ok((client, backend, import_queue, task_manager))
|
||||
})
|
||||
})
|
||||
}
|
||||
None => {
|
||||
let runner = cli.create_runner(&cli.run)?;
|
||||
|
||||
+77
-134
@@ -28,11 +28,8 @@ use sc_finality_grandpa::{
|
||||
StorageAndProofProvider,
|
||||
};
|
||||
use sc_service::{
|
||||
error::Error as ServiceError,
|
||||
Configuration,
|
||||
RpcHandlers,
|
||||
ServiceComponents,
|
||||
TaskManager,
|
||||
error::Error as ServiceError, Configuration, RpcHandlers,
|
||||
TaskManager, SpawnTasksParams, BuildNetworkParams, build_network,
|
||||
};
|
||||
use sp_consensus_aura::sr25519::AuthorityPair as AuraPair;
|
||||
use sp_inherents::InherentDataProviders;
|
||||
@@ -53,49 +50,19 @@ native_executor_instance!(
|
||||
test_node_runtime::native_version,
|
||||
);
|
||||
|
||||
type FullClient = sc_service::TFullClient<Block, RuntimeApi, Executor>;
|
||||
type FullBackend = sc_service::TFullBackend<Block>;
|
||||
type FullSelectChain = sc_consensus::LongestChain<FullBackend, Block>;
|
||||
|
||||
pub fn new_full_params(
|
||||
config: Configuration,
|
||||
) -> Result<
|
||||
(
|
||||
sc_service::ServiceParams<
|
||||
Block,
|
||||
FullClient,
|
||||
sc_consensus_aura::AuraImportQueue<Block, FullClient>,
|
||||
sc_transaction_pool::FullPool<Block, FullClient>,
|
||||
(),
|
||||
FullBackend,
|
||||
>,
|
||||
FullSelectChain,
|
||||
sp_inherents::InherentDataProviders,
|
||||
sc_finality_grandpa::GrandpaBlockImport<
|
||||
FullBackend,
|
||||
Block,
|
||||
FullClient,
|
||||
FullSelectChain,
|
||||
>,
|
||||
sc_finality_grandpa::LinkHalf<Block, FullClient, FullSelectChain>,
|
||||
),
|
||||
ServiceError,
|
||||
> {
|
||||
let inherent_data_providers = sp_inherents::InherentDataProviders::new();
|
||||
/// Builds a new service for a full client.
|
||||
pub fn new_full(config: Configuration) -> Result<(TaskManager, RpcHandlers), ServiceError> {
|
||||
let inherent_data_providers = sp_inherents::InherentDataProviders::new();
|
||||
|
||||
let (client, backend, keystore, task_manager) =
|
||||
let (client, backend, keystore, mut task_manager) =
|
||||
sc_service::new_full_parts::<Block, RuntimeApi, Executor>(&config)?;
|
||||
let client = Arc::new(client);
|
||||
|
||||
let select_chain = sc_consensus::LongestChain::new(backend.clone());
|
||||
|
||||
let pool_api = sc_transaction_pool::FullChainApi::new(
|
||||
client.clone(),
|
||||
config.prometheus_registry(),
|
||||
);
|
||||
let transaction_pool = sc_transaction_pool::BasicPool::new_full(
|
||||
config.transaction_pool.clone(),
|
||||
std::sync::Arc::new(pool_api),
|
||||
config.prometheus_registry(),
|
||||
task_manager.spawn_handle(),
|
||||
client.clone(),
|
||||
@@ -121,81 +88,52 @@ pub fn new_full_params(
|
||||
inherent_data_providers.clone(),
|
||||
&task_manager.spawn_handle(),
|
||||
config.prometheus_registry(),
|
||||
)?;
|
||||
|
||||
let provider = client.clone() as Arc<dyn StorageAndProofProvider<_, _>>;
|
||||
let finality_proof_provider =
|
||||
Arc::new(GrandpaFinalityProofProvider::new(backend.clone(), provider));
|
||||
|
||||
let params = sc_service::ServiceParams {
|
||||
backend,
|
||||
client,
|
||||
import_queue,
|
||||
keystore,
|
||||
task_manager,
|
||||
transaction_pool,
|
||||
config,
|
||||
block_announce_validator_builder: None,
|
||||
finality_proof_request_builder: None,
|
||||
finality_proof_provider: Some(finality_proof_provider),
|
||||
on_demand: None,
|
||||
remote_blockchain: None,
|
||||
rpc_extensions_builder: Box::new(|_| ()),
|
||||
};
|
||||
|
||||
Ok((
|
||||
params,
|
||||
select_chain,
|
||||
inherent_data_providers,
|
||||
grandpa_block_import,
|
||||
grandpa_link,
|
||||
))
|
||||
}
|
||||
|
||||
/// Builds a new service for a full client.
|
||||
pub fn new_full(
|
||||
config: Configuration,
|
||||
) -> Result<(TaskManager, Arc<RpcHandlers>), ServiceError> {
|
||||
let (params, select_chain, inherent_data_providers, block_import, grandpa_link) =
|
||||
new_full_params(config)?;
|
||||
|
||||
)?;
|
||||
let (
|
||||
role,
|
||||
force_authoring,
|
||||
name,
|
||||
enable_grandpa,
|
||||
prometheus_registry,
|
||||
client,
|
||||
transaction_pool,
|
||||
keystore,
|
||||
) = {
|
||||
let sc_service::ServiceParams {
|
||||
config,
|
||||
client,
|
||||
transaction_pool,
|
||||
keystore,
|
||||
..
|
||||
} = ¶ms;
|
||||
) = (
|
||||
config.role.clone(),
|
||||
config.force_authoring,
|
||||
config.network.node_name.clone(),
|
||||
!config.disable_grandpa,
|
||||
config.prometheus_registry().cloned(),
|
||||
);
|
||||
|
||||
(
|
||||
config.role.clone(),
|
||||
config.force_authoring,
|
||||
config.network.node_name.clone(),
|
||||
!config.disable_grandpa,
|
||||
config.prometheus_registry().cloned(),
|
||||
client.clone(),
|
||||
transaction_pool.clone(),
|
||||
keystore.clone(),
|
||||
)
|
||||
};
|
||||
let provider = client.clone() as Arc<dyn StorageAndProofProvider<_, _>>;
|
||||
let finality_proof_provider =
|
||||
Arc::new(GrandpaFinalityProofProvider::new(backend.clone(), provider));
|
||||
let (network, network_status_sinks, system_rpc_tx) = build_network(BuildNetworkParams {
|
||||
config: &config,
|
||||
client: client.clone(),
|
||||
transaction_pool: transaction_pool.clone(),
|
||||
spawn_handle: task_manager.spawn_handle(),
|
||||
import_queue,
|
||||
on_demand: None,
|
||||
block_announce_validator_builder: None,
|
||||
finality_proof_request_builder: None,
|
||||
finality_proof_provider: Some(finality_proof_provider),
|
||||
})?;
|
||||
let params = SpawnTasksParams {
|
||||
config,
|
||||
client: client.clone(),
|
||||
backend: backend.clone(),
|
||||
task_manager: &mut task_manager,
|
||||
keystore: keystore.clone(),
|
||||
on_demand: None,
|
||||
transaction_pool: transaction_pool.clone(),
|
||||
rpc_extensions_builder: Box::new(|_| {}),
|
||||
remote_blockchain: None,
|
||||
network: network.clone(),
|
||||
network_status_sinks,
|
||||
system_rpc_tx,
|
||||
telemetry_connection_sinks: Default::default()
|
||||
};
|
||||
|
||||
let ServiceComponents {
|
||||
task_manager,
|
||||
rpc_handlers,
|
||||
network,
|
||||
telemetry_on_connect_sinks,
|
||||
..
|
||||
} = sc_service::build(params)?;
|
||||
let rpc_handlers = sc_service::spawn_tasks(params)?;
|
||||
|
||||
if role.is_authority() {
|
||||
let proposer = sc_basic_authorship::ProposerFactory::new(
|
||||
@@ -211,7 +149,7 @@ pub fn new_full(
|
||||
sc_consensus_aura::slot_duration(&*client)?,
|
||||
client.clone(),
|
||||
select_chain,
|
||||
block_import,
|
||||
grandpa_block_import,
|
||||
proposer,
|
||||
network.clone(),
|
||||
inherent_data_providers.clone(),
|
||||
@@ -256,7 +194,7 @@ pub fn new_full(
|
||||
link: grandpa_link,
|
||||
network,
|
||||
inherent_data_providers,
|
||||
telemetry_on_connect: Some(telemetry_on_connect_sinks.on_connect_stream()),
|
||||
telemetry_on_connect: None,
|
||||
voting_rule: sc_finality_grandpa::VotingRulesBuilder::default().build(),
|
||||
prometheus_registry,
|
||||
shared_voter_state: SharedVoterState::empty(),
|
||||
@@ -282,20 +220,17 @@ pub fn new_full(
|
||||
/// Builds a new service for a light client.
|
||||
pub fn new_light(
|
||||
config: Configuration,
|
||||
) -> Result<(TaskManager, Arc<RpcHandlers>), ServiceError> {
|
||||
let (client, backend, keystore, task_manager, on_demand) =
|
||||
) -> Result<(TaskManager, RpcHandlers), ServiceError> {
|
||||
let (client, backend, keystore, mut task_manager, on_demand) =
|
||||
sc_service::new_light_parts::<Block, RuntimeApi, Executor>(&config)?;
|
||||
|
||||
let transaction_pool_api = Arc::new(sc_transaction_pool::LightChainApi::new(
|
||||
client.clone(),
|
||||
on_demand.clone(),
|
||||
));
|
||||
let transaction_pool = sc_transaction_pool::BasicPool::new_light(
|
||||
let transaction_pool = Arc::new(sc_transaction_pool::BasicPool::new_light(
|
||||
config.transaction_pool.clone(),
|
||||
transaction_pool_api,
|
||||
config.prometheus_registry(),
|
||||
task_manager.spawn_handle(),
|
||||
);
|
||||
task_manager.spawn_handle(),
|
||||
client.clone(),
|
||||
on_demand.clone(),
|
||||
));
|
||||
|
||||
let grandpa_block_import = sc_finality_grandpa::light_block_import(
|
||||
client.clone(),
|
||||
@@ -321,28 +256,36 @@ pub fn new_light(
|
||||
let finality_proof_provider = Arc::new(GrandpaFinalityProofProvider::new(
|
||||
backend.clone(),
|
||||
client.clone() as Arc<_>,
|
||||
));
|
||||
|
||||
sc_service::build(sc_service::ServiceParams {
|
||||
));
|
||||
|
||||
let (network, network_status_sinks, system_rpc_tx) = build_network(BuildNetworkParams {
|
||||
config: &config,
|
||||
client: client.clone(),
|
||||
transaction_pool: transaction_pool.clone(),
|
||||
spawn_handle: task_manager.spawn_handle(),
|
||||
import_queue,
|
||||
on_demand: Some(on_demand.clone()),
|
||||
block_announce_validator_builder: None,
|
||||
finality_proof_request_builder: Some(finality_proof_request_builder),
|
||||
finality_proof_provider: Some(finality_proof_provider),
|
||||
})?;
|
||||
|
||||
let params = SpawnTasksParams {
|
||||
on_demand: Some(on_demand),
|
||||
network,
|
||||
client,
|
||||
backend: backend.clone(),
|
||||
network_status_sinks,
|
||||
system_rpc_tx,
|
||||
telemetry_connection_sinks: Default::default(),
|
||||
remote_blockchain: Some(backend.remote_blockchain()),
|
||||
rpc_extensions_builder: Box::new(|_| ()),
|
||||
transaction_pool: Arc::new(transaction_pool),
|
||||
transaction_pool,
|
||||
config,
|
||||
client,
|
||||
import_queue,
|
||||
keystore,
|
||||
backend,
|
||||
task_manager,
|
||||
})
|
||||
.map(
|
||||
|ServiceComponents {
|
||||
task_manager,
|
||||
rpc_handlers,
|
||||
..
|
||||
}| (task_manager, rpc_handlers),
|
||||
)
|
||||
task_manager: &mut task_manager,
|
||||
};
|
||||
|
||||
sc_service::spawn_tasks(params)
|
||||
.map(|rpc_handlers| (task_manager, rpc_handlers))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user