Migrate back to Substrate master (#528)

* migrate back to Substrate master

* fmt

* clippy
This commit is contained in:
Svyatoslav Nikolsky
2020-11-24 22:39:21 +03:00
committed by Bastian Köcher
parent 698d8d5600
commit dd7242bc79
32 changed files with 307 additions and 307 deletions
+5 -3
View File
@@ -152,9 +152,11 @@ pub fn run() -> sc_cli::Result<()> {
}
None => {
let runner = cli.create_runner(&cli.run)?;
runner.run_node_until_exit(|config| match config.role {
Role::Light => service::new_light(config),
_ => service::new_full(config),
runner.run_node_until_exit(|config| async move {
match config.role {
Role::Light => service::new_light(config),
_ => service::new_full(config),
}
})
}
}
+41 -42
View File
@@ -28,16 +28,13 @@
// =====================================================================================
// =====================================================================================
use bp_message_lane::{LaneId, MessageNonce};
use bp_runtime::{InstanceId, MILLAU_BRIDGE_INSTANCE};
use rialto_runtime::{self, opaque::Block, RuntimeApi};
use sc_client_api::{ExecutorProvider, RemoteBackend};
use sc_executor::native_executor_instance;
pub use sc_executor::NativeExecutor;
use sc_finality_grandpa::{FinalityProofProvider as GrandpaFinalityProofProvider, SharedVoterState};
use sc_finality_grandpa::SharedVoterState;
use sc_service::{error::Error as ServiceError, Configuration, TaskManager};
use sp_consensus_aura::sr25519::AuthorityPair as AuraPair;
use sp_core::storage::StorageKey;
use sp_inherents::InherentDataProviders;
use std::sync::Arc;
use std::time::Duration;
@@ -65,7 +62,12 @@ pub fn new_partial(
sp_consensus::DefaultImportQueue<Block, FullClient>,
sc_transaction_pool::FullPool<Block, FullClient>,
(
sc_finality_grandpa::GrandpaBlockImport<FullBackend, Block, FullClient, FullSelectChain>,
sc_consensus_aura::AuraBlockImport<
Block,
FullClient,
sc_finality_grandpa::GrandpaBlockImport<FullBackend, Block, FullClient, FullSelectChain>,
AuraPair,
>,
sc_finality_grandpa::LinkHalf<Block, FullClient, FullSelectChain>,
),
>,
@@ -73,7 +75,8 @@ pub fn new_partial(
> {
let inherent_data_providers = sp_inherents::InherentDataProviders::new();
let (client, backend, keystore, task_manager) = sc_service::new_full_parts::<Block, RuntimeApi, Executor>(&config)?;
let (client, backend, keystore_container, 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());
@@ -93,9 +96,8 @@ pub fn new_partial(
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,
aura_block_import.clone(),
Some(Box::new(grandpa_block_import)),
client.clone(),
inherent_data_providers.clone(),
&task_manager.spawn_handle(),
@@ -108,11 +110,11 @@ pub fn new_partial(
backend,
task_manager,
import_queue,
keystore,
keystore_container,
select_chain,
transaction_pool,
inherent_data_providers,
other: (grandpa_block_import, grandpa_link),
other: (aura_block_import, grandpa_link),
})
}
@@ -123,15 +125,13 @@ pub fn new_full(config: Configuration) -> Result<TaskManager, ServiceError> {
backend,
mut task_manager,
import_queue,
keystore,
keystore_container,
select_chain,
transaction_pool,
inherent_data_providers,
other: (block_import, grandpa_link),
} = new_partial(&config)?;
let finality_proof_provider = GrandpaFinalityProofProvider::new_for_service(backend.clone(), client.clone());
let (network, network_status_sinks, system_rpc_tx, network_starter) =
sc_service::build_network(sc_service::BuildNetworkParams {
config: &config,
@@ -141,8 +141,6 @@ pub fn new_full(config: Configuration) -> Result<TaskManager, ServiceError> {
import_queue,
on_demand: None,
block_announce_validator_builder: None,
finality_proof_request_builder: None,
finality_proof_provider: Some(finality_proof_provider),
})?;
if config.offchain_worker.enabled {
@@ -157,12 +155,18 @@ pub fn new_full(config: Configuration) -> Result<TaskManager, ServiceError> {
let role = config.role.clone();
let force_authoring = config.force_authoring;
let backoff_authoring_blocks: Option<()> = None;
let name = config.network.node_name.clone();
let enable_grandpa = !config.disable_grandpa;
let prometheus_registry = config.prometheus_registry().cloned();
let telemetry_connection_sinks = sc_service::TelemetryConnectionSinks::default();
let rpc_extensions_builder = {
use bp_message_lane::{LaneId, MessageNonce};
use bp_runtime::{InstanceId, MILLAU_BRIDGE_INSTANCE};
use sc_finality_grandpa::FinalityProofProvider as GrandpaFinalityProofProvider;
use sp_core::storage::StorageKey;
// This struct is here to ease update process.
/// Rialto runtime from message-lane RPC point of view.
@@ -231,7 +235,7 @@ pub fn new_full(config: Configuration) -> Result<TaskManager, ServiceError> {
sc_service::spawn_tasks(sc_service::SpawnTasksParams {
network: network.clone(),
client: client.clone(),
keystore: keystore.clone(),
keystore: keystore_container.sync_keystore(),
task_manager: &mut task_manager,
transaction_pool: transaction_pool.clone(),
telemetry_connection_sinks: telemetry_connection_sinks.clone(),
@@ -245,21 +249,26 @@ pub fn new_full(config: Configuration) -> Result<TaskManager, ServiceError> {
})?;
if role.is_authority() {
let proposer =
sc_basic_authorship::ProposerFactory::new(client.clone(), transaction_pool, prometheus_registry.as_ref());
let proposer = sc_basic_authorship::ProposerFactory::new(
task_manager.spawn_handle(),
client.clone(),
transaction_pool,
prometheus_registry.as_ref(),
);
let can_author_with = sp_consensus::CanAuthorWithNativeVersion::new(client.executor().clone());
let aura = sc_consensus_aura::start_aura::<_, _, _, _, _, AuraPair, _, _, _>(
let aura = sc_consensus_aura::start_aura::<_, _, _, _, _, AuraPair, _, _, _, _>(
sc_consensus_aura::slot_duration(&*client)?,
client.clone(),
select_chain,
block_import,
proposer,
network.clone(),
inherent_data_providers.clone(),
inherent_data_providers,
force_authoring,
keystore.clone(),
backoff_authoring_blocks,
keystore_container.sync_keystore(),
can_author_with,
)?;
@@ -271,7 +280,7 @@ pub fn new_full(config: Configuration) -> Result<TaskManager, ServiceError> {
// if the node isn't actively participating in consensus then it doesn't
// need a keystore, regardless of which protocol we use below.
let keystore = if role.is_authority() {
Some(keystore as sp_core::traits::BareCryptoStorePtr)
Some(keystore_container.sync_keystore())
} else {
None
};
@@ -297,7 +306,6 @@ pub fn new_full(config: Configuration) -> Result<TaskManager, ServiceError> {
config: grandpa_config,
link: grandpa_link,
network,
inherent_data_providers,
telemetry_on_connect: Some(telemetry_connection_sinks.on_connect_stream()),
voting_rule: sc_finality_grandpa::VotingRulesBuilder::default().build(),
prometheus_registry,
@@ -310,7 +318,7 @@ pub fn new_full(config: Configuration) -> Result<TaskManager, ServiceError> {
.spawn_essential_handle()
.spawn_blocking("grandpa-voter", sc_finality_grandpa::run_grandpa_voter(grandpa_config)?);
} else {
sc_finality_grandpa::setup_disabled_grandpa(client, &inherent_data_providers, network)?;
sc_finality_grandpa::setup_disabled_grandpa(network)?;
}
network_starter.start_network();
@@ -319,9 +327,11 @@ pub fn new_full(config: Configuration) -> Result<TaskManager, ServiceError> {
/// Builds a new service for a light client.
pub fn new_light(config: Configuration) -> Result<TaskManager, ServiceError> {
let (client, backend, keystore, mut task_manager, on_demand) =
let (client, backend, keystore_container, mut task_manager, on_demand) =
sc_service::new_light_parts::<Block, RuntimeApi, Executor>(&config)?;
let select_chain = sc_consensus::LongestChain::new(backend.clone());
let transaction_pool = Arc::new(sc_transaction_pool::BasicPool::new_light(
config.transaction_pool.clone(),
config.prometheus_registry(),
@@ -330,20 +340,13 @@ pub fn new_light(config: Configuration) -> Result<TaskManager, ServiceError> {
on_demand.clone(),
));
let grandpa_block_import = sc_finality_grandpa::light_block_import(
client.clone(),
backend.clone(),
&(client.clone() as Arc<_>),
Arc::new(on_demand.checker().clone()) as Arc<_>,
)?;
let finality_proof_import = grandpa_block_import.clone();
let finality_proof_request_builder = finality_proof_import.create_finality_proof_request_builder();
let (grandpa_block_import, _) =
sc_finality_grandpa::block_import(client.clone(), &(client.clone() as Arc<_>), select_chain)?;
let import_queue = sc_consensus_aura::import_queue::<_, _, _, AuraPair, _, _>(
sc_consensus_aura::slot_duration(&*client)?,
grandpa_block_import,
None,
Some(Box::new(finality_proof_import)),
grandpa_block_import.clone(),
Some(Box::new(grandpa_block_import)),
client.clone(),
InherentDataProviders::new(),
&task_manager.spawn_handle(),
@@ -351,8 +354,6 @@ pub fn new_light(config: Configuration) -> Result<TaskManager, ServiceError> {
sp_consensus::NeverCanAuthor,
)?;
let finality_proof_provider = GrandpaFinalityProofProvider::new_for_service(backend.clone(), client.clone());
let (network, network_status_sinks, system_rpc_tx, network_starter) =
sc_service::build_network(sc_service::BuildNetworkParams {
config: &config,
@@ -362,8 +363,6 @@ pub fn new_light(config: Configuration) -> Result<TaskManager, ServiceError> {
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),
})?;
if config.offchain_worker.enabled {
@@ -385,7 +384,7 @@ pub fn new_light(config: Configuration) -> Result<TaskManager, ServiceError> {
telemetry_connection_sinks: sc_service::TelemetryConnectionSinks::default(),
config,
client,
keystore,
keystore: keystore_container.sync_keystore(),
backend,
network,
network_status_sinks,