Files
pezkuwi-runtime-templates/generic-template/runtime/src/constants.rs
T

91 lines
3.5 KiB
Rust

extern crate alloc;
use pezframe_support::weights::{constants::WEIGHT_REF_TIME_PER_SECOND, Weight};
use pezsp_runtime::Perbill;
use pezsp_version::RuntimeVersion;
use crate::{apis, types::BlockNumber};
pub mod currency {
use crate::types::Balance;
pub const MICTYRENTS: Balance = 1_000_000;
pub const MILLICENTS: Balance = 1_000_000_000;
pub const CENTS: Balance = 1_000 * MILLICENTS; // assume this is worth about a cent.
pub const DOLLARS: Balance = 100 * CENTS;
pub const GRAND: Balance = 1_000 * DOLLARS;
pub const EXISTENTIAL_DEPOSIT: Balance = MILLICENTS;
pub const fn deposit(items: u32, bytes: u32) -> Balance {
items as Balance * 15 * CENTS + (bytes as Balance) * 6 * CENTS
}
}
pub const P_FACTOR: u128 = 10;
pub const Q_FACTOR: u128 = 100;
pub const POLY_DEGREE: u8 = 1;
#[pezsp_version::runtime_version]
pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: alloc::borrow::Cow::Borrowed("template-teyrchain"),
impl_name: alloc::borrow::Cow::Borrowed("template-teyrchain"),
authoring_version: 1,
spec_version: 1,
impl_version: 0,
apis: apis::RUNTIME_API_VERSIONS,
transaction_version: 1,
system_version: 1,
};
/// This determines the average expected block time that we are targeting.
/// Blocks will be produced at a minimum duration defined by `SLOT_DURATION`.
/// `SLOT_DURATION` is picked up by `pezpallet_timestamp` which is in turn picked
/// up by `pezpallet_aura` to implement `fn slot_duration()`.
///
/// Change this to adjust the block time.
#[cfg(feature = "async-backing")]
pub const MILLISECS_PER_BLOCK: u64 = 6000;
#[cfg(not(feature = "async-backing"))]
pub const MILLISECS_PER_BLOCK: u64 = 12000;
// NOTE: Currently it is not possible to change the slot duration after the
// chain has started. Attempting to do so will brick block production.
pub const SLOT_DURATION: u64 = MILLISECS_PER_BLOCK;
// Time is measured by number of blocks.
pub const MINUTES: BlockNumber = 60_000 / (MILLISECS_PER_BLOCK as BlockNumber);
pub const HOURS: BlockNumber = MINUTES * 60;
pub const DAYS: BlockNumber = HOURS * 24;
/// We assume that ~5% of the block weight is consumed by `on_initialize`
/// handlers. This is used to limit the maximal weight of a single extrinsic.
pub const AVERAGE_ON_INITIALIZE_RATIO: Perbill = Perbill::from_percent(5);
/// We allow `Normal` extrinsics to fill up the block up to 75%, the rest can be
/// used by `Operational` extrinsics.
pub const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75);
/// We allow for 0.5 of a second of compute with a 12 second average block time.
pub const MAXIMUM_BLOCK_WEIGHT: Weight = Weight::from_parts(
#[cfg(feature = "async-backing")]
WEIGHT_REF_TIME_PER_SECOND.saturating_mul(2),
#[cfg(not(feature = "async-backing"))]
WEIGHT_REF_TIME_PER_SECOND.saturating_div(2),
pezcumulus_primitives_core::relay_chain::MAX_POV_SIZE as u64,
);
/// Maximum number of blocks simultaneously accepted by the Runtime, not yet
/// included into the relay chain.
#[cfg(feature = "async-backing")]
pub const UNINCLUDED_SEGMENT_CAPACITY: u32 = 3;
#[cfg(not(feature = "async-backing"))]
pub const UNINCLUDED_SEGMENT_CAPACITY: u32 = 1;
/// How many teyrchain blocks are processed by the relay chain per parent.
/// Limits the number of blocks authored per slot.
pub const BLOCK_PTYRESSING_VELOCITY: u32 = 1;
/// Relay chain slot duration, in milliseconds.
pub const RELAY_CHAIN_SLOT_DURATION_MILLIS: u32 = 6000;
/// Maximum length for a block.
pub const MAX_BLOCK_LENGTH: u32 = 5 * 1024 * 1024;