mirror of
https://github.com/pezkuwichain/pezkuwi-runtime-templates.git
synced 2026-04-30 06:57:58 +00:00
v3 into main (#390)
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
use cumulus_primitives_core::ParaId;
|
||||
use generic_runtime_template::{
|
||||
constants::currency::EXISTENTIAL_DEPOSIT, AccountId, AuraId, Signature,
|
||||
};
|
||||
#[cfg(not(feature = "tanssi"))]
|
||||
use generic_runtime_template::{constants::currency::EXISTENTIAL_DEPOSIT, AuraId};
|
||||
use generic_runtime_template::{AccountId, Signature};
|
||||
use sc_chain_spec::{ChainSpecExtension, ChainSpecGroup};
|
||||
use sc_service::ChainType;
|
||||
use serde::{Deserialize, Serialize};
|
||||
@@ -44,6 +44,7 @@ type AccountPublic = <Signature as Verify>::Signer;
|
||||
///
|
||||
/// This function's return type must always match the session keys of the chain
|
||||
/// in tuple format.
|
||||
#[cfg(not(feature = "tanssi"))]
|
||||
pub fn get_collator_keys_from_seed(seed: &str) -> AuraId {
|
||||
get_from_seed::<AuraId>(seed)
|
||||
}
|
||||
@@ -60,6 +61,8 @@ where
|
||||
///
|
||||
/// The input must be a tuple of individual keys (a single arg for now since we
|
||||
/// have just one key).
|
||||
///
|
||||
#[cfg(not(feature = "tanssi"))]
|
||||
pub fn template_session_keys(keys: AuraId) -> generic_runtime_template::SessionKeys {
|
||||
generic_runtime_template::SessionKeys { aura: keys }
|
||||
}
|
||||
@@ -86,6 +89,7 @@ pub fn development_config() -> ChainSpec {
|
||||
.with_chain_type(ChainType::Development)
|
||||
.with_genesis_config_patch(testnet_genesis(
|
||||
// initial collators.
|
||||
#[cfg(not(feature = "tanssi"))]
|
||||
vec![
|
||||
(
|
||||
get_account_id_from_seed::<sr25519::Public>("Alice"),
|
||||
@@ -137,6 +141,7 @@ pub fn local_testnet_config() -> ChainSpec {
|
||||
.with_chain_type(ChainType::Local)
|
||||
.with_genesis_config_patch(testnet_genesis(
|
||||
// initial collators.
|
||||
#[cfg(not(feature = "tanssi"))]
|
||||
vec![
|
||||
(
|
||||
get_account_id_from_seed::<sr25519::Public>("Alice"),
|
||||
@@ -169,6 +174,7 @@ pub fn local_testnet_config() -> ChainSpec {
|
||||
.build()
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "tanssi"))]
|
||||
fn testnet_genesis(
|
||||
invulnerables: Vec<(AccountId, AuraId)>,
|
||||
endowed_accounts: Vec<AccountId>,
|
||||
@@ -205,3 +211,24 @@ fn testnet_genesis(
|
||||
"sudo": { "key": Some(root) }
|
||||
})
|
||||
}
|
||||
|
||||
#[cfg(feature = "tanssi")]
|
||||
fn testnet_genesis(
|
||||
endowed_accounts: Vec<AccountId>,
|
||||
root: AccountId,
|
||||
id: ParaId,
|
||||
) -> serde_json::Value {
|
||||
serde_json::json!({
|
||||
"balances": {
|
||||
"balances": endowed_accounts.iter().cloned().map(|k| (k, 1u64 << 60)).collect::<Vec<_>>(),
|
||||
},
|
||||
"parachainInfo": {
|
||||
"parachainId": id,
|
||||
},
|
||||
"treasury": {},
|
||||
"polkadotXcm": {
|
||||
"safeXcmVersion": Some(SAFE_XCM_VERSION),
|
||||
},
|
||||
"sudo": { "key": Some(root) }
|
||||
})
|
||||
}
|
||||
|
||||
@@ -115,7 +115,10 @@ pub fn run() -> Result<()> {
|
||||
match &cli.subcommand {
|
||||
Some(Subcommand::BuildSpec(cmd)) => {
|
||||
let runner = cli.create_runner(cmd)?;
|
||||
runner.sync_run(|config| cmd.run(config.chain_spec, config.network))
|
||||
runner.sync_run(|config| {
|
||||
let chain_spec = config.chain_spec;
|
||||
cmd.run(chain_spec, config.network)
|
||||
})
|
||||
},
|
||||
Some(Subcommand::CheckBlock(cmd)) => {
|
||||
construct_async_run!(|components, cli, cmd, config| {
|
||||
|
||||
@@ -5,18 +5,24 @@ use std::{sync::Arc, time::Duration};
|
||||
|
||||
use cumulus_client_cli::CollatorOptions;
|
||||
// Cumulus Imports
|
||||
#[cfg(not(feature = "tanssi"))]
|
||||
use cumulus_client_collator::service::CollatorService;
|
||||
use cumulus_client_consensus_common::ParachainBlockImport as TParachainBlockImport;
|
||||
#[cfg(not(feature = "tanssi"))]
|
||||
use cumulus_client_consensus_proposer::Proposer;
|
||||
use cumulus_client_service::{
|
||||
build_network, build_relay_chain_interface, prepare_node_config, start_relay_chain_tasks,
|
||||
BuildNetworkParams, CollatorSybilResistance, DARecoveryProfile, ParachainHostFunctions,
|
||||
StartRelayChainTasksParams,
|
||||
};
|
||||
#[cfg(not(feature = "tanssi"))]
|
||||
use cumulus_primitives_core::relay_chain::CollatorPair;
|
||||
#[cfg(feature = "async-backing")]
|
||||
use cumulus_primitives_core::relay_chain::ValidationCode;
|
||||
use cumulus_primitives_core::{relay_chain::CollatorPair, ParaId};
|
||||
use cumulus_relay_chain_interface::{OverseerHandle, RelayChainInterface};
|
||||
use cumulus_primitives_core::ParaId;
|
||||
#[cfg(not(feature = "tanssi"))]
|
||||
use cumulus_relay_chain_interface::OverseerHandle;
|
||||
use cumulus_relay_chain_interface::RelayChainInterface;
|
||||
// Substrate Imports
|
||||
use frame_benchmarking_cli::SUBSTRATE_REFERENCE_HARDWARE;
|
||||
// Local Runtime Types
|
||||
@@ -29,9 +35,13 @@ use sc_consensus::ImportQueue;
|
||||
use sc_executor::{HeapAllocStrategy, WasmExecutor, DEFAULT_HEAP_ALLOC_STRATEGY};
|
||||
use sc_network::NetworkBlock;
|
||||
use sc_service::{Configuration, PartialComponents, TFullBackend, TFullClient, TaskManager};
|
||||
use sc_telemetry::{Telemetry, TelemetryHandle, TelemetryWorker, TelemetryWorkerHandle};
|
||||
#[cfg(not(feature = "tanssi"))]
|
||||
use sc_telemetry::TelemetryHandle;
|
||||
use sc_telemetry::{Telemetry, TelemetryWorker, TelemetryWorkerHandle};
|
||||
use sc_transaction_pool_api::OffchainTransactionPoolFactory;
|
||||
#[cfg(not(feature = "tanssi"))]
|
||||
use sp_keystore::KeystorePtr;
|
||||
#[cfg(not(feature = "tanssi"))]
|
||||
use substrate_prometheus_endpoint::Registry;
|
||||
|
||||
type ParachainExecutor = WasmExecutor<ParachainHostFunctions>;
|
||||
@@ -104,15 +114,23 @@ pub fn new_partial(config: &Configuration) -> Result<Service, sc_service::Error>
|
||||
client.clone(),
|
||||
);
|
||||
|
||||
let block_import = ParachainBlockImport::new(client.clone(), backend.clone());
|
||||
|
||||
let import_queue = build_import_queue(
|
||||
client.clone(),
|
||||
block_import.clone(),
|
||||
config,
|
||||
telemetry.as_ref().map(|telemetry| telemetry.handle()),
|
||||
&task_manager,
|
||||
)?;
|
||||
#[cfg(feature = "tanssi")]
|
||||
let (block_import, import_queue) =
|
||||
import_queue(config, client.clone(), backend.clone(), &task_manager);
|
||||
#[cfg(not(feature = "tanssi"))]
|
||||
let (block_import, import_queue) = {
|
||||
let block_import = ParachainBlockImport::new(client.clone(), backend.clone());
|
||||
(
|
||||
block_import.clone(),
|
||||
build_import_queue(
|
||||
client.clone(),
|
||||
block_import,
|
||||
config,
|
||||
telemetry.as_ref().map(|telemetry| telemetry.handle()),
|
||||
&task_manager,
|
||||
)?,
|
||||
)
|
||||
};
|
||||
|
||||
Ok(PartialComponents {
|
||||
backend,
|
||||
@@ -140,7 +158,10 @@ async fn start_node_impl(
|
||||
let parachain_config = prepare_node_config(parachain_config);
|
||||
|
||||
let params = new_partial(¶chain_config)?;
|
||||
#[cfg(not(feature = "tanssi"))]
|
||||
let (block_import, mut telemetry, telemetry_worker_handle) = params.other;
|
||||
#[cfg(feature = "tanssi")]
|
||||
let (_, mut telemetry, telemetry_worker_handle) = params.other;
|
||||
let net_config = sc_network::config::FullNetworkConfiguration::<
|
||||
_,
|
||||
_,
|
||||
@@ -151,7 +172,7 @@ async fn start_node_impl(
|
||||
let backend = params.backend.clone();
|
||||
let mut task_manager = params.task_manager;
|
||||
|
||||
let (relay_chain_interface, collator_key) = build_relay_chain_interface(
|
||||
let relay_chain_interface = build_relay_chain_interface(
|
||||
polkadot_config,
|
||||
¶chain_config,
|
||||
telemetry_worker_handle,
|
||||
@@ -162,7 +183,13 @@ async fn start_node_impl(
|
||||
.await
|
||||
.map_err(|e| sc_service::Error::Application(Box::new(e) as Box<_>))?;
|
||||
|
||||
#[cfg(not(feature = "tanssi"))]
|
||||
let (relay_chain_interface, collator_key) = relay_chain_interface;
|
||||
#[cfg(feature = "tanssi")]
|
||||
let (relay_chain_interface, _) = relay_chain_interface;
|
||||
|
||||
let validator = parachain_config.role.is_authority();
|
||||
#[cfg(not(feature = "tanssi"))]
|
||||
let prometheus_registry = parachain_config.prometheus_registry().cloned();
|
||||
let transaction_pool = params.transaction_pool.clone();
|
||||
let import_queue_service = params.import_queue.service();
|
||||
@@ -291,6 +318,7 @@ async fn start_node_impl(
|
||||
sync_service: sync_service.clone(),
|
||||
})?;
|
||||
|
||||
#[cfg(not(feature = "tanssi"))]
|
||||
if validator {
|
||||
start_consensus(
|
||||
client.clone(),
|
||||
@@ -316,7 +344,37 @@ async fn start_node_impl(
|
||||
Ok((task_manager, client))
|
||||
}
|
||||
|
||||
#[cfg(feature = "tanssi")]
|
||||
pub fn import_queue(
|
||||
parachain_config: &Configuration,
|
||||
client: Arc<ParachainClient>,
|
||||
backend: Arc<ParachainBackend>,
|
||||
task_manager: &TaskManager,
|
||||
) -> (ParachainBlockImport, sc_consensus::BasicQueue<Block>) {
|
||||
// The nimbus import queue ONLY checks the signature correctness
|
||||
// Any other checks corresponding to the author-correctness should be done
|
||||
// in the runtime
|
||||
let block_import = ParachainBlockImport::new(client.clone(), backend);
|
||||
|
||||
let import_queue = nimbus_consensus::import_queue(
|
||||
client,
|
||||
block_import.clone(),
|
||||
move |_, _| async move {
|
||||
let time = sp_timestamp::InherentDataProvider::from_system_time();
|
||||
|
||||
Ok((time,))
|
||||
},
|
||||
&task_manager.spawn_essential_handle(),
|
||||
parachain_config.prometheus_registry(),
|
||||
false,
|
||||
)
|
||||
.expect("function never fails");
|
||||
|
||||
(block_import, import_queue)
|
||||
}
|
||||
|
||||
/// Build the import queue for the parachain runtime.
|
||||
#[cfg(not(feature = "tanssi"))]
|
||||
fn build_import_queue(
|
||||
client: Arc<ParachainClient>,
|
||||
block_import: ParachainBlockImport,
|
||||
@@ -343,6 +401,7 @@ fn build_import_queue(
|
||||
))
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "tanssi"))]
|
||||
fn start_consensus(
|
||||
client: Arc<ParachainClient>,
|
||||
#[cfg(feature = "async-backing")] backend: Arc<ParachainBackend>,
|
||||
|
||||
Reference in New Issue
Block a user