// Copyright (C) Parity Technologies (UK) Ltd. and Dijital Kurdistan Tech Institute // SPDX-License-Identifier: Apache-2.0 // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. /// Universally recognized accounts. pub mod account { use pezframe_support::PalletId; /// Zagros treasury pezpallet id, used to convert into AccountId - in Zagros as a destination /// for slashed funds. pub const ZAGROS_TREASURY_PALLET_ID: PalletId = PalletId(*b"py/trsry"); /// Alliance pezpallet ID - used as a temporary place to deposit a slashed imbalance before the /// teleport to the Treasury. pub const ALLIANCE_PALLET_ID: PalletId = PalletId(*b"py/allia"); /// Referenda pezpallet ID - used as a temporary place to deposit a slashed imbalance before the /// teleport to the Treasury. pub const REFERENDA_PALLET_ID: PalletId = PalletId(*b"py/refer"); /// Ambassador Referenda pezpallet ID - used as a temporary place to deposit a slashed imbalance /// before the teleport to the Treasury. pub const AMBASSADOR_REFERENDA_PALLET_ID: PalletId = PalletId(*b"py/amref"); /// Fellowship treasury pezpallet ID. pub const FELLOWSHIP_TREASURY_PALLET_ID: PalletId = PalletId(*b"py/feltr"); } pub mod currency { use pezkuwi_core_primitives::Balance; use zagros_runtime_constants as constants; /// The existential deposit. Set to 1/10 of its parent Relay Chain. pub const EXISTENTIAL_DEPOSIT: Balance = constants::currency::EXISTENTIAL_DEPOSIT / 10; pub const UNITS: Balance = constants::currency::UNITS; pub const DOLLARS: Balance = UNITS; // 1_000_000_000_000 pub const CENTS: Balance = constants::currency::CENTS; pub const MILLICENTS: Balance = constants::currency::MILLICENTS; pub const GRAND: Balance = constants::currency::GRAND; pub const fn deposit(items: u32, bytes: u32) -> Balance { // 1/100 of Zagros testnet constants::currency::deposit(items, bytes) / 100 } } /// Fee-related. pub mod fee { use pezframe_support::{ pezpallet_prelude::Weight, weights::{ constants::ExtrinsicBaseWeight, FeePolynomial, WeightToFeeCoefficient, WeightToFeeCoefficients, WeightToFeePolynomial, }, }; use pezkuwi_core_primitives::Balance; pub use pezsp_runtime::Perbill; use smallvec::smallvec; /// The block saturation level. Fees will be updated based on this value. pub const TARGET_BLOCK_FULLNESS: Perbill = Perbill::from_percent(25); /// Handles converting a weight scalar to a fee value, based on the scale and granularity of the /// node's balance type. /// /// This should typically create a mapping between the following ranges: /// - [0, MAXIMUM_BLOCK_WEIGHT] /// - [Balance::min, Balance::max] /// /// Yet, it can be used for any other sort of change to weight-fee. Some examples being: /// - Setting it to `0` will essentially disable the weight fee. /// - Setting it to `1` will cause the literal `#[weight = x]` values to be charged. pub struct WeightToFee; impl pezframe_support::weights::WeightToFee for WeightToFee { type Balance = Balance; fn weight_to_fee(weight: &Weight) -> Self::Balance { let time_poly: FeePolynomial = RefTimeToFee::polynomial().into(); let proof_poly: FeePolynomial = ProofSizeToFee::polynomial().into(); // Take the maximum instead of the sum to charge by the more scarce resource. time_poly.eval(weight.ref_time()).max(proof_poly.eval(weight.proof_size())) } } /// Maps the reference time component of `Weight` to a fee. pub struct RefTimeToFee; impl WeightToFeePolynomial for RefTimeToFee { type Balance = Balance; fn polynomial() -> WeightToFeeCoefficients { // In Zagros, extrinsic base weight (smallest non-zero weight) is mapped to 1/10 CENT: // The standard system teyrchain configuration is 1/10 of that, as in 1/100 CENT. let p = super::currency::CENTS; let q = 100 * Balance::from(ExtrinsicBaseWeight::get().ref_time()); smallvec![WeightToFeeCoefficient { degree: 1, negative: false, coeff_frac: Perbill::from_rational(p % q, q), coeff_integer: p / q, }] } } /// Maps the proof size component of `Weight` to a fee. pub struct ProofSizeToFee; impl WeightToFeePolynomial for ProofSizeToFee { type Balance = Balance; fn polynomial() -> WeightToFeeCoefficients { // Map 10kb proof to 1 CENT. let p = super::currency::CENTS; let q = 10_000; smallvec![WeightToFeeCoefficient { degree: 1, negative: false, coeff_frac: Perbill::from_rational(p % q, q), coeff_integer: p / q, }] } } } /// Consensus-related. pub mod consensus { use pezframe_support::weights::{constants::WEIGHT_REF_TIME_PER_SECOND, Weight}; /// Maximum number of blocks simultaneously accepted by the Runtime, not yet included into the /// relay chain. pub const UNINCLUDED_SEGMENT_CAPACITY: u32 = 3; /// How many teyrchain blocks are processed by the relay chain per parent. Limits the number of /// blocks authored per slot. pub const BLOCK_PROCESSING_VELOCITY: u32 = 1; /// Relay chain slot duration, in milliseconds. pub const RELAY_CHAIN_SLOT_DURATION_MILLIS: u32 = 6000; /// We allow for 2 seconds of compute with a 6 second average block. pub const MAXIMUM_BLOCK_WEIGHT: Weight = Weight::from_parts( WEIGHT_REF_TIME_PER_SECOND.saturating_mul(2), pezcumulus_primitives_core::relay_chain::MAX_POV_SIZE as u64, ); /// 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. pub const MILLISECS_PER_BLOCK: u64 = 6000; pub const SLOT_DURATION: u64 = MILLISECS_PER_BLOCK; } /// Time-related pub mod time { use pezkuwi_core_primitives::BlockNumber; // Time is measured by number of blocks. pub const MINUTES: BlockNumber = 60_000 / (super::consensus::MILLISECS_PER_BLOCK as BlockNumber); pub const HOURS: BlockNumber = MINUTES * 60; pub const DAYS: BlockNumber = HOURS * 24; } pub mod snowbridge { use pezcumulus_primitives_core::ParaId; use pezframe_support::parameter_types; use xcm::prelude::{Location, NetworkId}; /// The pezpallet index of the Ethereum inbound queue pezpallet in the bridge hub runtime. pub const INBOUND_QUEUE_PALLET_INDEX_V1: u8 = 80; pub const INBOUND_QUEUE_PALLET_INDEX_V2: u8 = 91; pub const FRONTEND_PALLET_INDEX: u8 = 36; parameter_types! { /// Network and location for the Ethereum chain. On Zagros, the Ethereum chain bridged /// to is the Sepolia Ethereum testnet, with chain ID 11155111. /// /// pub EthereumNetwork: NetworkId = NetworkId::Ethereum { chain_id: 11155111 }; pub EthereumLocation: Location = Location::new(2, EthereumNetwork::get()); pub AssetHubParaId: ParaId = ParaId::from(zagros_runtime_constants::system_teyrchain::ASSET_HUB_ID); } } pub mod xcm_version { /// The default XCM version to set in genesis config. pub const SAFE_XCM_VERSION: u32 = xcm::prelude::XCM_VERSION; } pub mod locations { use pezframe_support::parameter_types; use xcm::latest::prelude::{Location, Teyrchain}; pub use zagros_runtime_constants::system_teyrchain::{AssetHubParaId, PeopleParaId}; parameter_types! { pub AssetHubLocation: Location = Location::new(1, Teyrchain(zagros_runtime_constants::system_teyrchain::ASSET_HUB_ID)); pub PeopleLocation: Location = Location::new(1, Teyrchain(zagros_runtime_constants::system_teyrchain::PEOPLE_ID)); } /// The governance on the AssetHub. pub type GovernanceLocation = AssetHubLocation; }