difftreelog
chore fix cargo fmt
in: master
4 files changed
node/cli/src/command.rsdiffbeforeafterboth--- a/node/cli/src/command.rs
+++ b/node/cli/src/command.rs
@@ -33,9 +33,7 @@
// limitations under the License.
use crate::{
- chain_spec::{
- self, RuntimeId, RuntimeIdentification, ServiceId, ServiceIdentification, default_runtime,
- },
+ chain_spec::{self, RuntimeId, RuntimeIdentification, ServiceId, ServiceIdentification},
cli::{Cli, RelayChainCli, Subcommand},
service::{new_partial, start_node, start_dev_node},
};
@@ -46,7 +44,7 @@
#[cfg(feature = "quartz-runtime")]
use crate::service::QuartzRuntimeExecutor;
-use crate::service::{OpalRuntimeExecutor, DefaultRuntimeExecutor};
+use crate::service::OpalRuntimeExecutor;
use codec::Encode;
use cumulus_primitives_core::ParaId;
node/cli/src/service.rsdiffbeforeafterboth1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617// std18use std::sync::Arc;19use std::sync::Mutex;20use std::collections::BTreeMap;21use std::time::Duration;22use std::pin::Pin;23use fc_rpc_core::types::FeeHistoryCache;24use futures::{25 Stream, StreamExt,26 stream::select,27 task::{Context, Poll},28};29use tokio::time::Interval;3031use unique_rpc::overrides_handle;3233use serde::{Serialize, Deserialize};3435// Cumulus Imports36use cumulus_client_consensus_aura::{AuraConsensus, BuildAuraConsensusParams, SlotProportion};37use cumulus_client_consensus_common::ParachainConsensus;38use cumulus_client_service::{39 prepare_node_config, start_collator, start_full_node, StartCollatorParams, StartFullNodeParams,40};41use cumulus_client_cli::CollatorOptions;42use cumulus_client_network::BlockAnnounceValidator;43use cumulus_primitives_core::ParaId;44use cumulus_relay_chain_inprocess_interface::build_inprocess_relay_chain;45use cumulus_relay_chain_interface::{RelayChainError, RelayChainInterface, RelayChainResult};46use cumulus_relay_chain_rpc_interface::{RelayChainRpcInterface, create_client_and_start_worker};4748// Substrate Imports49use sc_client_api::ExecutorProvider;50use sc_executor::NativeElseWasmExecutor;51use sc_executor::NativeExecutionDispatch;52use sc_network::{NetworkService, NetworkBlock};53use sc_service::{BasePath, Configuration, PartialComponents, TaskManager};54use sc_telemetry::{Telemetry, TelemetryHandle, TelemetryWorker, TelemetryWorkerHandle};55use sp_keystore::SyncCryptoStorePtr;56use sp_runtime::traits::BlakeTwo256;57use substrate_prometheus_endpoint::Registry;58use sc_client_api::BlockchainEvents;5960use polkadot_service::CollatorPair;6162// Frontier Imports63use fc_rpc_core::types::FilterPool;64use fc_mapping_sync::{MappingSyncWorker, SyncStrategy};6566use up_common::types::opaque::{67 AuraId, RuntimeInstance, AccountId, Balance, Index, Hash, Block, BlockNumber,68};6970// RMRK71use up_data_structs::{72 RmrkCollectionInfo, RmrkInstanceInfo, RmrkResourceInfo, RmrkPropertyInfo, RmrkBaseInfo,73 RmrkPartType, RmrkTheme,74};7576/// Unique native executor instance.77#[cfg(feature = "unique-runtime")]78pub struct UniqueRuntimeExecutor;7980#[cfg(feature = "quartz-runtime")]81/// Quartz native executor instance.82pub struct QuartzRuntimeExecutor;8384/// Opal native executor instance.85pub struct OpalRuntimeExecutor;8687#[cfg(feature = "unique-runtime")]88pub type DefaultRuntimeExecutor = UniqueRuntimeExecutor;8990#[cfg(all(not(feature = "unique-runtime"), feature = "quartz-runtime"))]91pub type DefaultRuntimeExecutor = QuartzRuntimeExecutor;9293#[cfg(all(not(feature = "unique-runtime"), not(feature = "quartz-runtime")))]94pub type DefaultRuntimeExecutor = OpalRuntimeExecutor;9596#[cfg(feature = "unique-runtime")]97impl NativeExecutionDispatch for UniqueRuntimeExecutor {98 type ExtendHostFunctions = frame_benchmarking::benchmarking::HostFunctions;99100 fn dispatch(method: &str, data: &[u8]) -> Option<Vec<u8>> {101 unique_runtime::api::dispatch(method, data)102 }103104 fn native_version() -> sc_executor::NativeVersion {105 unique_runtime::native_version()106 }107}108109#[cfg(feature = "quartz-runtime")]110impl NativeExecutionDispatch for QuartzRuntimeExecutor {111 type ExtendHostFunctions = frame_benchmarking::benchmarking::HostFunctions;112113 fn dispatch(method: &str, data: &[u8]) -> Option<Vec<u8>> {114 quartz_runtime::api::dispatch(method, data)115 }116117 fn native_version() -> sc_executor::NativeVersion {118 quartz_runtime::native_version()119 }120}121122impl NativeExecutionDispatch for OpalRuntimeExecutor {123 type ExtendHostFunctions = frame_benchmarking::benchmarking::HostFunctions;124125 fn dispatch(method: &str, data: &[u8]) -> Option<Vec<u8>> {126 opal_runtime::api::dispatch(method, data)127 }128129 fn native_version() -> sc_executor::NativeVersion {130 opal_runtime::native_version()131 }132}133134pub struct AutosealInterval {135 interval: Interval,136}137138impl AutosealInterval {139 pub fn new(config: &Configuration, interval: Duration) -> Self {140 let _tokio_runtime = config.tokio_handle.enter();141 let interval = tokio::time::interval(interval);142143 Self { interval }144 }145}146147impl Stream for AutosealInterval {148 type Item = tokio::time::Instant;149150 fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {151 self.interval.poll_tick(cx).map(Some)152 }153}154155pub fn open_frontier_backend(config: &Configuration) -> Result<Arc<fc_db::Backend<Block>>, String> {156 let config_dir = config157 .base_path158 .as_ref()159 .map(|base_path| base_path.config_dir(config.chain_spec.id()))160 .unwrap_or_else(|| {161 BasePath::from_project("", "", "unique").config_dir(config.chain_spec.id())162 });163 let database_dir = config_dir.join("frontier").join("db");164165 Ok(Arc::new(fc_db::Backend::<Block>::new(166 &fc_db::DatabaseSettings {167 source: fc_db::DatabaseSource::RocksDb {168 path: database_dir,169 cache_size: 0,170 },171 },172 )?))173}174175type FullClient<RuntimeApi, ExecutorDispatch> =176 sc_service::TFullClient<Block, RuntimeApi, NativeElseWasmExecutor<ExecutorDispatch>>;177type FullBackend = sc_service::TFullBackend<Block>;178type FullSelectChain = sc_consensus::LongestChain<FullBackend, Block>;179180/// Starts a `ServiceBuilder` for a full service.181///182/// Use this macro if you don't actually need the full service, but just the builder in order to183/// be able to perform chain operations.184#[allow(clippy::type_complexity)]185pub fn new_partial<RuntimeApi, ExecutorDispatch, BIQ>(186 config: &Configuration,187 build_import_queue: BIQ,188) -> Result<189 PartialComponents<190 FullClient<RuntimeApi, ExecutorDispatch>,191 FullBackend,192 FullSelectChain,193 sc_consensus::DefaultImportQueue<Block, FullClient<RuntimeApi, ExecutorDispatch>>,194 sc_transaction_pool::FullPool<Block, FullClient<RuntimeApi, ExecutorDispatch>>,195 (196 Option<Telemetry>,197 Option<FilterPool>,198 Arc<fc_db::Backend<Block>>,199 Option<TelemetryWorkerHandle>,200 FeeHistoryCache,201 ),202 >,203 sc_service::Error,204>205where206 sc_client_api::StateBackendFor<FullBackend, Block>: sp_api::StateBackend<BlakeTwo256>,207 RuntimeApi: sp_api::ConstructRuntimeApi<Block, FullClient<RuntimeApi, ExecutorDispatch>>208 + Send209 + Sync210 + 'static,211 RuntimeApi::RuntimeApi: sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block>,212 ExecutorDispatch: NativeExecutionDispatch + 'static,213 BIQ: FnOnce(214 Arc<FullClient<RuntimeApi, ExecutorDispatch>>,215 &Configuration,216 Option<TelemetryHandle>,217 &TaskManager,218 ) -> Result<219 sc_consensus::DefaultImportQueue<Block, FullClient<RuntimeApi, ExecutorDispatch>>,220 sc_service::Error,221 >,222{223 let _telemetry = config224 .telemetry_endpoints225 .clone()226 .filter(|x| !x.is_empty())227 .map(|endpoints| -> Result<_, sc_telemetry::Error> {228 let worker = TelemetryWorker::new(16)?;229 let telemetry = worker.handle().new_telemetry(endpoints);230 Ok((worker, telemetry))231 })232 .transpose()?;233234 let telemetry = config235 .telemetry_endpoints236 .clone()237 .filter(|x| !x.is_empty())238 .map(|endpoints| -> Result<_, sc_telemetry::Error> {239 let worker = TelemetryWorker::new(16)?;240 let telemetry = worker.handle().new_telemetry(endpoints);241 Ok((worker, telemetry))242 })243 .transpose()?;244245 let executor = NativeElseWasmExecutor::<ExecutorDispatch>::new(246 config.wasm_method,247 config.default_heap_pages,248 config.max_runtime_instances,249 config.runtime_cache_size,250 );251252 let (client, backend, keystore_container, task_manager) =253 sc_service::new_full_parts::<Block, RuntimeApi, _>(254 config,255 telemetry.as_ref().map(|(_, telemetry)| telemetry.handle()),256 executor,257 )?;258 let client = Arc::new(client);259260 let telemetry_worker_handle = telemetry.as_ref().map(|(worker, _)| worker.handle());261262 let telemetry = telemetry.map(|(worker, telemetry)| {263 task_manager264 .spawn_handle()265 .spawn("telemetry", None, worker.run());266 telemetry267 });268269 let select_chain = sc_consensus::LongestChain::new(backend.clone());270271 let transaction_pool = sc_transaction_pool::BasicPool::new_full(272 config.transaction_pool.clone(),273 config.role.is_authority().into(),274 config.prometheus_registry(),275 task_manager.spawn_essential_handle(),276 client.clone(),277 );278279 let filter_pool: Option<FilterPool> = Some(Arc::new(Mutex::new(BTreeMap::new())));280281 let frontier_backend = open_frontier_backend(config)?;282283 let import_queue = build_import_queue(284 client.clone(),285 config,286 telemetry.as_ref().map(|telemetry| telemetry.handle()),287 &task_manager,288 )?;289 let fee_history_cache: FeeHistoryCache = Arc::new(Mutex::new(BTreeMap::new()));290291 let params = PartialComponents {292 backend,293 client,294 import_queue,295 keystore_container,296 task_manager,297 transaction_pool,298 select_chain,299 other: (300 telemetry,301 filter_pool,302 frontier_backend,303 telemetry_worker_handle,304 fee_history_cache,305 ),306 };307308 Ok(params)309}310311async fn build_relay_chain_interface(312 polkadot_config: Configuration,313 parachain_config: &Configuration,314 telemetry_worker_handle: Option<TelemetryWorkerHandle>,315 task_manager: &mut TaskManager,316 collator_options: CollatorOptions,317 hwbench: Option<sc_sysinfo::HwBench>,318) -> RelayChainResult<(319 Arc<(dyn RelayChainInterface + 'static)>,320 Option<CollatorPair>,321)> {322 match collator_options.relay_chain_rpc_url {323 Some(relay_chain_url) => {324 let rpc_client = create_client_and_start_worker(relay_chain_url, task_manager).await?;325326 Ok((327 Arc::new(RelayChainRpcInterface::new(rpc_client)) as Arc<_>,328 None,329 ))330 }331 None => build_inprocess_relay_chain(332 polkadot_config,333 parachain_config,334 telemetry_worker_handle,335 task_manager,336 hwbench,337 ),338 }339}340341/// Start a node with the given parachain `Configuration` and relay chain `Configuration`.342///343/// This is the actual implementation that is abstract over the executor and the runtime api.344#[sc_tracing::logging::prefix_logs_with("Parachain")]345async fn start_node_impl<Runtime, RuntimeApi, ExecutorDispatch, BIQ, BIC>(346 parachain_config: Configuration,347 polkadot_config: Configuration,348 collator_options: CollatorOptions,349 id: ParaId,350 build_import_queue: BIQ,351 build_consensus: BIC,352 hwbench: Option<sc_sysinfo::HwBench>,353) -> sc_service::error::Result<(TaskManager, Arc<FullClient<RuntimeApi, ExecutorDispatch>>)>354where355 sc_client_api::StateBackendFor<FullBackend, Block>: sp_api::StateBackend<BlakeTwo256>,356 Runtime: RuntimeInstance + Send + Sync + 'static,357 <Runtime as RuntimeInstance>::CrossAccountId: Serialize,358 for<'de> <Runtime as RuntimeInstance>::CrossAccountId: Deserialize<'de>,359 RuntimeApi: sp_api::ConstructRuntimeApi<Block, FullClient<RuntimeApi, ExecutorDispatch>>360 + Send361 + Sync362 + 'static,363 RuntimeApi::RuntimeApi: sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block>364 + fp_rpc::EthereumRuntimeRPCApi<Block>365 + fp_rpc::ConvertTransactionRuntimeApi<Block>366 + sp_session::SessionKeys<Block>367 + sp_block_builder::BlockBuilder<Block>368 + pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance>369 + sp_api::ApiExt<Block, StateBackend = sc_client_api::StateBackendFor<FullBackend, Block>>370 + up_rpc::UniqueApi<Block, Runtime::CrossAccountId, AccountId>371 + app_promotion_rpc::AppPromotionApi<Block, BlockNumber, Runtime::CrossAccountId, AccountId>372 + rmrk_rpc::RmrkApi<373 Block,374 AccountId,375 RmrkCollectionInfo<AccountId>,376 RmrkInstanceInfo<AccountId>,377 RmrkResourceInfo,378 RmrkPropertyInfo,379 RmrkBaseInfo<AccountId>,380 RmrkPartType,381 RmrkTheme,382 > + substrate_frame_rpc_system::AccountNonceApi<Block, AccountId, Index>383 + sp_api::Metadata<Block>384 + sp_offchain::OffchainWorkerApi<Block>385 + cumulus_primitives_core::CollectCollationInfo<Block>,386 ExecutorDispatch: NativeExecutionDispatch + 'static,387 BIQ: FnOnce(388 Arc<FullClient<RuntimeApi, ExecutorDispatch>>,389 &Configuration,390 Option<TelemetryHandle>,391 &TaskManager,392 ) -> Result<393 sc_consensus::DefaultImportQueue<Block, FullClient<RuntimeApi, ExecutorDispatch>>,394 sc_service::Error,395 >,396 BIC: FnOnce(397 Arc<FullClient<RuntimeApi, ExecutorDispatch>>,398 Option<&Registry>,399 Option<TelemetryHandle>,400 &TaskManager,401 Arc<dyn RelayChainInterface>,402 Arc<sc_transaction_pool::FullPool<Block, FullClient<RuntimeApi, ExecutorDispatch>>>,403 Arc<NetworkService<Block, Hash>>,404 SyncCryptoStorePtr,405 bool,406 ) -> Result<Box<dyn ParachainConsensus<Block>>, sc_service::Error>,407{408 let parachain_config = prepare_node_config(parachain_config);409410 let params =411 new_partial::<RuntimeApi, ExecutorDispatch, BIQ>(¶chain_config, build_import_queue)?;412 let (mut telemetry, filter_pool, frontier_backend, telemetry_worker_handle, fee_history_cache) =413 params.other;414415 let client = params.client.clone();416 let backend = params.backend.clone();417 let mut task_manager = params.task_manager;418419 let (relay_chain_interface, collator_key) = build_relay_chain_interface(420 polkadot_config,421 ¶chain_config,422 telemetry_worker_handle,423 &mut task_manager,424 collator_options.clone(),425 hwbench.clone(),426 )427 .await428 .map_err(|e| match e {429 RelayChainError::ServiceError(polkadot_service::Error::Sub(x)) => x,430 s => s.to_string().into(),431 })?;432433 let block_announce_validator = BlockAnnounceValidator::new(relay_chain_interface.clone(), id);434435 let force_authoring = parachain_config.force_authoring;436 let validator = parachain_config.role.is_authority();437 let prometheus_registry = parachain_config.prometheus_registry().cloned();438 let transaction_pool = params.transaction_pool.clone();439 let import_queue = cumulus_client_service::SharedImportQueue::new(params.import_queue);440441 let (network, system_rpc_tx, tx_handler_controller, start_network) =442 sc_service::build_network(sc_service::BuildNetworkParams {443 config: ¶chain_config,444 client: client.clone(),445 transaction_pool: transaction_pool.clone(),446 spawn_handle: task_manager.spawn_handle(),447 import_queue: import_queue.clone(),448 block_announce_validator_builder: Some(Box::new(|_| {449 Box::new(block_announce_validator)450 })),451 warp_sync: None,452 })?;453454 let rpc_client = client.clone();455 let rpc_pool = transaction_pool.clone();456 let select_chain = params.select_chain.clone();457 let rpc_network = network.clone();458459 let rpc_frontier_backend = frontier_backend.clone();460461 let block_data_cache = Arc::new(fc_rpc::EthBlockDataCacheTask::new(462 task_manager.spawn_handle(),463 overrides_handle::<_, _, Runtime>(client.clone()),464 50,465 50,466 prometheus_registry.clone(),467 ));468469 task_manager.spawn_essential_handle().spawn(470 "frontier-mapping-sync-worker",471 None,472 MappingSyncWorker::new(473 client.import_notification_stream(),474 Duration::new(6, 0),475 client.clone(),476 backend.clone(),477 frontier_backend.clone(),478 3,479 0,480 SyncStrategy::Normal,481 )482 .for_each(|()| futures::future::ready(())),483 );484485 let rpc_builder = Box::new(move |deny_unsafe, subscription_task_executor| {486 let full_deps = unique_rpc::FullDeps {487 backend: rpc_frontier_backend.clone(),488 deny_unsafe,489 client: rpc_client.clone(),490 pool: rpc_pool.clone(),491 graph: rpc_pool.pool().clone(),492 // TODO: Unhardcode493 enable_dev_signer: false,494 filter_pool: filter_pool.clone(),495 network: rpc_network.clone(),496 select_chain: select_chain.clone(),497 is_authority: validator,498 // TODO: Unhardcode499 max_past_logs: 10000,500 block_data_cache: block_data_cache.clone(),501 fee_history_cache: fee_history_cache.clone(),502 // TODO: Unhardcode503 fee_history_limit: 2048,504 };505506 unique_rpc::create_full::<_, _, _, _, Runtime, RuntimeApi, _>(507 full_deps,508 subscription_task_executor,509 )510 .map_err(Into::into)511 });512513 sc_service::spawn_tasks(sc_service::SpawnTasksParams {514 rpc_builder,515 client: client.clone(),516 transaction_pool: transaction_pool.clone(),517 task_manager: &mut task_manager,518 config: parachain_config,519 keystore: params.keystore_container.sync_keystore(),520 backend: backend.clone(),521 network: network.clone(),522 system_rpc_tx,523 telemetry: telemetry.as_mut(),524 tx_handler_controller,525 })?;526527 if let Some(hwbench) = hwbench {528 sc_sysinfo::print_hwbench(&hwbench);529530 if let Some(ref mut telemetry) = telemetry {531 let telemetry_handle = telemetry.handle();532 task_manager.spawn_handle().spawn(533 "telemetry_hwbench",534 None,535 sc_sysinfo::initialize_hwbench_telemetry(telemetry_handle, hwbench),536 );537 }538 }539540 let announce_block = {541 let network = network.clone();542 Arc::new(Box::new(move |hash, data| {543 network.announce_block(hash, data)544 }))545 };546547 let relay_chain_slot_duration = Duration::from_secs(6);548549 if validator {550 let parachain_consensus = build_consensus(551 client.clone(),552 prometheus_registry.as_ref(),553 telemetry.as_ref().map(|t| t.handle()),554 &task_manager,555 relay_chain_interface.clone(),556 transaction_pool,557 network,558 params.keystore_container.sync_keystore(),559 force_authoring,560 )?;561562 let spawner = task_manager.spawn_handle();563564 let params = StartCollatorParams {565 para_id: id,566 block_status: client.clone(),567 announce_block,568 client: client.clone(),569 task_manager: &mut task_manager,570 spawner,571 parachain_consensus,572 import_queue,573 collator_key: collator_key.expect("Command line arguments do not allow this. qed"),574 relay_chain_interface,575 relay_chain_slot_duration,576 };577578 start_collator(params).await?;579 } else {580 let params = StartFullNodeParams {581 client: client.clone(),582 announce_block,583 task_manager: &mut task_manager,584 para_id: id,585 import_queue,586 relay_chain_interface,587 relay_chain_slot_duration,588 collator_options,589 };590591 start_full_node(params)?;592 }593594 start_network.start_network();595596 Ok((task_manager, client))597}598599/// Build the import queue for the the parachain runtime.600pub fn parachain_build_import_queue<RuntimeApi, ExecutorDispatch>(601 client: Arc<FullClient<RuntimeApi, ExecutorDispatch>>,602 config: &Configuration,603 telemetry: Option<TelemetryHandle>,604 task_manager: &TaskManager,605) -> Result<606 sc_consensus::DefaultImportQueue<Block, FullClient<RuntimeApi, ExecutorDispatch>>,607 sc_service::Error,608>609where610 RuntimeApi: sp_api::ConstructRuntimeApi<Block, FullClient<RuntimeApi, ExecutorDispatch>>611 + Send612 + Sync613 + 'static,614 RuntimeApi::RuntimeApi: sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block>615 + sp_block_builder::BlockBuilder<Block>616 + sp_consensus_aura::AuraApi<Block, AuraId>617 + sp_api::ApiExt<Block, StateBackend = sc_client_api::StateBackendFor<FullBackend, Block>>,618 ExecutorDispatch: NativeExecutionDispatch + 'static,619{620 let slot_duration = cumulus_client_consensus_aura::slot_duration(&*client)?;621622 cumulus_client_consensus_aura::import_queue::<623 sp_consensus_aura::sr25519::AuthorityPair,624 _,625 _,626 _,627 _,628 _,629 >(cumulus_client_consensus_aura::ImportQueueParams {630 block_import: client.clone(),631 client: client.clone(),632 create_inherent_data_providers: move |_, _| async move {633 let time = sp_timestamp::InherentDataProvider::from_system_time();634635 let slot =636 sp_consensus_aura::inherents::InherentDataProvider::from_timestamp_and_slot_duration(637 *time,638 slot_duration,639 );640641 Ok((slot, time))642 },643 registry: config.prometheus_registry(),644 spawner: &task_manager.spawn_essential_handle(),645 telemetry,646 })647 .map_err(Into::into)648}649650/// Start a normal parachain node.651pub async fn start_node<Runtime, RuntimeApi, ExecutorDispatch>(652 parachain_config: Configuration,653 polkadot_config: Configuration,654 collator_options: CollatorOptions,655 id: ParaId,656 hwbench: Option<sc_sysinfo::HwBench>,657) -> sc_service::error::Result<(TaskManager, Arc<FullClient<RuntimeApi, ExecutorDispatch>>)>658where659 Runtime: RuntimeInstance + Send + Sync + 'static,660 <Runtime as RuntimeInstance>::CrossAccountId: Serialize,661 for<'de> <Runtime as RuntimeInstance>::CrossAccountId: Deserialize<'de>,662 RuntimeApi: sp_api::ConstructRuntimeApi<Block, FullClient<RuntimeApi, ExecutorDispatch>>663 + Send664 + Sync665 + 'static,666 RuntimeApi::RuntimeApi: sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block>667 + fp_rpc::EthereumRuntimeRPCApi<Block>668 + fp_rpc::ConvertTransactionRuntimeApi<Block>669 + sp_session::SessionKeys<Block>670 + sp_block_builder::BlockBuilder<Block>671 + pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance>672 + sp_api::ApiExt<Block, StateBackend = sc_client_api::StateBackendFor<FullBackend, Block>>673 + up_rpc::UniqueApi<Block, Runtime::CrossAccountId, AccountId>674 + app_promotion_rpc::AppPromotionApi<Block, BlockNumber, Runtime::CrossAccountId, AccountId>675 + rmrk_rpc::RmrkApi<676 Block,677 AccountId,678 RmrkCollectionInfo<AccountId>,679 RmrkInstanceInfo<AccountId>,680 RmrkResourceInfo,681 RmrkPropertyInfo,682 RmrkBaseInfo<AccountId>,683 RmrkPartType,684 RmrkTheme,685 > + substrate_frame_rpc_system::AccountNonceApi<Block, AccountId, Index>686 + sp_api::Metadata<Block>687 + sp_offchain::OffchainWorkerApi<Block>688 + cumulus_primitives_core::CollectCollationInfo<Block>689 + sp_consensus_aura::AuraApi<Block, AuraId>,690 ExecutorDispatch: NativeExecutionDispatch + 'static,691{692 start_node_impl::<Runtime, RuntimeApi, ExecutorDispatch, _, _>(693 parachain_config,694 polkadot_config,695 collator_options,696 id,697 parachain_build_import_queue,698 |client,699 prometheus_registry,700 telemetry,701 task_manager,702 relay_chain_interface,703 transaction_pool,704 sync_oracle,705 keystore,706 force_authoring| {707 let slot_duration = cumulus_client_consensus_aura::slot_duration(&*client)?;708709 let proposer_factory = sc_basic_authorship::ProposerFactory::with_proof_recording(710 task_manager.spawn_handle(),711 client.clone(),712 transaction_pool,713 prometheus_registry,714 telemetry.clone(),715 );716717 Ok(AuraConsensus::build::<718 sp_consensus_aura::sr25519::AuthorityPair,719 _,720 _,721 _,722 _,723 _,724 _,725 >(BuildAuraConsensusParams {726 proposer_factory,727 create_inherent_data_providers: move |_, (relay_parent, validation_data)| {728 let relay_chain_interface = relay_chain_interface.clone();729 async move {730 let parachain_inherent =731 cumulus_primitives_parachain_inherent::ParachainInherentData::create_at(732 relay_parent,733 &relay_chain_interface,734 &validation_data,735 id,736 ).await;737738 let time = sp_timestamp::InherentDataProvider::from_system_time();739740 let slot =741 sp_consensus_aura::inherents::InherentDataProvider::from_timestamp_and_slot_duration(742 *time,743 slot_duration,744 );745746 let parachain_inherent = parachain_inherent.ok_or_else(|| {747 Box::<dyn std::error::Error + Send + Sync>::from(748 "Failed to create parachain inherent",749 )750 })?;751 Ok((slot, time, parachain_inherent))752 }753 },754 block_import: client.clone(),755 para_client: client,756 backoff_authoring_blocks: Option::<()>::None,757 sync_oracle,758 keystore,759 force_authoring,760 slot_duration,761 // We got around 500ms for proposing762 block_proposal_slot_portion: SlotProportion::new(1f32 / 24f32),763 telemetry,764 max_block_proposal_slot_portion: None,765 }))766 },767 hwbench,768 )769 .await770}771772fn dev_build_import_queue<RuntimeApi, ExecutorDispatch>(773 client: Arc<FullClient<RuntimeApi, ExecutorDispatch>>,774 config: &Configuration,775 _: Option<TelemetryHandle>,776 task_manager: &TaskManager,777) -> Result<778 sc_consensus::DefaultImportQueue<Block, FullClient<RuntimeApi, ExecutorDispatch>>,779 sc_service::Error,780>781where782 RuntimeApi: sp_api::ConstructRuntimeApi<Block, FullClient<RuntimeApi, ExecutorDispatch>>783 + Send784 + Sync785 + 'static,786 RuntimeApi::RuntimeApi: sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block>787 + sp_api::ApiExt<Block, StateBackend = sc_client_api::StateBackendFor<FullBackend, Block>>,788 ExecutorDispatch: NativeExecutionDispatch + 'static,789{790 Ok(sc_consensus_manual_seal::import_queue(791 Box::new(client.clone()),792 &task_manager.spawn_essential_handle(),793 config.prometheus_registry(),794 ))795}796797/// Builds a new development service. This service uses instant seal, and mocks798/// the parachain inherent799pub fn start_dev_node<Runtime, RuntimeApi, ExecutorDispatch>(800 config: Configuration,801 autoseal_interval: Duration,802) -> sc_service::error::Result<TaskManager>803where804 Runtime: RuntimeInstance + Send + Sync + 'static,805 <Runtime as RuntimeInstance>::CrossAccountId: Serialize,806 for<'de> <Runtime as RuntimeInstance>::CrossAccountId: Deserialize<'de>,807 RuntimeApi: sp_api::ConstructRuntimeApi<Block, FullClient<RuntimeApi, ExecutorDispatch>>808 + Send809 + Sync810 + 'static,811 RuntimeApi::RuntimeApi: sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block>812 + fp_rpc::EthereumRuntimeRPCApi<Block>813 + fp_rpc::ConvertTransactionRuntimeApi<Block>814 + sp_session::SessionKeys<Block>815 + sp_block_builder::BlockBuilder<Block>816 + pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance>817 + sp_api::ApiExt<Block, StateBackend = sc_client_api::StateBackendFor<FullBackend, Block>>818 + up_rpc::UniqueApi<Block, Runtime::CrossAccountId, AccountId>819 + app_promotion_rpc::AppPromotionApi<Block, BlockNumber, Runtime::CrossAccountId, AccountId>820 + rmrk_rpc::RmrkApi<821 Block,822 AccountId,823 RmrkCollectionInfo<AccountId>,824 RmrkInstanceInfo<AccountId>,825 RmrkResourceInfo,826 RmrkPropertyInfo,827 RmrkBaseInfo<AccountId>,828 RmrkPartType,829 RmrkTheme,830 > + substrate_frame_rpc_system::AccountNonceApi<Block, AccountId, Index>831 + sp_api::Metadata<Block>832 + sp_offchain::OffchainWorkerApi<Block>833 + cumulus_primitives_core::CollectCollationInfo<Block>834 + sp_consensus_aura::AuraApi<Block, AuraId>,835 ExecutorDispatch: NativeExecutionDispatch + 'static,836{837 use sc_consensus_manual_seal::{run_manual_seal, EngineCommand, ManualSealParams};838 use fc_consensus::FrontierBlockImport;839 use sc_client_api::HeaderBackend;840841 let sc_service::PartialComponents {842 client,843 backend,844 mut task_manager,845 import_queue,846 keystore_container,847 select_chain: maybe_select_chain,848 transaction_pool,849 other:850 (telemetry, filter_pool, frontier_backend, _telemetry_worker_handle, fee_history_cache),851 } = new_partial::<RuntimeApi, ExecutorDispatch, _>(852 &config,853 dev_build_import_queue::<RuntimeApi, ExecutorDispatch>,854 )?;855 let prometheus_registry = config.prometheus_registry().cloned();856857 let block_data_cache = Arc::new(fc_rpc::EthBlockDataCacheTask::new(858 task_manager.spawn_handle(),859 overrides_handle::<_, _, Runtime>(client.clone()),860 50,861 50,862 prometheus_registry.clone(),863 ));864865 let (network, system_rpc_tx, tx_handler_controller, network_starter) =866 sc_service::build_network(sc_service::BuildNetworkParams {867 config: &config,868 client: client.clone(),869 transaction_pool: transaction_pool.clone(),870 spawn_handle: task_manager.spawn_handle(),871 import_queue,872 block_announce_validator_builder: None,873 warp_sync: None,874 })?;875876 if config.offchain_worker.enabled {877 sc_service::build_offchain_workers(878 &config,879 task_manager.spawn_handle(),880 client.clone(),881 network.clone(),882 );883 }884885 let collator = config.role.is_authority();886887 let select_chain = maybe_select_chain.clone();888889 if collator {890 let block_import =891 FrontierBlockImport::new(client.clone(), client.clone(), frontier_backend.clone());892893 let env = sc_basic_authorship::ProposerFactory::new(894 task_manager.spawn_handle(),895 client.clone(),896 transaction_pool.clone(),897 prometheus_registry.as_ref(),898 telemetry.as_ref().map(|x| x.handle()),899 );900901 let transactions_commands_stream: Box<902 dyn Stream<Item = EngineCommand<Hash>> + Send + Sync + Unpin,903 > = Box::new(904 transaction_pool905 .pool()906 .validated_pool()907 .import_notification_stream()908 .map(|_| EngineCommand::SealNewBlock {909 create_empty: true,910 finalize: false,911 parent_hash: None,912 sender: None,913 }),914 );915916 let autoseal_interval = Box::pin(AutosealInterval::new(&config, autoseal_interval));917 let idle_commands_stream: Box<918 dyn Stream<Item = EngineCommand<Hash>> + Send + Sync + Unpin,919 > = Box::new(autoseal_interval.map(|_| EngineCommand::SealNewBlock {920 create_empty: true,921 finalize: false,922 parent_hash: None,923 sender: None,924 }));925926 let commands_stream = select(transactions_commands_stream, idle_commands_stream);927928 let slot_duration = cumulus_client_consensus_aura::slot_duration(&*client)?;929 let client_set_aside_for_cidp = client.clone();930931 task_manager.spawn_essential_handle().spawn_blocking(932 "authorship_task",933 Some("block-authoring"),934 run_manual_seal(ManualSealParams {935 block_import,936 env,937 client: client.clone(),938 pool: transaction_pool.clone(),939 commands_stream,940 select_chain: select_chain.clone(),941 consensus_data_provider: None,942 create_inherent_data_providers: move |block: Hash, ()| {943 let current_para_block = client_set_aside_for_cidp944 .number(block)945 .expect("Header lookup should succeed")946 .expect("Header passed in as parent should be present in backend.");947948 let client_for_xcm = client_set_aside_for_cidp.clone();949 async move {950 let time = sp_timestamp::InherentDataProvider::from_system_time();951952 let mocked_parachain = cumulus_primitives_parachain_inherent::MockValidationDataInherentDataProvider {953 current_para_block,954 relay_offset: 1000,955 relay_blocks_per_para_block: 2,956 para_blocks_per_relay_epoch: 0,957 xcm_config: cumulus_primitives_parachain_inherent::MockXcmConfig::new(958 &*client_for_xcm,959 block,960 Default::default(),961 Default::default(),962 ),963 relay_randomness_config: (),964 raw_downward_messages: vec![],965 raw_horizontal_messages: vec![],966 };967968 let slot =969 sp_consensus_aura::inherents::InherentDataProvider::from_timestamp_and_slot_duration(970 *time,971 slot_duration,972 );973974 Ok((time, slot, mocked_parachain))975 }976 },977 }),978 );979 }980981 task_manager.spawn_essential_handle().spawn(982 "frontier-mapping-sync-worker",983 Some("block-authoring"),984 MappingSyncWorker::new(985 client.import_notification_stream(),986 Duration::new(6, 0),987 client.clone(),988 backend.clone(),989 frontier_backend.clone(),990 3,991 0,992 SyncStrategy::Normal,993 )994 .for_each(|()| futures::future::ready(())),995 );996997 let rpc_client = client.clone();998 let rpc_pool = transaction_pool.clone();999 let rpc_network = network.clone();1000 let rpc_frontier_backend = frontier_backend.clone();1001 let rpc_builder = Box::new(move |deny_unsafe, subscription_executor| {1002 let full_deps = unique_rpc::FullDeps {1003 backend: rpc_frontier_backend.clone(),1004 deny_unsafe,1005 client: rpc_client.clone(),1006 pool: rpc_pool.clone(),1007 graph: rpc_pool.pool().clone(),1008 // TODO: Unhardcode1009 enable_dev_signer: false,1010 filter_pool: filter_pool.clone(),1011 network: rpc_network.clone(),1012 select_chain: select_chain.clone(),1013 is_authority: collator,1014 // TODO: Unhardcode1015 max_past_logs: 10000,1016 block_data_cache: block_data_cache.clone(),1017 fee_history_cache: fee_history_cache.clone(),1018 // TODO: Unhardcode1019 fee_history_limit: 2048,1020 };10211022 unique_rpc::create_full::<_, _, _, _, Runtime, RuntimeApi, _>(1023 full_deps,1024 subscription_executor,1025 )1026 .map_err(Into::into)1027 });10281029 sc_service::spawn_tasks(sc_service::SpawnTasksParams {1030 network,1031 client,1032 keystore: keystore_container.sync_keystore(),1033 task_manager: &mut task_manager,1034 transaction_pool,1035 rpc_builder,1036 backend,1037 system_rpc_tx,1038 config,1039 telemetry: None,1040 tx_handler_controller,1041 })?;10421043 network_starter.start_network();1044 Ok(task_manager)1045}1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617// std18use std::sync::Arc;19use std::sync::Mutex;20use std::collections::BTreeMap;21use std::time::Duration;22use std::pin::Pin;23use fc_rpc_core::types::FeeHistoryCache;24use futures::{25 Stream, StreamExt,26 stream::select,27 task::{Context, Poll},28};29use tokio::time::Interval;3031use unique_rpc::overrides_handle;3233use serde::{Serialize, Deserialize};3435// Cumulus Imports36use cumulus_client_consensus_aura::{AuraConsensus, BuildAuraConsensusParams, SlotProportion};37use cumulus_client_consensus_common::ParachainConsensus;38use cumulus_client_service::{39 prepare_node_config, start_collator, start_full_node, StartCollatorParams, StartFullNodeParams,40};41use cumulus_client_cli::CollatorOptions;42use cumulus_client_network::BlockAnnounceValidator;43use cumulus_primitives_core::ParaId;44use cumulus_relay_chain_inprocess_interface::build_inprocess_relay_chain;45use cumulus_relay_chain_interface::{RelayChainError, RelayChainInterface, RelayChainResult};46use cumulus_relay_chain_rpc_interface::{RelayChainRpcInterface, create_client_and_start_worker};4748// Substrate Imports49use sc_executor::NativeElseWasmExecutor;50use sc_executor::NativeExecutionDispatch;51use sc_network::{NetworkService, NetworkBlock};52use sc_service::{BasePath, Configuration, PartialComponents, TaskManager};53use sc_telemetry::{Telemetry, TelemetryHandle, TelemetryWorker, TelemetryWorkerHandle};54use sp_keystore::SyncCryptoStorePtr;55use sp_runtime::traits::BlakeTwo256;56use substrate_prometheus_endpoint::Registry;57use sc_client_api::BlockchainEvents;5859use polkadot_service::CollatorPair;6061// Frontier Imports62use fc_rpc_core::types::FilterPool;63use fc_mapping_sync::{MappingSyncWorker, SyncStrategy};6465use up_common::types::opaque::{66 AuraId, RuntimeInstance, AccountId, Balance, Index, Hash, Block, BlockNumber,67};6869// RMRK70use up_data_structs::{71 RmrkCollectionInfo, RmrkInstanceInfo, RmrkResourceInfo, RmrkPropertyInfo, RmrkBaseInfo,72 RmrkPartType, RmrkTheme,73};7475/// Unique native executor instance.76#[cfg(feature = "unique-runtime")]77pub struct UniqueRuntimeExecutor;7879#[cfg(feature = "quartz-runtime")]80/// Quartz native executor instance.81pub struct QuartzRuntimeExecutor;8283/// Opal native executor instance.84pub struct OpalRuntimeExecutor;8586#[cfg(feature = "unique-runtime")]87impl NativeExecutionDispatch for UniqueRuntimeExecutor {88 type ExtendHostFunctions = frame_benchmarking::benchmarking::HostFunctions;8990 fn dispatch(method: &str, data: &[u8]) -> Option<Vec<u8>> {91 unique_runtime::api::dispatch(method, data)92 }9394 fn native_version() -> sc_executor::NativeVersion {95 unique_runtime::native_version()96 }97}9899#[cfg(feature = "quartz-runtime")]100impl NativeExecutionDispatch for QuartzRuntimeExecutor {101 type ExtendHostFunctions = frame_benchmarking::benchmarking::HostFunctions;102103 fn dispatch(method: &str, data: &[u8]) -> Option<Vec<u8>> {104 quartz_runtime::api::dispatch(method, data)105 }106107 fn native_version() -> sc_executor::NativeVersion {108 quartz_runtime::native_version()109 }110}111112impl NativeExecutionDispatch for OpalRuntimeExecutor {113 type ExtendHostFunctions = frame_benchmarking::benchmarking::HostFunctions;114115 fn dispatch(method: &str, data: &[u8]) -> Option<Vec<u8>> {116 opal_runtime::api::dispatch(method, data)117 }118119 fn native_version() -> sc_executor::NativeVersion {120 opal_runtime::native_version()121 }122}123124pub struct AutosealInterval {125 interval: Interval,126}127128impl AutosealInterval {129 pub fn new(config: &Configuration, interval: Duration) -> Self {130 let _tokio_runtime = config.tokio_handle.enter();131 let interval = tokio::time::interval(interval);132133 Self { interval }134 }135}136137impl Stream for AutosealInterval {138 type Item = tokio::time::Instant;139140 fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {141 self.interval.poll_tick(cx).map(Some)142 }143}144145pub fn open_frontier_backend(config: &Configuration) -> Result<Arc<fc_db::Backend<Block>>, String> {146 let config_dir = config147 .base_path148 .as_ref()149 .map(|base_path| base_path.config_dir(config.chain_spec.id()))150 .unwrap_or_else(|| {151 BasePath::from_project("", "", "unique").config_dir(config.chain_spec.id())152 });153 let database_dir = config_dir.join("frontier").join("db");154155 Ok(Arc::new(fc_db::Backend::<Block>::new(156 &fc_db::DatabaseSettings {157 source: fc_db::DatabaseSource::RocksDb {158 path: database_dir,159 cache_size: 0,160 },161 },162 )?))163}164165type FullClient<RuntimeApi, ExecutorDispatch> =166 sc_service::TFullClient<Block, RuntimeApi, NativeElseWasmExecutor<ExecutorDispatch>>;167type FullBackend = sc_service::TFullBackend<Block>;168type FullSelectChain = sc_consensus::LongestChain<FullBackend, Block>;169170/// Starts a `ServiceBuilder` for a full service.171///172/// Use this macro if you don't actually need the full service, but just the builder in order to173/// be able to perform chain operations.174#[allow(clippy::type_complexity)]175pub fn new_partial<RuntimeApi, ExecutorDispatch, BIQ>(176 config: &Configuration,177 build_import_queue: BIQ,178) -> Result<179 PartialComponents<180 FullClient<RuntimeApi, ExecutorDispatch>,181 FullBackend,182 FullSelectChain,183 sc_consensus::DefaultImportQueue<Block, FullClient<RuntimeApi, ExecutorDispatch>>,184 sc_transaction_pool::FullPool<Block, FullClient<RuntimeApi, ExecutorDispatch>>,185 (186 Option<Telemetry>,187 Option<FilterPool>,188 Arc<fc_db::Backend<Block>>,189 Option<TelemetryWorkerHandle>,190 FeeHistoryCache,191 ),192 >,193 sc_service::Error,194>195where196 sc_client_api::StateBackendFor<FullBackend, Block>: sp_api::StateBackend<BlakeTwo256>,197 RuntimeApi: sp_api::ConstructRuntimeApi<Block, FullClient<RuntimeApi, ExecutorDispatch>>198 + Send199 + Sync200 + 'static,201 RuntimeApi::RuntimeApi: sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block>,202 ExecutorDispatch: NativeExecutionDispatch + 'static,203 BIQ: FnOnce(204 Arc<FullClient<RuntimeApi, ExecutorDispatch>>,205 &Configuration,206 Option<TelemetryHandle>,207 &TaskManager,208 ) -> Result<209 sc_consensus::DefaultImportQueue<Block, FullClient<RuntimeApi, ExecutorDispatch>>,210 sc_service::Error,211 >,212{213 let _telemetry = config214 .telemetry_endpoints215 .clone()216 .filter(|x| !x.is_empty())217 .map(|endpoints| -> Result<_, sc_telemetry::Error> {218 let worker = TelemetryWorker::new(16)?;219 let telemetry = worker.handle().new_telemetry(endpoints);220 Ok((worker, telemetry))221 })222 .transpose()?;223224 let telemetry = config225 .telemetry_endpoints226 .clone()227 .filter(|x| !x.is_empty())228 .map(|endpoints| -> Result<_, sc_telemetry::Error> {229 let worker = TelemetryWorker::new(16)?;230 let telemetry = worker.handle().new_telemetry(endpoints);231 Ok((worker, telemetry))232 })233 .transpose()?;234235 let executor = NativeElseWasmExecutor::<ExecutorDispatch>::new(236 config.wasm_method,237 config.default_heap_pages,238 config.max_runtime_instances,239 config.runtime_cache_size,240 );241242 let (client, backend, keystore_container, task_manager) =243 sc_service::new_full_parts::<Block, RuntimeApi, _>(244 config,245 telemetry.as_ref().map(|(_, telemetry)| telemetry.handle()),246 executor,247 )?;248 let client = Arc::new(client);249250 let telemetry_worker_handle = telemetry.as_ref().map(|(worker, _)| worker.handle());251252 let telemetry = telemetry.map(|(worker, telemetry)| {253 task_manager254 .spawn_handle()255 .spawn("telemetry", None, worker.run());256 telemetry257 });258259 let select_chain = sc_consensus::LongestChain::new(backend.clone());260261 let transaction_pool = sc_transaction_pool::BasicPool::new_full(262 config.transaction_pool.clone(),263 config.role.is_authority().into(),264 config.prometheus_registry(),265 task_manager.spawn_essential_handle(),266 client.clone(),267 );268269 let filter_pool: Option<FilterPool> = Some(Arc::new(Mutex::new(BTreeMap::new())));270271 let frontier_backend = open_frontier_backend(config)?;272273 let import_queue = build_import_queue(274 client.clone(),275 config,276 telemetry.as_ref().map(|telemetry| telemetry.handle()),277 &task_manager,278 )?;279 let fee_history_cache: FeeHistoryCache = Arc::new(Mutex::new(BTreeMap::new()));280281 let params = PartialComponents {282 backend,283 client,284 import_queue,285 keystore_container,286 task_manager,287 transaction_pool,288 select_chain,289 other: (290 telemetry,291 filter_pool,292 frontier_backend,293 telemetry_worker_handle,294 fee_history_cache,295 ),296 };297298 Ok(params)299}300301async fn build_relay_chain_interface(302 polkadot_config: Configuration,303 parachain_config: &Configuration,304 telemetry_worker_handle: Option<TelemetryWorkerHandle>,305 task_manager: &mut TaskManager,306 collator_options: CollatorOptions,307 hwbench: Option<sc_sysinfo::HwBench>,308) -> RelayChainResult<(309 Arc<(dyn RelayChainInterface + 'static)>,310 Option<CollatorPair>,311)> {312 match collator_options.relay_chain_rpc_url {313 Some(relay_chain_url) => {314 let rpc_client = create_client_and_start_worker(relay_chain_url, task_manager).await?;315316 Ok((317 Arc::new(RelayChainRpcInterface::new(rpc_client)) as Arc<_>,318 None,319 ))320 }321 None => build_inprocess_relay_chain(322 polkadot_config,323 parachain_config,324 telemetry_worker_handle,325 task_manager,326 hwbench,327 ),328 }329}330331/// Start a node with the given parachain `Configuration` and relay chain `Configuration`.332///333/// This is the actual implementation that is abstract over the executor and the runtime api.334#[sc_tracing::logging::prefix_logs_with("Parachain")]335async fn start_node_impl<Runtime, RuntimeApi, ExecutorDispatch, BIQ, BIC>(336 parachain_config: Configuration,337 polkadot_config: Configuration,338 collator_options: CollatorOptions,339 id: ParaId,340 build_import_queue: BIQ,341 build_consensus: BIC,342 hwbench: Option<sc_sysinfo::HwBench>,343) -> sc_service::error::Result<(TaskManager, Arc<FullClient<RuntimeApi, ExecutorDispatch>>)>344where345 sc_client_api::StateBackendFor<FullBackend, Block>: sp_api::StateBackend<BlakeTwo256>,346 Runtime: RuntimeInstance + Send + Sync + 'static,347 <Runtime as RuntimeInstance>::CrossAccountId: Serialize,348 for<'de> <Runtime as RuntimeInstance>::CrossAccountId: Deserialize<'de>,349 RuntimeApi: sp_api::ConstructRuntimeApi<Block, FullClient<RuntimeApi, ExecutorDispatch>>350 + Send351 + Sync352 + 'static,353 RuntimeApi::RuntimeApi: sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block>354 + fp_rpc::EthereumRuntimeRPCApi<Block>355 + fp_rpc::ConvertTransactionRuntimeApi<Block>356 + sp_session::SessionKeys<Block>357 + sp_block_builder::BlockBuilder<Block>358 + pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance>359 + sp_api::ApiExt<Block, StateBackend = sc_client_api::StateBackendFor<FullBackend, Block>>360 + up_rpc::UniqueApi<Block, Runtime::CrossAccountId, AccountId>361 + app_promotion_rpc::AppPromotionApi<Block, BlockNumber, Runtime::CrossAccountId, AccountId>362 + rmrk_rpc::RmrkApi<363 Block,364 AccountId,365 RmrkCollectionInfo<AccountId>,366 RmrkInstanceInfo<AccountId>,367 RmrkResourceInfo,368 RmrkPropertyInfo,369 RmrkBaseInfo<AccountId>,370 RmrkPartType,371 RmrkTheme,372 > + substrate_frame_rpc_system::AccountNonceApi<Block, AccountId, Index>373 + sp_api::Metadata<Block>374 + sp_offchain::OffchainWorkerApi<Block>375 + cumulus_primitives_core::CollectCollationInfo<Block>,376 ExecutorDispatch: NativeExecutionDispatch + 'static,377 BIQ: FnOnce(378 Arc<FullClient<RuntimeApi, ExecutorDispatch>>,379 &Configuration,380 Option<TelemetryHandle>,381 &TaskManager,382 ) -> Result<383 sc_consensus::DefaultImportQueue<Block, FullClient<RuntimeApi, ExecutorDispatch>>,384 sc_service::Error,385 >,386 BIC: FnOnce(387 Arc<FullClient<RuntimeApi, ExecutorDispatch>>,388 Option<&Registry>,389 Option<TelemetryHandle>,390 &TaskManager,391 Arc<dyn RelayChainInterface>,392 Arc<sc_transaction_pool::FullPool<Block, FullClient<RuntimeApi, ExecutorDispatch>>>,393 Arc<NetworkService<Block, Hash>>,394 SyncCryptoStorePtr,395 bool,396 ) -> Result<Box<dyn ParachainConsensus<Block>>, sc_service::Error>,397{398 let parachain_config = prepare_node_config(parachain_config);399400 let params =401 new_partial::<RuntimeApi, ExecutorDispatch, BIQ>(¶chain_config, build_import_queue)?;402 let (mut telemetry, filter_pool, frontier_backend, telemetry_worker_handle, fee_history_cache) =403 params.other;404405 let client = params.client.clone();406 let backend = params.backend.clone();407 let mut task_manager = params.task_manager;408409 let (relay_chain_interface, collator_key) = build_relay_chain_interface(410 polkadot_config,411 ¶chain_config,412 telemetry_worker_handle,413 &mut task_manager,414 collator_options.clone(),415 hwbench.clone(),416 )417 .await418 .map_err(|e| match e {419 RelayChainError::ServiceError(polkadot_service::Error::Sub(x)) => x,420 s => s.to_string().into(),421 })?;422423 let block_announce_validator = BlockAnnounceValidator::new(relay_chain_interface.clone(), id);424425 let force_authoring = parachain_config.force_authoring;426 let validator = parachain_config.role.is_authority();427 let prometheus_registry = parachain_config.prometheus_registry().cloned();428 let transaction_pool = params.transaction_pool.clone();429 let import_queue = cumulus_client_service::SharedImportQueue::new(params.import_queue);430431 let (network, system_rpc_tx, tx_handler_controller, start_network) =432 sc_service::build_network(sc_service::BuildNetworkParams {433 config: ¶chain_config,434 client: client.clone(),435 transaction_pool: transaction_pool.clone(),436 spawn_handle: task_manager.spawn_handle(),437 import_queue: import_queue.clone(),438 block_announce_validator_builder: Some(Box::new(|_| {439 Box::new(block_announce_validator)440 })),441 warp_sync: None,442 })?;443444 let rpc_client = client.clone();445 let rpc_pool = transaction_pool.clone();446 let select_chain = params.select_chain.clone();447 let rpc_network = network.clone();448449 let rpc_frontier_backend = frontier_backend.clone();450451 let block_data_cache = Arc::new(fc_rpc::EthBlockDataCacheTask::new(452 task_manager.spawn_handle(),453 overrides_handle::<_, _, Runtime>(client.clone()),454 50,455 50,456 prometheus_registry.clone(),457 ));458459 task_manager.spawn_essential_handle().spawn(460 "frontier-mapping-sync-worker",461 None,462 MappingSyncWorker::new(463 client.import_notification_stream(),464 Duration::new(6, 0),465 client.clone(),466 backend.clone(),467 frontier_backend.clone(),468 3,469 0,470 SyncStrategy::Normal,471 )472 .for_each(|()| futures::future::ready(())),473 );474475 let rpc_builder = Box::new(move |deny_unsafe, subscription_task_executor| {476 let full_deps = unique_rpc::FullDeps {477 backend: rpc_frontier_backend.clone(),478 deny_unsafe,479 client: rpc_client.clone(),480 pool: rpc_pool.clone(),481 graph: rpc_pool.pool().clone(),482 // TODO: Unhardcode483 enable_dev_signer: false,484 filter_pool: filter_pool.clone(),485 network: rpc_network.clone(),486 select_chain: select_chain.clone(),487 is_authority: validator,488 // TODO: Unhardcode489 max_past_logs: 10000,490 block_data_cache: block_data_cache.clone(),491 fee_history_cache: fee_history_cache.clone(),492 // TODO: Unhardcode493 fee_history_limit: 2048,494 };495496 unique_rpc::create_full::<_, _, _, _, Runtime, RuntimeApi, _>(497 full_deps,498 subscription_task_executor,499 )500 .map_err(Into::into)501 });502503 sc_service::spawn_tasks(sc_service::SpawnTasksParams {504 rpc_builder,505 client: client.clone(),506 transaction_pool: transaction_pool.clone(),507 task_manager: &mut task_manager,508 config: parachain_config,509 keystore: params.keystore_container.sync_keystore(),510 backend: backend.clone(),511 network: network.clone(),512 system_rpc_tx,513 telemetry: telemetry.as_mut(),514 tx_handler_controller,515 })?;516517 if let Some(hwbench) = hwbench {518 sc_sysinfo::print_hwbench(&hwbench);519520 if let Some(ref mut telemetry) = telemetry {521 let telemetry_handle = telemetry.handle();522 task_manager.spawn_handle().spawn(523 "telemetry_hwbench",524 None,525 sc_sysinfo::initialize_hwbench_telemetry(telemetry_handle, hwbench),526 );527 }528 }529530 let announce_block = {531 let network = network.clone();532 Arc::new(Box::new(move |hash, data| {533 network.announce_block(hash, data)534 }))535 };536537 let relay_chain_slot_duration = Duration::from_secs(6);538539 if validator {540 let parachain_consensus = build_consensus(541 client.clone(),542 prometheus_registry.as_ref(),543 telemetry.as_ref().map(|t| t.handle()),544 &task_manager,545 relay_chain_interface.clone(),546 transaction_pool,547 network,548 params.keystore_container.sync_keystore(),549 force_authoring,550 )?;551552 let spawner = task_manager.spawn_handle();553554 let params = StartCollatorParams {555 para_id: id,556 block_status: client.clone(),557 announce_block,558 client: client.clone(),559 task_manager: &mut task_manager,560 spawner,561 parachain_consensus,562 import_queue,563 collator_key: collator_key.expect("Command line arguments do not allow this. qed"),564 relay_chain_interface,565 relay_chain_slot_duration,566 };567568 start_collator(params).await?;569 } else {570 let params = StartFullNodeParams {571 client: client.clone(),572 announce_block,573 task_manager: &mut task_manager,574 para_id: id,575 import_queue,576 relay_chain_interface,577 relay_chain_slot_duration,578 collator_options,579 };580581 start_full_node(params)?;582 }583584 start_network.start_network();585586 Ok((task_manager, client))587}588589/// Build the import queue for the the parachain runtime.590pub fn parachain_build_import_queue<RuntimeApi, ExecutorDispatch>(591 client: Arc<FullClient<RuntimeApi, ExecutorDispatch>>,592 config: &Configuration,593 telemetry: Option<TelemetryHandle>,594 task_manager: &TaskManager,595) -> Result<596 sc_consensus::DefaultImportQueue<Block, FullClient<RuntimeApi, ExecutorDispatch>>,597 sc_service::Error,598>599where600 RuntimeApi: sp_api::ConstructRuntimeApi<Block, FullClient<RuntimeApi, ExecutorDispatch>>601 + Send602 + Sync603 + 'static,604 RuntimeApi::RuntimeApi: sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block>605 + sp_block_builder::BlockBuilder<Block>606 + sp_consensus_aura::AuraApi<Block, AuraId>607 + sp_api::ApiExt<Block, StateBackend = sc_client_api::StateBackendFor<FullBackend, Block>>,608 ExecutorDispatch: NativeExecutionDispatch + 'static,609{610 let slot_duration = cumulus_client_consensus_aura::slot_duration(&*client)?;611612 cumulus_client_consensus_aura::import_queue::<613 sp_consensus_aura::sr25519::AuthorityPair,614 _,615 _,616 _,617 _,618 _,619 >(cumulus_client_consensus_aura::ImportQueueParams {620 block_import: client.clone(),621 client: client.clone(),622 create_inherent_data_providers: move |_, _| async move {623 let time = sp_timestamp::InherentDataProvider::from_system_time();624625 let slot =626 sp_consensus_aura::inherents::InherentDataProvider::from_timestamp_and_slot_duration(627 *time,628 slot_duration,629 );630631 Ok((slot, time))632 },633 registry: config.prometheus_registry(),634 spawner: &task_manager.spawn_essential_handle(),635 telemetry,636 })637 .map_err(Into::into)638}639640/// Start a normal parachain node.641pub async fn start_node<Runtime, RuntimeApi, ExecutorDispatch>(642 parachain_config: Configuration,643 polkadot_config: Configuration,644 collator_options: CollatorOptions,645 id: ParaId,646 hwbench: Option<sc_sysinfo::HwBench>,647) -> sc_service::error::Result<(TaskManager, Arc<FullClient<RuntimeApi, ExecutorDispatch>>)>648where649 Runtime: RuntimeInstance + Send + Sync + 'static,650 <Runtime as RuntimeInstance>::CrossAccountId: Serialize,651 for<'de> <Runtime as RuntimeInstance>::CrossAccountId: Deserialize<'de>,652 RuntimeApi: sp_api::ConstructRuntimeApi<Block, FullClient<RuntimeApi, ExecutorDispatch>>653 + Send654 + Sync655 + 'static,656 RuntimeApi::RuntimeApi: sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block>657 + fp_rpc::EthereumRuntimeRPCApi<Block>658 + fp_rpc::ConvertTransactionRuntimeApi<Block>659 + sp_session::SessionKeys<Block>660 + sp_block_builder::BlockBuilder<Block>661 + pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance>662 + sp_api::ApiExt<Block, StateBackend = sc_client_api::StateBackendFor<FullBackend, Block>>663 + up_rpc::UniqueApi<Block, Runtime::CrossAccountId, AccountId>664 + app_promotion_rpc::AppPromotionApi<Block, BlockNumber, Runtime::CrossAccountId, AccountId>665 + rmrk_rpc::RmrkApi<666 Block,667 AccountId,668 RmrkCollectionInfo<AccountId>,669 RmrkInstanceInfo<AccountId>,670 RmrkResourceInfo,671 RmrkPropertyInfo,672 RmrkBaseInfo<AccountId>,673 RmrkPartType,674 RmrkTheme,675 > + substrate_frame_rpc_system::AccountNonceApi<Block, AccountId, Index>676 + sp_api::Metadata<Block>677 + sp_offchain::OffchainWorkerApi<Block>678 + cumulus_primitives_core::CollectCollationInfo<Block>679 + sp_consensus_aura::AuraApi<Block, AuraId>,680 ExecutorDispatch: NativeExecutionDispatch + 'static,681{682 start_node_impl::<Runtime, RuntimeApi, ExecutorDispatch, _, _>(683 parachain_config,684 polkadot_config,685 collator_options,686 id,687 parachain_build_import_queue,688 |client,689 prometheus_registry,690 telemetry,691 task_manager,692 relay_chain_interface,693 transaction_pool,694 sync_oracle,695 keystore,696 force_authoring| {697 let slot_duration = cumulus_client_consensus_aura::slot_duration(&*client)?;698699 let proposer_factory = sc_basic_authorship::ProposerFactory::with_proof_recording(700 task_manager.spawn_handle(),701 client.clone(),702 transaction_pool,703 prometheus_registry,704 telemetry.clone(),705 );706707 Ok(AuraConsensus::build::<708 sp_consensus_aura::sr25519::AuthorityPair,709 _,710 _,711 _,712 _,713 _,714 _,715 >(BuildAuraConsensusParams {716 proposer_factory,717 create_inherent_data_providers: move |_, (relay_parent, validation_data)| {718 let relay_chain_interface = relay_chain_interface.clone();719 async move {720 let parachain_inherent =721 cumulus_primitives_parachain_inherent::ParachainInherentData::create_at(722 relay_parent,723 &relay_chain_interface,724 &validation_data,725 id,726 ).await;727728 let time = sp_timestamp::InherentDataProvider::from_system_time();729730 let slot =731 sp_consensus_aura::inherents::InherentDataProvider::from_timestamp_and_slot_duration(732 *time,733 slot_duration,734 );735736 let parachain_inherent = parachain_inherent.ok_or_else(|| {737 Box::<dyn std::error::Error + Send + Sync>::from(738 "Failed to create parachain inherent",739 )740 })?;741 Ok((slot, time, parachain_inherent))742 }743 },744 block_import: client.clone(),745 para_client: client,746 backoff_authoring_blocks: Option::<()>::None,747 sync_oracle,748 keystore,749 force_authoring,750 slot_duration,751 // We got around 500ms for proposing752 block_proposal_slot_portion: SlotProportion::new(1f32 / 24f32),753 telemetry,754 max_block_proposal_slot_portion: None,755 }))756 },757 hwbench,758 )759 .await760}761762fn dev_build_import_queue<RuntimeApi, ExecutorDispatch>(763 client: Arc<FullClient<RuntimeApi, ExecutorDispatch>>,764 config: &Configuration,765 _: Option<TelemetryHandle>,766 task_manager: &TaskManager,767) -> Result<768 sc_consensus::DefaultImportQueue<Block, FullClient<RuntimeApi, ExecutorDispatch>>,769 sc_service::Error,770>771where772 RuntimeApi: sp_api::ConstructRuntimeApi<Block, FullClient<RuntimeApi, ExecutorDispatch>>773 + Send774 + Sync775 + 'static,776 RuntimeApi::RuntimeApi: sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block>777 + sp_api::ApiExt<Block, StateBackend = sc_client_api::StateBackendFor<FullBackend, Block>>,778 ExecutorDispatch: NativeExecutionDispatch + 'static,779{780 Ok(sc_consensus_manual_seal::import_queue(781 Box::new(client.clone()),782 &task_manager.spawn_essential_handle(),783 config.prometheus_registry(),784 ))785}786787/// Builds a new development service. This service uses instant seal, and mocks788/// the parachain inherent789pub fn start_dev_node<Runtime, RuntimeApi, ExecutorDispatch>(790 config: Configuration,791 autoseal_interval: Duration,792) -> sc_service::error::Result<TaskManager>793where794 Runtime: RuntimeInstance + Send + Sync + 'static,795 <Runtime as RuntimeInstance>::CrossAccountId: Serialize,796 for<'de> <Runtime as RuntimeInstance>::CrossAccountId: Deserialize<'de>,797 RuntimeApi: sp_api::ConstructRuntimeApi<Block, FullClient<RuntimeApi, ExecutorDispatch>>798 + Send799 + Sync800 + 'static,801 RuntimeApi::RuntimeApi: sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block>802 + fp_rpc::EthereumRuntimeRPCApi<Block>803 + fp_rpc::ConvertTransactionRuntimeApi<Block>804 + sp_session::SessionKeys<Block>805 + sp_block_builder::BlockBuilder<Block>806 + pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance>807 + sp_api::ApiExt<Block, StateBackend = sc_client_api::StateBackendFor<FullBackend, Block>>808 + up_rpc::UniqueApi<Block, Runtime::CrossAccountId, AccountId>809 + app_promotion_rpc::AppPromotionApi<Block, BlockNumber, Runtime::CrossAccountId, AccountId>810 + rmrk_rpc::RmrkApi<811 Block,812 AccountId,813 RmrkCollectionInfo<AccountId>,814 RmrkInstanceInfo<AccountId>,815 RmrkResourceInfo,816 RmrkPropertyInfo,817 RmrkBaseInfo<AccountId>,818 RmrkPartType,819 RmrkTheme,820 > + substrate_frame_rpc_system::AccountNonceApi<Block, AccountId, Index>821 + sp_api::Metadata<Block>822 + sp_offchain::OffchainWorkerApi<Block>823 + cumulus_primitives_core::CollectCollationInfo<Block>824 + sp_consensus_aura::AuraApi<Block, AuraId>,825 ExecutorDispatch: NativeExecutionDispatch + 'static,826{827 use sc_consensus_manual_seal::{run_manual_seal, EngineCommand, ManualSealParams};828 use fc_consensus::FrontierBlockImport;829 use sc_client_api::HeaderBackend;830831 let sc_service::PartialComponents {832 client,833 backend,834 mut task_manager,835 import_queue,836 keystore_container,837 select_chain: maybe_select_chain,838 transaction_pool,839 other:840 (telemetry, filter_pool, frontier_backend, _telemetry_worker_handle, fee_history_cache),841 } = new_partial::<RuntimeApi, ExecutorDispatch, _>(842 &config,843 dev_build_import_queue::<RuntimeApi, ExecutorDispatch>,844 )?;845 let prometheus_registry = config.prometheus_registry().cloned();846847 let block_data_cache = Arc::new(fc_rpc::EthBlockDataCacheTask::new(848 task_manager.spawn_handle(),849 overrides_handle::<_, _, Runtime>(client.clone()),850 50,851 50,852 prometheus_registry.clone(),853 ));854855 let (network, system_rpc_tx, tx_handler_controller, network_starter) =856 sc_service::build_network(sc_service::BuildNetworkParams {857 config: &config,858 client: client.clone(),859 transaction_pool: transaction_pool.clone(),860 spawn_handle: task_manager.spawn_handle(),861 import_queue,862 block_announce_validator_builder: None,863 warp_sync: None,864 })?;865866 if config.offchain_worker.enabled {867 sc_service::build_offchain_workers(868 &config,869 task_manager.spawn_handle(),870 client.clone(),871 network.clone(),872 );873 }874875 let collator = config.role.is_authority();876877 let select_chain = maybe_select_chain.clone();878879 if collator {880 let block_import =881 FrontierBlockImport::new(client.clone(), client.clone(), frontier_backend.clone());882883 let env = sc_basic_authorship::ProposerFactory::new(884 task_manager.spawn_handle(),885 client.clone(),886 transaction_pool.clone(),887 prometheus_registry.as_ref(),888 telemetry.as_ref().map(|x| x.handle()),889 );890891 let transactions_commands_stream: Box<892 dyn Stream<Item = EngineCommand<Hash>> + Send + Sync + Unpin,893 > = Box::new(894 transaction_pool895 .pool()896 .validated_pool()897 .import_notification_stream()898 .map(|_| EngineCommand::SealNewBlock {899 create_empty: true,900 finalize: false,901 parent_hash: None,902 sender: None,903 }),904 );905906 let autoseal_interval = Box::pin(AutosealInterval::new(&config, autoseal_interval));907 let idle_commands_stream: Box<908 dyn Stream<Item = EngineCommand<Hash>> + Send + Sync + Unpin,909 > = Box::new(autoseal_interval.map(|_| EngineCommand::SealNewBlock {910 create_empty: true,911 finalize: false,912 parent_hash: None,913 sender: None,914 }));915916 let commands_stream = select(transactions_commands_stream, idle_commands_stream);917918 let slot_duration = cumulus_client_consensus_aura::slot_duration(&*client)?;919 let client_set_aside_for_cidp = client.clone();920921 task_manager.spawn_essential_handle().spawn_blocking(922 "authorship_task",923 Some("block-authoring"),924 run_manual_seal(ManualSealParams {925 block_import,926 env,927 client: client.clone(),928 pool: transaction_pool.clone(),929 commands_stream,930 select_chain: select_chain.clone(),931 consensus_data_provider: None,932 create_inherent_data_providers: move |block: Hash, ()| {933 let current_para_block = client_set_aside_for_cidp934 .number(block)935 .expect("Header lookup should succeed")936 .expect("Header passed in as parent should be present in backend.");937938 let client_for_xcm = client_set_aside_for_cidp.clone();939 async move {940 let time = sp_timestamp::InherentDataProvider::from_system_time();941942 let mocked_parachain = cumulus_primitives_parachain_inherent::MockValidationDataInherentDataProvider {943 current_para_block,944 relay_offset: 1000,945 relay_blocks_per_para_block: 2,946 para_blocks_per_relay_epoch: 0,947 xcm_config: cumulus_primitives_parachain_inherent::MockXcmConfig::new(948 &*client_for_xcm,949 block,950 Default::default(),951 Default::default(),952 ),953 relay_randomness_config: (),954 raw_downward_messages: vec![],955 raw_horizontal_messages: vec![],956 };957958 let slot =959 sp_consensus_aura::inherents::InherentDataProvider::from_timestamp_and_slot_duration(960 *time,961 slot_duration,962 );963964 Ok((time, slot, mocked_parachain))965 }966 },967 }),968 );969 }970971 task_manager.spawn_essential_handle().spawn(972 "frontier-mapping-sync-worker",973 Some("block-authoring"),974 MappingSyncWorker::new(975 client.import_notification_stream(),976 Duration::new(6, 0),977 client.clone(),978 backend.clone(),979 frontier_backend.clone(),980 3,981 0,982 SyncStrategy::Normal,983 )984 .for_each(|()| futures::future::ready(())),985 );986987 let rpc_client = client.clone();988 let rpc_pool = transaction_pool.clone();989 let rpc_network = network.clone();990 let rpc_frontier_backend = frontier_backend.clone();991 let rpc_builder = Box::new(move |deny_unsafe, subscription_executor| {992 let full_deps = unique_rpc::FullDeps {993 backend: rpc_frontier_backend.clone(),994 deny_unsafe,995 client: rpc_client.clone(),996 pool: rpc_pool.clone(),997 graph: rpc_pool.pool().clone(),998 // TODO: Unhardcode999 enable_dev_signer: false,1000 filter_pool: filter_pool.clone(),1001 network: rpc_network.clone(),1002 select_chain: select_chain.clone(),1003 is_authority: collator,1004 // TODO: Unhardcode1005 max_past_logs: 10000,1006 block_data_cache: block_data_cache.clone(),1007 fee_history_cache: fee_history_cache.clone(),1008 // TODO: Unhardcode1009 fee_history_limit: 2048,1010 };10111012 unique_rpc::create_full::<_, _, _, _, Runtime, RuntimeApi, _>(1013 full_deps,1014 subscription_executor,1015 )1016 .map_err(Into::into)1017 });10181019 sc_service::spawn_tasks(sc_service::SpawnTasksParams {1020 network,1021 client,1022 keystore: keystore_container.sync_keystore(),1023 task_manager: &mut task_manager,1024 transaction_pool,1025 rpc_builder,1026 backend,1027 system_rpc_tx,1028 config,1029 telemetry: None,1030 tx_handler_controller,1031 })?;10321033 network_starter.start_network();1034 Ok(task_manager)1035}pallets/common/src/erc.rsdiffbeforeafterboth--- a/pallets/common/src/erc.rs
+++ b/pallets/common/src/erc.rs
@@ -27,7 +27,7 @@
use sp_std::vec::Vec;
use up_data_structs::{
AccessMode, CollectionMode, CollectionPermissions, OwnerRestrictedSet, Property,
- SponsoringRateLimit, SponsorshipState, PropertyKey,
+ SponsoringRateLimit, SponsorshipState,
};
use alloc::format;
@@ -106,7 +106,6 @@
caller: caller,
properties: Vec<(string, bytes)>,
) -> Result<void> {
-
let caller = T::CrossAccountId::from_eth(caller);
let properties = properties
pallets/unique/src/eth/mod.rsdiffbeforeafterboth--- a/pallets/unique/src/eth/mod.rs
+++ b/pallets/unique/src/eth/mod.rs
@@ -26,19 +26,15 @@
use pallet_common::{
CollectionById,
dispatch::CollectionDispatch,
- erc::{
- static_property::key,
- CollectionHelpersEvents,
- },
+ erc::{static_property::key, CollectionHelpersEvents},
Pallet as PalletCommon,
-
};
use pallet_evm::{account::CrossAccountId, OnMethodCall, PrecompileHandle, PrecompileResult};
use pallet_evm_coder_substrate::{dispatch_to_evm, SubstrateRecorder, WithRecorder};
use sp_std::vec;
use up_data_structs::{
CollectionDescription, CollectionMode, CollectionName, CollectionTokenPrefix,
- CreateCollectionData, PropertyValue,
+ CreateCollectionData,
};
use crate::{weights::WeightInfo, Config, SelfWeightOf};
@@ -86,23 +82,6 @@
error_field_too_long(stringify!(token_prefix), CollectionTokenPrefix::bound())
})?;
Ok((caller, name, description, token_prefix))
-}
-
-fn create_refungible_collection_internal<T: Config>(
- caller: caller,
- value: value,
- name: string,
- description: string,
- token_prefix: string,
-) -> Result<address> {
- self::create_collection_internal::<T>(
- caller,
- value,
- name,
- CollectionMode::ReFungible,
- description,
- token_prefix
- )
}
#[inline(always)]
@@ -233,27 +212,6 @@
name: string,
description: string,
token_prefix: string,
- ) -> Result<address> {
- create_collection_internal::<T>(
- caller,
- value,
- name,
- CollectionMode::ReFungible,
- description,
- token_prefix,
- )
- }
-
- #[weight(<SelfWeightOf<T>>::create_collection())]
- #[solidity(rename_selector = "createERC721MetadataCompatibleRFTCollection")]
- fn create_refungible_collection_with_properties(
- &mut self,
- caller: caller,
- value: value,
- name: string,
- description: string,
- token_prefix: string,
- base_uri: string,
) -> Result<address> {
create_collection_internal::<T>(
caller,