polkadot_omni_node_lib/common/
mod.rs1#![warn(missing_docs)]
20
21pub(crate) mod aura;
22pub mod chain_spec;
23pub mod command;
24pub mod rpc;
25pub mod runtime;
26pub mod spec;
27pub(crate) mod statement_store;
28pub mod types;
29
30use crate::cli::AuthoringPolicy;
31
32use cumulus_primitives_core::{CollectCollationInfo, GetParachainInfo, RelayParentOffsetApi};
33use sc_client_db::DbHash;
34use sc_offchain::OffchainWorkerApi;
35use serde::de::DeserializeOwned;
36use sp_api::{ApiExt, CallApiAt, ConstructRuntimeApi, Metadata};
37use sp_block_builder::BlockBuilder;
38use sp_runtime::{
39 traits::{Block as BlockT, BlockNumber, Header as HeaderT, NumberFor},
40 OpaqueExtrinsic,
41};
42use sp_session::SessionKeys;
43use sp_statement_store::runtime_api::ValidateStatement;
44use sp_transaction_pool::runtime_api::TaggedTransactionQueue;
45use std::{fmt::Debug, path::PathBuf, str::FromStr};
46
47pub trait NodeBlock:
48 BlockT<Extrinsic = OpaqueExtrinsic, Header = Self::BoundedHeader, Hash = DbHash> + DeserializeOwned
49{
50 type BoundedFromStrErr: Debug;
51 type BoundedNumber: FromStr<Err = Self::BoundedFromStrErr> + BlockNumber;
52 type BoundedHeader: HeaderT<Number = Self::BoundedNumber, Hash = DbHash> + Unpin;
53}
54
55impl<T> NodeBlock for T
56where
57 T: BlockT<Extrinsic = OpaqueExtrinsic, Hash = DbHash> + DeserializeOwned,
58 <T as BlockT>::Header: Unpin,
59 <NumberFor<T> as FromStr>::Err: Debug,
60{
61 type BoundedFromStrErr = <NumberFor<T> as FromStr>::Err;
62 type BoundedNumber = NumberFor<T>;
63 type BoundedHeader = <T as BlockT>::Header;
64}
65
66pub trait NodeRuntimeApi<Block: BlockT>:
68 ApiExt<Block>
69 + Metadata<Block>
70 + SessionKeys<Block>
71 + BlockBuilder<Block>
72 + TaggedTransactionQueue<Block>
73 + OffchainWorkerApi<Block>
74 + CollectCollationInfo<Block>
75 + ValidateStatement<Block>
76 + GetParachainInfo<Block>
77 + RelayParentOffsetApi<Block>
78 + Sized
79{
80}
81
82impl<T, Block: BlockT> NodeRuntimeApi<Block> for T where
83 T: ApiExt<Block>
84 + Metadata<Block>
85 + SessionKeys<Block>
86 + BlockBuilder<Block>
87 + TaggedTransactionQueue<Block>
88 + OffchainWorkerApi<Block>
89 + RelayParentOffsetApi<Block>
90 + CollectCollationInfo<Block>
91 + ValidateStatement<Block>
92 + GetParachainInfo<Block>
93{
94}
95
96pub trait ConstructNodeRuntimeApi<Block: BlockT, C: CallApiAt<Block>>:
99 ConstructRuntimeApi<Block, C, RuntimeApi = Self::BoundedRuntimeApi> + Send + Sync + 'static
100{
101 type BoundedRuntimeApi: NodeRuntimeApi<Block>;
103}
104
105impl<T, Block: BlockT, C: CallApiAt<Block>> ConstructNodeRuntimeApi<Block, C> for T
106where
107 T: ConstructRuntimeApi<Block, C> + Send + Sync + 'static,
108 T::RuntimeApi: NodeRuntimeApi<Block>,
109{
110 type BoundedRuntimeApi = T::RuntimeApi;
111}
112
113pub struct NodeExtraArgs {
115 pub authoring_policy: AuthoringPolicy,
119
120 pub export_pov: Option<PathBuf>,
122
123 pub max_pov_percentage: Option<u32>,
126
127 pub enable_statement_store: bool,
129}