feat: Rebrand Polkadot/Substrate references to PezkuwiChain
This commit systematically rebrands various references from Parity Technologies' Polkadot/Substrate ecosystem to PezkuwiChain within the kurdistan-sdk. Key changes include: - Updated external repository URLs (zombienet-sdk, parity-db, parity-scale-codec, wasm-instrument) to point to pezkuwichain forks. - Modified internal documentation and code comments to reflect PezkuwiChain naming and structure. - Replaced direct references to with or specific paths within the for XCM, Pezkuwi, and other modules. - Cleaned up deprecated issue and PR references in various and files, particularly in and modules. - Adjusted image and logo URLs in documentation to point to PezkuwiChain assets. - Removed or rephrased comments related to external Polkadot/Substrate PRs and issues. This is a significant step towards fully customizing the SDK for the PezkuwiChain ecosystem.
This commit is contained in:
@@ -0,0 +1,70 @@
|
||||
// Copyright (C) Parity Technologies (UK) Ltd.
|
||||
// This file is part of Pezcumulus.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
//! Aura-related primitives for pezcumulus teyrchain collators.
|
||||
|
||||
use codec::Codec;
|
||||
use cumulus_primitives_aura::AuraUnincludedSegmentApi;
|
||||
use pezsp_consensus_aura::AuraApi;
|
||||
use pezsp_runtime::{
|
||||
app_crypto::{AppCrypto, AppPair, AppSignature, Pair},
|
||||
traits::Block as BlockT,
|
||||
};
|
||||
|
||||
/// Convenience trait for defining the basic bounds of an `AuraId`.
|
||||
pub trait AuraIdT: AppCrypto<Pair = Self::BoundedPair> + Codec + Send {
|
||||
/// Extra bounds for the `Pair`.
|
||||
type BoundedPair: AppPair + AppCrypto<Signature = Self::BoundedSignature>;
|
||||
|
||||
/// Extra bounds for the `Signature`.
|
||||
type BoundedSignature: AppSignature
|
||||
+ TryFrom<Vec<u8>>
|
||||
+ std::hash::Hash
|
||||
+ pezsp_runtime::traits::Member
|
||||
+ Codec;
|
||||
}
|
||||
|
||||
impl<T> AuraIdT for T
|
||||
where
|
||||
T: AppCrypto + Codec + Send + Sync,
|
||||
<<T as AppCrypto>::Pair as AppCrypto>::Signature:
|
||||
TryFrom<Vec<u8>> + std::hash::Hash + pezsp_runtime::traits::Member + Codec,
|
||||
{
|
||||
type BoundedPair = <T as AppCrypto>::Pair;
|
||||
type BoundedSignature = <<T as AppCrypto>::Pair as AppCrypto>::Signature;
|
||||
}
|
||||
|
||||
/// Convenience trait for defining the basic bounds of a teyrchain runtime that supports
|
||||
/// the Aura consensus.
|
||||
pub trait AuraRuntimeApi<Block: BlockT, AuraId: AuraIdT>:
|
||||
pezsp_api::ApiExt<Block>
|
||||
+ AuraApi<Block, <AuraId::BoundedPair as Pair>::Public>
|
||||
+ AuraUnincludedSegmentApi<Block>
|
||||
+ Sized
|
||||
{
|
||||
/// Check if the runtime has the Aura API.
|
||||
fn has_aura_api(&self, at: Block::Hash) -> bool {
|
||||
self.has_api::<dyn AuraApi<Block, <AuraId::BoundedPair as Pair>::Public>>(at)
|
||||
.unwrap_or(false)
|
||||
}
|
||||
}
|
||||
|
||||
impl<T, Block: BlockT, AuraId: AuraIdT> AuraRuntimeApi<Block, AuraId> for T where
|
||||
T: pezsp_api::ApiExt<Block>
|
||||
+ AuraApi<Block, <AuraId::BoundedPair as Pair>::Public>
|
||||
+ AuraUnincludedSegmentApi<Block>
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
// Copyright (C) Parity Technologies (UK) Ltd.
|
||||
// This file is part of Pezcumulus.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
//! Chain spec primitives.
|
||||
|
||||
pub use pezsc_chain_spec::ChainSpec;
|
||||
use pezsc_chain_spec::ChainSpecExtension;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::fmt::Debug;
|
||||
|
||||
/// Helper trait used for loading/building a chain spec starting from the chain ID.
|
||||
pub trait LoadSpec {
|
||||
/// Load/Build a chain spec starting from the chain ID.
|
||||
fn load_spec(&self, id: &str) -> Result<Box<dyn ChainSpec>, String>;
|
||||
}
|
||||
|
||||
/// Default implementation for `LoadSpec` that just reads a chain spec from the disk.
|
||||
pub struct DiskChainSpecLoader;
|
||||
|
||||
impl LoadSpec for DiskChainSpecLoader {
|
||||
fn load_spec(&self, path: &str) -> Result<Box<dyn ChainSpec>, String> {
|
||||
Ok(Box::new(GenericChainSpec::from_json_file(path.into())?))
|
||||
}
|
||||
}
|
||||
|
||||
/// Generic extensions for Teyrchain ChainSpecs used for extracting the extensions from chain specs.
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, ChainSpecExtension)]
|
||||
pub struct Extensions {
|
||||
/// The relay chain of the Teyrchain. It is kept here only for compatibility reasons until
|
||||
/// people migrate to using the new `Extensions` struct and associated logic in the node
|
||||
/// corresponding to pulling the teyrchain id from the runtime.
|
||||
#[serde(alias = "relayChain", alias = "RelayChain")]
|
||||
relay_chain: String,
|
||||
/// The id of the Teyrchain.
|
||||
#[serde(alias = "paraId", alias = "ParaId")]
|
||||
para_id: Option<u32>,
|
||||
}
|
||||
|
||||
impl Extensions {
|
||||
/// Try to get the extension from the given `ChainSpec`.
|
||||
pub fn try_get(chain_spec: &dyn pezsc_service::ChainSpec) -> Option<&Self> {
|
||||
pezsc_chain_spec::get_extension(chain_spec.extensions())
|
||||
}
|
||||
|
||||
/// Create the extensions only with the relay_chain.
|
||||
pub fn new_with_relay_chain(relay_chain: String) -> Self {
|
||||
Extensions { relay_chain, para_id: None }
|
||||
}
|
||||
|
||||
/// Initialize extensions based on given parameters.
|
||||
pub fn new(relay_chain: String, para_id: u32) -> Self {
|
||||
Extensions { relay_chain, para_id: Some(para_id) }
|
||||
}
|
||||
|
||||
/// Para id field getter
|
||||
pub fn para_id(&self) -> Option<u32> {
|
||||
self.para_id
|
||||
}
|
||||
|
||||
/// Relay chain field getter
|
||||
pub fn relay_chain(&self) -> String {
|
||||
self.relay_chain.clone()
|
||||
}
|
||||
}
|
||||
|
||||
/// Generic chain spec for all pezkuwi-teyrchain runtimes
|
||||
pub type GenericChainSpec = pezsc_service::GenericChainSpec<Extensions>;
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn can_decode_extension_camel_and_snake_case() {
|
||||
let camel_case = r#"{"relayChain":"relay","paraId":1}"#;
|
||||
let snake_case = r#"{"relay_chain":"relay","para_id":1}"#;
|
||||
let pascal_case = r#"{"RelayChain":"relay","ParaId":1}"#;
|
||||
let para_id_missing = r#"{"RelayChain":"zagros"}"#;
|
||||
|
||||
let camel_case_extension: Extensions = serde_json::from_str(camel_case).unwrap();
|
||||
let snake_case_extension: Extensions = serde_json::from_str(snake_case).unwrap();
|
||||
let pascal_case_extension: Extensions = serde_json::from_str(pascal_case).unwrap();
|
||||
let missing_paraid_extension: Extensions = serde_json::from_str(para_id_missing).unwrap();
|
||||
assert_eq!(camel_case_extension, snake_case_extension);
|
||||
assert_eq!(snake_case_extension, pascal_case_extension);
|
||||
assert_eq!(missing_paraid_extension.relay_chain, "zagros".to_string());
|
||||
assert!(missing_paraid_extension.para_id.is_none());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,162 @@
|
||||
// Copyright (C) Parity Technologies (UK) Ltd.
|
||||
// This file is part of Pezcumulus.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
use crate::common::spec::BaseNodeSpec;
|
||||
use cumulus_client_cli::ExportGenesisHeadCommand;
|
||||
use pezframe_benchmarking_cli::BlockCmd;
|
||||
#[cfg(any(feature = "runtime-benchmarks"))]
|
||||
use pezframe_benchmarking_cli::StorageCmd;
|
||||
use pezsc_cli::{CheckBlockCmd, ExportBlocksCmd, ExportStateCmd, ImportBlocksCmd, RevertCmd};
|
||||
use pezsc_service::{Configuration, TaskManager};
|
||||
use std::{future::Future, pin::Pin};
|
||||
|
||||
type SyncCmdResult = pezsc_cli::Result<()>;
|
||||
|
||||
type AsyncCmdResult<'a> =
|
||||
pezsc_cli::Result<(Pin<Box<dyn Future<Output = SyncCmdResult> + 'a>>, TaskManager)>;
|
||||
|
||||
pub trait NodeCommandRunner {
|
||||
fn prepare_check_block_cmd(
|
||||
self: Box<Self>,
|
||||
config: Configuration,
|
||||
cmd: &CheckBlockCmd,
|
||||
) -> AsyncCmdResult<'_>;
|
||||
|
||||
fn prepare_export_blocks_cmd(
|
||||
self: Box<Self>,
|
||||
config: Configuration,
|
||||
cmd: &ExportBlocksCmd,
|
||||
) -> AsyncCmdResult<'_>;
|
||||
|
||||
fn prepare_export_state_cmd(
|
||||
self: Box<Self>,
|
||||
config: Configuration,
|
||||
cmd: &ExportStateCmd,
|
||||
) -> AsyncCmdResult<'_>;
|
||||
|
||||
fn prepare_import_blocks_cmd(
|
||||
self: Box<Self>,
|
||||
config: Configuration,
|
||||
cmd: &ImportBlocksCmd,
|
||||
) -> AsyncCmdResult<'_>;
|
||||
|
||||
fn prepare_revert_cmd(
|
||||
self: Box<Self>,
|
||||
config: Configuration,
|
||||
cmd: &RevertCmd,
|
||||
) -> AsyncCmdResult<'_>;
|
||||
|
||||
fn run_export_genesis_head_cmd(
|
||||
self: Box<Self>,
|
||||
config: Configuration,
|
||||
cmd: &ExportGenesisHeadCommand,
|
||||
) -> SyncCmdResult;
|
||||
|
||||
fn run_benchmark_block_cmd(
|
||||
self: Box<Self>,
|
||||
config: Configuration,
|
||||
cmd: &BlockCmd,
|
||||
) -> SyncCmdResult;
|
||||
|
||||
#[cfg(any(feature = "runtime-benchmarks"))]
|
||||
fn run_benchmark_storage_cmd(
|
||||
self: Box<Self>,
|
||||
config: Configuration,
|
||||
cmd: &StorageCmd,
|
||||
) -> SyncCmdResult;
|
||||
}
|
||||
|
||||
impl<T> NodeCommandRunner for T
|
||||
where
|
||||
T: BaseNodeSpec,
|
||||
{
|
||||
fn prepare_check_block_cmd(
|
||||
self: Box<Self>,
|
||||
config: Configuration,
|
||||
cmd: &CheckBlockCmd,
|
||||
) -> AsyncCmdResult<'_> {
|
||||
let partial = T::new_partial(&config).map_err(pezsc_cli::Error::Service)?;
|
||||
Ok((Box::pin(cmd.run(partial.client, partial.import_queue)), partial.task_manager))
|
||||
}
|
||||
|
||||
fn prepare_export_blocks_cmd(
|
||||
self: Box<Self>,
|
||||
config: Configuration,
|
||||
cmd: &ExportBlocksCmd,
|
||||
) -> AsyncCmdResult<'_> {
|
||||
let partial = T::new_partial(&config).map_err(pezsc_cli::Error::Service)?;
|
||||
Ok((Box::pin(cmd.run(partial.client, config.database)), partial.task_manager))
|
||||
}
|
||||
|
||||
fn prepare_export_state_cmd(
|
||||
self: Box<Self>,
|
||||
config: Configuration,
|
||||
cmd: &ExportStateCmd,
|
||||
) -> AsyncCmdResult<'_> {
|
||||
let partial = T::new_partial(&config).map_err(pezsc_cli::Error::Service)?;
|
||||
Ok((Box::pin(cmd.run(partial.client, config.chain_spec)), partial.task_manager))
|
||||
}
|
||||
|
||||
fn prepare_import_blocks_cmd(
|
||||
self: Box<Self>,
|
||||
config: Configuration,
|
||||
cmd: &ImportBlocksCmd,
|
||||
) -> AsyncCmdResult<'_> {
|
||||
let partial = T::new_partial(&config).map_err(pezsc_cli::Error::Service)?;
|
||||
Ok((Box::pin(cmd.run(partial.client, partial.import_queue)), partial.task_manager))
|
||||
}
|
||||
|
||||
fn prepare_revert_cmd(
|
||||
self: Box<Self>,
|
||||
config: Configuration,
|
||||
cmd: &RevertCmd,
|
||||
) -> AsyncCmdResult<'_> {
|
||||
let partial = T::new_partial(&config).map_err(pezsc_cli::Error::Service)?;
|
||||
Ok((Box::pin(cmd.run(partial.client, partial.backend, None)), partial.task_manager))
|
||||
}
|
||||
|
||||
fn run_export_genesis_head_cmd(
|
||||
self: Box<Self>,
|
||||
config: Configuration,
|
||||
cmd: &ExportGenesisHeadCommand,
|
||||
) -> SyncCmdResult {
|
||||
let partial = T::new_partial(&config).map_err(pezsc_cli::Error::Service)?;
|
||||
cmd.run(partial.client)
|
||||
}
|
||||
|
||||
fn run_benchmark_block_cmd(
|
||||
self: Box<Self>,
|
||||
config: Configuration,
|
||||
cmd: &BlockCmd,
|
||||
) -> SyncCmdResult {
|
||||
let partial = T::new_partial(&config).map_err(pezsc_cli::Error::Service)?;
|
||||
cmd.run(partial.client)
|
||||
}
|
||||
|
||||
#[cfg(any(feature = "runtime-benchmarks"))]
|
||||
fn run_benchmark_storage_cmd(
|
||||
self: Box<Self>,
|
||||
config: Configuration,
|
||||
cmd: &StorageCmd,
|
||||
) -> SyncCmdResult {
|
||||
let partial = T::new_partial(&config).map_err(pezsc_cli::Error::Service)?;
|
||||
let db = partial.backend.expose_db();
|
||||
let storage = partial.backend.expose_storage();
|
||||
let shared_trie_cache = partial.backend.expose_shared_trie_cache();
|
||||
|
||||
cmd.run(config, partial.client, db, storage, shared_trie_cache)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,132 @@
|
||||
// Copyright (C) Parity Technologies (UK) Ltd.
|
||||
// This file is part of Pezcumulus.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
//! Pezcumulus teyrchain collator primitives.
|
||||
|
||||
#![warn(missing_docs)]
|
||||
|
||||
pub(crate) mod aura;
|
||||
pub mod chain_spec;
|
||||
pub mod command;
|
||||
pub mod rpc;
|
||||
pub mod runtime;
|
||||
pub mod spec;
|
||||
pub(crate) mod statement_store;
|
||||
pub mod types;
|
||||
|
||||
use crate::cli::AuthoringPolicy;
|
||||
|
||||
use cumulus_primitives_core::{CollectCollationInfo, GetTeyrchainInfo, RelayParentOffsetApi};
|
||||
use pezsc_client_db::DbHash;
|
||||
use pezsc_offchain::OffchainWorkerApi;
|
||||
use serde::de::DeserializeOwned;
|
||||
use pezsp_api::{ApiExt, CallApiAt, ConstructRuntimeApi, Metadata};
|
||||
use pezsp_block_builder::BlockBuilder;
|
||||
use pezsp_runtime::{
|
||||
traits::{Block as BlockT, BlockNumber, Header as HeaderT, NumberFor},
|
||||
OpaqueExtrinsic,
|
||||
};
|
||||
use pezsp_session::SessionKeys;
|
||||
use pezsp_statement_store::runtime_api::ValidateStatement;
|
||||
use pezsp_transaction_pool::runtime_api::TaggedTransactionQueue;
|
||||
use std::{fmt::Debug, path::PathBuf, str::FromStr};
|
||||
|
||||
pub trait NodeBlock:
|
||||
BlockT<Extrinsic = OpaqueExtrinsic, Header = Self::BoundedHeader, Hash = DbHash> + DeserializeOwned
|
||||
{
|
||||
type BoundedFromStrErr: Debug;
|
||||
type BoundedNumber: FromStr<Err = Self::BoundedFromStrErr> + BlockNumber;
|
||||
type BoundedHeader: HeaderT<Number = Self::BoundedNumber, Hash = DbHash> + Unpin;
|
||||
}
|
||||
|
||||
impl<T> NodeBlock for T
|
||||
where
|
||||
T: BlockT<Extrinsic = OpaqueExtrinsic, Hash = DbHash> + DeserializeOwned,
|
||||
<T as BlockT>::Header: Unpin,
|
||||
<NumberFor<T> as FromStr>::Err: Debug,
|
||||
{
|
||||
type BoundedFromStrErr = <NumberFor<T> as FromStr>::Err;
|
||||
type BoundedNumber = NumberFor<T>;
|
||||
type BoundedHeader = <T as BlockT>::Header;
|
||||
}
|
||||
|
||||
/// Convenience trait that defines the basic bounds for the `RuntimeApi` of a teyrchain node.
|
||||
pub trait NodeRuntimeApi<Block: BlockT>:
|
||||
ApiExt<Block>
|
||||
+ Metadata<Block>
|
||||
+ SessionKeys<Block>
|
||||
+ BlockBuilder<Block>
|
||||
+ TaggedTransactionQueue<Block>
|
||||
+ OffchainWorkerApi<Block>
|
||||
+ CollectCollationInfo<Block>
|
||||
+ ValidateStatement<Block>
|
||||
+ GetTeyrchainInfo<Block>
|
||||
+ RelayParentOffsetApi<Block>
|
||||
+ Sized
|
||||
{
|
||||
}
|
||||
|
||||
impl<T, Block: BlockT> NodeRuntimeApi<Block> for T where
|
||||
T: ApiExt<Block>
|
||||
+ Metadata<Block>
|
||||
+ SessionKeys<Block>
|
||||
+ BlockBuilder<Block>
|
||||
+ TaggedTransactionQueue<Block>
|
||||
+ OffchainWorkerApi<Block>
|
||||
+ RelayParentOffsetApi<Block>
|
||||
+ CollectCollationInfo<Block>
|
||||
+ ValidateStatement<Block>
|
||||
+ GetTeyrchainInfo<Block>
|
||||
{
|
||||
}
|
||||
|
||||
/// Convenience trait that defines the basic bounds for the `ConstructRuntimeApi` of a teyrchain
|
||||
/// node.
|
||||
pub trait ConstructNodeRuntimeApi<Block: BlockT, C: CallApiAt<Block>>:
|
||||
ConstructRuntimeApi<Block, C, RuntimeApi = Self::BoundedRuntimeApi> + Send + Sync + 'static
|
||||
{
|
||||
/// Basic bounds for the `RuntimeApi` of a teyrchain node.
|
||||
type BoundedRuntimeApi: NodeRuntimeApi<Block>;
|
||||
}
|
||||
|
||||
impl<T, Block: BlockT, C: CallApiAt<Block>> ConstructNodeRuntimeApi<Block, C> for T
|
||||
where
|
||||
T: ConstructRuntimeApi<Block, C> + Send + Sync + 'static,
|
||||
T::RuntimeApi: NodeRuntimeApi<Block>,
|
||||
{
|
||||
type BoundedRuntimeApi = T::RuntimeApi;
|
||||
}
|
||||
|
||||
/// Extra args that are passed when creating a new node spec.
|
||||
pub struct NodeExtraArgs {
|
||||
/// The authoring policy to use.
|
||||
///
|
||||
/// Can be used to influence details of block production.
|
||||
pub authoring_policy: AuthoringPolicy,
|
||||
|
||||
/// If set, each `PoV` build by the node will be exported to this folder.
|
||||
pub export_pov: Option<PathBuf>,
|
||||
|
||||
/// The maximum percentage of the maximum PoV size that the collator can use.
|
||||
/// It will be removed once <https://github.com/pezkuwichain/pezkuwi-sdk/issues/23> is fixed.
|
||||
pub max_pov_percentage: Option<u32>,
|
||||
|
||||
/// If true then the statement store will be enabled.
|
||||
pub enable_statement_store: bool,
|
||||
|
||||
/// Parameters for storage monitoring.
|
||||
pub storage_monitor: pezsc_storage_monitor::StorageMonitorParams,
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
// Copyright (C) Parity Technologies (UK) Ltd.
|
||||
// This file is part of Pezcumulus.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
//! Teyrchain-specific RPCs implementation.
|
||||
|
||||
#![warn(missing_docs)]
|
||||
|
||||
use crate::common::{
|
||||
types::{AccountId, Balance, Nonce, TeyrchainBackend, TeyrchainClient},
|
||||
ConstructNodeRuntimeApi,
|
||||
};
|
||||
use pezpallet_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApiServer};
|
||||
use pezsc_rpc::{
|
||||
dev::{Dev, DevApiServer},
|
||||
statement::{StatementApiServer, StatementStore},
|
||||
};
|
||||
use pezsp_runtime::traits::Block as BlockT;
|
||||
use std::{marker::PhantomData, sync::Arc};
|
||||
use bizinikiwi_frame_rpc_system::{System, SystemApiServer};
|
||||
use bizinikiwi_state_trie_migration_rpc::{StateMigration, StateMigrationApiServer};
|
||||
|
||||
/// A type representing all RPC extensions.
|
||||
pub type RpcExtension = jsonrpsee::RpcModule<()>;
|
||||
|
||||
pub(crate) trait BuildRpcExtensions<Client, Backend, Pool, StatementStore> {
|
||||
fn build_rpc_extensions(
|
||||
client: Arc<Client>,
|
||||
backend: Arc<Backend>,
|
||||
pool: Arc<Pool>,
|
||||
statement_store: Option<Arc<StatementStore>>,
|
||||
) -> pezsc_service::error::Result<RpcExtension>;
|
||||
}
|
||||
|
||||
pub(crate) struct BuildTeyrchainRpcExtensions<Block, RuntimeApi>(PhantomData<(Block, RuntimeApi)>);
|
||||
|
||||
impl<Block: BlockT, RuntimeApi>
|
||||
BuildRpcExtensions<
|
||||
TeyrchainClient<Block, RuntimeApi>,
|
||||
TeyrchainBackend<Block>,
|
||||
pezsc_transaction_pool::TransactionPoolHandle<Block, TeyrchainClient<Block, RuntimeApi>>,
|
||||
pezsc_statement_store::Store,
|
||||
> for BuildTeyrchainRpcExtensions<Block, RuntimeApi>
|
||||
where
|
||||
RuntimeApi:
|
||||
ConstructNodeRuntimeApi<Block, TeyrchainClient<Block, RuntimeApi>> + Send + Sync + 'static,
|
||||
RuntimeApi::RuntimeApi: pezpallet_transaction_payment_rpc::TransactionPaymentRuntimeApi<Block, Balance>
|
||||
+ bizinikiwi_frame_rpc_system::AccountNonceApi<Block, AccountId, Nonce>,
|
||||
{
|
||||
fn build_rpc_extensions(
|
||||
client: Arc<TeyrchainClient<Block, RuntimeApi>>,
|
||||
backend: Arc<TeyrchainBackend<Block>>,
|
||||
pool: Arc<
|
||||
pezsc_transaction_pool::TransactionPoolHandle<Block, TeyrchainClient<Block, RuntimeApi>>,
|
||||
>,
|
||||
statement_store: Option<Arc<pezsc_statement_store::Store>>,
|
||||
) -> pezsc_service::error::Result<RpcExtension> {
|
||||
let build = || -> Result<RpcExtension, Box<dyn std::error::Error + Send + Sync>> {
|
||||
let mut module = RpcExtension::new(());
|
||||
|
||||
module.merge(System::new(client.clone(), pool).into_rpc())?;
|
||||
module.merge(TransactionPayment::new(client.clone()).into_rpc())?;
|
||||
module.merge(StateMigration::new(client.clone(), backend).into_rpc())?;
|
||||
if let Some(statement_store) = statement_store {
|
||||
module.merge(StatementStore::new(statement_store).into_rpc())?;
|
||||
}
|
||||
module.merge(Dev::new(client).into_rpc())?;
|
||||
|
||||
Ok(module)
|
||||
};
|
||||
build().map_err(Into::into)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,213 @@
|
||||
// Copyright (C) Parity Technologies (UK) Ltd.
|
||||
// This file is part of Pezcumulus.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
//! Runtime parameters.
|
||||
|
||||
use codec::Decode;
|
||||
use cumulus_client_service::TeyrchainHostFunctions;
|
||||
use pezsc_chain_spec::ChainSpec;
|
||||
use pezsc_executor::WasmExecutor;
|
||||
use pezsc_runtime_utilities::fetch_latest_metadata_from_code_blob;
|
||||
use scale_info::{form::PortableForm, TypeDef, TypeDefPrimitive};
|
||||
use std::fmt::Display;
|
||||
use subxt_metadata::{Metadata, StorageEntryType};
|
||||
|
||||
/// Expected teyrchain system pallet runtime type name.
|
||||
pub const DEFAULT_TEYRCHAIN_SYSTEM_PALLET_NAME: &str = "TeyrchainSystem";
|
||||
/// Expected frame system pallet runtime type name.
|
||||
pub const DEFAULT_FRAME_SYSTEM_PALLET_NAME: &str = "System";
|
||||
|
||||
/// The Aura ID used by the Aura consensus
|
||||
#[derive(PartialEq)]
|
||||
pub enum AuraConsensusId {
|
||||
/// Ed25519
|
||||
Ed25519,
|
||||
/// Sr25519
|
||||
Sr25519,
|
||||
}
|
||||
|
||||
/// The choice of consensus for the teyrchain omni-node.
|
||||
#[derive(PartialEq)]
|
||||
pub enum Consensus {
|
||||
/// Aura consensus.
|
||||
Aura(AuraConsensusId),
|
||||
}
|
||||
|
||||
/// The choice of block number for the teyrchain omni-node.
|
||||
#[derive(PartialEq, Debug)]
|
||||
pub enum BlockNumber {
|
||||
/// u32
|
||||
U32,
|
||||
/// u64
|
||||
U64,
|
||||
}
|
||||
|
||||
impl Display for BlockNumber {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
match self {
|
||||
BlockNumber::U32 => write!(f, "u32"),
|
||||
BlockNumber::U64 => write!(f, "u64"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Into<TypeDefPrimitive> for BlockNumber {
|
||||
fn into(self) -> TypeDefPrimitive {
|
||||
match self {
|
||||
BlockNumber::U32 => TypeDefPrimitive::U32,
|
||||
BlockNumber::U64 => TypeDefPrimitive::U64,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl BlockNumber {
|
||||
fn from_type_def(type_def: &TypeDef<PortableForm>) -> Option<BlockNumber> {
|
||||
match type_def {
|
||||
TypeDef::Primitive(TypeDefPrimitive::U32) => Some(BlockNumber::U32),
|
||||
TypeDef::Primitive(TypeDefPrimitive::U64) => Some(BlockNumber::U64),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Helper enum listing the supported Runtime types
|
||||
#[derive(PartialEq)]
|
||||
pub enum Runtime {
|
||||
/// None of the system-chain runtimes, rather the node will act agnostic to the runtime ie. be
|
||||
/// an omni-node, and simply run a node with the given consensus algorithm.
|
||||
Omni(BlockNumber, Consensus),
|
||||
}
|
||||
|
||||
/// Helper trait used for extracting the Runtime variant from the chain spec ID.
|
||||
pub trait RuntimeResolver {
|
||||
/// Extract the Runtime variant from the chain spec ID.
|
||||
fn runtime(&self, chain_spec: &dyn ChainSpec) -> pezsc_cli::Result<Runtime>;
|
||||
}
|
||||
|
||||
/// Default implementation for `RuntimeResolver` that just returns
|
||||
/// `Runtime::Omni(BlockNumber::U32, Consensus::Aura(AuraConsensusId::Sr25519))`.
|
||||
pub struct DefaultRuntimeResolver;
|
||||
|
||||
impl RuntimeResolver for DefaultRuntimeResolver {
|
||||
fn runtime(&self, chain_spec: &dyn ChainSpec) -> pezsc_cli::Result<Runtime> {
|
||||
let Ok(metadata_inspector) = MetadataInspector::new(chain_spec) else {
|
||||
log::info!("Unable to check metadata. Skipping metadata checks. Metadata checks are supported for metadata versions v14 and higher.");
|
||||
return Ok(Runtime::Omni(BlockNumber::U32, Consensus::Aura(AuraConsensusId::Sr25519)));
|
||||
};
|
||||
|
||||
let block_number = match metadata_inspector.block_number() {
|
||||
Some(inner) => inner,
|
||||
None => {
|
||||
log::warn!(
|
||||
r#"⚠️ There isn't a runtime type named `System`, corresponding to the `pezframe-system`
|
||||
pallet (https://docs.rs/pezframe-system/latest/pezframe_system/). Please check Omni Node docs for runtime conventions:
|
||||
https://docs.pezkuwichain.io/sdk/master/polkadot_sdk_docs/reference_docs/omni_node/index.html#runtime-conventions.
|
||||
Note: We'll assume a block number size of `u32`."#
|
||||
);
|
||||
BlockNumber::U32
|
||||
},
|
||||
};
|
||||
|
||||
if !metadata_inspector.pezpallet_exists(DEFAULT_TEYRCHAIN_SYSTEM_PALLET_NAME) {
|
||||
log::warn!(
|
||||
r#"⚠️ The teyrchain system pallet (https://docs.rs/crate/pezcumulus-pezpallet-parachain-system/latest) is
|
||||
missing from the runtime’s metadata. Please check Omni Node docs for runtime conventions:
|
||||
https://docs.pezkuwichain.io/sdk/master/polkadot_sdk_docs/reference_docs/omni_node/index.html#runtime-conventions."#
|
||||
);
|
||||
}
|
||||
|
||||
Ok(Runtime::Omni(block_number, Consensus::Aura(AuraConsensusId::Sr25519)))
|
||||
}
|
||||
}
|
||||
|
||||
struct MetadataInspector(Metadata);
|
||||
|
||||
impl MetadataInspector {
|
||||
fn new(chain_spec: &dyn ChainSpec) -> Result<MetadataInspector, pezsc_cli::Error> {
|
||||
MetadataInspector::fetch_metadata(chain_spec).map(MetadataInspector)
|
||||
}
|
||||
|
||||
fn pezpallet_exists(&self, name: &str) -> bool {
|
||||
self.0.pezpallet_by_name(name).is_some()
|
||||
}
|
||||
|
||||
fn block_number(&self) -> Option<BlockNumber> {
|
||||
let pezpallet_metadata = self.0.pezpallet_by_name(DEFAULT_FRAME_SYSTEM_PALLET_NAME);
|
||||
pezpallet_metadata
|
||||
.and_then(|inner| inner.storage())
|
||||
.and_then(|inner| inner.entry_by_name("Number"))
|
||||
.and_then(|number_ty| match number_ty.entry_type() {
|
||||
StorageEntryType::Plain(ty_id) => Some(ty_id),
|
||||
_ => None,
|
||||
})
|
||||
.and_then(|ty_id| self.0.types().resolve(*ty_id))
|
||||
.and_then(|portable_type| BlockNumber::from_type_def(&portable_type.type_def))
|
||||
}
|
||||
|
||||
fn fetch_metadata(chain_spec: &dyn ChainSpec) -> Result<Metadata, pezsc_cli::Error> {
|
||||
let mut storage = chain_spec.build_storage()?;
|
||||
let code_bytes = storage
|
||||
.top
|
||||
.remove(pezsp_storage::well_known_keys::CODE)
|
||||
.ok_or("chain spec genesis does not contain code")?;
|
||||
let opaque_metadata = fetch_latest_metadata_from_code_blob(
|
||||
&WasmExecutor::<TeyrchainHostFunctions>::builder()
|
||||
.with_allow_missing_host_functions(true)
|
||||
.build(),
|
||||
pezsp_runtime::Cow::Borrowed(code_bytes.as_slice()),
|
||||
)
|
||||
.map_err(|err| err.to_string())?;
|
||||
|
||||
Metadata::decode(&mut (*opaque_metadata).as_slice()).map_err(Into::into)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::runtime::{
|
||||
BlockNumber, MetadataInspector, DEFAULT_FRAME_SYSTEM_PALLET_NAME,
|
||||
DEFAULT_TEYRCHAIN_SYSTEM_PALLET_NAME,
|
||||
};
|
||||
use codec::Decode;
|
||||
use cumulus_client_service::TeyrchainHostFunctions;
|
||||
use pezsc_executor::WasmExecutor;
|
||||
use pezsc_runtime_utilities::fetch_latest_metadata_from_code_blob;
|
||||
|
||||
fn cumulus_test_runtime_metadata() -> subxt_metadata::Metadata {
|
||||
let opaque_metadata = fetch_latest_metadata_from_code_blob(
|
||||
&WasmExecutor::<TeyrchainHostFunctions>::builder()
|
||||
.with_allow_missing_host_functions(true)
|
||||
.build(),
|
||||
pezsp_runtime::Cow::Borrowed(cumulus_test_runtime::WASM_BINARY.unwrap()),
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
subxt_metadata::Metadata::decode(&mut (*opaque_metadata).as_slice()).unwrap()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_pallet_exists() {
|
||||
let metadata_inspector = MetadataInspector(cumulus_test_runtime_metadata());
|
||||
assert!(metadata_inspector.pezpallet_exists(DEFAULT_TEYRCHAIN_SYSTEM_PALLET_NAME));
|
||||
assert!(metadata_inspector.pezpallet_exists(DEFAULT_FRAME_SYSTEM_PALLET_NAME));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_runtime_block_number() {
|
||||
let metadata_inspector = MetadataInspector(cumulus_test_runtime_metadata());
|
||||
assert_eq!(metadata_inspector.block_number().unwrap(), BlockNumber::U32);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,634 @@
|
||||
// Copyright (C) Parity Technologies (UK) Ltd.
|
||||
// This file is part of Pezcumulus.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
use crate::{
|
||||
chain_spec::Extensions,
|
||||
cli::DevSealMode,
|
||||
common::{
|
||||
command::NodeCommandRunner,
|
||||
rpc::BuildRpcExtensions,
|
||||
statement_store::{build_statement_store, new_statement_handler_proto},
|
||||
types::{
|
||||
TeyrchainBackend, TeyrchainBlockImport, TeyrchainClient, TeyrchainHostFunctions,
|
||||
TeyrchainService,
|
||||
},
|
||||
ConstructNodeRuntimeApi, NodeBlock, NodeExtraArgs,
|
||||
},
|
||||
};
|
||||
use codec::Encode;
|
||||
use cumulus_client_bootnodes::{start_bootnode_tasks, StartBootnodeTasksParams};
|
||||
use cumulus_client_cli::CollatorOptions;
|
||||
use cumulus_client_service::{
|
||||
build_network, build_relay_chain_interface, prepare_node_config, start_relay_chain_tasks,
|
||||
BuildNetworkParams, CollatorSybilResistance, DARecoveryProfile, StartRelayChainTasksParams,
|
||||
TeyrchainTracingExecuteBlock,
|
||||
};
|
||||
use cumulus_primitives_core::{BlockT, GetTeyrchainInfo, ParaId};
|
||||
use cumulus_relay_chain_interface::{OverseerHandle, RelayChainInterface};
|
||||
use futures::FutureExt;
|
||||
use log::info;
|
||||
use pezkuwi_primitives::CollatorPair;
|
||||
use prometheus_endpoint::Registry;
|
||||
use pezsc_client_api::Backend;
|
||||
use pezsc_consensus::DefaultImportQueue;
|
||||
use pezsc_executor::{HeapAllocStrategy, DEFAULT_HEAP_ALLOC_STRATEGY};
|
||||
use pezsc_network::{
|
||||
config::FullNetworkConfiguration, NetworkBackend, NetworkBlock, NetworkStateInfo, PeerId,
|
||||
};
|
||||
use pezsc_service::{Configuration, ImportQueue, PartialComponents, TaskManager};
|
||||
use pezsc_statement_store::Store;
|
||||
use pezsc_sysinfo::HwBench;
|
||||
use pezsc_telemetry::{TelemetryHandle, TelemetryWorker};
|
||||
use pezsc_tracing::tracing::Instrument;
|
||||
use pezsc_transaction_pool::TransactionPoolHandle;
|
||||
use pezsc_transaction_pool_api::OffchainTransactionPoolFactory;
|
||||
use pezsp_api::{ApiExt, ProvideRuntimeApi};
|
||||
use pezsp_keystore::KeystorePtr;
|
||||
use pezsp_runtime::traits::AccountIdConversion;
|
||||
use std::{future::Future, pin::Pin, sync::Arc, time::Duration};
|
||||
use teyrchains_common::Hash;
|
||||
|
||||
pub(crate) trait BuildImportQueue<
|
||||
Block: BlockT,
|
||||
RuntimeApi,
|
||||
BlockImport: pezsc_consensus::BlockImport<Block>,
|
||||
>
|
||||
{
|
||||
fn build_import_queue(
|
||||
client: Arc<TeyrchainClient<Block, RuntimeApi>>,
|
||||
block_import: TeyrchainBlockImport<Block, BlockImport>,
|
||||
config: &Configuration,
|
||||
telemetry_handle: Option<TelemetryHandle>,
|
||||
task_manager: &TaskManager,
|
||||
) -> pezsc_service::error::Result<DefaultImportQueue<Block>>;
|
||||
}
|
||||
|
||||
pub(crate) trait StartConsensus<Block: BlockT, RuntimeApi, BI, BIAuxiliaryData>
|
||||
where
|
||||
RuntimeApi: ConstructNodeRuntimeApi<Block, TeyrchainClient<Block, RuntimeApi>>,
|
||||
{
|
||||
fn start_consensus(
|
||||
client: Arc<TeyrchainClient<Block, RuntimeApi>>,
|
||||
block_import: TeyrchainBlockImport<Block, BI>,
|
||||
prometheus_registry: Option<&Registry>,
|
||||
telemetry: Option<TelemetryHandle>,
|
||||
task_manager: &TaskManager,
|
||||
relay_chain_interface: Arc<dyn RelayChainInterface>,
|
||||
transaction_pool: Arc<TransactionPoolHandle<Block, TeyrchainClient<Block, RuntimeApi>>>,
|
||||
keystore: KeystorePtr,
|
||||
relay_chain_slot_duration: Duration,
|
||||
para_id: ParaId,
|
||||
collator_key: CollatorPair,
|
||||
collator_peer_id: PeerId,
|
||||
overseer_handle: OverseerHandle,
|
||||
announce_block: Arc<dyn Fn(Hash, Option<Vec<u8>>) + Send + Sync>,
|
||||
backend: Arc<TeyrchainBackend<Block>>,
|
||||
node_extra_args: NodeExtraArgs,
|
||||
block_import_extra_return_value: BIAuxiliaryData,
|
||||
) -> Result<(), pezsc_service::Error>;
|
||||
}
|
||||
|
||||
/// Checks that the hardware meets the requirements and print a warning otherwise.
|
||||
fn warn_if_slow_hardware(hwbench: &pezsc_sysinfo::HwBench) {
|
||||
// Pezkuwi para-chains should generally use these requirements to ensure that the relay-chain
|
||||
// will not take longer than expected to import its blocks.
|
||||
if let Err(err) =
|
||||
pezframe_benchmarking_cli::BIZINIKIWI_REFERENCE_HARDWARE.check_hardware(hwbench, false)
|
||||
{
|
||||
log::warn!(
|
||||
"⚠️ The hardware does not meet the minimal requirements {} for role 'Authority' find out more at:\n\
|
||||
https://wiki.network.pezkuwichain.io/docs/maintain-guides-how-to-validate-polkadot#reference-hardware",
|
||||
err
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) trait InitBlockImport<Block: BlockT, RuntimeApi> {
|
||||
type BlockImport: pezsc_consensus::BlockImport<Block> + Clone + Send + Sync;
|
||||
type BlockImportAuxiliaryData;
|
||||
|
||||
fn init_block_import(
|
||||
client: Arc<TeyrchainClient<Block, RuntimeApi>>,
|
||||
) -> pezsc_service::error::Result<(Self::BlockImport, Self::BlockImportAuxiliaryData)>;
|
||||
}
|
||||
|
||||
pub(crate) struct ClientBlockImport;
|
||||
|
||||
impl<Block: BlockT, RuntimeApi> InitBlockImport<Block, RuntimeApi> for ClientBlockImport
|
||||
where
|
||||
RuntimeApi: Send + ConstructNodeRuntimeApi<Block, TeyrchainClient<Block, RuntimeApi>>,
|
||||
{
|
||||
type BlockImport = Arc<TeyrchainClient<Block, RuntimeApi>>;
|
||||
type BlockImportAuxiliaryData = ();
|
||||
|
||||
fn init_block_import(
|
||||
client: Arc<TeyrchainClient<Block, RuntimeApi>>,
|
||||
) -> pezsc_service::error::Result<(Self::BlockImport, Self::BlockImportAuxiliaryData)> {
|
||||
Ok((client.clone(), ()))
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) trait BaseNodeSpec {
|
||||
type Block: NodeBlock;
|
||||
|
||||
type RuntimeApi: ConstructNodeRuntimeApi<
|
||||
Self::Block,
|
||||
TeyrchainClient<Self::Block, Self::RuntimeApi>,
|
||||
>;
|
||||
|
||||
type BuildImportQueue: BuildImportQueue<
|
||||
Self::Block,
|
||||
Self::RuntimeApi,
|
||||
<Self::InitBlockImport as InitBlockImport<Self::Block, Self::RuntimeApi>>::BlockImport,
|
||||
>;
|
||||
|
||||
type InitBlockImport: self::InitBlockImport<Self::Block, Self::RuntimeApi>;
|
||||
|
||||
/// Retrieves teyrchain id.
|
||||
fn teyrchain_id(
|
||||
client: &TeyrchainClient<Self::Block, Self::RuntimeApi>,
|
||||
teyrchain_config: &Configuration,
|
||||
) -> Option<ParaId> {
|
||||
let best_hash = client.chain_info().best_hash;
|
||||
let para_id = if client
|
||||
.runtime_api()
|
||||
.has_api::<dyn GetTeyrchainInfo<Self::Block>>(best_hash)
|
||||
.ok()
|
||||
.filter(|has_api| *has_api)
|
||||
.is_some()
|
||||
{
|
||||
client
|
||||
.runtime_api()
|
||||
.teyrchain_id(best_hash)
|
||||
.inspect_err(|err| {
|
||||
log::error!(
|
||||
"`cumulus_primitives_core::GetTeyrchainInfo` runtime API call errored with {}",
|
||||
err
|
||||
);
|
||||
})
|
||||
.ok()?
|
||||
} else {
|
||||
ParaId::from(
|
||||
Extensions::try_get(&*teyrchain_config.chain_spec).and_then(|ext| ext.para_id())?,
|
||||
)
|
||||
};
|
||||
|
||||
let teyrchain_account =
|
||||
AccountIdConversion::<pezkuwi_primitives::AccountId>::into_account_truncating(¶_id);
|
||||
|
||||
info!("🪪 Teyrchain id: {:?}", para_id);
|
||||
info!("🧾 Teyrchain Account: {}", teyrchain_account);
|
||||
|
||||
Some(para_id)
|
||||
}
|
||||
|
||||
/// Starts a `ServiceBuilder` for a full service.
|
||||
///
|
||||
/// Use this macro if you don't actually need the full service, but just the builder in order to
|
||||
/// be able to perform chain operations.
|
||||
fn new_partial(
|
||||
config: &Configuration,
|
||||
) -> pezsc_service::error::Result<
|
||||
TeyrchainService<
|
||||
Self::Block,
|
||||
Self::RuntimeApi,
|
||||
<Self::InitBlockImport as InitBlockImport<Self::Block, Self::RuntimeApi>>::BlockImport,
|
||||
<Self::InitBlockImport as InitBlockImport<Self::Block, Self::RuntimeApi>>::BlockImportAuxiliaryData
|
||||
>
|
||||
>{
|
||||
let telemetry = config
|
||||
.telemetry_endpoints
|
||||
.clone()
|
||||
.filter(|x| !x.is_empty())
|
||||
.map(|endpoints| -> Result<_, pezsc_telemetry::Error> {
|
||||
let worker = TelemetryWorker::new(16)?;
|
||||
let telemetry = worker.handle().new_telemetry(endpoints);
|
||||
Ok((worker, telemetry))
|
||||
})
|
||||
.transpose()?;
|
||||
|
||||
let heap_pages =
|
||||
config.executor.default_heap_pages.map_or(DEFAULT_HEAP_ALLOC_STRATEGY, |h| {
|
||||
HeapAllocStrategy::Static { extra_pages: h as _ }
|
||||
});
|
||||
|
||||
let executor = pezsc_executor::WasmExecutor::<TeyrchainHostFunctions>::builder()
|
||||
.with_execution_method(config.executor.wasm_method)
|
||||
.with_max_runtime_instances(config.executor.max_runtime_instances)
|
||||
.with_runtime_cache_size(config.executor.runtime_cache_size)
|
||||
.with_onchain_heap_alloc_strategy(heap_pages)
|
||||
.with_offchain_heap_alloc_strategy(heap_pages)
|
||||
.build();
|
||||
|
||||
let (client, backend, keystore_container, task_manager) =
|
||||
pezsc_service::new_full_parts_record_import::<Self::Block, Self::RuntimeApi, _>(
|
||||
config,
|
||||
telemetry.as_ref().map(|(_, telemetry)| telemetry.handle()),
|
||||
executor,
|
||||
true,
|
||||
)?;
|
||||
let client = Arc::new(client);
|
||||
|
||||
let telemetry_worker_handle = telemetry.as_ref().map(|(worker, _)| worker.handle());
|
||||
|
||||
let telemetry = telemetry.map(|(worker, telemetry)| {
|
||||
task_manager.spawn_handle().spawn("telemetry", None, worker.run());
|
||||
telemetry
|
||||
});
|
||||
|
||||
let transaction_pool = Arc::from(
|
||||
pezsc_transaction_pool::Builder::new(
|
||||
task_manager.spawn_essential_handle(),
|
||||
client.clone(),
|
||||
config.role.is_authority().into(),
|
||||
)
|
||||
.with_options(config.transaction_pool.clone())
|
||||
.with_prometheus(config.prometheus_registry())
|
||||
.build(),
|
||||
);
|
||||
|
||||
let (block_import, block_import_auxiliary_data) =
|
||||
Self::InitBlockImport::init_block_import(client.clone())?;
|
||||
|
||||
let block_import = TeyrchainBlockImport::new(block_import, backend.clone());
|
||||
|
||||
let import_queue = Self::BuildImportQueue::build_import_queue(
|
||||
client.clone(),
|
||||
block_import.clone(),
|
||||
config,
|
||||
telemetry.as_ref().map(|telemetry| telemetry.handle()),
|
||||
&task_manager,
|
||||
)?;
|
||||
|
||||
Ok(PartialComponents {
|
||||
backend,
|
||||
client,
|
||||
import_queue,
|
||||
keystore_container,
|
||||
task_manager,
|
||||
transaction_pool,
|
||||
select_chain: (),
|
||||
other: (block_import, telemetry, telemetry_worker_handle, block_import_auxiliary_data),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) trait NodeSpec: BaseNodeSpec {
|
||||
type BuildRpcExtensions: BuildRpcExtensions<
|
||||
TeyrchainClient<Self::Block, Self::RuntimeApi>,
|
||||
TeyrchainBackend<Self::Block>,
|
||||
TransactionPoolHandle<Self::Block, TeyrchainClient<Self::Block, Self::RuntimeApi>>,
|
||||
Store,
|
||||
>;
|
||||
|
||||
type StartConsensus: StartConsensus<
|
||||
Self::Block,
|
||||
Self::RuntimeApi,
|
||||
<Self::InitBlockImport as InitBlockImport<Self::Block, Self::RuntimeApi>>::BlockImport,
|
||||
<Self::InitBlockImport as InitBlockImport<Self::Block, Self::RuntimeApi>>::BlockImportAuxiliaryData,
|
||||
>;
|
||||
|
||||
const SYBIL_RESISTANCE: CollatorSybilResistance;
|
||||
|
||||
fn start_dev_node(
|
||||
_config: Configuration,
|
||||
_mode: DevSealMode,
|
||||
) -> pezsc_service::error::Result<TaskManager> {
|
||||
Err(pezsc_service::Error::Other("Dev not supported for this node type".into()))
|
||||
}
|
||||
|
||||
/// Start a node with the given teyrchain spec.
|
||||
///
|
||||
/// This is the actual implementation that is abstract over the executor and the runtime api.
|
||||
fn start_node<Net>(
|
||||
teyrchain_config: Configuration,
|
||||
pezkuwi_config: Configuration,
|
||||
collator_options: CollatorOptions,
|
||||
hwbench: Option<pezsc_sysinfo::HwBench>,
|
||||
node_extra_args: NodeExtraArgs,
|
||||
) -> Pin<Box<dyn Future<Output = pezsc_service::error::Result<TaskManager>>>>
|
||||
where
|
||||
Net: NetworkBackend<Self::Block, Hash>,
|
||||
{
|
||||
let fut = async move {
|
||||
let teyrchain_config = prepare_node_config(teyrchain_config);
|
||||
let teyrchain_public_addresses = teyrchain_config.network.public_addresses.clone();
|
||||
let teyrchain_fork_id = teyrchain_config.chain_spec.fork_id().map(ToString::to_string);
|
||||
let advertise_non_global_ips = teyrchain_config.network.allow_non_globals_in_dht;
|
||||
let params = Self::new_partial(&teyrchain_config)?;
|
||||
let (block_import, mut telemetry, telemetry_worker_handle, block_import_auxiliary_data) =
|
||||
params.other;
|
||||
let client = params.client.clone();
|
||||
let backend = params.backend.clone();
|
||||
let mut task_manager = params.task_manager;
|
||||
|
||||
// Resolve teyrchain id based on runtime, or based on chain spec.
|
||||
let para_id = Self::teyrchain_id(&client, &teyrchain_config)
|
||||
.ok_or("Failed to retrieve the teyrchain id")?;
|
||||
let relay_chain_fork_id = pezkuwi_config.chain_spec.fork_id().map(ToString::to_string);
|
||||
let (relay_chain_interface, collator_key, relay_chain_network, paranode_rx) =
|
||||
build_relay_chain_interface(
|
||||
pezkuwi_config,
|
||||
&teyrchain_config,
|
||||
telemetry_worker_handle,
|
||||
&mut task_manager,
|
||||
collator_options.clone(),
|
||||
hwbench.clone(),
|
||||
)
|
||||
.await
|
||||
.map_err(|e| pezsc_service::Error::Application(Box::new(e)))?;
|
||||
|
||||
let validator = teyrchain_config.role.is_authority();
|
||||
let prometheus_registry = teyrchain_config.prometheus_registry().cloned();
|
||||
let transaction_pool = params.transaction_pool.clone();
|
||||
let import_queue_service = params.import_queue.service();
|
||||
let mut net_config = FullNetworkConfiguration::<_, _, Net>::new(
|
||||
&teyrchain_config.network,
|
||||
prometheus_registry.clone(),
|
||||
);
|
||||
|
||||
let metrics = Net::register_notification_metrics(
|
||||
teyrchain_config.prometheus_config.as_ref().map(|config| &config.registry),
|
||||
);
|
||||
|
||||
let statement_handler_proto = node_extra_args.enable_statement_store.then(|| {
|
||||
new_statement_handler_proto(&*client, &teyrchain_config, &metrics, &mut net_config)
|
||||
});
|
||||
|
||||
let (network, system_rpc_tx, tx_handler_controller, sync_service) =
|
||||
build_network(BuildNetworkParams {
|
||||
teyrchain_config: &teyrchain_config,
|
||||
net_config,
|
||||
client: client.clone(),
|
||||
transaction_pool: transaction_pool.clone(),
|
||||
para_id,
|
||||
spawn_handle: task_manager.spawn_handle(),
|
||||
relay_chain_interface: relay_chain_interface.clone(),
|
||||
import_queue: params.import_queue,
|
||||
sybil_resistance_level: Self::SYBIL_RESISTANCE,
|
||||
metrics,
|
||||
})
|
||||
.await?;
|
||||
let peer_id = network.local_peer_id();
|
||||
|
||||
let statement_store = statement_handler_proto
|
||||
.map(|statement_handler_proto| {
|
||||
build_statement_store(
|
||||
&teyrchain_config,
|
||||
&mut task_manager,
|
||||
client.clone(),
|
||||
network.clone(),
|
||||
sync_service.clone(),
|
||||
params.keystore_container.local_keystore(),
|
||||
statement_handler_proto,
|
||||
)
|
||||
})
|
||||
.transpose()?;
|
||||
|
||||
if teyrchain_config.offchain_worker.enabled {
|
||||
let custom_extensions = {
|
||||
let statement_store = statement_store.clone();
|
||||
move |_hash| {
|
||||
if let Some(statement_store) = &statement_store {
|
||||
vec![Box::new(statement_store.clone().as_statement_store_ext())
|
||||
as Box<_>]
|
||||
} else {
|
||||
vec![]
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
let offchain_workers =
|
||||
pezsc_offchain::OffchainWorkers::new(pezsc_offchain::OffchainWorkerOptions {
|
||||
runtime_api_provider: client.clone(),
|
||||
keystore: Some(params.keystore_container.keystore()),
|
||||
offchain_db: backend.offchain_storage(),
|
||||
transaction_pool: Some(OffchainTransactionPoolFactory::new(
|
||||
transaction_pool.clone(),
|
||||
)),
|
||||
network_provider: Arc::new(network.clone()),
|
||||
is_validator: teyrchain_config.role.is_authority(),
|
||||
enable_http_requests: true,
|
||||
custom_extensions,
|
||||
})?;
|
||||
task_manager.spawn_handle().spawn(
|
||||
"offchain-workers-runner",
|
||||
"offchain-work",
|
||||
offchain_workers.run(client.clone(), task_manager.spawn_handle()).boxed(),
|
||||
);
|
||||
}
|
||||
|
||||
let rpc_builder = {
|
||||
let client = client.clone();
|
||||
let transaction_pool = transaction_pool.clone();
|
||||
let backend_for_rpc = backend.clone();
|
||||
let statement_store = statement_store.clone();
|
||||
|
||||
Box::new(move |_| {
|
||||
Self::BuildRpcExtensions::build_rpc_extensions(
|
||||
client.clone(),
|
||||
backend_for_rpc.clone(),
|
||||
transaction_pool.clone(),
|
||||
statement_store.clone(),
|
||||
)
|
||||
})
|
||||
};
|
||||
|
||||
let database_path = teyrchain_config.database.path().map(|p| p.to_path_buf());
|
||||
|
||||
pezsc_service::spawn_tasks(pezsc_service::SpawnTasksParams {
|
||||
rpc_builder,
|
||||
client: client.clone(),
|
||||
transaction_pool: transaction_pool.clone(),
|
||||
task_manager: &mut task_manager,
|
||||
config: teyrchain_config,
|
||||
keystore: params.keystore_container.keystore(),
|
||||
backend: backend.clone(),
|
||||
network: network.clone(),
|
||||
sync_service: sync_service.clone(),
|
||||
system_rpc_tx,
|
||||
tx_handler_controller,
|
||||
telemetry: telemetry.as_mut(),
|
||||
tracing_execute_block: Some(Arc::new(TeyrchainTracingExecuteBlock::new(
|
||||
client.clone(),
|
||||
))),
|
||||
})?;
|
||||
|
||||
// Spawn the storage monitor
|
||||
if let Some(database_path) = database_path {
|
||||
pezsc_storage_monitor::StorageMonitorService::try_spawn(
|
||||
node_extra_args.storage_monitor.clone(),
|
||||
database_path,
|
||||
&task_manager.spawn_essential_handle(),
|
||||
)
|
||||
.map_err(|e| pezsc_service::Error::Application(Box::new(e) as Box<_>))?;
|
||||
}
|
||||
|
||||
if let Some(hwbench) = hwbench {
|
||||
pezsc_sysinfo::print_hwbench(&hwbench);
|
||||
if validator {
|
||||
warn_if_slow_hardware(&hwbench);
|
||||
}
|
||||
|
||||
if let Some(ref mut telemetry) = telemetry {
|
||||
let telemetry_handle = telemetry.handle();
|
||||
task_manager.spawn_handle().spawn(
|
||||
"telemetry_hwbench",
|
||||
None,
|
||||
pezsc_sysinfo::initialize_hwbench_telemetry(telemetry_handle, hwbench),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
let announce_block = {
|
||||
let sync_service = sync_service.clone();
|
||||
Arc::new(move |hash, data| sync_service.announce_block(hash, data))
|
||||
};
|
||||
|
||||
let relay_chain_slot_duration = Duration::from_secs(6);
|
||||
|
||||
let overseer_handle = relay_chain_interface
|
||||
.overseer_handle()
|
||||
.map_err(|e| pezsc_service::Error::Application(Box::new(e)))?;
|
||||
|
||||
start_relay_chain_tasks(StartRelayChainTasksParams {
|
||||
client: client.clone(),
|
||||
announce_block: announce_block.clone(),
|
||||
para_id,
|
||||
relay_chain_interface: relay_chain_interface.clone(),
|
||||
task_manager: &mut task_manager,
|
||||
da_recovery_profile: if validator {
|
||||
DARecoveryProfile::Collator
|
||||
} else {
|
||||
DARecoveryProfile::FullNode
|
||||
},
|
||||
import_queue: import_queue_service,
|
||||
relay_chain_slot_duration,
|
||||
recovery_handle: Box::new(overseer_handle.clone()),
|
||||
sync_service,
|
||||
prometheus_registry: prometheus_registry.as_ref(),
|
||||
})?;
|
||||
|
||||
start_bootnode_tasks(StartBootnodeTasksParams {
|
||||
embedded_dht_bootnode: collator_options.embedded_dht_bootnode,
|
||||
dht_bootnode_discovery: collator_options.dht_bootnode_discovery,
|
||||
para_id,
|
||||
task_manager: &mut task_manager,
|
||||
relay_chain_interface: relay_chain_interface.clone(),
|
||||
relay_chain_fork_id,
|
||||
relay_chain_network,
|
||||
request_receiver: paranode_rx,
|
||||
teyrchain_network: network,
|
||||
advertise_non_global_ips,
|
||||
teyrchain_genesis_hash: client.chain_info().genesis_hash.encode(),
|
||||
teyrchain_fork_id,
|
||||
teyrchain_public_addresses,
|
||||
});
|
||||
|
||||
if validator {
|
||||
Self::StartConsensus::start_consensus(
|
||||
client.clone(),
|
||||
block_import,
|
||||
prometheus_registry.as_ref(),
|
||||
telemetry.as_ref().map(|t| t.handle()),
|
||||
&task_manager,
|
||||
relay_chain_interface.clone(),
|
||||
transaction_pool,
|
||||
params.keystore_container.keystore(),
|
||||
relay_chain_slot_duration,
|
||||
para_id,
|
||||
collator_key.expect("Command line arguments do not allow this. qed"),
|
||||
peer_id,
|
||||
overseer_handle,
|
||||
announce_block,
|
||||
backend.clone(),
|
||||
node_extra_args,
|
||||
block_import_auxiliary_data,
|
||||
)?;
|
||||
}
|
||||
|
||||
Ok(task_manager)
|
||||
};
|
||||
|
||||
Box::pin(Instrument::instrument(
|
||||
fut,
|
||||
pezsc_tracing::tracing::info_span!(
|
||||
pezsc_tracing::logging::PREFIX_LOG_SPAN,
|
||||
name = "Teyrchain"
|
||||
),
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) trait DynNodeSpec: NodeCommandRunner {
|
||||
/// Start node with manual or instant seal consensus.
|
||||
fn start_dev_node(
|
||||
self: Box<Self>,
|
||||
config: Configuration,
|
||||
mode: DevSealMode,
|
||||
) -> pezsc_service::error::Result<TaskManager>;
|
||||
|
||||
/// Start the node.
|
||||
fn start_node(
|
||||
self: Box<Self>,
|
||||
teyrchain_config: Configuration,
|
||||
pezkuwi_config: Configuration,
|
||||
collator_options: CollatorOptions,
|
||||
hwbench: Option<HwBench>,
|
||||
node_extra_args: NodeExtraArgs,
|
||||
) -> Pin<Box<dyn Future<Output = pezsc_service::error::Result<TaskManager>>>>;
|
||||
}
|
||||
|
||||
impl<T> DynNodeSpec for T
|
||||
where
|
||||
T: NodeSpec + NodeCommandRunner,
|
||||
{
|
||||
fn start_dev_node(
|
||||
self: Box<Self>,
|
||||
config: Configuration,
|
||||
mode: DevSealMode,
|
||||
) -> pezsc_service::error::Result<TaskManager> {
|
||||
<Self as NodeSpec>::start_dev_node(config, mode)
|
||||
}
|
||||
|
||||
fn start_node(
|
||||
self: Box<Self>,
|
||||
teyrchain_config: Configuration,
|
||||
pezkuwi_config: Configuration,
|
||||
collator_options: CollatorOptions,
|
||||
hwbench: Option<HwBench>,
|
||||
node_extra_args: NodeExtraArgs,
|
||||
) -> Pin<Box<dyn Future<Output = pezsc_service::error::Result<TaskManager>>>> {
|
||||
match teyrchain_config.network.network_backend {
|
||||
pezsc_network::config::NetworkBackendType::Libp2p =>
|
||||
<Self as NodeSpec>::start_node::<pezsc_network::NetworkWorker<_, _>>(
|
||||
teyrchain_config,
|
||||
pezkuwi_config,
|
||||
collator_options,
|
||||
hwbench,
|
||||
node_extra_args,
|
||||
),
|
||||
pezsc_network::config::NetworkBackendType::Litep2p =>
|
||||
<Self as NodeSpec>::start_node::<pezsc_network::Litep2pNetworkBackend>(
|
||||
teyrchain_config,
|
||||
pezkuwi_config,
|
||||
collator_options,
|
||||
hwbench,
|
||||
node_extra_args,
|
||||
),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
// Copyright (C) Parity Technologies (UK) Ltd.
|
||||
// This file is part of Pezcumulus.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
use crate::common::{types::TeyrchainClient, ConstructNodeRuntimeApi, NodeBlock};
|
||||
use pezsc_network::{
|
||||
config::FullNetworkConfiguration, service::traits::NetworkService, NetworkBackend,
|
||||
};
|
||||
use pezsc_service::{Configuration, TaskManager};
|
||||
use pezsc_statement_store::Store;
|
||||
use std::sync::Arc;
|
||||
use teyrchains_common::Hash;
|
||||
|
||||
/// Helper function to setup the statement store in `NodeSpec::start_node`.
|
||||
///
|
||||
/// Functions are tailored for internal usage, types are unnecessary opinionated for usage in
|
||||
/// `NodeSpec::start_node`.
|
||||
|
||||
/// Build the statement handler prototype. Register the notification protocol in the network
|
||||
/// configuration.
|
||||
pub(crate) fn new_statement_handler_proto<
|
||||
Block: NodeBlock,
|
||||
RuntimeApi,
|
||||
Net: NetworkBackend<Block, Hash>,
|
||||
>(
|
||||
client: &TeyrchainClient<Block, RuntimeApi>,
|
||||
teyrchain_config: &Configuration,
|
||||
metrics: &pezsc_network::NotificationMetrics,
|
||||
net_config: &mut FullNetworkConfiguration<Block, Hash, Net>,
|
||||
) -> pezsc_network_statement::StatementHandlerPrototype {
|
||||
let (statement_handler_proto, statement_config) =
|
||||
pezsc_network_statement::StatementHandlerPrototype::new::<_, _, Net>(
|
||||
client.chain_info().genesis_hash,
|
||||
teyrchain_config.chain_spec.fork_id(),
|
||||
metrics.clone(),
|
||||
Arc::clone(&net_config.peer_store_handle()),
|
||||
);
|
||||
net_config.add_notification_protocol(statement_config);
|
||||
statement_handler_proto
|
||||
}
|
||||
|
||||
/// Build the statement store, spawn the tasks.
|
||||
pub(crate) fn build_statement_store<
|
||||
Block: NodeBlock,
|
||||
RuntimeApi: ConstructNodeRuntimeApi<Block, TeyrchainClient<Block, RuntimeApi>>,
|
||||
>(
|
||||
teyrchain_config: &Configuration,
|
||||
task_manager: &mut TaskManager,
|
||||
client: Arc<TeyrchainClient<Block, RuntimeApi>>,
|
||||
network: Arc<dyn NetworkService + 'static>,
|
||||
sync_service: Arc<pezsc_network_sync::service::syncing_service::SyncingService<Block>>,
|
||||
local_keystore: Arc<pezsc_keystore::LocalKeystore>,
|
||||
statement_handler_proto: pezsc_network_statement::StatementHandlerPrototype,
|
||||
) -> pezsc_service::error::Result<Arc<Store>> {
|
||||
let statement_store = pezsc_statement_store::Store::new_shared(
|
||||
&teyrchain_config.data_path,
|
||||
Default::default(),
|
||||
client,
|
||||
local_keystore,
|
||||
teyrchain_config.prometheus_registry(),
|
||||
&task_manager.spawn_handle(),
|
||||
)
|
||||
.map_err(|e| pezsc_service::Error::Application(Box::new(e) as Box<_>))?;
|
||||
let statement_protocol_executor = {
|
||||
let spawn_handle = task_manager.spawn_handle();
|
||||
Box::new(move |fut| {
|
||||
spawn_handle.spawn("network-statement-validator", Some("networking"), fut);
|
||||
})
|
||||
};
|
||||
let statement_handler = statement_handler_proto.build(
|
||||
network,
|
||||
sync_service,
|
||||
statement_store.clone(),
|
||||
teyrchain_config.prometheus_registry(),
|
||||
statement_protocol_executor,
|
||||
)?;
|
||||
task_manager.spawn_handle().spawn(
|
||||
"network-statement-handler",
|
||||
Some("networking"),
|
||||
statement_handler.run(),
|
||||
);
|
||||
|
||||
Ok(statement_store)
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
// Copyright (C) Parity Technologies (UK) Ltd.
|
||||
// This file is part of Pezcumulus.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
use cumulus_client_consensus_common::TeyrchainBlockImport as TTeyrchainBlockImport;
|
||||
use cumulus_primitives_core::relay_chain::UncheckedExtrinsic;
|
||||
use pezsc_consensus::DefaultImportQueue;
|
||||
use pezsc_executor::WasmExecutor;
|
||||
use pezsc_service::{PartialComponents, TFullBackend, TFullClient};
|
||||
use pezsc_telemetry::{Telemetry, TelemetryWorkerHandle};
|
||||
use pezsc_transaction_pool::TransactionPoolHandle;
|
||||
use pezsp_runtime::{generic, traits::BlakeTwo256};
|
||||
|
||||
pub use teyrchains_common::{AccountId, Balance, Hash, Nonce};
|
||||
|
||||
type Header<BlockNumber> = generic::Header<BlockNumber, BlakeTwo256>;
|
||||
pub type Block<BlockNumber> = generic::Block<Header<BlockNumber>, UncheckedExtrinsic>;
|
||||
|
||||
#[cfg(not(feature = "runtime-benchmarks"))]
|
||||
pub type TeyrchainHostFunctions = (
|
||||
cumulus_client_service::TeyrchainHostFunctions,
|
||||
pezsp_statement_store::runtime_api::HostFunctions,
|
||||
);
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
pub type TeyrchainHostFunctions = (
|
||||
cumulus_client_service::TeyrchainHostFunctions,
|
||||
pezsp_statement_store::runtime_api::HostFunctions,
|
||||
pezframe_benchmarking::benchmarking::HostFunctions,
|
||||
);
|
||||
|
||||
pub type TeyrchainClient<Block, RuntimeApi> =
|
||||
TFullClient<Block, RuntimeApi, WasmExecutor<TeyrchainHostFunctions>>;
|
||||
|
||||
pub type TeyrchainBackend<Block> = TFullBackend<Block>;
|
||||
|
||||
pub type TeyrchainBlockImport<Block, BI> =
|
||||
TTeyrchainBlockImport<Block, BI, TeyrchainBackend<Block>>;
|
||||
|
||||
/// Assembly of PartialComponents (enough to run chain ops subcommands)
|
||||
pub type TeyrchainService<Block, RuntimeApi, BI, BIExtraReturnValue> = PartialComponents<
|
||||
TeyrchainClient<Block, RuntimeApi>,
|
||||
TeyrchainBackend<Block>,
|
||||
(),
|
||||
DefaultImportQueue<Block>,
|
||||
TransactionPoolHandle<Block, TeyrchainClient<Block, RuntimeApi>>,
|
||||
(
|
||||
TeyrchainBlockImport<Block, BI>,
|
||||
Option<Telemetry>,
|
||||
Option<TelemetryWorkerHandle>,
|
||||
BIExtraReturnValue,
|
||||
),
|
||||
>;
|
||||
Reference in New Issue
Block a user