Skip to content

Commit

Permalink
changes
Browse files Browse the repository at this point in the history
  • Loading branch information
enddynayn committed Aug 8, 2024
1 parent 8c3cc3e commit 8e515fd
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 17 deletions.
2 changes: 1 addition & 1 deletion node/cli/src/run_as_localchain.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::cli::Cli;
use frequency_service::block_sealing::frequency_dev_sealing;
use frequency_service::block_sealing::start_frequency_dev_sealing_node;
use sc_cli::SubstrateCli;

pub fn run_as_localchain(cli: Cli) -> sc_service::Result<(), sc_cli::Error> {
Expand Down
18 changes: 9 additions & 9 deletions node/cli/src/run_as_parachain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,25 @@ pub fn run_as_parachain(cli: Cli) -> sc_service::Result<(), sc_cli::Error> {

runner.run_node_until_exit(|config| async move {
let hwbench = (!cli.no_hardware_benchmarks)
.then_some(config.database.path().map(|database_path| {
let _ = std::fs::create_dir_all(database_path);
sc_sysinfo::gather_hwbench(Some(database_path))
}))
.flatten();
.then_some(config.database.path().map(|database_path| {
let _ = std::fs::create_dir_all(database_path);
sc_sysinfo::gather_hwbench(Some(database_path))
}))
.flatten();

let para_id = chain_spec::Extensions::try_get(&*config.chain_spec)
.map(|e: &chain_spec::Extensions| e.para_id)
.ok_or("Could not find parachain ID in chain-spec.")?;

let polkadot_cli = RelayChainCli::new(
&config,
[RelayChainCli::executable_name()].iter().chain(cli.relay_chain_args.iter()),
);

let id = ParaId::from(para_id);

let tokio_handle = config.tokio_handle.clone();

let polkadot_config =
SubstrateCli::create_configuration(&polkadot_cli, &polkadot_cli, tokio_handle)
.map_err(|err| format!("Relay chain argument error: {}", err))?;
Expand Down
15 changes: 12 additions & 3 deletions node/service/src/block_sealing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use cli_opt::SealingMode;
pub use futures::stream::StreamExt;
use sc_consensus::block_import::BlockImport;

use common_primitives::node::{Block, Hash};
use common_primitives::node::{Block, BlockNumber, Hash};
use core::marker::PhantomData;
use futures::Stream;
use sc_client_api::backend::{Backend as ClientBackend, Finalizer};
Expand All @@ -12,14 +12,15 @@ use sc_consensus_manual_seal::{
};

use futures::FutureExt;
use sc_network::NetworkBackend;
use sc_service::{Configuration, TaskManager};
use sc_transaction_pool_api::{OffchainTransactionPoolFactory, TransactionPool};
use sp_api::ProvideRuntimeApi;
use sp_blockchain::HeaderBackend;
use sp_consensus::{Environment, Proposer, SelectChain};
use sp_inherents::CreateInherentDataProviders;
use sp_runtime::traits::Block as BlockT;
use std::{task::Poll, sync::Arc};
use std::{sync::Arc, task::Poll};

/// Function to start Frequency in dev mode without a relay chain
/// This function is called when --chain dev --sealing= is passed.
Expand All @@ -37,7 +38,11 @@ pub fn start_frequency_dev_sealing_node(
};
log::info!("📎 Development mode (no relay chain) with {} sealing{}", sealing_mode, extra);

let net_config = sc_network::config::FullNetworkConfiguration::<_, _, sc_network::NetworkWorker<Block, Hash>>::new(&config.network);
let net_config = sc_network::config::FullNetworkConfiguration::<
_,
_,
sc_network::NetworkWorker<Block, Hash>,
>::new(&config.network);
let sc_service::PartialComponents {
client,
backend,
Expand All @@ -48,6 +53,9 @@ pub fn start_frequency_dev_sealing_node(
transaction_pool,
other: (_block_import, mut telemetry, _),
} = new_partial(&config, true)?;
let metrics = sc_network::NetworkWorker::<Block, Hash>::register_notification_metrics(
config.prometheus_config.as_ref().map(|cfg| &cfg.registry),
);

// Build the network components required for the blockchain.
let (network, system_rpc_tx, tx_handler_controller, network_starter, sync_service) =
Expand All @@ -61,6 +69,7 @@ pub fn start_frequency_dev_sealing_node(
block_announce_validator_builder: None,
warp_sync_params: None,
block_relay: None,
metrics,
})?;

// Start off-chain workers if enabled
Expand Down
22 changes: 18 additions & 4 deletions node/service/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ use sc_executor::{
HeapAllocStrategy, NativeElseWasmExecutor, WasmExecutor, DEFAULT_HEAP_ALLOC_STRATEGY,
};

use sc_network::{NetworkBlock, NetworkBackend, NetworkService};
use sc_network::{NetworkBackend, NetworkBlock, NetworkService};
use sc_network_sync::SyncingService;
use sc_service::{Configuration, PartialComponents, TFullBackend, TFullClient, TaskManager};
use sc_telemetry::{Telemetry, TelemetryHandle, TelemetryWorker, TelemetryWorkerHandle};
Expand Down Expand Up @@ -494,8 +494,22 @@ pub async fn start_parachain_node(
) -> sc_service::error::Result<(TaskManager, Arc<ParachainClient>)> {
match polkadot_config.network.network_backend {
sc_network::config::NetworkBackendType::Libp2p =>
start_node_impl::<sc_network::NetworkWorker<_, _>>(parachain_config, polkadot_config, collator_options, id, hwbench).await,
sc_network::config::NetworkBackendType::Litep2p =>
start_node_impl::<sc_network::Litep2pNetworkBackend>(parachain_config, polkadot_config, collator_options, para_id, hwbench).await,
start_node_impl::<sc_network::NetworkWorker<_, _>>(
parachain_config,
polkadot_config,
collator_options,
id,
hwbench,
)
.await,
sc_network::config::NetworkBackendType::Litep2p =>
start_node_impl::<sc_network::Litep2pNetworkBackend>(
parachain_config,
polkadot_config,
collator_options,
para_id,
hwbench,
)
.await,
}
}

0 comments on commit 8e515fd

Please sign in to comment.