Skip to content
Snippets Groups Projects
Select Git revision
  • e5f97358bb2e72ecfb17f23b14d4b4c25d727911
  • dev default protected
  • release/1.9.1 protected
  • pini-1.8-docker
  • pini-sync-onlypeers
  • duniter-v2s-issue-123-industrialize-releases
  • feature/build-aarch64-nodejs16
  • release/1.8 protected
  • pini-docker
  • ci_tags
  • fix/1448/1.8/txs_not_stored
  • feature/node-20
  • fix/1441/node_summary_with_storage
  • fix/1442/improve_bma_tx_history
  • feature/wotwizard-1.8
  • release/1.9 protected
  • 1.7 protected
  • feature/docker-set-latest protected
  • feature/fast-docker-build-1.8.4
  • fast-docker-build protected
  • feature/dump-distance
  • v1.8.7 protected
  • v1.8.7-rc4 protected
  • v1.8.7-rc3 protected
  • v1.8.7-rc2 protected
  • v1.8.7-rc1 protected
  • v1.8.6 protected
  • v1.7.23 protected
  • v1.8.5 protected
  • v1.8.4 protected
  • v1.8.3 protected
  • v1.8.2 protected
  • v1.8.1 protected
  • v1.8.0 protected
  • v1.8.0-rc1 protected
  • v1.8.0-beta5 protected
  • v1.8.0-beta4 protected
  • v1.8.0-beta3 protected
  • v1.8.0-beta2 protected
  • v1.8.0-beta protected
  • v1.7.21 protected
41 results

install.sh

Blame
  • constants.rs 3.90 KiB
    // Copyright 2021 Axiom-Team
    //
    // This file is part of Duniter-v2S.
    //
    // Duniter-v2S is free software: you can redistribute it and/or modify
    // it under the terms of the GNU Affero General Public License as published by
    // the Free Software Foundation, version 3 of the License.
    //
    // Duniter-v2S is distributed in the hope that it will be useful,
    // but WITHOUT ANY WARRANTY; without even the implied warranty of
    // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    // GNU Affero General Public License for more details.
    //
    // You should have received a copy of the GNU Affero General Public License
    // along with Duniter-v2S. If not, see <https://www.gnu.org/licenses/>.
    
    use crate::{Balance, BlockNumber};
    use frame_support::weights::Weight;
    use sp_runtime::Perbill;
    
    pub use crate::weights::paritydb_weights::constants::ParityDbWeight as DbWeight;
    
    /// 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 `pallet_timestamp` which is in turn picked
    /// up by `pallet_babe` to implement `fn slot_duration()`.
    ///
    /// Change this to adjust the block time.
    pub const MILLISECS_PER_BLOCK: u64 = 6000;
    pub const SECS_PER_BLOCK: u64 = MILLISECS_PER_BLOCK / 1_000;
    
    // 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;
    const SECS_PER_YEAR: u64 = 31_557_600; // (365.25 * 24 * 60 * 60)
    pub const MONTHS: BlockNumber = (SECS_PER_YEAR / (12 * SECS_PER_BLOCK)) as BlockNumber;
    pub const YEARS: BlockNumber = (SECS_PER_YEAR / SECS_PER_BLOCK) as BlockNumber;
    
    // 1 in 4 blocks (on average, not counting collisions) will be primary babe blocks.
    pub const PRIMARY_PROBABILITY: (u64, u64) = (1, 4);
    
    /// The BABE epoch configuration at genesis.
    pub const BABE_GENESIS_EPOCH_CONFIG: sp_consensus_babe::BabeEpochConfiguration =
        sp_consensus_babe::BabeEpochConfiguration {
            c: PRIMARY_PROBABILITY,
            allowed_slots: sp_consensus_babe::AllowedSlots::PrimaryAndSecondaryVRFSlots,
        };
    
    pub const DEPOSIT_PER_BYTE: Balance = 1;
    pub const DEPOSIT_PER_ITEM: Balance = 100;
    
    // Compute storage deposit per items and bytes
    pub const fn deposit(items: u32, bytes: u32) -> Balance {
        items as Balance * DEPOSIT_PER_ITEM + (bytes as Balance * DEPOSIT_PER_BYTE)
    }
    
    // Maximal weight proportion of normal extrinsics per block
    pub const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75);
    
    // WEIGHTS CONSTANTS //
    
    // Block weights limits
    pub fn block_weights(
        expected_block_weight: Weight,
        normal_ratio: sp_arithmetic::Perbill,
    ) -> frame_system::limits::BlockWeights {
        let base_weight = crate::weights::extrinsic_weights::ExtrinsicBaseWeight::get();
        let normal_weight = normal_ratio * expected_block_weight;
        frame_system::limits::BlockWeights::builder()
            .base_block(crate::weights::block_weights::BlockExecutionWeight::get())
            .for_class(frame_support::dispatch::DispatchClass::all(), |weights| {
                weights.base_extrinsic = base_weight;
            })
            .for_class(frame_support::dispatch::DispatchClass::Normal, |weights| {
                weights.max_total = normal_weight.into();
            })
            .for_class(
                frame_support::dispatch::DispatchClass::Operational,
                |weights| {
                    weights.max_total = expected_block_weight.into();
                    weights.reserved = (expected_block_weight - normal_weight).into();
                },
            )
            .avg_block_initialization(sp_arithmetic::Perbill::from_percent(10))
            .build()
            .expect("Fatal error: invalid BlockWeights configuration")
    }