mirror of
https://github.com/pezkuwichain/pez-solochain-template.git
synced 2026-04-22 05:37:59 +00:00
Apply local rebrand updates (compatible with pezkuwi-sdk)
This commit is contained in:
+27
-25
@@ -4,14 +4,14 @@
|
||||
|
||||
use crate::service::FullClient;
|
||||
|
||||
use pez_solochain_template_runtime as runtime;
|
||||
use pezsc_cli::Result;
|
||||
use pezsc_client_api::BlockBackend;
|
||||
use pezsp_core::{Encode, Pair};
|
||||
use pezsp_inherents::{InherentData, InherentDataProvider};
|
||||
use pezsp_keyring::Sr25519Keyring;
|
||||
use pezsp_runtime::{OpaqueExtrinsic, SaturatedConversion};
|
||||
use runtime::{AccountId, Balance, BalancesCall, SystemCall};
|
||||
use sc_cli::Result;
|
||||
use sc_client_api::BlockBackend;
|
||||
use solochain_template_runtime as runtime;
|
||||
use sp_core::{Encode, Pair};
|
||||
use sp_inherents::{InherentData, InherentDataProvider};
|
||||
use sp_keyring::Sr25519Keyring;
|
||||
use sp_runtime::{OpaqueExtrinsic, SaturatedConversion};
|
||||
|
||||
use std::{sync::Arc, time::Duration};
|
||||
|
||||
@@ -29,8 +29,8 @@ impl RemarkBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
impl frame_benchmarking_cli::ExtrinsicBuilder for RemarkBuilder {
|
||||
fn pallet(&self) -> &str {
|
||||
impl pezframe_benchmarking_cli::ExtrinsicBuilder for RemarkBuilder {
|
||||
fn pezpallet(&self) -> &str {
|
||||
"system"
|
||||
}
|
||||
|
||||
@@ -68,8 +68,8 @@ impl TransferKeepAliveBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
impl frame_benchmarking_cli::ExtrinsicBuilder for TransferKeepAliveBuilder {
|
||||
fn pallet(&self) -> &str {
|
||||
impl pezframe_benchmarking_cli::ExtrinsicBuilder for TransferKeepAliveBuilder {
|
||||
fn pezpallet(&self) -> &str {
|
||||
"balances"
|
||||
}
|
||||
|
||||
@@ -97,7 +97,7 @@ impl frame_benchmarking_cli::ExtrinsicBuilder for TransferKeepAliveBuilder {
|
||||
/// Note: Should only be used for benchmarking.
|
||||
pub fn create_benchmark_extrinsic(
|
||||
client: &FullClient,
|
||||
sender: sp_core::sr25519::Pair,
|
||||
sender: pezsp_core::sr25519::Pair,
|
||||
call: runtime::RuntimeCall,
|
||||
nonce: u32,
|
||||
) -> runtime::UncheckedExtrinsic {
|
||||
@@ -110,25 +110,27 @@ pub fn create_benchmark_extrinsic(
|
||||
.map(|c| c / 2)
|
||||
.unwrap_or(2) as u64;
|
||||
let tx_ext: runtime::TxExtension = (
|
||||
frame_system::CheckNonZeroSender::<runtime::Runtime>::new(),
|
||||
frame_system::CheckSpecVersion::<runtime::Runtime>::new(),
|
||||
frame_system::CheckTxVersion::<runtime::Runtime>::new(),
|
||||
frame_system::CheckGenesis::<runtime::Runtime>::new(),
|
||||
frame_system::CheckEra::<runtime::Runtime>::from(sp_runtime::generic::Era::mortal(
|
||||
pezframe_system::AuthorizeCall::<runtime::Runtime>::new(),
|
||||
pezframe_system::CheckNonZeroSender::<runtime::Runtime>::new(),
|
||||
pezframe_system::CheckSpecVersion::<runtime::Runtime>::new(),
|
||||
pezframe_system::CheckTxVersion::<runtime::Runtime>::new(),
|
||||
pezframe_system::CheckGenesis::<runtime::Runtime>::new(),
|
||||
pezframe_system::CheckEra::<runtime::Runtime>::from(pezsp_runtime::generic::Era::mortal(
|
||||
period,
|
||||
best_block.saturated_into(),
|
||||
)),
|
||||
frame_system::CheckNonce::<runtime::Runtime>::from(nonce),
|
||||
frame_system::CheckWeight::<runtime::Runtime>::new(),
|
||||
pallet_transaction_payment::ChargeTransactionPayment::<runtime::Runtime>::from(0),
|
||||
frame_metadata_hash_extension::CheckMetadataHash::<runtime::Runtime>::new(false),
|
||||
frame_system::WeightReclaim::<runtime::Runtime>::new(),
|
||||
pezframe_system::CheckNonce::<runtime::Runtime>::from(nonce),
|
||||
pezframe_system::CheckWeight::<runtime::Runtime>::new(),
|
||||
pezpallet_transaction_payment::ChargeTransactionPayment::<runtime::Runtime>::from(0),
|
||||
pezframe_metadata_hash_extension::CheckMetadataHash::<runtime::Runtime>::new(false),
|
||||
pezframe_system::WeightReclaim::<runtime::Runtime>::new(),
|
||||
);
|
||||
|
||||
let raw_payload = runtime::SignedPayload::from_raw(
|
||||
call.clone(),
|
||||
tx_ext.clone(),
|
||||
(
|
||||
(),
|
||||
(),
|
||||
runtime::VERSION.spec_version,
|
||||
runtime::VERSION.transaction_version,
|
||||
@@ -145,7 +147,7 @@ pub fn create_benchmark_extrinsic(
|
||||
|
||||
runtime::UncheckedExtrinsic::new_signed(
|
||||
call,
|
||||
sp_runtime::AccountId32::from(sender.public()).into(),
|
||||
pezsp_runtime::AccountId32::from(sender.public()).into(),
|
||||
runtime::Signature::Sr25519(signature),
|
||||
tx_ext,
|
||||
)
|
||||
@@ -157,9 +159,9 @@ pub fn create_benchmark_extrinsic(
|
||||
pub fn inherent_benchmark_data() -> Result<InherentData> {
|
||||
let mut inherent_data = InherentData::new();
|
||||
let d = Duration::from_millis(0);
|
||||
let timestamp = sp_timestamp::InherentDataProvider::new(d.into());
|
||||
let timestamp = pezsp_timestamp::InherentDataProvider::new(d.into());
|
||||
|
||||
futures::executor::block_on(timestamp.provide_inherent_data(&mut inherent_data))
|
||||
.map_err(|e| format!("creating inherent data: {:?}", e))?;
|
||||
.map_err(|e| format!("creating inherent data: {e:?}"))?;
|
||||
Ok(inherent_data)
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
use sc_service::ChainType;
|
||||
use solochain_template_runtime::WASM_BINARY;
|
||||
use pez_solochain_template_runtime::WASM_BINARY;
|
||||
use pezsc_service::ChainType;
|
||||
|
||||
/// Specialized `ChainSpec`. This is a specialization of the general Substrate ChainSpec type.
|
||||
pub type ChainSpec = sc_service::GenericChainSpec;
|
||||
/// Specialized `ChainSpec`. This is a specialization of the general Bizinikiwi ChainSpec type.
|
||||
pub type ChainSpec = pezsc_service::GenericChainSpec;
|
||||
|
||||
pub fn development_chain_spec() -> Result<ChainSpec, String> {
|
||||
Ok(ChainSpec::builder(
|
||||
@@ -12,7 +12,7 @@ pub fn development_chain_spec() -> Result<ChainSpec, String> {
|
||||
.with_name("Development")
|
||||
.with_id("dev")
|
||||
.with_chain_type(ChainType::Development)
|
||||
.with_genesis_config_preset_name(sp_genesis_builder::DEV_RUNTIME_PRESET)
|
||||
.with_genesis_config_preset_name(pezsp_genesis_builder::DEV_RUNTIME_PRESET)
|
||||
.build())
|
||||
}
|
||||
|
||||
@@ -24,6 +24,6 @@ pub fn local_chain_spec() -> Result<ChainSpec, String> {
|
||||
.with_name("Local Testnet")
|
||||
.with_id("local_testnet")
|
||||
.with_chain_type(ChainType::Local)
|
||||
.with_genesis_config_preset_name(sp_genesis_builder::LOCAL_TESTNET_RUNTIME_PRESET)
|
||||
.with_genesis_config_preset_name(pezsp_genesis_builder::LOCAL_TESTNET_RUNTIME_PRESET)
|
||||
.build())
|
||||
}
|
||||
|
||||
+19
-13
@@ -1,12 +1,10 @@
|
||||
use sc_cli::RunCmd;
|
||||
|
||||
#[derive(Debug, clap::Parser)]
|
||||
pub struct Cli {
|
||||
#[command(subcommand)]
|
||||
pub subcommand: Option<Subcommand>,
|
||||
|
||||
#[clap(flatten)]
|
||||
pub run: RunCmd,
|
||||
pub run: pezsc_cli::RunCmd,
|
||||
}
|
||||
|
||||
#[derive(Debug, clap::Subcommand)]
|
||||
@@ -14,33 +12,41 @@ pub struct Cli {
|
||||
pub enum Subcommand {
|
||||
/// Key management cli utilities
|
||||
#[command(subcommand)]
|
||||
Key(sc_cli::KeySubcommand),
|
||||
Key(pezsc_cli::KeySubcommand),
|
||||
|
||||
/// Build a chain specification.
|
||||
BuildSpec(sc_cli::BuildSpecCmd),
|
||||
/// DEPRECATED: `build-spec` command will be removed after 1/04/2026. Use `export-chain-spec`
|
||||
/// command instead.
|
||||
#[deprecated(
|
||||
note = "build-spec command will be removed after 1/04/2026. Use export-chain-spec command instead"
|
||||
)]
|
||||
BuildSpec(pezsc_cli::BuildSpecCmd),
|
||||
|
||||
/// Export the chain specification.
|
||||
ExportChainSpec(pezsc_cli::ExportChainSpecCmd),
|
||||
|
||||
/// Validate blocks.
|
||||
CheckBlock(sc_cli::CheckBlockCmd),
|
||||
CheckBlock(pezsc_cli::CheckBlockCmd),
|
||||
|
||||
/// Export blocks.
|
||||
ExportBlocks(sc_cli::ExportBlocksCmd),
|
||||
ExportBlocks(pezsc_cli::ExportBlocksCmd),
|
||||
|
||||
/// Export the state of a given block into a chain spec.
|
||||
ExportState(sc_cli::ExportStateCmd),
|
||||
ExportState(pezsc_cli::ExportStateCmd),
|
||||
|
||||
/// Import blocks.
|
||||
ImportBlocks(sc_cli::ImportBlocksCmd),
|
||||
ImportBlocks(pezsc_cli::ImportBlocksCmd),
|
||||
|
||||
/// Remove the whole chain.
|
||||
PurgeChain(sc_cli::PurgeChainCmd),
|
||||
PurgeChain(pezsc_cli::PurgeChainCmd),
|
||||
|
||||
/// Revert the chain to a previous state.
|
||||
Revert(sc_cli::RevertCmd),
|
||||
Revert(pezsc_cli::RevertCmd),
|
||||
|
||||
/// Sub-commands concerned with benchmarking.
|
||||
#[command(subcommand)]
|
||||
Benchmark(frame_benchmarking_cli::BenchmarkCmd),
|
||||
Benchmark(pezframe_benchmarking_cli::BenchmarkCmd),
|
||||
|
||||
/// Db meta columns information.
|
||||
ChainInfo(sc_cli::ChainInfoCmd),
|
||||
ChainInfo(pezsc_cli::ChainInfoCmd),
|
||||
}
|
||||
|
||||
+35
-27
@@ -4,19 +4,19 @@ use crate::{
|
||||
cli::{Cli, Subcommand},
|
||||
service,
|
||||
};
|
||||
use frame_benchmarking_cli::{BenchmarkCmd, ExtrinsicFactory, SUBSTRATE_REFERENCE_HARDWARE};
|
||||
use sc_cli::SubstrateCli;
|
||||
use sc_service::PartialComponents;
|
||||
use solochain_template_runtime::{Block, EXISTENTIAL_DEPOSIT};
|
||||
use sp_keyring::Sr25519Keyring;
|
||||
use pez_solochain_template_runtime::{Block, EXISTENTIAL_DEPOSIT};
|
||||
use pezframe_benchmarking_cli::{BenchmarkCmd, ExtrinsicFactory, BIZINIKIWI_REFERENCE_HARDWARE};
|
||||
use pezsc_cli::BizinikiwiCli;
|
||||
use pezsc_service::PartialComponents;
|
||||
use pezsp_keyring::Sr25519Keyring;
|
||||
|
||||
impl SubstrateCli for Cli {
|
||||
impl BizinikiwiCli for Cli {
|
||||
fn impl_name() -> String {
|
||||
"Substrate Node".into()
|
||||
"Bizinikiwi Node".into()
|
||||
}
|
||||
|
||||
fn impl_version() -> String {
|
||||
env!("SUBSTRATE_CLI_IMPL_VERSION").into()
|
||||
env!("BIZINIKIWI_CLI_IMPL_VERSION").into()
|
||||
}
|
||||
|
||||
fn description() -> String {
|
||||
@@ -35,22 +35,24 @@ impl SubstrateCli for Cli {
|
||||
2017
|
||||
}
|
||||
|
||||
fn load_spec(&self, id: &str) -> Result<Box<dyn sc_service::ChainSpec>, String> {
|
||||
fn load_spec(&self, id: &str) -> Result<Box<dyn pezsc_service::ChainSpec>, String> {
|
||||
Ok(match id {
|
||||
"dev" => Box::new(chain_spec::development_chain_spec()?),
|
||||
"" | "local" => Box::new(chain_spec::local_chain_spec()?),
|
||||
path =>
|
||||
Box::new(chain_spec::ChainSpec::from_json_file(std::path::PathBuf::from(path))?),
|
||||
path => {
|
||||
Box::new(chain_spec::ChainSpec::from_json_file(std::path::PathBuf::from(path))?)
|
||||
},
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
/// Parse and run command line arguments
|
||||
pub fn run() -> sc_cli::Result<()> {
|
||||
pub fn run() -> pezsc_cli::Result<()> {
|
||||
let cli = Cli::from_args();
|
||||
|
||||
match &cli.subcommand {
|
||||
Some(Subcommand::Key(cmd)) => cmd.run(&cli),
|
||||
#[allow(deprecated)]
|
||||
Some(Subcommand::BuildSpec(cmd)) => {
|
||||
let runner = cli.create_runner(cmd)?;
|
||||
runner.sync_run(|config| cmd.run(config.chain_spec, config.network))
|
||||
@@ -63,6 +65,10 @@ pub fn run() -> sc_cli::Result<()> {
|
||||
Ok((cmd.run(client, import_queue), task_manager))
|
||||
})
|
||||
},
|
||||
Some(Subcommand::ExportChainSpec(cmd)) => {
|
||||
let chain_spec = cli.load_spec(&cmd.chain)?;
|
||||
cmd.run(chain_spec)
|
||||
},
|
||||
Some(Subcommand::ExportBlocks(cmd)) => {
|
||||
let runner = cli.create_runner(cmd)?;
|
||||
runner.async_run(|config| {
|
||||
@@ -95,7 +101,7 @@ pub fn run() -> sc_cli::Result<()> {
|
||||
let PartialComponents { client, task_manager, backend, .. } =
|
||||
service::new_partial(&config)?;
|
||||
let aux_revert = Box::new(|client, _, blocks| {
|
||||
sc_consensus_grandpa::revert(client, blocks)?;
|
||||
pezsc_consensus_grandpa::revert(client, blocks)?;
|
||||
Ok(())
|
||||
});
|
||||
Ok((cmd.run(client, backend, Some(aux_revert)), task_manager))
|
||||
@@ -108,7 +114,7 @@ pub fn run() -> sc_cli::Result<()> {
|
||||
// This switch needs to be in the client, since the client decides
|
||||
// which sub-commands it wants to support.
|
||||
match cmd {
|
||||
BenchmarkCmd::Pallet(cmd) => {
|
||||
BenchmarkCmd::Pezpallet(cmd) => {
|
||||
if !cfg!(feature = "runtime-benchmarks") {
|
||||
return Err(
|
||||
"Runtime benchmarking wasn't enabled when building the node. \
|
||||
@@ -117,7 +123,7 @@ pub fn run() -> sc_cli::Result<()> {
|
||||
);
|
||||
}
|
||||
|
||||
cmd.run_with_spec::<sp_runtime::traits::HashingFor<Block>, ()>(Some(
|
||||
cmd.run_with_spec::<pezsp_runtime::traits::HashingFor<Block>, ()>(Some(
|
||||
config.chain_spec,
|
||||
))
|
||||
},
|
||||
@@ -136,8 +142,9 @@ pub fn run() -> sc_cli::Result<()> {
|
||||
service::new_partial(&config)?;
|
||||
let db = backend.expose_db();
|
||||
let storage = backend.expose_storage();
|
||||
let shared_cache = backend.expose_shared_trie_cache();
|
||||
|
||||
cmd.run(config, client, db, storage)
|
||||
cmd.run(config, client, db, storage, shared_cache)
|
||||
},
|
||||
BenchmarkCmd::Overhead(cmd) => {
|
||||
let PartialComponents { client, .. } = service::new_partial(&config)?;
|
||||
@@ -166,8 +173,9 @@ pub fn run() -> sc_cli::Result<()> {
|
||||
|
||||
cmd.run(client, inherent_benchmark_data()?, Vec::new(), &ext_factory)
|
||||
},
|
||||
BenchmarkCmd::Machine(cmd) =>
|
||||
cmd.run(&config, SUBSTRATE_REFERENCE_HARDWARE.clone()),
|
||||
BenchmarkCmd::Machine(cmd) => {
|
||||
cmd.run(&config, BIZINIKIWI_REFERENCE_HARDWARE.clone())
|
||||
},
|
||||
}
|
||||
})
|
||||
},
|
||||
@@ -178,17 +186,17 @@ pub fn run() -> sc_cli::Result<()> {
|
||||
None => {
|
||||
let runner = cli.create_runner(&cli.run)?;
|
||||
runner.run_node_until_exit(|config| async move {
|
||||
match config.network.network_backend.unwrap_or_default() {
|
||||
sc_network::config::NetworkBackendType::Libp2p => service::new_full::<
|
||||
sc_network::NetworkWorker<
|
||||
solochain_template_runtime::opaque::Block,
|
||||
<solochain_template_runtime::opaque::Block as sp_runtime::traits::Block>::Hash,
|
||||
match config.network.network_backend {
|
||||
pezsc_network::config::NetworkBackendType::Libp2p => service::new_full::<
|
||||
pezsc_network::NetworkWorker<
|
||||
pez_solochain_template_runtime::opaque::Block,
|
||||
<pez_solochain_template_runtime::opaque::Block as pezsp_runtime::traits::Block>::Hash,
|
||||
>,
|
||||
>(config)
|
||||
.map_err(sc_cli::Error::Service),
|
||||
sc_network::config::NetworkBackendType::Litep2p =>
|
||||
service::new_full::<sc_network::Litep2pNetworkBackend>(config)
|
||||
.map_err(sc_cli::Error::Service),
|
||||
.map_err(pezsc_cli::Error::Service),
|
||||
pezsc_network::config::NetworkBackendType::Litep2p =>
|
||||
service::new_full::<pezsc_network::Litep2pNetworkBackend>(config)
|
||||
.map_err(pezsc_cli::Error::Service),
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
//! Substrate Node Template CLI library.
|
||||
//! Bizinikiwi Node Template CLI library.
|
||||
#![warn(missing_docs)]
|
||||
|
||||
mod benchmarking;
|
||||
@@ -8,6 +8,6 @@ mod command;
|
||||
mod rpc;
|
||||
mod service;
|
||||
|
||||
fn main() -> sc_cli::Result<()> {
|
||||
fn main() -> pezsc_cli::Result<()> {
|
||||
command::run()
|
||||
}
|
||||
|
||||
+11
-11
@@ -1,6 +1,6 @@
|
||||
//! A collection of node-specific RPC methods.
|
||||
//! Substrate provides the `sc-rpc` crate, which defines the core RPC layer
|
||||
//! used by Substrate nodes. This file extends those RPC definitions with
|
||||
//! Bizinikiwi provides the `sc-rpc` crate, which defines the core RPC layer
|
||||
//! used by Bizinikiwi nodes. This file extends those RPC definitions with
|
||||
//! capabilities that are specific to this project's runtime configuration.
|
||||
|
||||
#![warn(missing_docs)]
|
||||
@@ -8,11 +8,11 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use jsonrpsee::RpcModule;
|
||||
use sc_transaction_pool_api::TransactionPool;
|
||||
use solochain_template_runtime::{opaque::Block, AccountId, Balance, Nonce};
|
||||
use sp_api::ProvideRuntimeApi;
|
||||
use sp_block_builder::BlockBuilder;
|
||||
use sp_blockchain::{Error as BlockChainError, HeaderBackend, HeaderMetadata};
|
||||
use pez_solochain_template_runtime::{opaque::Block, AccountId, Balance, Nonce};
|
||||
use pezsc_transaction_pool_api::TransactionPool;
|
||||
use pezsp_api::ProvideRuntimeApi;
|
||||
use pezsp_block_builder::BlockBuilder;
|
||||
use pezsp_blockchain::{Error as BlockChainError, HeaderBackend, HeaderMetadata};
|
||||
|
||||
/// Full client dependencies.
|
||||
pub struct FullDeps<C, P> {
|
||||
@@ -30,13 +30,13 @@ where
|
||||
C: ProvideRuntimeApi<Block>,
|
||||
C: HeaderBackend<Block> + HeaderMetadata<Block, Error = BlockChainError> + 'static,
|
||||
C: Send + Sync + 'static,
|
||||
C::Api: substrate_frame_rpc_system::AccountNonceApi<Block, AccountId, Nonce>,
|
||||
C::Api: pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi<Block, Balance>,
|
||||
C::Api: bizinikiwi_frame_rpc_system::AccountNonceApi<Block, AccountId, Nonce>,
|
||||
C::Api: pezpallet_transaction_payment_rpc::TransactionPaymentRuntimeApi<Block, Balance>,
|
||||
C::Api: BlockBuilder<Block>,
|
||||
P: TransactionPool + 'static,
|
||||
{
|
||||
use pallet_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApiServer};
|
||||
use substrate_frame_rpc_system::{System, SystemApiServer};
|
||||
use bizinikiwi_frame_rpc_system::{System, SystemApiServer};
|
||||
use pezpallet_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApiServer};
|
||||
|
||||
let mut module = RpcModule::new(());
|
||||
let FullDeps { client, pool } = deps;
|
||||
|
||||
+55
-48
@@ -1,37 +1,42 @@
|
||||
//! Service and ServiceFactory implementation. Specialized wrapper over substrate service.
|
||||
//! Service and ServiceFactory implementation. Specialized wrapper over bizinikiwi service.
|
||||
|
||||
use futures::FutureExt;
|
||||
use sc_client_api::{Backend, BlockBackend};
|
||||
use sc_consensus_aura::{ImportQueueParams, SlotProportion, StartAuraParams};
|
||||
use sc_consensus_grandpa::SharedVoterState;
|
||||
use sc_service::{error::Error as ServiceError, Configuration, TaskManager, WarpSyncConfig};
|
||||
use sc_telemetry::{Telemetry, TelemetryWorker};
|
||||
use sc_transaction_pool_api::OffchainTransactionPoolFactory;
|
||||
use solochain_template_runtime::{self, apis::RuntimeApi, opaque::Block};
|
||||
use sp_consensus_aura::sr25519::AuthorityPair as AuraPair;
|
||||
use pez_solochain_template_runtime::{self, apis::RuntimeApi, opaque::Block};
|
||||
use pezsc_client_api::{Backend, BlockBackend};
|
||||
use pezsc_consensus_aura::{ImportQueueParams, SlotProportion, StartAuraParams};
|
||||
use pezsc_consensus_grandpa::SharedVoterState;
|
||||
use pezsc_service::{error::Error as ServiceError, Configuration, TaskManager, WarpSyncConfig};
|
||||
use pezsc_telemetry::{Telemetry, TelemetryWorker};
|
||||
use pezsc_transaction_pool_api::OffchainTransactionPoolFactory;
|
||||
use pezsp_consensus_aura::sr25519::AuthorityPair as AuraPair;
|
||||
use std::{sync::Arc, time::Duration};
|
||||
|
||||
pub(crate) type FullClient = sc_service::TFullClient<
|
||||
pub(crate) type FullClient = pezsc_service::TFullClient<
|
||||
Block,
|
||||
RuntimeApi,
|
||||
sc_executor::WasmExecutor<sp_io::SubstrateHostFunctions>,
|
||||
pezsc_executor::WasmExecutor<pezsp_io::BizinikiwiHostFunctions>,
|
||||
>;
|
||||
type FullBackend = sc_service::TFullBackend<Block>;
|
||||
type FullSelectChain = sc_consensus::LongestChain<FullBackend, Block>;
|
||||
type FullBackend = pezsc_service::TFullBackend<Block>;
|
||||
type FullSelectChain = pezsc_consensus::LongestChain<FullBackend, Block>;
|
||||
|
||||
/// The minimum period of blocks on which justifications will be
|
||||
/// imported and generated.
|
||||
const GRANDPA_JUSTIFICATION_PERIOD: u32 = 512;
|
||||
|
||||
pub type Service = sc_service::PartialComponents<
|
||||
pub type Service = pezsc_service::PartialComponents<
|
||||
FullClient,
|
||||
FullBackend,
|
||||
FullSelectChain,
|
||||
sc_consensus::DefaultImportQueue<Block>,
|
||||
sc_transaction_pool::TransactionPoolHandle<Block, FullClient>,
|
||||
pezsc_consensus::DefaultImportQueue<Block>,
|
||||
pezsc_transaction_pool::TransactionPoolHandle<Block, FullClient>,
|
||||
(
|
||||
sc_consensus_grandpa::GrandpaBlockImport<FullBackend, Block, FullClient, FullSelectChain>,
|
||||
sc_consensus_grandpa::LinkHalf<Block, FullClient, FullSelectChain>,
|
||||
pezsc_consensus_grandpa::GrandpaBlockImport<
|
||||
FullBackend,
|
||||
Block,
|
||||
FullClient,
|
||||
FullSelectChain,
|
||||
>,
|
||||
pezsc_consensus_grandpa::LinkHalf<Block, FullClient, FullSelectChain>,
|
||||
Option<Telemetry>,
|
||||
),
|
||||
>;
|
||||
@@ -41,16 +46,17 @@ pub fn new_partial(config: &Configuration) -> Result<Service, ServiceError> {
|
||||
.telemetry_endpoints
|
||||
.clone()
|
||||
.filter(|x| !x.is_empty())
|
||||
.map(|endpoints| -> Result<_, sc_telemetry::Error> {
|
||||
.map(|endpoints| -> Result<_, pezsc_telemetry::Error> {
|
||||
let worker = TelemetryWorker::new(16)?;
|
||||
let telemetry = worker.handle().new_telemetry(endpoints);
|
||||
Ok((worker, telemetry))
|
||||
})
|
||||
.transpose()?;
|
||||
|
||||
let executor = sc_service::new_wasm_executor::<sp_io::SubstrateHostFunctions>(&config.executor);
|
||||
let executor =
|
||||
pezsc_service::new_wasm_executor::<pezsp_io::BizinikiwiHostFunctions>(&config.executor);
|
||||
let (client, backend, keystore_container, task_manager) =
|
||||
sc_service::new_full_parts::<Block, RuntimeApi, _>(
|
||||
pezsc_service::new_full_parts::<Block, RuntimeApi, _>(
|
||||
config,
|
||||
telemetry.as_ref().map(|(_, telemetry)| telemetry.handle()),
|
||||
executor,
|
||||
@@ -62,10 +68,10 @@ pub fn new_partial(config: &Configuration) -> Result<Service, ServiceError> {
|
||||
telemetry
|
||||
});
|
||||
|
||||
let select_chain = sc_consensus::LongestChain::new(backend.clone());
|
||||
let select_chain = pezsc_consensus::LongestChain::new(backend.clone());
|
||||
|
||||
let transaction_pool = Arc::from(
|
||||
sc_transaction_pool::Builder::new(
|
||||
pezsc_transaction_pool::Builder::new(
|
||||
task_manager.spawn_essential_handle(),
|
||||
client.clone(),
|
||||
config.role.is_authority().into(),
|
||||
@@ -75,7 +81,7 @@ pub fn new_partial(config: &Configuration) -> Result<Service, ServiceError> {
|
||||
.build(),
|
||||
);
|
||||
|
||||
let (grandpa_block_import, grandpa_link) = sc_consensus_grandpa::block_import(
|
||||
let (grandpa_block_import, grandpa_link) = pezsc_consensus_grandpa::block_import(
|
||||
client.clone(),
|
||||
GRANDPA_JUSTIFICATION_PERIOD,
|
||||
&client,
|
||||
@@ -85,21 +91,21 @@ pub fn new_partial(config: &Configuration) -> Result<Service, ServiceError> {
|
||||
|
||||
let cidp_client = client.clone();
|
||||
let import_queue =
|
||||
sc_consensus_aura::import_queue::<AuraPair, _, _, _, _, _>(ImportQueueParams {
|
||||
pezsc_consensus_aura::import_queue::<AuraPair, _, _, _, _, _>(ImportQueueParams {
|
||||
block_import: grandpa_block_import.clone(),
|
||||
justification_import: Some(Box::new(grandpa_block_import.clone())),
|
||||
client: client.clone(),
|
||||
create_inherent_data_providers: move |parent_hash, _| {
|
||||
let cidp_client = cidp_client.clone();
|
||||
async move {
|
||||
let slot_duration = sc_consensus_aura::standalone::slot_duration_at(
|
||||
let slot_duration = pezsc_consensus_aura::standalone::slot_duration_at(
|
||||
&*cidp_client,
|
||||
parent_hash,
|
||||
)?;
|
||||
let timestamp = sp_timestamp::InherentDataProvider::from_system_time();
|
||||
let timestamp = pezsp_timestamp::InherentDataProvider::from_system_time();
|
||||
|
||||
let slot =
|
||||
sp_consensus_aura::inherents::InherentDataProvider::from_timestamp_and_slot_duration(
|
||||
pezsp_consensus_aura::inherents::InherentDataProvider::from_timestamp_and_slot_duration(
|
||||
*timestamp,
|
||||
slot_duration,
|
||||
);
|
||||
@@ -114,7 +120,7 @@ pub fn new_partial(config: &Configuration) -> Result<Service, ServiceError> {
|
||||
compatibility_mode: Default::default(),
|
||||
})?;
|
||||
|
||||
Ok(sc_service::PartialComponents {
|
||||
Ok(pezsc_service::PartialComponents {
|
||||
client,
|
||||
backend,
|
||||
task_manager,
|
||||
@@ -128,11 +134,11 @@ pub fn new_partial(config: &Configuration) -> Result<Service, ServiceError> {
|
||||
|
||||
/// Builds a new service for a full client.
|
||||
pub fn new_full<
|
||||
N: sc_network::NetworkBackend<Block, <Block as sp_runtime::traits::Block>::Hash>,
|
||||
N: pezsc_network::NetworkBackend<Block, <Block as pezsp_runtime::traits::Block>::Hash>,
|
||||
>(
|
||||
config: Configuration,
|
||||
) -> Result<TaskManager, ServiceError> {
|
||||
let sc_service::PartialComponents {
|
||||
let pezsc_service::PartialComponents {
|
||||
client,
|
||||
backend,
|
||||
mut task_manager,
|
||||
@@ -143,34 +149,34 @@ pub fn new_full<
|
||||
other: (block_import, grandpa_link, mut telemetry),
|
||||
} = new_partial(&config)?;
|
||||
|
||||
let mut net_config = sc_network::config::FullNetworkConfiguration::<
|
||||
let mut net_config = pezsc_network::config::FullNetworkConfiguration::<
|
||||
Block,
|
||||
<Block as sp_runtime::traits::Block>::Hash,
|
||||
<Block as pezsp_runtime::traits::Block>::Hash,
|
||||
N,
|
||||
>::new(&config.network, config.prometheus_registry().cloned());
|
||||
let metrics = N::register_notification_metrics(config.prometheus_registry());
|
||||
|
||||
let peer_store_handle = net_config.peer_store_handle();
|
||||
let grandpa_protocol_name = sc_consensus_grandpa::protocol_standard_name(
|
||||
let grandpa_protocol_name = pezsc_consensus_grandpa::protocol_standard_name(
|
||||
&client.block_hash(0).ok().flatten().expect("Genesis block exists; qed"),
|
||||
&config.chain_spec,
|
||||
);
|
||||
let (grandpa_protocol_config, grandpa_notification_service) =
|
||||
sc_consensus_grandpa::grandpa_peers_set_config::<_, N>(
|
||||
pezsc_consensus_grandpa::grandpa_peers_set_config::<_, N>(
|
||||
grandpa_protocol_name.clone(),
|
||||
metrics.clone(),
|
||||
peer_store_handle,
|
||||
);
|
||||
net_config.add_notification_protocol(grandpa_protocol_config);
|
||||
|
||||
let warp_sync = Arc::new(sc_consensus_grandpa::warp_proof::NetworkProvider::new(
|
||||
let warp_sync = Arc::new(pezsc_consensus_grandpa::warp_proof::NetworkProvider::new(
|
||||
backend.clone(),
|
||||
grandpa_link.shared_authority_set().clone(),
|
||||
Vec::default(),
|
||||
));
|
||||
|
||||
let (network, system_rpc_tx, tx_handler_controller, sync_service) =
|
||||
sc_service::build_network(sc_service::BuildNetworkParams {
|
||||
pezsc_service::build_network(pezsc_service::BuildNetworkParams {
|
||||
config: &config,
|
||||
net_config,
|
||||
client: client.clone(),
|
||||
@@ -185,7 +191,7 @@ pub fn new_full<
|
||||
|
||||
if config.offchain_worker.enabled {
|
||||
let offchain_workers =
|
||||
sc_offchain::OffchainWorkers::new(sc_offchain::OffchainWorkerOptions {
|
||||
pezsc_offchain::OffchainWorkers::new(pezsc_offchain::OffchainWorkerOptions {
|
||||
runtime_api_provider: client.clone(),
|
||||
is_validator: config.role.is_authority(),
|
||||
keystore: Some(keystore_container.keystore()),
|
||||
@@ -221,7 +227,7 @@ pub fn new_full<
|
||||
})
|
||||
};
|
||||
|
||||
let _rpc_handlers = sc_service::spawn_tasks(sc_service::SpawnTasksParams {
|
||||
let _rpc_handlers = pezsc_service::spawn_tasks(pezsc_service::SpawnTasksParams {
|
||||
network: Arc::new(network.clone()),
|
||||
client: client.clone(),
|
||||
keystore: keystore_container.keystore(),
|
||||
@@ -234,10 +240,11 @@ pub fn new_full<
|
||||
sync_service: sync_service.clone(),
|
||||
config,
|
||||
telemetry: telemetry.as_mut(),
|
||||
tracing_execute_block: None,
|
||||
})?;
|
||||
|
||||
if role.is_authority() {
|
||||
let proposer_factory = sc_basic_authorship::ProposerFactory::new(
|
||||
let proposer_factory = pezsc_basic_authorship::ProposerFactory::new(
|
||||
task_manager.spawn_handle(),
|
||||
client.clone(),
|
||||
transaction_pool.clone(),
|
||||
@@ -245,9 +252,9 @@ pub fn new_full<
|
||||
telemetry.as_ref().map(|x| x.handle()),
|
||||
);
|
||||
|
||||
let slot_duration = sc_consensus_aura::slot_duration(&*client)?;
|
||||
let slot_duration = pezsc_consensus_aura::slot_duration(&*client)?;
|
||||
|
||||
let aura = sc_consensus_aura::start_aura::<AuraPair, _, _, _, _, _, _, _, _, _, _>(
|
||||
let aura = pezsc_consensus_aura::start_aura::<AuraPair, _, _, _, _, _, _, _, _, _, _>(
|
||||
StartAuraParams {
|
||||
slot_duration,
|
||||
client,
|
||||
@@ -255,10 +262,10 @@ pub fn new_full<
|
||||
block_import,
|
||||
proposer_factory,
|
||||
create_inherent_data_providers: move |_, ()| async move {
|
||||
let timestamp = sp_timestamp::InherentDataProvider::from_system_time();
|
||||
let timestamp = pezsp_timestamp::InherentDataProvider::from_system_time();
|
||||
|
||||
let slot =
|
||||
sp_consensus_aura::inherents::InherentDataProvider::from_timestamp_and_slot_duration(
|
||||
pezsp_consensus_aura::inherents::InherentDataProvider::from_timestamp_and_slot_duration(
|
||||
*timestamp,
|
||||
slot_duration,
|
||||
);
|
||||
@@ -289,7 +296,7 @@ pub fn new_full<
|
||||
// need a keystore, regardless of which protocol we use below.
|
||||
let keystore = if role.is_authority() { Some(keystore_container.keystore()) } else { None };
|
||||
|
||||
let grandpa_config = sc_consensus_grandpa::Config {
|
||||
let grandpa_config = pezsc_consensus_grandpa::Config {
|
||||
// FIXME #1578 make this available through chainspec
|
||||
gossip_duration: Duration::from_millis(333),
|
||||
justification_generation_period: GRANDPA_JUSTIFICATION_PERIOD,
|
||||
@@ -307,13 +314,13 @@ pub fn new_full<
|
||||
// and vote data availability than the observer. The observer has not
|
||||
// been tested extensively yet and having most nodes in a network run it
|
||||
// could lead to finality stalls.
|
||||
let grandpa_config = sc_consensus_grandpa::GrandpaParams {
|
||||
let grandpa_config = pezsc_consensus_grandpa::GrandpaParams {
|
||||
config: grandpa_config,
|
||||
link: grandpa_link,
|
||||
network,
|
||||
sync: Arc::new(sync_service),
|
||||
notification_service: grandpa_notification_service,
|
||||
voting_rule: sc_consensus_grandpa::VotingRulesBuilder::default().build(),
|
||||
voting_rule: pezsc_consensus_grandpa::VotingRulesBuilder::default().build(),
|
||||
prometheus_registry,
|
||||
shared_voter_state: SharedVoterState::empty(),
|
||||
telemetry: telemetry.as_ref().map(|x| x.handle()),
|
||||
@@ -325,7 +332,7 @@ pub fn new_full<
|
||||
task_manager.spawn_essential_handle().spawn_blocking(
|
||||
"grandpa-voter",
|
||||
None,
|
||||
sc_consensus_grandpa::run_grandpa_voter(grandpa_config)?,
|
||||
pezsc_consensus_grandpa::run_grandpa_voter(grandpa_config)?,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user