pezkuwi_sdk_docs/pezkuwi_sdk/
pezcumulus.rs

1//! # Pezcumulus
2//!
3//! Bizinikiwi provides a framework ([FRAME]) through which a blockchain node and runtime can easily
4//! be created. Pezcumulus aims to extend the same approach to creation of Pezkuwi teyrchains.
5//!
6//! > Pezcumulus clouds are shaped sort of like dots; together they form a system that is intricate,
7//! > beautiful and functional.
8//!
9//! ## Example: Runtime
10//!
11//! A Pezcumulus-based runtime is fairly similar to other [FRAME]-based runtimes. Most notably, the
12//! following changes are applied to a normal FRAME-based runtime to make it a Pezcumulus-based
13//! runtime:
14//!
15//! #### Pezcumulus Pallets
16//!
17//! A teyrchain runtime should use a number of pallets that are provided by Pezcumulus and
18//! Bizinikiwi. Notably:
19//!
20//! - [`pezframe-system`](pezframe::prelude::pezframe_system), like all FRAME-based runtimes.
21//! - [`pezcumulus_pezpallet_teyrchain_system`]
22//! - [`teyrchain_info`]
23#![doc = docify::embed!("./src/pezkuwi_sdk/pezcumulus.rs", system_pallets)]
24//!
25//! Given that all Pezcumulus-based runtimes use a simple Aura-based consensus mechanism, the
26//! following pallets also need to be added:
27//!
28//! - [`pezpallet_timestamp`]
29//! - [`pezpallet_aura`]
30//! - [`pezcumulus_pezpallet_aura_ext`]
31#![doc = docify::embed!("./src/pezkuwi_sdk/pezcumulus.rs", consensus_pallets)]
32//!
33//!
34//! Finally, a separate macro, similar to
35//! [`impl_runtime_api`](pezframe::runtime::prelude::impl_runtime_apis), which creates the default set
36//! of runtime APIs, will generate the teyrchain runtime's validation runtime API, also known as
37//! teyrchain validation function (PVF). Without this API, the relay chain is unable to validate
38//! blocks produced by our teyrchain.
39#![doc = docify::embed!("./src/pezkuwi_sdk/pezcumulus.rs", validate_block)]
40//!
41//! ---
42//!
43//! [FRAME]: crate::pezkuwi_sdk::frame_runtime
44
45#![deny(rustdoc::broken_intra_doc_links)]
46#![deny(rustdoc::private_intra_doc_links)]
47
48#[cfg(test)]
49mod tests {
50	mod runtime {
51		pub use pezframe::{
52			deps::pezsp_consensus_aura::sr25519::AuthorityId as AuraId, prelude::*,
53			runtime::prelude::*, testing_prelude::*,
54		};
55
56		#[docify::export(CR)]
57		construct_runtime!(
58			pub enum Runtime {
59				// system-level pallets.
60				System: pezframe_system,
61				Timestamp: pezpallet_timestamp,
62				TeyrchainSystem: pezcumulus_pezpallet_teyrchain_system,
63				TeyrchainInfo: teyrchain_info,
64
65				// teyrchain consensus support -- mandatory.
66				Aura: pezpallet_aura,
67				AuraExt: pezcumulus_pezpallet_aura_ext,
68			}
69		);
70
71		#[docify::export]
72		mod system_pallets {
73			use super::*;
74
75			#[derive_impl(pezframe_system::config_preludes::TestDefaultConfig)]
76			impl pezframe_system::Config for Runtime {
77				type Block = MockBlock<Self>;
78				type OnSetCode = pezcumulus_pezpallet_teyrchain_system::TeyrchainSetCode<Self>;
79			}
80
81			impl pezcumulus_pezpallet_teyrchain_system::Config for Runtime {
82				type RuntimeEvent = RuntimeEvent;
83				type OnSystemEvent = ();
84				type SelfParaId = teyrchain_info::Pezpallet<Runtime>;
85				type OutboundXcmpMessageSource = ();
86				type XcmpMessageHandler = ();
87				type ReservedDmpWeight = ();
88				type ReservedXcmpWeight = ();
89				type CheckAssociatedRelayNumber =
90					pezcumulus_pezpallet_teyrchain_system::RelayNumberMonotonicallyIncreases;
91				type ConsensusHook = pezcumulus_pezpallet_aura_ext::FixedVelocityConsensusHook<
92					Runtime,
93					6000, // relay chain block time
94					1,
95					1,
96				>;
97				type WeightInfo = ();
98				type DmpQueue = pezframe::traits::EnqueueWithOrigin<(), pezsp_core::ConstU8<0>>;
99				type RelayParentOffset = ConstU32<0>;
100			}
101
102			impl teyrchain_info::Config for Runtime {}
103		}
104
105		#[docify::export]
106		mod consensus_pallets {
107			use super::*;
108
109			impl pezpallet_aura::Config for Runtime {
110				type AuthorityId = AuraId;
111				type DisabledValidators = ();
112				type MaxAuthorities = ConstU32<100_000>;
113				type AllowMultipleBlocksPerSlot = ConstBool<false>;
114				type SlotDuration = pezpallet_aura::MinimumPeriodTimesTwo<Self>;
115			}
116
117			#[docify::export(timestamp)]
118			#[derive_impl(pezpallet_timestamp::config_preludes::TestDefaultConfig)]
119			impl pezpallet_timestamp::Config for Runtime {}
120
121			impl pezcumulus_pezpallet_aura_ext::Config for Runtime {}
122		}
123
124		#[docify::export(validate_block)]
125		pezcumulus_pezpallet_teyrchain_system::register_validate_block! {
126			Runtime = Runtime,
127			BlockExecutor = pezcumulus_pezpallet_aura_ext::BlockExecutor::<Runtime, Executive>,
128		}
129	}
130}