mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-18 01:21:01 +00:00
Updating glutton for async backing (#1619)
Applied changes from the [User Update Guide](https://docs.google.com/document/d/1WQijD3bZTCsudOyPcDvugv659nCa2hEp2b_8eRU0h-Q), diverging in the node side where service.rs is different for `polkadot-parachain` than in the parachain template.
This commit is contained in:
Generated
+2
@@ -5739,6 +5739,7 @@ dependencies = [
|
|||||||
"cumulus-pallet-aura-ext",
|
"cumulus-pallet-aura-ext",
|
||||||
"cumulus-pallet-parachain-system",
|
"cumulus-pallet-parachain-system",
|
||||||
"cumulus-pallet-xcm",
|
"cumulus-pallet-xcm",
|
||||||
|
"cumulus-primitives-aura",
|
||||||
"cumulus-primitives-core",
|
"cumulus-primitives-core",
|
||||||
"cumulus-primitives-timestamp",
|
"cumulus-primitives-timestamp",
|
||||||
"frame-benchmarking",
|
"frame-benchmarking",
|
||||||
@@ -12325,6 +12326,7 @@ dependencies = [
|
|||||||
"cumulus-client-consensus-proposer",
|
"cumulus-client-consensus-proposer",
|
||||||
"cumulus-client-consensus-relay-chain",
|
"cumulus-client-consensus-relay-chain",
|
||||||
"cumulus-client-service",
|
"cumulus-client-service",
|
||||||
|
"cumulus-primitives-aura",
|
||||||
"cumulus-primitives-core",
|
"cumulus-primitives-core",
|
||||||
"cumulus-primitives-parachain-inherent",
|
"cumulus-primitives-parachain-inherent",
|
||||||
"cumulus-relay-chain-interface",
|
"cumulus-relay-chain-interface",
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ xcm-executor = { package = "staging-xcm-executor", path = "../../../../../polkad
|
|||||||
cumulus-pallet-aura-ext = { path = "../../../../pallets/aura-ext", default-features = false }
|
cumulus-pallet-aura-ext = { path = "../../../../pallets/aura-ext", default-features = false }
|
||||||
cumulus-pallet-parachain-system = { path = "../../../../pallets/parachain-system", default-features = false, features = ["parameterized-consensus-hook",] }
|
cumulus-pallet-parachain-system = { path = "../../../../pallets/parachain-system", default-features = false, features = ["parameterized-consensus-hook",] }
|
||||||
cumulus-pallet-xcm = { path = "../../../../pallets/xcm", default-features = false }
|
cumulus-pallet-xcm = { path = "../../../../pallets/xcm", default-features = false }
|
||||||
|
cumulus-primitives-aura = { path = "../../../../primitives/aura", default-features = false }
|
||||||
cumulus-primitives-core = { path = "../../../../primitives/core", default-features = false }
|
cumulus-primitives-core = { path = "../../../../primitives/core", default-features = false }
|
||||||
cumulus-primitives-timestamp = { path = "../../../../primitives/timestamp", default-features = false }
|
cumulus-primitives-timestamp = { path = "../../../../primitives/timestamp", default-features = false }
|
||||||
parachain-info = { path = "../../../pallets/parachain-info", default-features = false }
|
parachain-info = { path = "../../../pallets/parachain-info", default-features = false }
|
||||||
@@ -72,6 +73,7 @@ std = [
|
|||||||
"cumulus-pallet-aura-ext/std",
|
"cumulus-pallet-aura-ext/std",
|
||||||
"cumulus-pallet-parachain-system/std",
|
"cumulus-pallet-parachain-system/std",
|
||||||
"cumulus-pallet-xcm/std",
|
"cumulus-pallet-xcm/std",
|
||||||
|
"cumulus-primitives-aura/std",
|
||||||
"cumulus-primitives-core/std",
|
"cumulus-primitives-core/std",
|
||||||
"cumulus-primitives-timestamp/std",
|
"cumulus-primitives-timestamp/std",
|
||||||
"frame-benchmarking?/std",
|
"frame-benchmarking?/std",
|
||||||
|
|||||||
@@ -81,12 +81,7 @@ use frame_system::{
|
|||||||
limits::{BlockLength, BlockWeights},
|
limits::{BlockLength, BlockWeights},
|
||||||
EnsureRoot,
|
EnsureRoot,
|
||||||
};
|
};
|
||||||
use parachains_common::{
|
use parachains_common::{AccountId, Signature};
|
||||||
kusama::consensus::{
|
|
||||||
BLOCK_PROCESSING_VELOCITY, RELAY_CHAIN_SLOT_DURATION_MILLIS, UNINCLUDED_SEGMENT_CAPACITY,
|
|
||||||
},
|
|
||||||
AccountId, Signature, SLOT_DURATION,
|
|
||||||
};
|
|
||||||
#[cfg(any(feature = "std", test))]
|
#[cfg(any(feature = "std", test))]
|
||||||
pub use sp_runtime::BuildStorage;
|
pub use sp_runtime::BuildStorage;
|
||||||
pub use sp_runtime::{Perbill, Permill};
|
pub use sp_runtime::{Perbill, Permill};
|
||||||
@@ -123,10 +118,28 @@ const AVERAGE_ON_INITIALIZE_RATIO: Perbill = Perbill::from_percent(10);
|
|||||||
const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75);
|
const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75);
|
||||||
/// We allow for .5 seconds of compute with a 12 second average block time.
|
/// We allow for .5 seconds of compute with a 12 second average block time.
|
||||||
const MAXIMUM_BLOCK_WEIGHT: Weight = Weight::from_parts(
|
const MAXIMUM_BLOCK_WEIGHT: Weight = Weight::from_parts(
|
||||||
WEIGHT_REF_TIME_PER_SECOND.saturating_div(2),
|
WEIGHT_REF_TIME_PER_SECOND.saturating_mul(2),
|
||||||
cumulus_primitives_core::relay_chain::MAX_POV_SIZE as u64,
|
cumulus_primitives_core::relay_chain::MAX_POV_SIZE as u64,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/// Maximum number of blocks simultaneously accepted by the Runtime, not yet included
|
||||||
|
/// into the relay chain.
|
||||||
|
const UNINCLUDED_SEGMENT_CAPACITY: u32 = 3;
|
||||||
|
/// How many parachain blocks are processed by the relay chain per parent. Limits the
|
||||||
|
/// number of blocks authored per slot.
|
||||||
|
const BLOCK_PROCESSING_VELOCITY: u32 = 2;
|
||||||
|
/// Relay chain slot duration, in milliseconds.
|
||||||
|
const RELAY_CHAIN_SLOT_DURATION_MILLIS: u32 = 6000;
|
||||||
|
|
||||||
|
/// This determines the average expected block time that we are targeting.
|
||||||
|
/// Blocks will be produced at a minimum duration defined by `SLOT_DURATION`.
|
||||||
|
/// `SLOT_DURATION` is picked up by `pallet_timestamp` which is in turn picked
|
||||||
|
/// up by `pallet_aura` to implement `fn slot_duration()`.
|
||||||
|
///
|
||||||
|
/// Change this to adjust the block time.
|
||||||
|
pub const MILLISECS_PER_BLOCK: u64 = 6000;
|
||||||
|
pub const SLOT_DURATION: u64 = MILLISECS_PER_BLOCK;
|
||||||
|
|
||||||
parameter_types! {
|
parameter_types! {
|
||||||
pub const BlockHashCount: BlockNumber = 4096;
|
pub const BlockHashCount: BlockNumber = 4096;
|
||||||
pub const Version: RuntimeVersion = VERSION;
|
pub const Version: RuntimeVersion = VERSION;
|
||||||
@@ -184,6 +197,13 @@ parameter_types! {
|
|||||||
pub const ReservedDmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT.saturating_div(2);
|
pub const ReservedDmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT.saturating_div(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type ConsensusHook = cumulus_pallet_aura_ext::FixedVelocityConsensusHook<
|
||||||
|
Runtime,
|
||||||
|
RELAY_CHAIN_SLOT_DURATION_MILLIS,
|
||||||
|
BLOCK_PROCESSING_VELOCITY,
|
||||||
|
UNINCLUDED_SEGMENT_CAPACITY,
|
||||||
|
>;
|
||||||
|
|
||||||
impl cumulus_pallet_parachain_system::Config for Runtime {
|
impl cumulus_pallet_parachain_system::Config for Runtime {
|
||||||
type RuntimeEvent = RuntimeEvent;
|
type RuntimeEvent = RuntimeEvent;
|
||||||
type OnSystemEvent = ();
|
type OnSystemEvent = ();
|
||||||
@@ -194,12 +214,7 @@ impl cumulus_pallet_parachain_system::Config for Runtime {
|
|||||||
type XcmpMessageHandler = ();
|
type XcmpMessageHandler = ();
|
||||||
type ReservedXcmpWeight = ();
|
type ReservedXcmpWeight = ();
|
||||||
type CheckAssociatedRelayNumber = RelayNumberMonotonicallyIncreases;
|
type CheckAssociatedRelayNumber = RelayNumberMonotonicallyIncreases;
|
||||||
type ConsensusHook = cumulus_pallet_aura_ext::FixedVelocityConsensusHook<
|
type ConsensusHook = ConsensusHook;
|
||||||
Runtime,
|
|
||||||
RELAY_CHAIN_SLOT_DURATION_MILLIS,
|
|
||||||
BLOCK_PROCESSING_VELOCITY,
|
|
||||||
UNINCLUDED_SEGMENT_CAPACITY,
|
|
||||||
>;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl parachain_info::Config for Runtime {}
|
impl parachain_info::Config for Runtime {}
|
||||||
@@ -209,7 +224,7 @@ impl cumulus_pallet_aura_ext::Config for Runtime {}
|
|||||||
impl pallet_timestamp::Config for Runtime {
|
impl pallet_timestamp::Config for Runtime {
|
||||||
type Moment = u64;
|
type Moment = u64;
|
||||||
type OnTimestampSet = Aura;
|
type OnTimestampSet = Aura;
|
||||||
type MinimumPeriod = ConstU64<{ SLOT_DURATION / 2 }>;
|
type MinimumPeriod = ConstU64<0>;
|
||||||
type WeightInfo = weights::pallet_timestamp::WeightInfo<Runtime>;
|
type WeightInfo = weights::pallet_timestamp::WeightInfo<Runtime>;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -217,9 +232,9 @@ impl pallet_aura::Config for Runtime {
|
|||||||
type AuthorityId = AuraId;
|
type AuthorityId = AuraId;
|
||||||
type DisabledValidators = ();
|
type DisabledValidators = ();
|
||||||
type MaxAuthorities = ConstU32<100_000>;
|
type MaxAuthorities = ConstU32<100_000>;
|
||||||
type AllowMultipleBlocksPerSlot = ConstBool<false>;
|
type AllowMultipleBlocksPerSlot = ConstBool<true>;
|
||||||
#[cfg(feature = "experimental")]
|
#[cfg(feature = "experimental")]
|
||||||
type SlotDuration = pallet_aura::MinimumPeriodTimesTwo<Self>;
|
type SlotDuration = ConstU64<SLOT_DURATION>;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl pallet_glutton::Config for Runtime {
|
impl pallet_glutton::Config for Runtime {
|
||||||
@@ -340,7 +355,7 @@ impl_runtime_apis! {
|
|||||||
|
|
||||||
impl sp_consensus_aura::AuraApi<Block, AuraId> for Runtime {
|
impl sp_consensus_aura::AuraApi<Block, AuraId> for Runtime {
|
||||||
fn slot_duration() -> sp_consensus_aura::SlotDuration {
|
fn slot_duration() -> sp_consensus_aura::SlotDuration {
|
||||||
sp_consensus_aura::SlotDuration::from_millis(Aura::slot_duration())
|
sp_consensus_aura::SlotDuration::from_millis(SLOT_DURATION)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn authorities() -> Vec<AuraId> {
|
fn authorities() -> Vec<AuraId> {
|
||||||
@@ -348,6 +363,15 @@ impl_runtime_apis! {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl cumulus_primitives_aura::AuraUnincludedSegmentApi<Block> for Runtime {
|
||||||
|
fn can_build_upon(
|
||||||
|
included_hash: <Block as BlockT>::Hash,
|
||||||
|
slot: cumulus_primitives_aura::Slot,
|
||||||
|
) -> bool {
|
||||||
|
ConsensusHook::can_build_upon(included_hash, slot)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl sp_block_builder::BlockBuilder<Block> for Runtime {
|
impl sp_block_builder::BlockBuilder<Block> for Runtime {
|
||||||
fn apply_extrinsic(
|
fn apply_extrinsic(
|
||||||
extrinsic: <Block as BlockT>::Extrinsic,
|
extrinsic: <Block as BlockT>::Extrinsic,
|
||||||
|
|||||||
@@ -87,6 +87,7 @@ cumulus-client-consensus-relay-chain = { path = "../client/consensus/relay-chain
|
|||||||
cumulus-client-consensus-common = { path = "../client/consensus/common" }
|
cumulus-client-consensus-common = { path = "../client/consensus/common" }
|
||||||
cumulus-client-consensus-proposer = { path = "../client/consensus/proposer" }
|
cumulus-client-consensus-proposer = { path = "../client/consensus/proposer" }
|
||||||
cumulus-client-service = { path = "../client/service" }
|
cumulus-client-service = { path = "../client/service" }
|
||||||
|
cumulus-primitives-aura = { path = "../primitives/aura" }
|
||||||
cumulus-primitives-core = { path = "../primitives/core" }
|
cumulus-primitives-core = { path = "../primitives/core" }
|
||||||
cumulus-primitives-parachain-inherent = { path = "../primitives/parachain-inherent" }
|
cumulus-primitives-parachain-inherent = { path = "../primitives/parachain-inherent" }
|
||||||
cumulus-relay-chain-interface = { path = "../client/relay-chain-interface" }
|
cumulus-relay-chain-interface = { path = "../client/relay-chain-interface" }
|
||||||
|
|||||||
@@ -876,12 +876,17 @@ pub fn run() -> Result<()> {
|
|||||||
.await
|
.await
|
||||||
.map(|r| r.0)
|
.map(|r| r.0)
|
||||||
.map_err(Into::into),
|
.map_err(Into::into),
|
||||||
Runtime::Seedling => crate::service::start_shell_node::<
|
Runtime::Seedling =>
|
||||||
seedling_runtime::RuntimeApi,
|
crate::service::start_shell_node::<seedling_runtime::RuntimeApi>(
|
||||||
>(config, polkadot_config, collator_options, id, hwbench)
|
config,
|
||||||
.await
|
polkadot_config,
|
||||||
.map(|r| r.0)
|
collator_options,
|
||||||
.map_err(Into::into),
|
id,
|
||||||
|
hwbench
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
.map(|r| r.0)
|
||||||
|
.map_err(Into::into),
|
||||||
Runtime::ContractsRococo => crate::service::start_contracts_rococo_node(
|
Runtime::ContractsRococo => crate::service::start_contracts_rococo_node(
|
||||||
config,
|
config,
|
||||||
polkadot_config,
|
polkadot_config,
|
||||||
@@ -949,13 +954,10 @@ pub fn run() -> Result<()> {
|
|||||||
.map(|r| r.0)
|
.map(|r| r.0)
|
||||||
.map_err(Into::into),
|
.map_err(Into::into),
|
||||||
Runtime::Glutton =>
|
Runtime::Glutton =>
|
||||||
crate::service::start_shell_node::<glutton_runtime::RuntimeApi>(
|
crate::service::start_basic_lookahead_node::<
|
||||||
config,
|
glutton_runtime::RuntimeApi,
|
||||||
polkadot_config,
|
AuraId,
|
||||||
collator_options,
|
>(config, polkadot_config, collator_options, id, hwbench)
|
||||||
id,
|
|
||||||
hwbench,
|
|
||||||
)
|
|
||||||
.await
|
.await
|
||||||
.map(|r| r.0)
|
.map(|r| r.0)
|
||||||
.map_err(Into::into),
|
.map_err(Into::into),
|
||||||
|
|||||||
@@ -17,8 +17,9 @@
|
|||||||
use codec::Codec;
|
use codec::Codec;
|
||||||
use cumulus_client_cli::CollatorOptions;
|
use cumulus_client_cli::CollatorOptions;
|
||||||
use cumulus_client_collator::service::CollatorService;
|
use cumulus_client_collator::service::CollatorService;
|
||||||
use cumulus_client_consensus_aura::collators::basic::{
|
use cumulus_client_consensus_aura::collators::{
|
||||||
self as basic_aura, Params as BasicAuraParams,
|
basic::{self as basic_aura, Params as BasicAuraParams},
|
||||||
|
lookahead::{self as aura, Params as AuraParams},
|
||||||
};
|
};
|
||||||
use cumulus_client_consensus_common::{
|
use cumulus_client_consensus_common::{
|
||||||
ParachainBlockImport as TParachainBlockImport, ParachainCandidate, ParachainConsensus,
|
ParachainBlockImport as TParachainBlockImport, ParachainCandidate, ParachainConsensus,
|
||||||
@@ -31,7 +32,7 @@ use cumulus_client_service::{
|
|||||||
BuildNetworkParams, CollatorSybilResistance, DARecoveryProfile, StartRelayChainTasksParams,
|
BuildNetworkParams, CollatorSybilResistance, DARecoveryProfile, StartRelayChainTasksParams,
|
||||||
};
|
};
|
||||||
use cumulus_primitives_core::{
|
use cumulus_primitives_core::{
|
||||||
relay_chain::{Hash as PHash, PersistedValidationData},
|
relay_chain::{Hash as PHash, PersistedValidationData, ValidationCode},
|
||||||
ParaId,
|
ParaId,
|
||||||
};
|
};
|
||||||
use cumulus_relay_chain_interface::{OverseerHandle, RelayChainInterface};
|
use cumulus_relay_chain_interface::{OverseerHandle, RelayChainInterface};
|
||||||
@@ -696,6 +697,188 @@ where
|
|||||||
Ok((task_manager, client))
|
Ok((task_manager, client))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Start a node with the given parachain `Configuration` and relay chain `Configuration`.
|
||||||
|
///
|
||||||
|
/// This is the actual implementation that is abstract over the executor and the runtime api.
|
||||||
|
///
|
||||||
|
/// This node is basic in the sense that it doesn't support functionality like transaction
|
||||||
|
/// payment. Intended to replace start_shell_node in use for glutton, shell, and seedling.
|
||||||
|
#[sc_tracing::logging::prefix_logs_with("Parachain")]
|
||||||
|
async fn start_basic_lookahead_node_impl<RuntimeApi, RB, BIQ, SC>(
|
||||||
|
parachain_config: Configuration,
|
||||||
|
polkadot_config: Configuration,
|
||||||
|
collator_options: CollatorOptions,
|
||||||
|
sybil_resistance_level: CollatorSybilResistance,
|
||||||
|
para_id: ParaId,
|
||||||
|
rpc_ext_builder: RB,
|
||||||
|
build_import_queue: BIQ,
|
||||||
|
start_consensus: SC,
|
||||||
|
hwbench: Option<sc_sysinfo::HwBench>,
|
||||||
|
) -> sc_service::error::Result<(TaskManager, Arc<ParachainClient<RuntimeApi>>)>
|
||||||
|
where
|
||||||
|
RuntimeApi: ConstructRuntimeApi<Block, ParachainClient<RuntimeApi>> + Send + Sync + 'static,
|
||||||
|
RuntimeApi::RuntimeApi: sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block>
|
||||||
|
+ sp_api::Metadata<Block>
|
||||||
|
+ sp_session::SessionKeys<Block>
|
||||||
|
+ sp_api::ApiExt<Block>
|
||||||
|
+ sp_offchain::OffchainWorkerApi<Block>
|
||||||
|
+ sp_block_builder::BlockBuilder<Block>
|
||||||
|
+ cumulus_primitives_core::CollectCollationInfo<Block>
|
||||||
|
+ frame_rpc_system::AccountNonceApi<Block, AccountId, Nonce>,
|
||||||
|
RB: Fn(Arc<ParachainClient<RuntimeApi>>) -> Result<jsonrpsee::RpcModule<()>, sc_service::Error>
|
||||||
|
+ 'static,
|
||||||
|
BIQ: FnOnce(
|
||||||
|
Arc<ParachainClient<RuntimeApi>>,
|
||||||
|
ParachainBlockImport<RuntimeApi>,
|
||||||
|
&Configuration,
|
||||||
|
Option<TelemetryHandle>,
|
||||||
|
&TaskManager,
|
||||||
|
) -> Result<sc_consensus::DefaultImportQueue<Block>, sc_service::Error>,
|
||||||
|
SC: FnOnce(
|
||||||
|
Arc<ParachainClient<RuntimeApi>>,
|
||||||
|
ParachainBlockImport<RuntimeApi>,
|
||||||
|
Option<&Registry>,
|
||||||
|
Option<TelemetryHandle>,
|
||||||
|
&TaskManager,
|
||||||
|
Arc<dyn RelayChainInterface>,
|
||||||
|
Arc<sc_transaction_pool::FullPool<Block, ParachainClient<RuntimeApi>>>,
|
||||||
|
Arc<SyncingService<Block>>,
|
||||||
|
KeystorePtr,
|
||||||
|
Duration,
|
||||||
|
ParaId,
|
||||||
|
CollatorPair,
|
||||||
|
OverseerHandle,
|
||||||
|
Arc<dyn Fn(Hash, Option<Vec<u8>>) + Send + Sync>,
|
||||||
|
Arc<ParachainBackend>,
|
||||||
|
) -> Result<(), sc_service::Error>,
|
||||||
|
{
|
||||||
|
let parachain_config = prepare_node_config(parachain_config);
|
||||||
|
|
||||||
|
let params = new_partial::<RuntimeApi, BIQ>(¶chain_config, build_import_queue)?;
|
||||||
|
let (block_import, mut telemetry, telemetry_worker_handle) = params.other;
|
||||||
|
|
||||||
|
let client = params.client.clone();
|
||||||
|
let backend = params.backend.clone();
|
||||||
|
|
||||||
|
let mut task_manager = params.task_manager;
|
||||||
|
let (relay_chain_interface, collator_key) = build_relay_chain_interface(
|
||||||
|
polkadot_config,
|
||||||
|
¶chain_config,
|
||||||
|
telemetry_worker_handle,
|
||||||
|
&mut task_manager,
|
||||||
|
collator_options.clone(),
|
||||||
|
hwbench.clone(),
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
.map_err(|e| sc_service::Error::Application(Box::new(e) as Box<_>))?;
|
||||||
|
|
||||||
|
let validator = parachain_config.role.is_authority();
|
||||||
|
let prometheus_registry = parachain_config.prometheus_registry().cloned();
|
||||||
|
let transaction_pool = params.transaction_pool.clone();
|
||||||
|
let import_queue_service = params.import_queue.service();
|
||||||
|
let net_config = FullNetworkConfiguration::new(¶chain_config.network);
|
||||||
|
|
||||||
|
let (network, system_rpc_tx, tx_handler_controller, start_network, sync_service) =
|
||||||
|
build_network(BuildNetworkParams {
|
||||||
|
parachain_config: ¶chain_config,
|
||||||
|
net_config,
|
||||||
|
client: client.clone(),
|
||||||
|
transaction_pool: transaction_pool.clone(),
|
||||||
|
para_id,
|
||||||
|
spawn_handle: task_manager.spawn_handle(),
|
||||||
|
relay_chain_interface: relay_chain_interface.clone(),
|
||||||
|
import_queue: params.import_queue,
|
||||||
|
sybil_resistance_level,
|
||||||
|
})
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
let rpc_client = client.clone();
|
||||||
|
let rpc_builder = Box::new(move |_, _| rpc_ext_builder(rpc_client.clone()));
|
||||||
|
|
||||||
|
sc_service::spawn_tasks(sc_service::SpawnTasksParams {
|
||||||
|
rpc_builder,
|
||||||
|
client: client.clone(),
|
||||||
|
transaction_pool: transaction_pool.clone(),
|
||||||
|
task_manager: &mut task_manager,
|
||||||
|
config: parachain_config,
|
||||||
|
keystore: params.keystore_container.keystore(),
|
||||||
|
backend: backend.clone(),
|
||||||
|
network: network.clone(),
|
||||||
|
sync_service: sync_service.clone(),
|
||||||
|
system_rpc_tx,
|
||||||
|
tx_handler_controller,
|
||||||
|
telemetry: telemetry.as_mut(),
|
||||||
|
})?;
|
||||||
|
|
||||||
|
if let Some(hwbench) = hwbench {
|
||||||
|
sc_sysinfo::print_hwbench(&hwbench);
|
||||||
|
if validator {
|
||||||
|
warn_if_slow_hardware(&hwbench);
|
||||||
|
}
|
||||||
|
|
||||||
|
if let Some(ref mut telemetry) = telemetry {
|
||||||
|
let telemetry_handle = telemetry.handle();
|
||||||
|
task_manager.spawn_handle().spawn(
|
||||||
|
"telemetry_hwbench",
|
||||||
|
None,
|
||||||
|
sc_sysinfo::initialize_hwbench_telemetry(telemetry_handle, hwbench),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let announce_block = {
|
||||||
|
let sync_service = sync_service.clone();
|
||||||
|
Arc::new(move |hash, data| sync_service.announce_block(hash, data))
|
||||||
|
};
|
||||||
|
|
||||||
|
let relay_chain_slot_duration = Duration::from_secs(6);
|
||||||
|
|
||||||
|
let overseer_handle = relay_chain_interface
|
||||||
|
.overseer_handle()
|
||||||
|
.map_err(|e| sc_service::Error::Application(Box::new(e)))?;
|
||||||
|
|
||||||
|
start_relay_chain_tasks(StartRelayChainTasksParams {
|
||||||
|
client: client.clone(),
|
||||||
|
announce_block: announce_block.clone(),
|
||||||
|
para_id,
|
||||||
|
relay_chain_interface: relay_chain_interface.clone(),
|
||||||
|
task_manager: &mut task_manager,
|
||||||
|
da_recovery_profile: if validator {
|
||||||
|
DARecoveryProfile::Collator
|
||||||
|
} else {
|
||||||
|
DARecoveryProfile::FullNode
|
||||||
|
},
|
||||||
|
import_queue: import_queue_service,
|
||||||
|
relay_chain_slot_duration,
|
||||||
|
recovery_handle: Box::new(overseer_handle.clone()),
|
||||||
|
sync_service: sync_service.clone(),
|
||||||
|
})?;
|
||||||
|
|
||||||
|
if validator {
|
||||||
|
start_consensus(
|
||||||
|
client.clone(),
|
||||||
|
block_import,
|
||||||
|
prometheus_registry.as_ref(),
|
||||||
|
telemetry.as_ref().map(|t| t.handle()),
|
||||||
|
&task_manager,
|
||||||
|
relay_chain_interface.clone(),
|
||||||
|
transaction_pool,
|
||||||
|
sync_service.clone(),
|
||||||
|
params.keystore_container.keystore(),
|
||||||
|
relay_chain_slot_duration,
|
||||||
|
para_id,
|
||||||
|
collator_key.expect("Command line arguments do not allow this. qed"),
|
||||||
|
overseer_handle,
|
||||||
|
announce_block,
|
||||||
|
backend.clone(),
|
||||||
|
)?;
|
||||||
|
}
|
||||||
|
|
||||||
|
start_network.start_network();
|
||||||
|
|
||||||
|
Ok((task_manager, client))
|
||||||
|
}
|
||||||
|
|
||||||
/// Build the import queue for the rococo parachain runtime.
|
/// Build the import queue for the rococo parachain runtime.
|
||||||
pub fn rococo_parachain_build_import_queue(
|
pub fn rococo_parachain_build_import_queue(
|
||||||
client: Arc<ParachainClient<rococo_parachain_runtime::RuntimeApi>>,
|
client: Arc<ParachainClient<rococo_parachain_runtime::RuntimeApi>>,
|
||||||
@@ -1206,6 +1389,104 @@ where
|
|||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Start an aura powered parachain node which uses the lookahead collator to support async backing.
|
||||||
|
/// This node is basic in the sense that its runtime api doesn't include common contents such as
|
||||||
|
/// transaction payment. Used for aura glutton.
|
||||||
|
pub async fn start_basic_lookahead_node<RuntimeApi, AuraId: AppCrypto>(
|
||||||
|
parachain_config: Configuration,
|
||||||
|
polkadot_config: Configuration,
|
||||||
|
collator_options: CollatorOptions,
|
||||||
|
para_id: ParaId,
|
||||||
|
hwbench: Option<sc_sysinfo::HwBench>,
|
||||||
|
) -> sc_service::error::Result<(TaskManager, Arc<ParachainClient<RuntimeApi>>)>
|
||||||
|
where
|
||||||
|
RuntimeApi: ConstructRuntimeApi<Block, ParachainClient<RuntimeApi>> + Send + Sync + 'static,
|
||||||
|
RuntimeApi::RuntimeApi: sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block>
|
||||||
|
+ sp_api::Metadata<Block>
|
||||||
|
+ sp_session::SessionKeys<Block>
|
||||||
|
+ sp_api::ApiExt<Block>
|
||||||
|
+ sp_offchain::OffchainWorkerApi<Block>
|
||||||
|
+ sp_block_builder::BlockBuilder<Block>
|
||||||
|
+ cumulus_primitives_core::CollectCollationInfo<Block>
|
||||||
|
+ sp_consensus_aura::AuraApi<Block, <<AuraId as AppCrypto>::Pair as Pair>::Public>
|
||||||
|
+ frame_rpc_system::AccountNonceApi<Block, AccountId, Nonce>
|
||||||
|
+ cumulus_primitives_aura::AuraUnincludedSegmentApi<Block>,
|
||||||
|
<<AuraId as AppCrypto>::Pair as Pair>::Signature:
|
||||||
|
TryFrom<Vec<u8>> + std::hash::Hash + sp_runtime::traits::Member + Codec,
|
||||||
|
{
|
||||||
|
start_basic_lookahead_node_impl::<RuntimeApi, _, _, _>(
|
||||||
|
parachain_config,
|
||||||
|
polkadot_config,
|
||||||
|
collator_options,
|
||||||
|
CollatorSybilResistance::Resistant, // Aura
|
||||||
|
para_id,
|
||||||
|
|_| Ok(RpcModule::new(())),
|
||||||
|
aura_build_import_queue::<_, AuraId>,
|
||||||
|
|client,
|
||||||
|
block_import,
|
||||||
|
prometheus_registry,
|
||||||
|
telemetry,
|
||||||
|
task_manager,
|
||||||
|
relay_chain_interface,
|
||||||
|
transaction_pool,
|
||||||
|
sync_oracle,
|
||||||
|
keystore,
|
||||||
|
relay_chain_slot_duration,
|
||||||
|
para_id,
|
||||||
|
collator_key,
|
||||||
|
overseer_handle,
|
||||||
|
announce_block,
|
||||||
|
backend| {
|
||||||
|
let slot_duration = cumulus_client_consensus_aura::slot_duration(&*client)?;
|
||||||
|
|
||||||
|
let proposer_factory = sc_basic_authorship::ProposerFactory::with_proof_recording(
|
||||||
|
task_manager.spawn_handle(),
|
||||||
|
client.clone(),
|
||||||
|
transaction_pool,
|
||||||
|
prometheus_registry,
|
||||||
|
telemetry.clone(),
|
||||||
|
);
|
||||||
|
let proposer = Proposer::new(proposer_factory);
|
||||||
|
|
||||||
|
let collator_service = CollatorService::new(
|
||||||
|
client.clone(),
|
||||||
|
Arc::new(task_manager.spawn_handle()),
|
||||||
|
announce_block,
|
||||||
|
client.clone(),
|
||||||
|
);
|
||||||
|
|
||||||
|
let params = AuraParams {
|
||||||
|
create_inherent_data_providers: move |_, ()| async move { Ok(()) },
|
||||||
|
block_import,
|
||||||
|
para_client: client.clone(),
|
||||||
|
para_backend: backend.clone(),
|
||||||
|
relay_client: relay_chain_interface,
|
||||||
|
code_hash_provider: move |block_hash| {
|
||||||
|
client.code_at(block_hash).ok().map(ValidationCode).map(|c| c.hash())
|
||||||
|
},
|
||||||
|
sync_oracle,
|
||||||
|
keystore,
|
||||||
|
collator_key,
|
||||||
|
para_id,
|
||||||
|
overseer_handle,
|
||||||
|
slot_duration,
|
||||||
|
relay_chain_slot_duration,
|
||||||
|
proposer,
|
||||||
|
collator_service,
|
||||||
|
authoring_duration: Duration::from_millis(1500),
|
||||||
|
};
|
||||||
|
|
||||||
|
let fut =
|
||||||
|
aura::run::<Block, <AuraId as AppCrypto>::Pair, _, _, _, _, _, _, _, _, _>(params);
|
||||||
|
task_manager.spawn_essential_handle().spawn("aura", None, fut);
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
},
|
||||||
|
hwbench,
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
}
|
||||||
|
|
||||||
#[sc_tracing::logging::prefix_logs_with("Parachain")]
|
#[sc_tracing::logging::prefix_logs_with("Parachain")]
|
||||||
async fn start_contracts_rococo_node_impl<RuntimeApi, RB, BIQ, SC>(
|
async fn start_contracts_rococo_node_impl<RuntimeApi, RB, BIQ, SC>(
|
||||||
parachain_config: Configuration,
|
parachain_config: Configuration,
|
||||||
|
|||||||
Reference in New Issue
Block a user