#![cfg_attr(not(feature = "std"), no_std)]
use frame_support::{
pallet_prelude::{DispatchClass, Weight},
parameter_types,
weights::constants::{BlockExecutionWeight, ExtrinsicBaseWeight, WEIGHT_REF_TIME_PER_SECOND},
};
use frame_system::limits::{BlockLength, BlockWeights};
use sp_runtime::{
generic,
traits::{BlakeTwo256, CheckedDiv, IdentifyAccount, Verify, Zero},
MultiSignature, Perbill, Saturating,
};
pub type BlockNumber = u32;
pub type Signature = MultiSignature;
pub type AccountId = <<Signature as Verify>::Signer as IdentifyAccount>::AccountId;
pub type Balance = u128;
pub type Amount = i128;
pub type AssetId = u32;
pub type Index = u32;
pub type Nonce = u32;
pub type Hash = sp_core::H256;
pub type EvmAddress = sp_core::H160;
pub type AccountIndex = u32;
pub enum TokenId {
Native,
Asset(AssetId),
}
pub const CONTRACTS_DEBUG_OUTPUT: bool = true;
pub const MILLISECS_PER_BLOCK: u64 = 12_000;
pub const SLOT_DURATION: u64 = MILLISECS_PER_BLOCK;
pub const MINUTES: BlockNumber = 60_000 / (MILLISECS_PER_BLOCK as BlockNumber);
pub const HOURS: BlockNumber = MINUTES * 60;
pub const DAYS: BlockNumber = HOURS * 24;
pub const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75);
pub const AVERAGE_ON_INITIALIZE_RATIO: Perbill = Perbill::from_percent(25);
pub const MAXIMUM_BLOCK_WEIGHT: Weight = Weight::from_parts(
WEIGHT_REF_TIME_PER_SECOND.saturating_div(2),
cumulus_primitives_core::relay_chain::MAX_POV_SIZE as u64,
);
pub const UNIT: Balance = 1_000_000_000_000;
pub const MILLIUNIT: Balance = 1_000_000_000;
pub const MICROUNIT: Balance = 1_000_000;
pub const MAX_POV_SIZE: u64 = 5 * 1024 * 1024;
pub const GAS_PRICE: u128 = 1_000;
pub const BLOCK_GAS_LIMIT: u64 = 150_000_000;
pub const GAS_WEIGHT: Weight = Weight::from_parts(7u64, 0);
pub const WEIGHT_PER_GAS: Weight = Weight::from_parts(20_000, 0);
pub const GAS_LIMIT_POV_SIZE_RATIO: u64 = 4;
parameter_types! {
pub const BlockHashCount: BlockNumber = 4096;
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 const SS58Prefix: u16 = 9935;
pub const SS58PrefixT1rn: u16 = 4815;
}
pub type Address = sp_runtime::MultiAddress<AccountId, ()>;
pub type Header = generic::Header<BlockNumber, BlakeTwo256>;
pub fn base_tx_fee() -> Balance {
MILLIUNIT / 10
}
pub fn default_fee_per_second() -> u128 {
let base_weight = Balance::from(ExtrinsicBaseWeight::get().ref_time());
let base_tx_per_second = (WEIGHT_REF_TIME_PER_SECOND as u128) / base_weight;
base_tx_per_second * base_tx_fee()
}
#[test]
fn fixed_block_time_12s() {
assert_eq!(MILLISECS_PER_BLOCK, 12_000);
assert_eq!(SLOT_DURATION, 12_000);
}