timechain_runtime/configs/
core.rsuse static_assertions::const_assert;
use polkadot_sdk::*;
use frame_support::{
derive_impl,
dispatch::DispatchClass,
parameter_types,
traits::{ConstU16, ConstU32, Everything},
weights::{constants::ParityDbWeight, Weight},
};
use frame_system::limits::{BlockLength, BlockWeights};
use sp_version::RuntimeVersion;
use sp_runtime::Perbill;
use time_primitives::{BlockHash, BlockNumber, Moment, SS58_ADDRESS_PREFIX};
use crate::{
weights::{self, BlockExecutionWeight, ExtrinsicBaseWeight},
AccountId, Babe, Balance, Block, Nonce, PalletInfo, Runtime, RuntimeCall, RuntimeEvent,
RuntimeOrigin, RuntimeTask, MAXIMUM_BLOCK_WEIGHT, SLOT_DURATION, VERSION,
};
pub const AVERAGE_ON_INITIALIZE_RATIO: Perbill = Perbill::from_percent(10);
const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75);
parameter_types! {
pub const BlockHashCount: BlockNumber = 4096;
pub const Version: RuntimeVersion = VERSION;
pub RuntimeBlockLength: BlockLength =
BlockLength::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO);
pub RuntimeBlockWeights: BlockWeights = BlockWeights::builder()
.base_block(BlockExecutionWeight::get())
.for_class(DispatchClass::all(), |weights| {
weights.base_extrinsic = ExtrinsicBaseWeight::get();
})
.for_class(DispatchClass::Normal, |weights| {
weights.max_total = Some(NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT);
})
.for_class(DispatchClass::Operational, |weights| {
weights.max_total = Some(MAXIMUM_BLOCK_WEIGHT);
weights.reserved = Some(
MAXIMUM_BLOCK_WEIGHT - NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT
);
})
.avg_block_initialization(AVERAGE_ON_INITIALIZE_RATIO)
.build_or_panic();
pub MaxCollectivesProposalWeight: Weight = Perbill::from_percent(50) * RuntimeBlockWeights::get().max_block;
}
const_assert!(NORMAL_DISPATCH_RATIO.deconstruct() >= AVERAGE_ON_INITIALIZE_RATIO.deconstruct());
#[derive_impl(frame_system::config_preludes::SolochainDefaultConfig)]
impl frame_system::Config for Runtime {
type BaseCallFilter = Everything;
type BlockWeights = RuntimeBlockWeights;
type BlockLength = RuntimeBlockLength;
type DbWeight = ParityDbWeight;
type Nonce = Nonce;
type Hash = BlockHash;
type AccountId = AccountId;
type Block = Block;
type BlockHashCount = BlockHashCount;
type Version = Version;
type AccountData = pallet_balances::AccountData<Balance>;
type SystemWeightInfo = weights::frame_system::WeightInfo<Runtime>;
type SS58Prefix = ConstU16<{ SS58_ADDRESS_PREFIX }>;
type MaxConsumers = ConstU32<16>;
}
parameter_types! {
pub const MinimumPeriod: Moment = SLOT_DURATION / 2;
}
impl pallet_timestamp::Config for Runtime {
type Moment = Moment;
type OnTimestampSet = Babe;
type MinimumPeriod = MinimumPeriod;
type WeightInfo = weights::pallet_timestamp::WeightInfo<Runtime>;
}