Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision
  • 1000i100-test
  • 105_gitlab_container_registry
  • cgeek/issue-297-cpu
  • ci_cache
  • debug/podman
  • elois-compose-metrics
  • elois-duniter-storage
  • elois-smoldot
  • feature/dc-dump
  • feature/distance-rule
  • feature/show_milestone
  • fix-252
  • fix_picked_up_file_in_runtime_release
  • gdev-800-tests
  • hugo-release/runtime-701
  • hugo-tmp-dockerfile-cache
  • hugo/195-doc
  • hugo/195-graphql-schema
  • hugo/distance-precompute
  • hugo/endpoint-gossip
  • hugo/tmp-0.9.1
  • master
  • network/gdev-800
  • network/gdev-802
  • network/gdev-803
  • network/gdev-900
  • network/gtest-1000
  • pini-check-password
  • release/client-800.2
  • release/hugo-chainspec-gdev5
  • release/poka-chainspec-gdev5
  • release/poka-chainspec-gdev5-pini-docker
  • release/runtime-100
  • release/runtime-200
  • release/runtime-300
  • release/runtime-400
  • release/runtime-401
  • release/runtime-500
  • release/runtime-600
  • release/runtime-700
  • release/runtime-701
  • release/runtime-800
  • runtime/gtest-1000
  • tests/distance-with-oracle
  • tuxmain/anonymous-tx
  • tuxmain/benchmark-distance
  • tuxmain/fix-change-owner-key
  • update-docker-compose-rpc-squid-names
  • upgradable-multisig
  • gdev-800
  • gdev-800-0.8.0
  • gdev-802
  • gdev-803
  • gdev-900-0.10.0
  • gdev-900-0.10.1
  • gdev-900-0.9.0
  • gdev-900-0.9.1
  • gdev-900-0.9.2
  • gtest-1000
  • gtest-1000-0.11.0
  • gtest-1000-0.11.1
  • runtime-100
  • runtime-101
  • runtime-102
  • runtime-103
  • runtime-104
  • runtime-105
  • runtime-200
  • runtime-201
  • runtime-300
  • runtime-301
  • runtime-302
  • runtime-303
  • runtime-400
  • runtime-401
  • runtime-500
  • runtime-600
  • runtime-700
  • runtime-701
  • runtime-800
  • runtime-800-backup
  • runtime-800-bis
  • runtime-801
  • v0.1.0
  • v0.2.0
  • v0.3.0
  • v0.4.0
  • v0.4.1
88 results

Target

Select target project
  • nodes/rust/duniter-v2s
  • llaq/lc-core-substrate
  • pini-gh/duniter-v2s
  • vincentux/duniter-v2s
  • mildred/duniter-v2s
  • d0p1/duniter-v2s
  • bgallois/duniter-v2s
  • Nicolas80/duniter-v2s
8 results
Select Git revision
  • master
1 result
Show changes
Showing
with 2645 additions and 0 deletions
// 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 sp_runtime::Perbill;
/// 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);
// 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 frame_support::pallet_prelude::*;
use scale_info::TypeInfo;
#[macro_export]
macro_rules! declare_session_keys {
{} => {
pub mod opaque {
use super::*;
impl_opaque_keys! {
pub struct SessionKeys {
pub grandpa: Grandpa,
pub babe: Babe,
pub im_online: ImOnline,
pub authority_discovery: AuthorityDiscovery,
}
}
}
}
}
#[derive(
Clone,
Encode,
Decode,
DecodeWithMemTracking,
Default,
Eq,
PartialEq,
RuntimeDebug,
TypeInfo,
MaxEncodedLen,
serde::Deserialize,
serde::Serialize,
)]
pub struct IdtyData {
/// number of the first claimable UD
pub first_eligible_ud: pallet_universal_dividend::FirstEligibleUd,
}
impl From<IdtyData> for pallet_universal_dividend::FirstEligibleUd {
fn from(idty_data: IdtyData) -> Self {
idty_data.first_eligible_ud
}
}
#[derive(
Encode,
Decode,
DecodeWithMemTracking,
Default,
Clone,
Copy,
PartialEq,
Eq,
PartialOrd,
Ord,
RuntimeDebug,
TypeInfo,
serde::Deserialize,
serde::Serialize,
)]
pub struct ValidatorFullIdentification;
// 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/>.
/// In our deployed fee model, users will not pay any fees if blockchain usage remains below a
/// specified threshold, and fees are applied based on transaction weight and length once this
/// threshold is exceeded, helping to prevent spamming attacks.
///
/// When the current block's weight and length are below the targeted thresholds, no fees are charged,
/// as the weight-to-fee conversion results in zero. Once the block's weight and length exceed these
/// targets, the weight-to-fee conversion maps BASE_EXTRINSIC_WEIGHT_COST to a base extrinsic weight.
/// Additionally, a fee is applied based on the length of the extrinsic and is mapped affinely:
/// 2_000 (20G) corresponds to an extrinsic length of BYTES_PER_UNIT*10 plus the BASE_EXTRINSIC_LENGTH_COST and will be applied only if the extrinsic
/// exceeds MAX_EXTRINSIC_LENGTH bytes or if the block target in weight or length is surpassed.
///
/// To further deter abuse, if the previous block's weight or length the target thresholds,
/// the chain increases the fees by multiplying the transaction weight with a `FeeMultiplier`. For each
/// consecutive block that exceeds the targets, this multiplier increases by one. If the targets are
/// not reached, the multiplier decreases by one. The `FeeMultiplier` ranges from 1 (normal usage) to
/// `MaxMultiplier`, where heavy usage causes a number `MaxMultiplier` of consecutive blocks to exceed targets.
///
/// For testing purposes, a simplified, human-predictable weight system is used. This test model sets
/// a constant `weight_to_fee` of 1 and a `length_to_fee` of 0, making each extrinsic cost 2 (2cG),
/// and can be activated with the #[cfg(feature = "constant-fees")] feature.
pub use frame_support::weights::{Weight, WeightToFee};
use pallet_transaction_payment::{Multiplier, MultiplierUpdate};
use scale_info::prelude::marker::PhantomData;
use sp_arithmetic::traits::{BaseArithmetic, Unsigned};
use sp_core::Get;
use sp_runtime::{traits::Convert, Perquintill};
#[cfg(not(feature = "constant-fees"))]
use {
frame_support::pallet_prelude::DispatchClass,
frame_support::weights::{
WeightToFeeCoefficient, WeightToFeeCoefficients, WeightToFeePolynomial,
},
smallvec::smallvec,
sp_arithmetic::MultiplyRational,
sp_runtime::traits::One,
sp_runtime::Perbill,
sp_runtime::SaturatedConversion,
sp_runtime::Saturating,
};
/// A structure to implement Length to Fee conversion.
/// - `Balance`: The balance type.
/// - `Runtime`: The system configuration type, providing access to block weights.
/// - `Target`: A type providing the target block fullness.
pub struct LengthToFeeImpl<Balance, Runtime, Target>(
PhantomData<Balance>,
PhantomData<Runtime>,
PhantomData<Target>,
);
/// Trait implementation for converting transaction length to fee.
impl<Balance, Runtime, Target> WeightToFee for LengthToFeeImpl<Balance, Runtime, Target>
where
Balance: BaseArithmetic + From<u32> + Copy + Unsigned,
Runtime: frame_system::Config + pallet_transaction_payment::Config,
Target: Get<Perquintill>,
{
type Balance = Balance;
/// Function to convert weight to fee when "constant-fees" feature is not enabled.
///
/// This function calculates the fee based on the length of the transaction in bytes.
/// If the current block weight and length are less than a fraction of the max block weight and length, the fee multiplier is one,
/// and the extrinsic length is less than MAX_EXTRINSIC_LENGTH bytes, no fees are applied. Otherwise, it calculates the fee based on the length in bytes.
#[cfg(not(feature = "constant-fees"))]
fn weight_to_fee(length_in_bytes: &Weight) -> Self::Balance {
// The extrinsic overhead for a remark is approximately 110 bytes.
// This leaves 146 bytes available for the actual remark content.
const MAX_EXTRINSIC_LENGTH: u64 = 256;
const BYTES_PER_UNIT: u64 = 350;
const BASE_EXTRINSIC_LENGTH_COST: u64 = 5;
let weights = Runtime::BlockWeights::get();
let fee_multiplier = pallet_transaction_payment::Pallet::<Runtime>::next_fee_multiplier();
let normal_max_weight = weights
.get(DispatchClass::Normal)
.max_total
.unwrap_or(weights.max_block);
let current_block_weight = <frame_system::Pallet<Runtime>>::block_weight();
let length = Runtime::BlockLength::get();
let normal_max_length = *length.max.get(DispatchClass::Normal) as u64;
let current_block_length = <frame_system::Pallet<Runtime>>::all_extrinsics_len() as u64;
if current_block_weight
.get(DispatchClass::Normal)
.all_lt(Target::get() * normal_max_weight)
&& current_block_length < (Target::get() * normal_max_length)
&& fee_multiplier.is_one()
&& length_in_bytes.ref_time() < MAX_EXTRINSIC_LENGTH
{
0u32.into()
} else {
Self::Balance::saturated_from(
length_in_bytes.ref_time() / BYTES_PER_UNIT + BASE_EXTRINSIC_LENGTH_COST,
)
}
}
/// Function to convert weight to fee when "constant-fees" feature is enabled.
///
/// This function always returns a constant fee of zero when the "constant-fees" feature is enabled.
#[cfg(feature = "constant-fees")]
fn weight_to_fee(_length_in_bytes: &Weight) -> Self::Balance {
0u32.into()
}
}
/// A structure to implement Weight to Fee conversion.
/// - `Balance`: The balance type.
/// - `Runtime`: The system configuration type, providing access to block weights.
/// - `Target`: A type providing the target block fullness.
pub struct WeightToFeeImpl<Balance, Runtime, Target>(
PhantomData<Balance>,
PhantomData<Runtime>,
PhantomData<Target>,
);
/// Trait implementation for converting transaction weight to fee.
///
/// This implementation is only included when the "constant-fees" feature is not enabled.
#[cfg(not(feature = "constant-fees"))]
impl<Balance, Runtime, Target> WeightToFeePolynomial for WeightToFeeImpl<Balance, Runtime, Target>
where
Balance: BaseArithmetic + From<u64> + Copy + Unsigned + From<u32> + MultiplyRational,
Runtime: frame_system::Config + pallet_transaction_payment::Config,
Target: Get<Perquintill>,
{
type Balance = Balance;
/// Function to get the polynomial coefficients for weight to fee conversion.
///
/// This function calculates the polynomial coefficients for converting transaction weight to fee.
/// If the current block weight and length are less than a fraction of the block max weight and length, and the fee multiplier is one,
/// it returns zero. Otherwise, it calculates the coefficients based on the extrinsic base weight mapped to 5 cents.
fn polynomial() -> WeightToFeeCoefficients<Self::Balance> {
let weights = Runtime::BlockWeights::get();
let fee_multiplier = pallet_transaction_payment::Pallet::<Runtime>::next_fee_multiplier();
let normal_max_weight = weights
.get(DispatchClass::Normal)
.max_total
.unwrap_or(weights.max_block);
let current_block_weight = <frame_system::Pallet<Runtime>>::block_weight();
let length = Runtime::BlockLength::get();
let normal_max_length = *length.max.get(DispatchClass::Normal) as u64;
let current_block_length = <frame_system::Pallet<Runtime>>::all_extrinsics_len() as u64;
if current_block_weight
.get(DispatchClass::Normal)
.all_lt(Target::get() * normal_max_weight)
&& current_block_length < (Target::get() * normal_max_length)
&& fee_multiplier.is_one()
{
smallvec![WeightToFeeCoefficient {
degree: 1,
negative: false,
coeff_frac: Perbill::zero(),
coeff_integer: Self::Balance::zero(),
}]
} else {
// The extrinsic base weight (smallest non-zero weight) is mapped to 5 cents
const BASE_EXTRINSIC_WEIGHT_COST: u64 = 5;
let p: Self::Balance = BASE_EXTRINSIC_WEIGHT_COST.into();
let q: Self::Balance =
Self::Balance::from(weights.get(DispatchClass::Normal).base_extrinsic.ref_time());
smallvec![WeightToFeeCoefficient {
degree: 1,
negative: false,
coeff_frac: Perbill::from_rational(p % q, q),
coeff_integer: p / q,
}]
}
}
}
/// Trait implementation for converting transaction weight to a constant fee.
///
/// This implementation is only included when the "constant-fees" feature is enabled.
#[cfg(feature = "constant-fees")]
impl<Balance, Runtime, Target> WeightToFee for WeightToFeeImpl<Balance, Runtime, Target>
where
Balance: BaseArithmetic + From<u32> + Copy + Unsigned,
{
type Balance = Balance;
fn weight_to_fee(_weight: &Weight) -> Self::Balance {
1u32.into()
}
}
/// A structure to implement fee multiplier adjustments.
///
/// - `Runtime`: The system configuration type.
/// - `Target`: A type providing the target block fullness.
/// - `MaxMultiplier`: A type providing the maximum multiplier value.
pub struct FeeMultiplier<Runtime, Target, MaxMultiplier>(
PhantomData<Runtime>,
PhantomData<Target>,
PhantomData<MaxMultiplier>,
);
/// Trait implementation for updating the fee multiplier.
impl<Runtime, Target, MaxMultiplier> MultiplierUpdate
for FeeMultiplier<Runtime, Target, MaxMultiplier>
where
Runtime: frame_system::Config,
Target: Get<Perquintill>,
MaxMultiplier: Get<Multiplier>,
{
fn min() -> Multiplier {
0.into()
}
fn max() -> Multiplier {
MaxMultiplier::get()
}
fn target() -> Perquintill {
Target::get()
}
fn variability() -> Multiplier {
Default::default()
}
}
/// Trait implementation for converting previous `Multiplier` to another for fee adjustment.
impl<Runtime, Target, MaxMultiplier> Convert<Multiplier, Multiplier>
for FeeMultiplier<Runtime, Target, MaxMultiplier>
where
Runtime: frame_system::Config,
Target: Get<Perquintill>,
MaxMultiplier: Get<Multiplier>,
{
/// Function to convert the previous fee multiplier to a new fee multiplier.
///
/// This function adjusts the fee multiplier based on the current block weight, length and target block fullness.
/// - If the current block weight and length are less than the target, it decreases the multiplier by one, with a minimum of one.
/// - If the current block weight or length is more than the target, it increases the multiplier by one, up to the maximum multiplier.
#[cfg(not(feature = "constant-fees"))]
fn convert(previous: Multiplier) -> Multiplier {
let max_multiplier = MaxMultiplier::get();
let target_block_fullness = Target::get();
let weights = Runtime::BlockWeights::get();
let normal_max_weight = weights
.get(DispatchClass::Normal)
.max_total
.unwrap_or(weights.max_block);
let length = Runtime::BlockLength::get();
let normal_max_length = *length.max.get(DispatchClass::Normal) as u64;
let current_block_length = <frame_system::Pallet<Runtime>>::all_extrinsics_len() as u64;
if <frame_system::Pallet<Runtime>>::block_weight()
.get(DispatchClass::Normal)
.all_lt(target_block_fullness * normal_max_weight)
&& current_block_length < (target_block_fullness * normal_max_length)
{
// If the current block weight and length are less than the target, keep the
// multiplier at the minimum or decrease it by one to slowly
// return to the minimum.
previous.saturating_sub(1.into()).max(1.into())
} else {
// If the current block weight or length is more than the target, increase
// the multiplier by one.
previous.saturating_add(1.into()).min(max_multiplier)
}
}
/// Function to convert the previous fee multiplier to a constant fee multiplier when "constant-fees" feature is enabled.
///
/// This function always returns a constant multiplier of 1 when the "constant-fees" feature is enabled.
#[cfg(feature = "constant-fees")]
fn convert(_previous: Multiplier) -> Multiplier {
1.into()
}
}
// 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 super::{entities::*, AccountId, IdtyIndex};
use frame_support::{
pallet_prelude::Weight,
traits::{Imbalance, UnfilteredDispatchable},
};
use frame_system::pallet_prelude::BlockNumberFor;
use pallet_smith_members::SmithRemovalReason;
use sp_core::Get;
/// OnNewSession handler for the runtime calling all the implementation
/// of OnNewSession
pub struct OnNewSessionHandler<Runtime>(core::marker::PhantomData<Runtime>);
impl<Runtime> pallet_authority_members::traits::OnNewSession for OnNewSessionHandler<Runtime>
where
Runtime: pallet_provide_randomness::Config + pallet_smith_members::Config,
{
fn on_new_session(index: sp_staking::SessionIndex) {
pallet_provide_randomness::Pallet::<Runtime>::on_new_epoch();
pallet_smith_members::Pallet::<Runtime>::on_new_session(index);
}
}
/// Runtime handler for OnNewIdty, calling all implementations of
/// OnNewIdty and implementing logic at the runtime level.
pub struct OnNewIdtyHandler<Runtime>(core::marker::PhantomData<Runtime>);
impl<Runtime: pallet_duniter_wot::Config> pallet_identity::traits::OnNewIdty<Runtime>
for OnNewIdtyHandler<Runtime>
{
fn on_created(idty_index: &IdtyIndex, creator: &IdtyIndex) {
pallet_duniter_wot::Pallet::<Runtime>::on_created(idty_index, creator);
}
}
/// Runtime handler for OnRemoveIdty, calling all implementations of
/// OnRemoveIdty and implementing logic at the runtime level.
pub struct OnRemoveIdtyHandler<Runtime>(core::marker::PhantomData<Runtime>);
impl<Runtime: pallet_duniter_wot::Config + pallet_duniter_account::Config>
pallet_identity::traits::OnRemoveIdty<Runtime> for OnRemoveIdtyHandler<Runtime>
{
fn on_removed(idty_index: &IdtyIndex) -> Weight {
pallet_duniter_wot::Pallet::<Runtime>::on_removed(idty_index)
}
fn on_revoked(idty_index: &IdtyIndex) -> Weight {
pallet_duniter_wot::Pallet::<Runtime>::on_revoked(idty_index).saturating_add(
pallet_duniter_account::Pallet::<Runtime>::on_revoked(idty_index),
)
}
}
/// Runtime handler for OnNewMembership, calling all implementations of
/// OnNewMembership and implementing logic at the runtime level.
pub struct OnNewMembershipHandler<Runtime>(core::marker::PhantomData<Runtime>);
impl<
Runtime: frame_system::Config<AccountId = AccountId>
+ pallet_identity::Config<IdtyData = IdtyData, IdtyIndex = IdtyIndex>
+ pallet_duniter_wot::Config
+ pallet_universal_dividend::Config
+ pallet_quota::Config,
> sp_membership::traits::OnNewMembership<IdtyIndex> for OnNewMembershipHandler<Runtime>
{
fn on_created(idty_index: &IdtyIndex) {
// duniter-wot related actions
pallet_duniter_wot::Pallet::<Runtime>::on_created(idty_index);
pallet_quota::Pallet::<Runtime>::on_created(idty_index);
// When main membership is acquired, it starts getting right to UD.
pallet_identity::Identities::<Runtime>::mutate_exists(idty_index, |idty_val_opt| {
if let Some(ref mut idty_val) = idty_val_opt {
idty_val.data = IdtyData {
first_eligible_ud:
pallet_universal_dividend::Pallet::<Runtime>::init_first_eligible_ud(),
};
}
});
}
fn on_renewed(_idty_index: &IdtyIndex) {}
}
/// Runtime handler for OnRemoveMembership, calling all implementations of
///
/// OnRemoveMembership and implementing logic at the runtime level.
/// As the weight accounting is not trivial in this handler, the weight is
/// done at the handler level.
pub struct OnRemoveMembershipHandler<Runtime>(core::marker::PhantomData<Runtime>);
impl<
Runtime: frame_system::Config
+ pallet_identity::Config<IdtyData = IdtyData, IdtyIndex = IdtyIndex>
+ pallet_smith_members::Config<IdtyIndex = IdtyIndex>
+ pallet_duniter_wot::Config
+ pallet_quota::Config
+ pallet_universal_dividend::Config,
> sp_membership::traits::OnRemoveMembership<IdtyIndex> for OnRemoveMembershipHandler<Runtime>
{
fn on_removed(idty_index: &IdtyIndex) -> Weight {
// duniter-wot related actions
let mut weight = pallet_duniter_wot::Pallet::<Runtime>::on_removed(idty_index);
// When membership is removed:
// - call on_removed_member handler which auto claims UD;
// - set the first_eligible_ud to None so the identity cannot claim UD anymore.
pallet_identity::Identities::<Runtime>::mutate(idty_index, |maybe_idty_value| {
if let Some(idty_value) = maybe_idty_value {
if let Some(first_ud_index) = idty_value.data.first_eligible_ud.0.take() {
weight += pallet_universal_dividend::Pallet::<Runtime>::on_removed_member(
first_ud_index.into(),
&idty_value.owner_key,
);
}
}
});
weight.saturating_add(pallet_quota::Pallet::<Runtime>::on_removed(idty_index));
weight.saturating_add(Runtime::DbWeight::get().reads_writes(1, 1));
// When membership is removed, also remove from smith member.
weight.saturating_add(
pallet_smith_members::Pallet::<Runtime>::on_removed_wot_member(*idty_index),
)
}
}
/// Runtime handler for TreasurySpendFunds.
pub struct TreasurySpendFunds<Runtime>(core::marker::PhantomData<Runtime>);
impl<Runtime> pallet_treasury::SpendFunds<Runtime> for TreasurySpendFunds<Runtime>
where
Runtime: pallet_treasury::Config,
{
fn spend_funds(
_budget_remaining: &mut pallet_treasury::BalanceOf<Runtime>,
_imbalance: &mut pallet_treasury::PositiveImbalanceOf<Runtime>,
_total_weight: &mut Weight,
missed_any: &mut bool,
) {
*missed_any = true;
}
}
/// Runtime handler for OnSmithDelete.
pub struct OnSmithDeletedHandler<Runtime>(core::marker::PhantomData<Runtime>);
impl<Runtime> pallet_smith_members::traits::OnSmithDelete<Runtime::MemberId>
for OnSmithDeletedHandler<Runtime>
where
Runtime: pallet_authority_members::Config,
{
fn on_smith_delete(idty_index: Runtime::MemberId, _reason: SmithRemovalReason) {
let call = pallet_authority_members::Call::<Runtime>::remove_member {
member_id: idty_index,
};
if let Err(e) = call.dispatch_bypass_filter(frame_system::Origin::<Runtime>::Root.into()) {
#[cfg(feature = "std")]
println!("faid to remove member: {:?}", e)
}
}
}
/// Runtime handler OwnerKeyChangePermission.
pub struct KeyChangeHandler<Runtime, ReportLongevity>(
core::marker::PhantomData<(Runtime, ReportLongevity)>,
);
impl<
Runtime: frame_system::Config<AccountId = AccountId>
+ pallet_identity::Config<IdtyIndex = IdtyIndex>
+ pallet_authority_members::Config<MemberId = IdtyIndex>
+ pallet_smith_members::Config<IdtyIndex = IdtyIndex>,
ReportLongevity: Get<BlockNumberFor<Runtime>>,
> pallet_identity::traits::KeyChange<Runtime> for KeyChangeHandler<Runtime, ReportLongevity>
{
/// Handles the event when an identity's owner key is changed.
///
/// # Errors
/// * Returns `OwnerKeyInBound` if the smith was a validator and the bond period is not finished, meaning it can still be punished for past actions.
/// * Returns `OwnerKeyUsedAsValidator` if the owner key is currently used as a validator.
///
/// # Behavior
/// * If the smith is online, the operation is rejected.
/// * If the smith was a validator and is still within the bond period, the operation is rejected. It means they can still be punished for past actions.
/// * If the smith is neither online nor within the bond period, the owner key is changed successfully and the change is reflected in the validator member data if available.
fn on_changed(
idty_index: IdtyIndex,
account_id: AccountId,
) -> Result<(), sp_runtime::DispatchError> {
if let Some(smith) = pallet_smith_members::Pallet::<Runtime>::smiths(&idty_index) {
if let Some(last_online) = smith.last_online {
if last_online + ReportLongevity::get()
> frame_system::pallet::Pallet::<Runtime>::block_number()
{
return Err(pallet_identity::Error::<Runtime>::OwnerKeyInBound.into());
} else {
pallet_authority_members::Pallet::<Runtime>::change_owner_key(
idty_index, account_id,
)
.map_err(|e| e.error)?;
}
} else {
return Err(pallet_identity::Error::<Runtime>::OwnerKeyUsedAsValidator.into());
}
}
Ok(())
}
}
/// Runtime handler for managing fee handling by transferring unbalanced amounts to a treasury account.
pub struct HandleFees<TreasuryAccount, Balances>(
frame_support::pallet_prelude::PhantomData<(TreasuryAccount, Balances)>,
);
type CreditOf<Balances> = frame_support::traits::tokens::fungible::Credit<AccountId, Balances>;
impl<TreasuryAccount, Balances> frame_support::traits::OnUnbalanced<CreditOf<Balances>>
for HandleFees<TreasuryAccount, Balances>
where
TreasuryAccount: Get<AccountId>,
Balances: frame_support::traits::fungible::Balanced<AccountId>,
{
fn on_nonzero_unbalanced(amount: CreditOf<Balances>) {
// fee is moved to treasury
let _ = Balances::deposit(
&TreasuryAccount::get(),
amount.peek(),
frame_support::traits::tokens::Precision::Exact,
);
}
}
// 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/>.
#![cfg_attr(not(feature = "std"), no_std)]
mod apis;
mod benchmarks;
pub mod constants;
pub mod entities;
pub mod fees;
pub mod handlers;
mod offchain;
mod pallets_config;
pub mod providers;
pub use pallet_duniter_account::GenesisAccountData;
pub use pallet_identity::{GenesisIdty, IdtyName, IdtyStatus, IdtyValue};
pub use sp_runtime::OpaqueExtrinsic as UncheckedExtrinsic;
/// Some way of identifying an account on the chain. We intentionally make it equivalent
/// to the public key of our transaction signing scheme.
pub type AccountId = <<Signature as sp_runtime::traits::Verify>::Signer as sp_runtime::traits::IdentifyAccount>::AccountId;
/// The address format for describing accounts.
pub type Address = sp_runtime::MultiAddress<AccountId, ()>;
/// Balance of an account.
pub type Balance = u64;
/// Block type.
pub type Block = sp_runtime::generic::Block<Header, UncheckedExtrinsic>;
/// Block identifier type.
pub type BlockId = sp_runtime::generic::BlockId<Block>;
/// An index to a block.
pub type BlockNumber = u32;
/// A hash of some data used by the chain.
pub type Hash = sp_core::H256;
/// Block header type
pub type Header = sp_runtime::generic::Header<BlockNumber, sp_runtime::traits::BlakeTwo256>;
/// Index of a transaction in the chain.
pub type Index = u32;
/// Alias to 512-bit hash when used in the context of a transaction signature on the chain.
pub type Signature = sp_runtime::MultiSignature;
/// Index of an identity
pub type IdtyIndex = u32;
/// Time in milliseconds
pub type Moment = u64;
pub struct FullIdentificationOfImpl;
impl sp_runtime::traits::Convert<AccountId, Option<entities::ValidatorFullIdentification>>
for FullIdentificationOfImpl
{
fn convert(_: AccountId) -> Option<entities::ValidatorFullIdentification> {
Some(entities::ValidatorFullIdentification)
}
}
pub struct GetCurrentEpochIndex<Runtime>(core::marker::PhantomData<Runtime>);
impl<Runtime: pallet_babe::Config> frame_support::pallet_prelude::Get<u64>
for GetCurrentEpochIndex<Runtime>
{
fn get() -> u64 {
pallet_babe::Pallet::<Runtime>::epoch_index()
}
}
pub struct IdtyNameValidatorImpl;
impl pallet_identity::traits::IdtyNameValidator for IdtyNameValidatorImpl {
fn validate(idty_name: &pallet_identity::IdtyName) -> bool {
duniter_primitives::validate_idty_name(&idty_name.0)
}
}
// 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/>.
#[macro_export]
macro_rules! offchain_config {
() => {
impl<LocalCall> frame_system::offchain::CreateTransaction<LocalCall> for Runtime
where
RuntimeCall: From<LocalCall>,
{
type Extension = TxExtension;
fn create_transaction(call: RuntimeCall, extension: TxExtension) -> UncheckedExtrinsic {
generic::UncheckedExtrinsic::new_transaction(call, extension)
}
}
impl<LocalCall> frame_system::offchain::CreateInherent<LocalCall> for Runtime
where
RuntimeCall: From<LocalCall>,
{
fn create_inherent(call: RuntimeCall) -> UncheckedExtrinsic {
generic::UncheckedExtrinsic::new_bare(call)
}
}
impl<LocalCall> frame_system::offchain::CreateTransactionBase<LocalCall> for Runtime
where
RuntimeCall: From<LocalCall>,
{
type Extrinsic = UncheckedExtrinsic;
type RuntimeCall = RuntimeCall;
}
};
}
// 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/>.
#[macro_export]
macro_rules! pallets_config {
() => {
// SYSTEM //
parameter_types! {
pub const Version: RuntimeVersion = VERSION;
}
impl frame_system::Config for Runtime {
/// The data to be stored in an account.
type AccountData = pallet_duniter_account::AccountData<Balance, IdtyIndex>;
/// The identifier used to distinguish between accounts.
type AccountId = AccountId;
/// The basic call filter to use in dispatchable.
type BaseCallFilter = BaseCallFilter;
/// The block type for the runtime.
type Block = Block;
/// Maximum number of block number to block hash mappings to keep (oldest pruned first).
type BlockHashCount = BlockHashCount;
/// The maximum length of a block (in bytes).
type BlockLength = BlockLength;
/// Block & extrinsics weights: base values and limits.
type BlockWeights = BlockWeights;
/// The weight of database operations that the runtime can invoke.
type DbWeight = DbWeight;
/// The weight of transaction extensions.
type ExtensionsWeightInfo = weights::frame_system_extensions::WeightInfo<Runtime>;
/// The type for hashing blocks and tries.
type Hash = Hash;
/// The hashing algorithm used.
type Hashing = BlakeTwo256;
/// The lookup mechanism to get account ID from whatever is passed in dispatchers.
type Lookup = AccountIdLookup<AccountId, ()>;
type MaxConsumers = frame_support::traits::ConstU32<16>;
type MultiBlockMigrator = ();
/// The type for storing how many extrinsics an account has signed.
type Nonce = node_primitives::Nonce;
/// What to do if an account is fully reaped from the system.
type OnKilledAccount = ();
/// What to do if a new account is created.
type OnNewAccount = ();
/// The set code logic, just the default since we're not a parachain.
type OnSetCode = ();
/// Converts a module to the index of the module in `construct_runtime!`.
///
/// This type is being generated by `construct_runtime!`.
type PalletInfo = PalletInfo;
type PostInherents = ();
type PostTransactions = ();
type PreInherents = ();
/// The aggregated dispatch type that is available for extrinsics.
type RuntimeCall = RuntimeCall;
/// The ubiquitous event type.
type RuntimeEvent = RuntimeEvent;
/// The ubiquitous origin type.
type RuntimeOrigin = RuntimeOrigin;
type RuntimeTask = ();
/// This is used as an identifier of the chain. 42 is the generic substrate prefix.
type SS58Prefix = SS58Prefix;
type SingleBlockMigrations = ();
/// Weight information for the extrinsics of this pallet.
type SystemWeightInfo = weights::frame_system::WeightInfo<Runtime>;
/// Version of the runtime.
type Version = Version;
}
// SCHEDULER //
parameter_types! {
pub MaximumSchedulerWeight: Weight = Perbill::from_percent(80) *
BlockWeights::get().max_block;
pub const MaxScheduledPerBlock: u32 = 50;
pub const NoPreimagePostponement: Option<u32> = Some(10);
}
impl pallet_scheduler::Config for Runtime {
type BlockNumberProvider = frame_system::Pallet<Runtime>;
type MaxScheduledPerBlock = MaxScheduledPerBlock;
type MaximumWeight = MaximumSchedulerWeight;
type OriginPrivilegeCmp = EqualPrivilegeOnly;
type PalletsOrigin = OriginCaller;
type Preimages = Preimage;
type RuntimeCall = RuntimeCall;
type RuntimeEvent = RuntimeEvent;
type RuntimeOrigin = RuntimeOrigin;
type ScheduleOrigin = EnsureRoot<AccountId>;
type WeightInfo = weights::pallet_scheduler::WeightInfo<Runtime>;
}
// ACCOUNT //
impl pallet_duniter_account::Config for Runtime {
// does currency adapter in any case, but adds "refund with quota" feature
type InnerOnChargeTransaction =
FungibleAdapter<Balances, HandleFees<TreasuryAccount, Balances>>;
type Refund = Quota;
type RuntimeEvent = RuntimeEvent;
type WeightInfo = weights::pallet_duniter_account::WeightInfo<Runtime>;
}
parameter_types! {
pub const ReloadRate: BlockNumber = 1 * HOURS; // faster than DAYS
pub const MaxQuota: Balance = 1000; // 10 ĞD
pub const MaxNominators: u32 = 64;
pub TreasuryAccount: AccountId = Treasury::account_id();
}
impl pallet_quota::Config for Runtime {
type MaxQuota = MaxQuota;
type RefundAccount = TreasuryAccount;
type ReloadRate = ReloadRate;
type RuntimeEvent = RuntimeEvent;
type WeightInfo = weights::pallet_quota::WeightInfo<Runtime>;
}
// BLOCK CREATION //
impl pallet_babe::Config for Runtime {
type DisabledValidators = Session;
// session module is the trigger
type EpochChangeTrigger = pallet_babe::ExternalTrigger;
type EpochDuration = EpochDuration;
type EquivocationReportSystem =
pallet_babe::EquivocationReportSystem<Self, Offences, Historical, ReportLongevity>;
type ExpectedBlockTime = ExpectedBlockTime;
type KeyOwnerProof =
<Historical as KeyOwnerProofSystem<(KeyTypeId, pallet_babe::AuthorityId)>>::Proof;
type MaxAuthorities = MaxAuthorities;
type MaxNominators = MaxNominators;
type WeightInfo = weights::pallet_babe::WeightInfo<Runtime>;
}
impl pallet_timestamp::Config for Runtime {
type MinimumPeriod = MinimumPeriod;
type Moment = u64;
type OnTimestampSet = (Babe, UniversalDividend);
type WeightInfo = weights::pallet_timestamp::WeightInfo<Runtime>;
}
// MONEY MANAGEMENT //
impl pallet_balances::Config for Runtime {
type AccountStore = Account;
type Balance = Balance;
type DoneSlashHandler = ();
type DustRemoval = HandleFees<TreasuryAccount, Balances>;
type ExistentialDeposit = ExistentialDeposit;
type FreezeIdentifier = ();
type MaxFreezes = frame_support::pallet_prelude::ConstU32<0>;
type MaxLocks = MaxLocks;
type MaxReserves = frame_support::pallet_prelude::ConstU32<5>;
type ReserveIdentifier = [u8; 8];
type RuntimeEvent = RuntimeEvent;
type RuntimeFreezeReason = ();
type RuntimeHoldReason = RuntimeHoldReason;
type WeightInfo = weights::pallet_balances::WeightInfo<Runtime>;
}
parameter_types! {
pub Target: Perquintill = Perquintill::from_percent(25);
pub MaxMultiplier: sp_runtime::FixedU128 = 10.into();
}
impl pallet_transaction_payment::Config for Runtime {
type FeeMultiplierUpdate =
common_runtime::fees::FeeMultiplier<Self, Target, MaxMultiplier>;
type LengthToFee = common_runtime::fees::LengthToFeeImpl<Balance, Self, Target>;
// does a filter on the call
type OnChargeTransaction = OneshotAccount;
type OperationalFeeMultiplier = frame_support::traits::ConstU8<5>;
type RuntimeEvent = RuntimeEvent;
type WeightInfo = weights::pallet_transaction_payment::WeightInfo<Runtime>;
type WeightToFee = common_runtime::fees::WeightToFeeImpl<Balance, Self, Target>;
}
impl pallet_oneshot_account::Config for Runtime {
type Currency = Balances;
// when call is not oneshot account, fall back to duniter-account implementation
type InnerOnChargeTransaction = Account;
type RuntimeEvent = RuntimeEvent;
type WeightInfo = weights::pallet_oneshot_account::WeightInfo<Runtime>;
}
// CONSENSUS //
impl pallet_authority_discovery::Config for Runtime {
type MaxAuthorities = MaxAuthorities;
}
impl pallet_authority_members::Config for Runtime {
type IsMember = SmithMembers;
type MaxAuthorities = MaxAuthorities;
type MemberId = IdtyIndex;
type MemberIdOf = common_runtime::providers::IdentityIndexOf<Self>;
type OnIncomingMember = SmithMembers;
type OnNewSession = OnNewSessionHandler<Runtime>;
type OnOutgoingMember = SmithMembers;
type RemoveMemberOrigin = EnsureRoot<Self::AccountId>;
type RuntimeEvent = RuntimeEvent;
type WeightInfo = weights::pallet_authority_members::WeightInfo<Runtime>;
}
impl pallet_authorship::Config for Runtime {
type EventHandler = ImOnline;
type FindAuthor = pallet_session::FindAccountFromAuthorIndex<Self, Babe>;
}
impl pallet_im_online::Config for Runtime {
type AuthorityId = ImOnlineId;
#[cfg(not(feature = "runtime-benchmarks"))]
type MaxKeys = MaxAuthorities;
#[cfg(feature = "runtime-benchmarks")]
type MaxKeys = frame_support::traits::ConstU32<1_000>;
type MaxPeerInHeartbeats = MaxPeerInHeartbeats;
type NextSessionRotation = Babe;
type ReportUnresponsiveness = Offences;
type RuntimeEvent = RuntimeEvent;
type UnsignedPriority = ImOnlineUnsignedPriority;
type ValidatorSet = Historical;
type WeightInfo = weights::pallet_im_online::WeightInfo<Runtime>;
}
impl pallet_offences::Config for Runtime {
type IdentificationTuple = pallet_session::historical::IdentificationTuple<Self>;
type OnOffenceHandler = AuthorityMembers;
type RuntimeEvent = RuntimeEvent;
}
impl pallet_session::Config for Runtime {
type DisablingStrategy =
pallet_session::disabling::UpToLimitWithReEnablingDisablingStrategy;
type Keys = opaque::SessionKeys;
type NextSessionRotation = Babe;
type RuntimeEvent = RuntimeEvent;
type SessionHandler = <opaque::SessionKeys as OpaqueKeys>::KeyTypeIdProviders;
type SessionManager =
pallet_session::historical::NoteHistoricalRoot<Self, AuthorityMembers>;
type ShouldEndSession = Babe;
type ValidatorId = AccountId;
type ValidatorIdOf = sp_runtime::traits::ConvertInto;
type WeightInfo = weights::pallet_session::WeightInfo<Runtime>;
}
impl pallet_session::historical::Config for Runtime {
type FullIdentification = ValidatorFullIdentification;
type FullIdentificationOf = FullIdentificationOfImpl;
}
impl pallet_grandpa::Config for Runtime {
type EquivocationReportSystem = pallet_grandpa::EquivocationReportSystem<
Self,
Offences,
Historical,
ReportLongevity,
>;
type KeyOwnerProof = <Historical as KeyOwnerProofSystem<(KeyTypeId, GrandpaId)>>::Proof;
type MaxAuthorities = MaxAuthorities;
type MaxNominators = frame_support::traits::ConstU32<64>;
type MaxSetIdSessionEntries = MaxSetIdSessionEntries;
type RuntimeEvent = RuntimeEvent;
type WeightInfo = weights::pallet_grandpa::WeightInfo<Runtime>;
}
parameter_types! {
// BondingDuration::get() * SessionsPerEra::get();
pub const MaxSetIdSessionEntries: u32 = 1000;
}
// ONCHAIN GOVERNANCE //
#[cfg(feature = "runtime-benchmarks")]
parameter_types! {
pub const WorstCaseOrigin: WorstOrigin = WorstOrigin::Members(2, 3);
}
impl pallet_upgrade_origin::Config for Runtime {
type Call = RuntimeCall;
type RuntimeEvent = RuntimeEvent;
type UpgradableOrigin = pallet_collective::EnsureProportionAtLeast<
AccountId,
TechnicalCommitteeInstance,
2,
3,
>;
type WeightInfo = weights::pallet_upgrade_origin::WeightInfo<Runtime>;
#[cfg(feature = "runtime-benchmarks")]
type WorstCaseOrigin = WorstCaseOrigin;
#[cfg(feature = "runtime-benchmarks")]
type WorstCaseOriginType = RawOrigin<AccountId, TechnicalCommitteeInstance>;
}
parameter_types! {
pub const PreimageMaxSize: u32 = 4096 * 1024;
pub const PreimageBaseDeposit: Balance = deposit(2, 64);
pub const PreimageByteDeposit: Balance = deposit(0, 1);
}
impl pallet_preimage::Config for Runtime {
type Consideration = ();
type Currency = Balances;
type ManagerOrigin = EnsureRoot<AccountId>;
type RuntimeEvent = RuntimeEvent;
type WeightInfo = weights::pallet_preimage::WeightInfo<Runtime>;
}
// UTILITIES //
impl pallet_atomic_swap::Config for Runtime {
type ProofLimit = frame_support::traits::ConstU32<1_024>;
type RuntimeEvent = RuntimeEvent;
type SwapAction = pallet_atomic_swap::BalanceSwapAction<AccountId, Balances>;
}
impl pallet_provide_randomness::Config for Runtime {
type Currency = Balances;
type GetCurrentEpochIndex = GetCurrentEpochIndex<Self>;
type MaxRequests = frame_support::traits::ConstU32<100>;
type OnFilledRandomness = ();
type OnUnbalanced = HandleFees<TreasuryAccount, Balances>;
type ParentBlockRandomness = pallet_babe::ParentBlockRandomness<Self>;
type RandomnessFromOneEpochAgo = pallet_babe::RandomnessFromOneEpochAgo<Self>;
type RequestPrice = frame_support::traits::ConstU64<2_000>;
type RuntimeEvent = RuntimeEvent;
type WeightInfo = weights::pallet_provide_randomness::WeightInfo<Runtime>;
}
parameter_types! {
// One storage item; key size 32, value size 8; .
pub const ProxyDepositBase: Balance = deposit(1, 8);
// Additional storage item size of 33 bytes.
pub const ProxyDepositFactor: Balance = deposit(0, 33);
pub const AnnouncementDepositBase: Balance = deposit(1, 8);
pub const AnnouncementDepositFactor: Balance = deposit(0, 66);
}
impl pallet_proxy::Config for Runtime {
type AnnouncementDepositBase = AnnouncementDepositBase;
type AnnouncementDepositFactor = AnnouncementDepositFactor;
type BlockNumberProvider = frame_system::Pallet<Runtime>;
type CallHasher = BlakeTwo256;
type Currency = Balances;
type MaxPending = frame_support::traits::ConstU32<32>;
type MaxProxies = frame_support::traits::ConstU32<32>;
type ProxyDepositBase = ProxyDepositBase;
type ProxyDepositFactor = ProxyDepositFactor;
type ProxyType = ProxyType;
type RuntimeCall = RuntimeCall;
type RuntimeEvent = RuntimeEvent;
type WeightInfo = weights::pallet_proxy::WeightInfo<Runtime>;
}
parameter_types! {
pub const DepositBase: Balance = DEPOSIT_PER_ITEM;
pub const DepositFactor: Balance = DEPOSIT_PER_BYTE * 32;
}
impl pallet_multisig::Config for Runtime {
type BlockNumberProvider = frame_system::Pallet<Runtime>;
type Currency = Balances;
type DepositBase = DepositBase;
type DepositFactor = DepositFactor;
type MaxSignatories = MaxSignatories;
type RuntimeCall = RuntimeCall;
type RuntimeEvent = RuntimeEvent;
type WeightInfo = weights::pallet_multisig::WeightInfo<Runtime>;
}
impl pallet_utility::Config for Runtime {
type PalletsOrigin = OriginCaller;
type RuntimeCall = RuntimeCall;
type RuntimeEvent = RuntimeEvent;
type WeightInfo = weights::pallet_utility::WeightInfo<Runtime>;
}
parameter_types! {
pub const Burn: Permill = Permill::zero();
pub const ProposalBond: Permill = Permill::from_percent(1);
pub const ProposalBondMaximum: Option<Balance> = None;
pub const SpendPeriod: BlockNumber = DAYS;
// Treasury account address:
// gdev/gtest: 5EYCAe5ijiYfyeZ2JJCGq56LmPyNRAKzpG4QkoQkkQNB5e6Z
pub const TreasuryPalletId: PalletId = PalletId(*b"py/trsry");
}
impl pallet_treasury::Config for Runtime {
type AssetKind = ();
type BalanceConverter = frame_support::traits::tokens::UnityAssetBalanceConversion;
#[cfg(feature = "runtime-benchmarks")]
type BenchmarkHelper = ();
type Beneficiary = AccountId;
type BeneficiaryLookup = AccountIdLookup<AccountId, ()>;
type BlockNumberProvider = System;
type Burn = Burn;
type BurnDestination = ();
type Currency = Balances;
type MaxApprovals = frame_support::traits::ConstU32<100>;
type PalletId = TreasuryPalletId;
type Paymaster =
frame_support::traits::tokens::pay::PayFromAccount<Balances, TreasuryAccount>;
type PayoutPeriod = sp_core::ConstU32<10>;
type RejectOrigin = TreasuryRejectOrigin;
type RuntimeEvent = RuntimeEvent;
type SpendFunds = TreasurySpendFunds<Self>;
type SpendOrigin = frame_support::traits::NeverEnsureOrigin<Balance>;
type SpendPeriod = SpendPeriod;
type WeightInfo = weights::pallet_treasury::WeightInfo<Runtime>;
}
// UNIVERSAL DIVIDEND //
impl pallet_universal_dividend::Config for Runtime {
type Currency = Balances;
#[cfg(feature = "runtime-benchmarks")]
type IdtyAttr = Identity;
type MaxPastReeval = frame_support::traits::ConstU32<160>;
type MembersCount = common_runtime::providers::MembersCount<Membership>;
type MembersStorage = common_runtime::providers::UdMembersStorage<Runtime>;
type MomentIntoBalance = sp_runtime::traits::ConvertInto;
type RuntimeEvent = RuntimeEvent;
type SquareMoneyGrowthRate = SquareMoneyGrowthRate;
type UdCreationPeriod = UdCreationPeriod;
type UdReevalPeriod = UdReevalPeriod;
type WeightInfo = weights::pallet_universal_dividend::WeightInfo<Runtime>;
}
// WEB OF TRUST //
impl pallet_duniter_wot::Config for Runtime {
type FirstIssuableOn = WotFirstCertIssuableOn;
type MinCertForCreateIdtyRight = WotMinCertForCreateIdtyRight;
type MinCertForMembership = WotMinCertForMembership;
}
parameter_types! {
pub const ValidationPeriod: BlockNumber = 2 * MONTHS;
}
impl pallet_identity::Config for Runtime {
type AccountId32 = AccountId;
type AccountLinker = Account;
type AutorevocationPeriod = AutorevocationPeriod;
type ChangeOwnerKeyPeriod = ChangeOwnerKeyPeriod;
type CheckAccountWorthiness = Account;
type CheckIdtyCallAllowed = Wot;
type ConfirmPeriod = ConfirmPeriod;
type DeletionPeriod = DeletionPeriod;
type IdtyCreationPeriod = IdtyCreationPeriod;
type IdtyData = IdtyData;
type IdtyIndex = IdtyIndex;
type IdtyNameValidator = IdtyNameValidatorImpl;
type OnKeyChange = KeyChangeHandler<Runtime, ReportLongevity>;
type OnNewIdty = OnNewIdtyHandler<Runtime>;
type OnRemoveIdty = OnRemoveIdtyHandler<Runtime>;
type RuntimeEvent = RuntimeEvent;
type Signature = Signature;
type Signer = <Signature as sp_runtime::traits::Verify>::Signer;
type ValidationPeriod = ValidationPeriod;
type WeightInfo = weights::pallet_identity::WeightInfo<Runtime>;
}
impl pallet_sudo::Config for Runtime {
type RuntimeCall = RuntimeCall;
type RuntimeEvent = RuntimeEvent;
type WeightInfo = weights::pallet_sudo::WeightInfo<Runtime>;
}
impl pallet_membership::Config for Runtime {
#[cfg(feature = "runtime-benchmarks")]
type BenchmarkSetupHandler = common_runtime::providers::BenchmarkSetupHandler<Runtime>;
type CheckMembershipOpAllowed = Wot;
type IdtyAttr = Identity;
type IdtyId = IdtyIndex;
type MembershipPeriod = MembershipPeriod;
type MembershipRenewalPeriod = MembershipRenewalPeriod;
type OnNewMembership = OnNewMembershipHandler<Runtime>;
type OnRemoveMembership = OnRemoveMembershipHandler<Runtime>;
type RuntimeEvent = RuntimeEvent;
type WeightInfo = weights::pallet_membership::WeightInfo<Runtime>;
}
impl pallet_certification::Config for Runtime {
type CertPeriod = CertPeriod;
type CheckCertAllowed = Wot;
type IdtyAttr = Identity;
type IdtyIndex = IdtyIndex;
type MaxByIssuer = MaxByIssuer;
type MinReceivedCertToBeAbleToIssueCert = MinReceivedCertToBeAbleToIssueCert;
type OnNewcert = Wot;
type OnRemovedCert = Wot;
type RuntimeEvent = RuntimeEvent;
type ValidityPeriod = ValidityPeriod;
type WeightInfo = weights::pallet_certification::WeightInfo<Runtime>;
}
impl pallet_distance::Config for Runtime {
type CheckRequestDistanceEvaluation = Wot;
type Currency = Balances;
type EvaluationPeriod = frame_support::traits::ConstU32<7>;
type EvaluationPrice = frame_support::traits::ConstU64<1000>;
type MaxRefereeDistance = MaxRefereeDistance;
type MinAccessibleReferees = MinAccessibleReferees;
type OnUnbalanced = HandleFees<TreasuryAccount, Balances>;
type OnValidDistanceStatus = Wot;
type RuntimeEvent = RuntimeEvent;
type RuntimeHoldReason = RuntimeHoldReason;
type WeightInfo = weights::pallet_distance::WeightInfo<Runtime>;
}
// SMITH-MEMBERS
impl pallet_smith_members::Config for Runtime {
type IdtyAttr = Identity;
type IdtyIdOfAuthorityId = sp_runtime::traits::ConvertInto;
type IdtyIndex = IdtyIndex;
type IsWoTMember = common_runtime::providers::IsWoTMemberProvider<Runtime>;
type MaxByIssuer = SmithMaxByIssuer;
type MemberId = IdtyIndex;
type MinCertForMembership = SmithWotMinCertForMembership;
type OnSmithDelete = OnSmithDeletedHandler<Runtime>;
type RuntimeEvent = RuntimeEvent;
type SmithInactivityMaxDuration = SmithInactivityMaxDuration;
type WeightInfo = weights::pallet_smith_members::WeightInfo<Runtime>;
}
pub struct TechnicalCommitteeDefaultVote;
impl pallet_collective::DefaultVote for TechnicalCommitteeDefaultVote {
fn default_vote(
_prime_vote: Option<bool>,
_yes_votes: u32,
_no_votes: u32,
_len: u32,
) -> bool {
false
}
}
parameter_types! {
pub const TechnicalCommitteeMotionDuration: BlockNumber = 7 * DAYS;
pub MaxWeight: Weight = Perbill::from_percent(50) * BlockWeights::get().max_block;
}
impl pallet_collective::Config<Instance2> for Runtime {
type Consideration = ();
#[cfg(not(feature = "runtime-benchmarks"))]
type DefaultVote = TechnicalCommitteeDefaultVote;
#[cfg(feature = "runtime-benchmarks")]
type DefaultVote = pallet_collective::PrimeDefaultVote;
type DisapproveOrigin = EnsureRoot<Self::AccountId>;
type KillOrigin = EnsureRoot<Self::AccountId>;
type MaxMembers = frame_support::pallet_prelude::ConstU32<100>;
type MaxProposalWeight = MaxWeight;
type MaxProposals = frame_support::pallet_prelude::ConstU32<20>;
type MotionDuration = TechnicalCommitteeMotionDuration;
type Proposal = RuntimeCall;
type RuntimeEvent = RuntimeEvent;
type RuntimeOrigin = RuntimeOrigin;
type SetMembersOrigin = EnsureRoot<AccountId>;
type WeightInfo = weights::pallet_collective::WeightInfo<Runtime>;
}
};
}
// 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::{entities::IdtyData, AccountId, Balance, IdtyIndex};
use core::marker::PhantomData;
use pallet_universal_dividend::FirstEligibleUd;
/// A provider for converting IdtyIndex to associated AccountId.
pub struct IdentityAccountIdProvider<Runtime>(PhantomData<Runtime>);
impl<Runtime> sp_runtime::traits::Convert<IdtyIndex, Option<AccountId>>
for IdentityAccountIdProvider<Runtime>
where
Runtime: frame_system::Config<AccountId = AccountId>
+ pallet_identity::Config<IdtyIndex = IdtyIndex>,
{
fn convert(idty_index: IdtyIndex) -> Option<AccountId> {
pallet_identity::Pallet::<Runtime>::identity(idty_index).map(|idty| idty.owner_key)
}
}
/// A provider for converting AccountId to their associated IdtyIndex.
pub struct IdentityIndexOf<T: pallet_identity::Config>(PhantomData<T>);
impl<T> sp_runtime::traits::Convert<T::AccountId, Option<T::IdtyIndex>> for IdentityIndexOf<T>
where
T: pallet_identity::Config,
{
fn convert(account_id: T::AccountId) -> Option<T::IdtyIndex> {
pallet_identity::Pallet::<T>::identity_index_of(account_id)
}
}
/// A provider associating an AccountId to their first eligible UD creation time.
pub struct UdMembersStorage<T: pallet_identity::Config>(PhantomData<T>);
impl<T> frame_support::traits::StoredMap<AccountId, FirstEligibleUd> for UdMembersStorage<T>
where
T: frame_system::Config<AccountId = AccountId>,
T: pallet_identity::Config<IdtyData = IdtyData>,
{
fn get(key: &T::AccountId) -> FirstEligibleUd {
pallet_identity::Pallet::<T>::get(key).first_eligible_ud
}
fn try_mutate_exists<R, E: From<sp_runtime::DispatchError>>(
key: &T::AccountId,
f: impl FnOnce(&mut Option<FirstEligibleUd>) -> Result<R, E>,
) -> Result<R, E> {
pallet_identity::Pallet::<T>::try_mutate_exists(key, |maybe_idty_data| {
if let Some(ref mut idty_data) = maybe_idty_data {
let mut maybe_first_eligible_ud = Some(idty_data.first_eligible_ud.clone());
let result = f(&mut maybe_first_eligible_ud)?;
if let Some(first_eligible_ud) = maybe_first_eligible_ud {
idty_data.first_eligible_ud = first_eligible_ud;
}
Ok(result)
} else {
f(&mut None)
}
})
}
}
/// A provider to WoT membership status based on an IdtyIndex.
pub struct IsWoTMemberProvider<T>(PhantomData<T>);
impl<T> sp_runtime::traits::IsMember<<T as pallet_membership::Config>::IdtyId>
for IsWoTMemberProvider<T>
where
T: pallet_distance::Config + pallet_membership::Config + pallet_smith_members::Config,
{
fn is_member(idty_id: &T::IdtyId) -> bool {
pallet_membership::Pallet::<T>::is_member(idty_id)
}
}
#[cfg(feature = "runtime-benchmarks")]
pub struct BenchmarkSetupHandler<T>(PhantomData<T>);
// Macro implementing the BenchmarkSetupHandler trait for pallets requiring identity preparation for benchmarks.
#[cfg(feature = "runtime-benchmarks")]
macro_rules! impl_benchmark_setup_handler {
($t:ty) => {
impl<T> $t for BenchmarkSetupHandler<T>
where
T: pallet_distance::Config,
T: pallet_certification::Config,
<T as pallet_certification::Config>::IdtyIndex: From<u32>,
{
fn force_valid_distance_status(idty_id: &IdtyIndex) -> () {
let _ = pallet_distance::Pallet::<T>::do_valid_distance_status(
*idty_id,
sp_runtime::Perbill::one(),
);
}
fn add_cert(issuer: &IdtyIndex, receiver: &IdtyIndex) {
let _ = pallet_certification::Pallet::<T>::do_add_cert_checked(
(*issuer).into(),
(*receiver).into(),
false,
);
}
}
};
}
#[cfg(feature = "runtime-benchmarks")]
impl_benchmark_setup_handler!(pallet_membership::SetupBenchmark<<T as pallet_identity::Config>::IdtyIndex, T::AccountId>);
/// A provider for retrieving the number of accounts allowed to create the universal dividend.
pub struct MembersCount<T>(PhantomData<T>);
impl<T> frame_support::pallet_prelude::Get<Balance> for MembersCount<T>
where
T: sp_membership::traits::MembersCount,
{
fn get() -> Balance {
T::members_count() as Balance
}
}
[package]
authors.workspace = true
edition.workspace = true
homepage.workspace = true
license.workspace = true
name = "g1-runtime"
repository.workspace = true
version.workspace = true
[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]
[features]
default = ["std"]
constant-fees = ["common-runtime/constant-fees"]
# Enable the metadata hash generation.
#
# This is hidden behind a feature because it increases the compile time.
# The wasm binary needs to be compiled twice, once to fetch the metadata,
# generate the metadata hash and then a second time with the
# `RUNTIME_METADATA_HASH` environment variable set for the `CheckMetadataHash`
# extension.
metadata-hash = ["substrate-wasm-builder/metadata-hash"]
runtime-benchmarks = [
"common-runtime/runtime-benchmarks",
"frame-benchmarking/runtime-benchmarks",
"frame-support/runtime-benchmarks",
"frame-system-benchmarking/runtime-benchmarks",
"frame-system/runtime-benchmarks",
"pallet-authority-members/runtime-benchmarks",
"pallet-babe/runtime-benchmarks",
"pallet-balances/runtime-benchmarks",
"pallet-certification/runtime-benchmarks",
"pallet-collective/runtime-benchmarks",
"pallet-distance/runtime-benchmarks",
"pallet-duniter-account/runtime-benchmarks",
"pallet-duniter-wot/runtime-benchmarks",
"pallet-grandpa/runtime-benchmarks",
"pallet-identity/runtime-benchmarks",
"pallet-im-online/runtime-benchmarks",
"pallet-membership/runtime-benchmarks",
"pallet-multisig/runtime-benchmarks",
"pallet-offences/runtime-benchmarks",
"pallet-oneshot-account/runtime-benchmarks",
"pallet-preimage/runtime-benchmarks",
"pallet-provide-randomness/runtime-benchmarks",
"pallet-proxy/runtime-benchmarks",
"pallet-quota/runtime-benchmarks",
"pallet-scheduler/runtime-benchmarks",
"pallet-session-benchmarking/runtime-benchmarks",
"pallet-smith-members/runtime-benchmarks",
"pallet-sudo/runtime-benchmarks",
"pallet-timestamp/runtime-benchmarks",
"pallet-transaction-payment/runtime-benchmarks",
"pallet-treasury/runtime-benchmarks",
"pallet-universal-dividend/runtime-benchmarks",
"pallet-upgrade-origin/runtime-benchmarks",
"pallet-utility/runtime-benchmarks",
"sp-runtime/runtime-benchmarks",
"sp-staking/runtime-benchmarks",
]
std = [
"codec/std",
"common-runtime/std",
"frame-benchmarking/std",
"frame-executive/std",
"frame-support/std",
"frame-system-benchmarking/std",
"frame-system-rpc-runtime-api/std",
"frame-system/std",
"frame-try-runtime/std",
"log/std",
"node-primitives/std",
"pallet-atomic-swap/std",
"pallet-authority-discovery/std",
"pallet-authority-members/std",
"pallet-authorship/std",
"pallet-babe/std",
"pallet-balances/std",
"pallet-certification/std",
"pallet-collective/std",
"pallet-distance/std",
"pallet-duniter-account/std",
"pallet-duniter-wot/std",
"pallet-grandpa/std",
"pallet-identity/std",
"pallet-im-online/std",
"pallet-membership/std",
"pallet-multisig/std",
"pallet-offences/std",
"pallet-oneshot-account/std",
"pallet-preimage/std",
"pallet-provide-randomness/std",
"pallet-proxy/std",
"pallet-quota/std",
"pallet-scheduler/std",
"pallet-session-benchmarking/std",
"pallet-session/std",
"pallet-smith-members/std",
"pallet-sudo/std",
"pallet-timestamp/std",
"pallet-transaction-payment-rpc-runtime-api/std",
"pallet-transaction-payment/std",
"pallet-treasury/std",
"pallet-universal-dividend/std",
"pallet-upgrade-origin/std",
"pallet-utility/std",
"scale-info/std",
"serde/std",
"serde_derive",
"sp-api/std",
"sp-arithmetic/std",
"sp-authority-discovery/std",
"sp-block-builder/std",
"sp-consensus-babe/std",
"sp-consensus-grandpa/std",
"sp-core/std",
"sp-distance/std",
"sp-genesis-builder/std",
"sp-inherents/std",
"sp-membership/std",
"sp-offchain/std",
"sp-runtime/std",
"sp-session/std",
"sp-staking/std",
"sp-transaction-pool/std",
"sp-version/std",
"substrate-wasm-builder",
"sp-weights/std",
]
try-runtime = [
"common-runtime/try-runtime",
"frame-executive/try-runtime",
"frame-support/try-runtime",
"frame-system/try-runtime",
"frame-try-runtime/try-runtime",
"pallet-atomic-swap/try-runtime",
"pallet-authority-discovery/try-runtime",
"pallet-authority-members/try-runtime",
"pallet-authorship/try-runtime",
"pallet-babe/try-runtime",
"pallet-balances/try-runtime",
"pallet-certification/try-runtime",
"pallet-collective/try-runtime",
"pallet-distance/try-runtime",
"pallet-duniter-account/try-runtime",
"pallet-duniter-wot/try-runtime",
"pallet-grandpa/try-runtime",
"pallet-identity/try-runtime",
"pallet-im-online/try-runtime",
"pallet-membership/try-runtime",
"pallet-multisig/try-runtime",
"pallet-offences/try-runtime",
"pallet-oneshot-account/try-runtime",
"pallet-preimage/try-runtime",
"pallet-provide-randomness/try-runtime",
"pallet-proxy/try-runtime",
"pallet-quota/try-runtime",
"pallet-scheduler/try-runtime",
"pallet-session-benchmarking/try-runtime",
"pallet-session/try-runtime",
"pallet-smith-members/try-runtime",
"pallet-sudo/try-runtime",
"pallet-timestamp/try-runtime",
"pallet-transaction-payment/try-runtime",
"pallet-treasury/try-runtime",
"pallet-universal-dividend/try-runtime",
"pallet-upgrade-origin/try-runtime",
"pallet-utility/try-runtime",
"sp-distance/try-runtime",
"sp-membership/try-runtime",
"sp-runtime/try-runtime",
]
[dev-dependencies]
sp-staking = { workspace = true }
[build-dependencies]
substrate-wasm-builder = { workspace = true, optional = true }
[dependencies]
codec = { workspace = true, features = ["derive"] }
common-runtime = { workspace = true }
frame-executive = { workspace = true }
pallet-session-benchmarking = { workspace = true }
frame-support = { workspace = true }
frame-benchmarking = { workspace = true }
frame-system-benchmarking = { workspace = true }
frame-system = { workspace = true }
frame-system-rpc-runtime-api = { workspace = true }
frame-try-runtime = { workspace = true, optional = true }
frame-metadata-hash-extension = { workspace = true }
hex-literal = { workspace = true, optional = true }
log = { workspace = true }
pallet-atomic-swap = { workspace = true }
pallet-authority-discovery = { workspace = true }
pallet-authority-members = { workspace = true }
pallet-authorship = { workspace = true }
pallet-babe = { workspace = true }
pallet-balances = { workspace = true }
pallet-certification = { workspace = true }
pallet-collective = { workspace = true }
pallet-distance = { workspace = true }
pallet-duniter-account = { workspace = true }
pallet-duniter-wot = { workspace = true }
pallet-grandpa = { workspace = true }
pallet-identity = { workspace = true }
pallet-im-online = { workspace = true }
pallet-membership = { workspace = true }
pallet-multisig = { workspace = true }
pallet-offences = { workspace = true }
pallet-oneshot-account = { workspace = true }
pallet-preimage = { workspace = true }
pallet-provide-randomness = { workspace = true }
pallet-proxy = { workspace = true }
pallet-quota = { workspace = true }
pallet-scheduler = { workspace = true }
pallet-session = { workspace = true }
pallet-smith-members = { workspace = true }
pallet-sudo = { workspace = true }
pallet-timestamp = { workspace = true }
pallet-transaction-payment = { workspace = true }
pallet-transaction-payment-rpc-runtime-api = { workspace = true }
pallet-treasury = { workspace = true }
pallet-universal-dividend = { workspace = true }
pallet-upgrade-origin = { workspace = true }
pallet-utility = { workspace = true }
scale-info = { workspace = true, features = ["derive"] }
serde = { workspace = true }
serde_derive = { workspace = true, optional = true }
sp-api = { workspace = true }
sp-arithmetic = { workspace = true }
sp-authority-discovery = { workspace = true }
sp-block-builder = { workspace = true }
sp-consensus-babe = { workspace = true }
sp-consensus-grandpa = { workspace = true }
sp-core = { workspace = true }
sp-distance = { workspace = true }
sp-inherents = { workspace = true }
sp-membership = { workspace = true }
sp-offchain = { workspace = true }
sp-runtime = { workspace = true }
sp-session = { workspace = true }
sp-transaction-pool = { workspace = true }
sp-version = { workspace = true }
node-primitives = { workspace = true }
sp-genesis-builder = { workspace = true }
sp-weights = { workspace = true }
# Ğ1 runtime
Ğ1 runtime is the one used in the production Ğ1 network.
It is the same as ĞTest runtime with a bit of delay on updates necessary to test them.
\ No newline at end of file
// 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/>.
fn main() {
#[cfg(feature = "std")]
{
#[cfg(not(feature = "metadata-hash"))]
substrate_wasm_builder::WasmBuilder::init_with_defaults().build();
#[cfg(feature = "metadata-hash")]
substrate_wasm_builder::WasmBuilder::init_with_defaults()
.enable_metadata_hash("Ğ", 2)
.build();
}
}
// 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/>.
#![cfg_attr(not(feature = "std"), no_std)]
// `construct_runtime!` does a lot of recursion and requires us to increase the limit to 256.
#![recursion_limit = "256"]
// Make the WASM binary available.
#[cfg(feature = "std")]
include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));
pub mod parameters;
pub mod weights;
pub use self::parameters::*;
use common_runtime::IdtyNameValidatorImpl;
pub use common_runtime::{
constants::*, entities::*, handlers::*, AccountId, Address, Balance, BlockNumber,
FullIdentificationOfImpl, GetCurrentEpochIndex, Hash, Header, IdtyIndex, Index, Signature,
};
use frame_support::{traits::Contains, PalletId};
pub use frame_system::Call as SystemCall;
use frame_system::EnsureRoot;
pub use pallet_balances::Call as BalancesCall;
use pallet_grandpa::{
fg_primitives, AuthorityId as GrandpaId, AuthorityList as GrandpaAuthorityList,
};
pub use pallet_identity::{IdtyStatus, IdtyValue};
pub use pallet_im_online::sr25519::AuthorityId as ImOnlineId;
use pallet_session::historical as session_historical;
pub use pallet_timestamp::Call as TimestampCall;
use pallet_transaction_payment::FungibleAdapter;
pub use pallet_universal_dividend;
use scale_info::prelude::{vec, vec::Vec};
use sp_api::impl_runtime_apis;
use sp_core::OpaqueMetadata;
#[cfg(any(feature = "std", test))]
pub use sp_runtime::BuildStorage;
use sp_runtime::{
generic, impl_opaque_keys,
traits::{AccountIdLookup, BlakeTwo256, Block as BlockT, NumberFor, OpaqueKeys},
transaction_validity::{TransactionSource, TransactionValidity},
ApplyExtrinsicResult, Cow, Perquintill,
};
pub use sp_runtime::{KeyTypeId, Perbill, Permill};
#[cfg(feature = "std")]
use sp_version::NativeVersion;
use sp_version::RuntimeVersion;
pub use weights::paritydb_weights::constants::ParityDbWeight as DbWeight;
// A few exports that help ease life for downstream crates.
use frame_support::instances::Instance2;
pub use frame_support::{
construct_runtime, parameter_types,
traits::{EqualPrivilegeOnly, KeyOwnerProofSystem, Randomness},
weights::{
constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight},
Weight, WeightToFeeCoefficient, WeightToFeeCoefficients, WeightToFeePolynomial,
},
StorageValue,
};
// To learn more about runtime versioning and what each of the following value means:
// https://substrate.dev/docs/en/knowledgebase/runtime/upgrades#runtime-versioning
#[sp_version::runtime_version]
pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: Cow::Borrowed("g1"),
impl_name: Cow::Borrowed("duniter-g1"),
authoring_version: 1,
// The version of the runtime specification. A full node will not attempt to use its native
// runtime in substitute for the on-chain Wasm runtime unless all of `spec_name`,
// `spec_version`, and `authoring_version` are the same between Wasm and native.
// This value is set to 100 to notify Polkadot-JS App (https://polkadot.js.org/apps) to use
// the compatible custom types.
spec_version: 1000,
impl_version: 1,
apis: RUNTIME_API_VERSIONS,
transaction_version: 1,
system_version: 1,
};
/// The version information used to identify this runtime when compiled natively.
#[cfg(feature = "std")]
pub fn native_version() -> NativeVersion {
NativeVersion {
runtime_version: VERSION,
can_author_with: Default::default(),
}
}
/// Block type as expected by this runtime.
pub type Block = sp_runtime::generic::Block<Header, UncheckedExtrinsic>;
/// Unchecked extrinsic type as expected by this runtime.
pub type UncheckedExtrinsic =
generic::UncheckedExtrinsic<Address, RuntimeCall, Signature, TxExtension>;
/// The `TransactionExtension` to the basic transaction logic.
pub type TxExtension = (
frame_system::CheckNonZeroSender<Runtime>,
frame_system::CheckSpecVersion<Runtime>,
frame_system::CheckTxVersion<Runtime>,
frame_system::CheckGenesis<Runtime>,
frame_system::CheckEra<Runtime>,
pallet_oneshot_account::CheckNonce<Runtime>,
frame_system::CheckWeight<Runtime>,
pallet_transaction_payment::ChargeTransactionPayment<Runtime>,
frame_metadata_hash_extension::CheckMetadataHash<Runtime>,
);
/// Executive: handles dispatch to the various modules.
pub type Executive = frame_executive::Executive<
Runtime,
Block,
frame_system::ChainContext<Runtime>,
Runtime,
AllPalletsWithSystem,
>;
pub type TechnicalCommitteeInstance = Instance2;
pub struct BaseCallFilter;
impl Contains<RuntimeCall> for BaseCallFilter {
fn contains(call: &RuntimeCall) -> bool {
!matches!(call, RuntimeCall::Session(_))
}
}
/// The type used to represent the kinds of proxying allowed.
#[derive(
Copy,
Clone,
codec::DecodeWithMemTracking,
Eq,
PartialEq,
Ord,
PartialOrd,
codec::Encode,
codec::Decode,
frame_support::pallet_prelude::RuntimeDebug,
codec::MaxEncodedLen,
scale_info::TypeInfo,
)]
#[allow(clippy::unnecessary_cast)]
pub enum ProxyType {
AlmostAny = 0,
TransferOnly = 1,
CancelProxy = 2,
}
impl Default for ProxyType {
fn default() -> Self {
Self::AlmostAny
}
}
impl frame_support::traits::InstanceFilter<RuntimeCall> for ProxyType {
fn filter(&self, c: &RuntimeCall) -> bool {
match self {
ProxyType::AlmostAny => {
// Some calls are never authorized from a proxied account
!matches!(
c,
RuntimeCall::Certification(..)
| RuntimeCall::Identity(..)
| RuntimeCall::SmithMembers(..)
)
}
ProxyType::TransferOnly => {
matches!(
c,
RuntimeCall::Balances(..) | RuntimeCall::UniversalDividend(..)
)
}
ProxyType::CancelProxy => {
matches!(
c,
RuntimeCall::Proxy(pallet_proxy::Call::reject_announcement { .. })
)
}
}
}
}
// Create the runtime by composing the pallets that were previously configured.
construct_runtime!(
pub enum Runtime
{
// Basic stuff
System: frame_system = 0,
Account: pallet_duniter_account = 1,
Scheduler: pallet_scheduler = 2,
// Block creation
Babe: pallet_babe = 3,
Timestamp: pallet_timestamp = 4,
// Money management
Balances: pallet_balances = 6,
TransactionPayment: pallet_transaction_payment = 32,
OneshotAccount: pallet_oneshot_account = 7,
Quota: pallet_quota = 66,
// Consensus support
SmithMembers: pallet_smith_members = 10,
AuthorityMembers: pallet_authority_members = 11,
Authorship: pallet_authorship = 12,
Offences: pallet_offences = 13,
Historical: session_historical = 14,
Session: pallet_session = 15,
Grandpa: pallet_grandpa= 16,
ImOnline: pallet_im_online = 17,
AuthorityDiscovery: pallet_authority_discovery = 18,
// Governance stuff
Sudo: pallet_sudo = 20,
UpgradeOrigin: pallet_upgrade_origin = 21,
Preimage: pallet_preimage = 22,
TechnicalCommittee: pallet_collective::<Instance2> = 23,
// Universal dividend
UniversalDividend: pallet_universal_dividend = 30,
// Web Of Trust
Wot: pallet_duniter_wot = 40,
Identity: pallet_identity = 41,
Membership: pallet_membership = 42,
Certification: pallet_certification = 43,
Distance: pallet_distance = 44,
// Utilities
AtomicSwap: pallet_atomic_swap = 50,
Multisig: pallet_multisig = 51,
ProvideRandomness: pallet_provide_randomness = 52,
Proxy: pallet_proxy = 53,
Utility: pallet_utility = 54,
Treasury: pallet_treasury = 55,
}
);
// All of our runtimes share most of their Runtime API implementations.
// We use a macro to implement this common part and add runtime-specific additional implementations.
common_runtime::pallets_config!();
common_runtime::declare_session_keys! {}
#[cfg(feature = "runtime-benchmarks")]
common_runtime::benchmarks_config!();
common_runtime::offchain_config! {}
common_runtime::runtime_apis! {}
// 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::*;
use common_runtime::{constants::*, Moment};
use frame_support::{parameter_types, weights::constants::WEIGHT_REF_TIME_PER_SECOND};
use sp_runtime::transaction_validity::TransactionPriority;
parameter_types! {
pub const BlockHashCount: BlockNumber = 2400;
/// We allow for 2 seconds of compute with a 6 second average block time.
pub BlockWeights: frame_system::limits::BlockWeights = frame_system::limits::BlockWeights::with_sensible_defaults(Weight::from_parts(WEIGHT_REF_TIME_PER_SECOND * 2u64, u64::MAX), NORMAL_DISPATCH_RATIO);
pub BlockLength: frame_system::limits::BlockLength = frame_system::limits::BlockLength
::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO);
pub const SS58Prefix: u16 = 4450;
}
/*************/
/* CONSENSUS */
/*************/
// Authority discovery
parameter_types! {
pub const MaxAuthorities: u32 = 100;
}
// Authorship
parameter_types! {
pub const UncleGenerations: u32 = 0;
}
// Timestamp
parameter_types! {
pub const MinimumPeriod: u64 = SLOT_DURATION / 2;
}
// Distance
parameter_types! {
pub const MinAccessibleReferees: Perbill = Perbill::from_percent(80);
pub const MaxRefereeDistance: u32 = 5;
}
// Babe
pub const EPOCH_DURATION_IN_SLOTS: BlockNumber = 4 * HOURS;
parameter_types! {
pub const EpochDuration: u64 = EPOCH_DURATION_IN_SLOTS as u64;
pub const ExpectedBlockTime: u64 = MILLISECS_PER_BLOCK;
pub const ReportLongevity: BlockNumber = 168 * EPOCH_DURATION_IN_SLOTS;
}
// ImOnline
parameter_types! {
pub const ImOnlineUnsignedPriority: TransactionPriority = TransactionPriority::MAX;
pub const MaxPeerInHeartbeats: u32 = 10_000;
pub const MaxPeerDataEncodingSize: u32 = 1_000;
}
/*********/
/* MONEY */
/*********/
// Balances
// Why? Pallet treasury benchmarks are broken because the spend
// value is hardcoded 100 in benchmark and the account is not provided enough funds
// to exist if ED > 100.
#[cfg(feature = "runtime-benchmarks")]
frame_support::parameter_types! {
pub const ExistentialDeposit: Balance = 100;
pub const MaxLocks: u32 = 50;
}
#[cfg(not(feature = "runtime-benchmarks"))]
frame_support::parameter_types! {
pub const ExistentialDeposit: Balance = 200;
pub const MaxLocks: u32 = 50;
}
// Universal dividend
parameter_types! {
// 0.002_381_440 = 0.0488^2
pub const SquareMoneyGrowthRate: Perbill = Perbill::from_parts(2_381_440);
pub const UdCreationPeriod: Moment = 86_400_000; // 1 day
pub const UdReevalPeriod: Moment = 15_778_800_000; // 1/2 year
}
/*******/
/* WOT */
/*******/
parameter_types! {
pub const WotFirstCertIssuableOn: BlockNumber = 30 * DAYS;
pub const WotMinCertForMembership: u32 = 5;
pub const WotMinCertForCreateIdtyRight: u32 = 5;
}
// Identity
parameter_types! {
pub const ChangeOwnerKeyPeriod: BlockNumber = 6 * MONTHS;
pub const ConfirmPeriod: BlockNumber = 14 * DAYS;
pub const IdtyCreationPeriod: BlockNumber = MONTHS;
pub const ValidationPeriod: BlockNumber = YEARS;
pub const AutorevocationPeriod: BlockNumber = YEARS;
pub const DeletionPeriod: BlockNumber = 10 * YEARS;
}
// Membership
parameter_types! {
pub const MembershipPeriod: BlockNumber = YEARS;
pub const MembershipRenewalPeriod: BlockNumber = 2 * MONTHS;
}
// Certification
parameter_types! {
pub const CertPeriod: BlockNumber = 5 * DAYS;
pub const MaxByIssuer: u32 = 100;
pub const MinReceivedCertToBeAbleToIssueCert: u32 = 5;
pub const ValidityPeriod: BlockNumber = 2 * YEARS;
}
/******************/
/* SMITH-MEMBERS */
/******************/
parameter_types! {
pub const SmithWotMinCertForMembership: u32 = 3;
pub const SmithMaxByIssuer: u32 = 12;
pub const SmithInactivityMaxDuration: u32 = 48;
}
/*************/
/* UTILITIES */
/*************/
// Multisig
parameter_types! {
pub const MaxSignatories: u16 = 10;
}
// Treasury
pub type TreasuryApproveOrigin =
pallet_collective::EnsureProportionMoreThan<AccountId, TechnicalCommitteeInstance, 1, 2>;
pub type TreasuryRejectOrigin =
pallet_collective::EnsureProportionMoreThan<AccountId, TechnicalCommitteeInstance, 1, 3>;
// 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/>.
#![cfg_attr(rustfmt, rustfmt_skip)]
#![allow(unused_parens)]
#![allow(unused_imports)]
#![allow(clippy::unnecessary_cast)]
#![allow(unused_doc_comments)]
pub mod frame_system_extensions;
pub mod pallet_transaction_payment;
pub mod block_weights;
pub mod extrinsic_weights;
pub mod frame_system;
pub mod pallet_babe;
pub mod pallet_balances;
pub mod pallet_collective;
pub mod pallet_distance;
pub mod pallet_grandpa;
pub mod pallet_im_online;
pub mod pallet_multisig;
pub mod pallet_proxy;
pub mod pallet_session;
pub mod pallet_scheduler;
pub mod pallet_timestamp;
pub mod pallet_treasury;
pub mod pallet_universal_dividend;
pub mod pallet_upgrade_origin;
pub mod pallet_provide_randomness;
pub mod pallet_identity;
pub mod pallet_preimage;
pub mod pallet_utility;
pub mod pallet_duniter_account;
pub mod pallet_quota;
pub mod pallet_oneshot_account;
pub mod pallet_certification;
pub mod pallet_membership;
pub mod pallet_smith_members;
pub mod pallet_sudo;
pub mod pallet_authority_members;
pub mod paritydb_weights;
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 47.0.0
//! DATE: 2025-04-09 (Y/M/D)
//! HOSTNAME: `bgallois-ms7d43`, CPU: `12th Gen Intel(R) Core(TM) i3-12100F`
//!
//! SHORT-NAME: `block`, LONG-NAME: `BlockExecution`, RUNTIME: `Ğ1 Local Testnet`
//! WARMUPS: `10`, REPEAT: `100`
//! WEIGHT-PATH: `./runtime/g1/src/weights/`
//! WEIGHT-METRIC: `Average`, WEIGHT-MUL: `1.0`, WEIGHT-ADD: `0`
// Executed Command:
// target/release/duniter
// benchmark
// overhead
// --chain=dev
// --wasm-execution=compiled
// --weight-path=./runtime/g1/src/weights/
// --warmup=10
// --repeat=100
use sp_core::parameter_types;
use sp_weights::{constants::WEIGHT_REF_TIME_PER_NANOS, Weight};
parameter_types! {
/// Weight of executing an empty block.
/// Calculated by multiplying the *Average* with `1.0` and adding `0`.
///
/// Stats nanoseconds:
/// Min, Max: 126_592, 173_147
/// Average: 134_865
/// Median: 133_906
/// Std-Dev: 5688.69
///
/// Percentiles nanoseconds:
/// 99th: 156_296
/// 95th: 142_398
/// 75th: 135_389
pub const BlockExecutionWeight: Weight =
Weight::from_parts(WEIGHT_REF_TIME_PER_NANOS.saturating_mul(134_865), 0);
}
#[cfg(test)]
mod test_weights {
use sp_weights::constants;
/// Checks that the weight exists and is sane.
// NOTE: If this test fails but you are sure that the generated values are fine,
// you can delete it.
#[test]
fn sane() {
let w = super::BlockExecutionWeight::get();
// At least 100 µs.
assert!(
w.ref_time() >= 100u64 * constants::WEIGHT_REF_TIME_PER_MICROS,
"Weight should be at least 100 µs."
);
// At most 50 ms.
assert!(
w.ref_time() <= 50u64 * constants::WEIGHT_REF_TIME_PER_MILLIS,
"Weight should be at most 50 ms."
);
}
}
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 47.0.0
//! DATE: 2025-04-09 (Y/M/D)
//! HOSTNAME: `bgallois-ms7d43`, CPU: `12th Gen Intel(R) Core(TM) i3-12100F`
//!
//! SHORT-NAME: `extrinsic`, LONG-NAME: `ExtrinsicBase`, RUNTIME: `Ğ1 Local Testnet`
//! WARMUPS: `10`, REPEAT: `100`
//! WEIGHT-PATH: `./runtime/g1/src/weights/`
//! WEIGHT-METRIC: `Average`, WEIGHT-MUL: `1.0`, WEIGHT-ADD: `0`
// Executed Command:
// target/release/duniter
// benchmark
// overhead
// --chain=dev
// --wasm-execution=compiled
// --weight-path=./runtime/g1/src/weights/
// --warmup=10
// --repeat=100
use sp_core::parameter_types;
use sp_weights::{constants::WEIGHT_REF_TIME_PER_NANOS, Weight};
parameter_types! {
/// Weight of executing a NO-OP extrinsic, for example `System::remark`.
/// Calculated by multiplying the *Average* with `1.0` and adding `0`.
///
/// Stats nanoseconds:
/// Min, Max: 89_494, 92_927
/// Average: 89_805
/// Median: 89_707
/// Std-Dev: 381.19
///
/// Percentiles nanoseconds:
/// 99th: 90_892
/// 95th: 90_126
/// 75th: 89_864
pub const ExtrinsicBaseWeight: Weight =
Weight::from_parts(WEIGHT_REF_TIME_PER_NANOS.saturating_mul(89_805), 0);
}
#[cfg(test)]
mod test_weights {
use sp_weights::constants;
/// Checks that the weight exists and is sane.
// NOTE: If this test fails but you are sure that the generated values are fine,
// you can delete it.
#[test]
fn sane() {
let w = super::ExtrinsicBaseWeight::get();
// At least 10 µs.
assert!(
w.ref_time() >= 10u64 * constants::WEIGHT_REF_TIME_PER_MICROS,
"Weight should be at least 10 µs."
);
// At most 1 ms.
assert!(
w.ref_time() <= constants::WEIGHT_REF_TIME_PER_MILLIS,
"Weight should be at most 1 ms."
);
}
}
// Copyright 2021-2022 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/>.
//! Autogenerated weights for `frame_benchmarking::baseline`
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0
//! DATE: 2025-01-22, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! WORST CASE MAP SIZE: `1000000`
//! HOSTNAME: `bgallois-ms7d43`, CPU: `12th Gen Intel(R) Core(TM) i3-12100F`
//! WASM-EXECUTION: `Compiled`, CHAIN: `None`, DB CACHE: 1024
// Executed Command:
// target/release/duniter
// benchmark
// pallet
// --genesis-builder=spec-genesis
// --steps=50
// --repeat=20
// --pallet=*
// --extrinsic=*
// --wasm-execution=compiled
// --heap-pages=4096
// --header=./file_header.txt
// --output=./runtime/gdev/src/weights/
#![cfg_attr(rustfmt, rustfmt_skip)]
#![allow(unused_parens)]
#![allow(unused_imports)]
#![allow(missing_docs)]
use frame_support::{traits::Get, weights::Weight};
use core::marker::PhantomData;
/// Weight functions for `frame_benchmarking::baseline`.
pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Config> frame_benchmarking::baseline::WeightInfo for WeightInfo<T> {
/// The range of component `i` is `[0, 1000000]`.
fn addition(_i: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 83_000 picoseconds.
Weight::from_parts(120_949, 0)
.saturating_add(Weight::from_parts(0, 0))
}
/// The range of component `i` is `[0, 1000000]`.
fn subtraction(_i: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 83_000 picoseconds.
Weight::from_parts(112_667, 0)
.saturating_add(Weight::from_parts(0, 0))
}
/// The range of component `i` is `[0, 1000000]`.
fn multiplication(_i: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 84_000 picoseconds.
Weight::from_parts(112_957, 0)
.saturating_add(Weight::from_parts(0, 0))
}
/// The range of component `i` is `[0, 1000000]`.
fn division(_i: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 83_000 picoseconds.
Weight::from_parts(112_463, 0)
.saturating_add(Weight::from_parts(0, 0))
}
fn hashing() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 19_580_244_000 picoseconds.
Weight::from_parts(19_630_816_000, 0)
.saturating_add(Weight::from_parts(0, 0))
}
/// The range of component `i` is `[0, 100]`.
fn sr25519_verification(i: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 97_000 picoseconds.
Weight::from_parts(27_435_845, 0)
.saturating_add(Weight::from_parts(0, 0))
// Standard Error: 12_491
.saturating_add(Weight::from_parts(31_686_916, 0).saturating_mul(i.into()))
}
}
// Copyright 2021-2022 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/>.
//! Autogenerated weights for `frame_system`
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 47.0.0
//! DATE: 2025-04-09, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! WORST CASE MAP SIZE: `1000000`
//! HOSTNAME: `bgallois-ms7d43`, CPU: `12th Gen Intel(R) Core(TM) i3-12100F`
//! WASM-EXECUTION: `Compiled`, CHAIN: `None`, DB CACHE: 1024
// Executed Command:
// target/release/duniter
// benchmark
// pallet
// --genesis-builder=spec-genesis
// --steps=50
// --repeat=20
// --pallet=*
// --extrinsic=*
// --wasm-execution=compiled
// --heap-pages=4096
// --header=./file_header.txt
// --output=./runtime/g1/src/weights/
#![cfg_attr(rustfmt, rustfmt_skip)]
#![allow(unused_parens)]
#![allow(unused_imports)]
#![allow(missing_docs)]
use frame_support::{traits::Get, weights::Weight};
use core::marker::PhantomData;
/// Weight functions for `frame_system`.
pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Config> frame_system::WeightInfo for WeightInfo<T> {
/// The range of component `b` is `[0, 3932160]`.
fn remark(b: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 1_739_000 picoseconds.
Weight::from_parts(1_808_000, 0)
.saturating_add(Weight::from_parts(0, 0))
// Standard Error: 313
.saturating_add(Weight::from_parts(25_549, 0).saturating_mul(b.into()))
}
/// The range of component `b` is `[0, 3932160]`.
fn remark_with_event(b: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 4_579_000 picoseconds.
Weight::from_parts(4_709_000, 0)
.saturating_add(Weight::from_parts(0, 0))
// Standard Error: 312
.saturating_add(Weight::from_parts(26_320, 0).saturating_mul(b.into()))
}
/// Storage: UNKNOWN KEY `0x3a686561707061676573` (r:0 w:1)
/// Proof: UNKNOWN KEY `0x3a686561707061676573` (r:0 w:1)
fn set_heap_pages() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 3_063_000 picoseconds.
Weight::from_parts(3_235_000, 0)
.saturating_add(Weight::from_parts(0, 0))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: UNKNOWN KEY `0x3a636f6465` (r:0 w:1)
/// Proof: UNKNOWN KEY `0x3a636f6465` (r:0 w:1)
fn set_code() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 227_772_433_000 picoseconds.
Weight::from_parts(234_382_327_000, 0)
.saturating_add(Weight::from_parts(0, 0))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: `Skipped::Metadata` (r:0 w:0)
/// Proof: `Skipped::Metadata` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// The range of component `i` is `[0, 1000]`.
fn set_storage(i: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 1_712_000 picoseconds.
Weight::from_parts(1_841_000, 0)
.saturating_add(Weight::from_parts(0, 0))
// Standard Error: 702
.saturating_add(Weight::from_parts(545_522, 0).saturating_mul(i.into()))
.saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(i.into())))
}
/// Storage: `Skipped::Metadata` (r:0 w:0)
/// Proof: `Skipped::Metadata` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// The range of component `i` is `[0, 1000]`.
fn kill_storage(i: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 1_640_000 picoseconds.
Weight::from_parts(1_819_000, 0)
.saturating_add(Weight::from_parts(0, 0))
// Standard Error: 553
.saturating_add(Weight::from_parts(429_463, 0).saturating_mul(i.into()))
.saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(i.into())))
}
/// Storage: `Skipped::Metadata` (r:0 w:0)
/// Proof: `Skipped::Metadata` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// The range of component `p` is `[0, 1000]`.
fn kill_prefix(p: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `77 + p * (69 ±0)`
// Estimated: `75 + p * (70 ±0)`
// Minimum execution time: 3_130_000 picoseconds.
Weight::from_parts(3_406_000, 0)
.saturating_add(Weight::from_parts(0, 75))
// Standard Error: 757
.saturating_add(Weight::from_parts(1_017_920, 0).saturating_mul(p.into()))
.saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(p.into())))
.saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(p.into())))
.saturating_add(Weight::from_parts(0, 70).saturating_mul(p.into()))
}
/// Storage: `System::AuthorizedUpgrade` (r:0 w:1)
/// Proof: `System::AuthorizedUpgrade` (`max_values`: Some(1), `max_size`: Some(33), added: 528, mode: `MaxEncodedLen`)
fn authorize_upgrade() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 7_846_000 picoseconds.
Weight::from_parts(9_082_000, 0)
.saturating_add(Weight::from_parts(0, 0))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: `System::AuthorizedUpgrade` (r:1 w:1)
/// Proof: `System::AuthorizedUpgrade` (`max_values`: Some(1), `max_size`: Some(33), added: 528, mode: `MaxEncodedLen`)
/// Storage: UNKNOWN KEY `0x3a636f6465` (r:0 w:1)
/// Proof: UNKNOWN KEY `0x3a636f6465` (r:0 w:1)
fn apply_authorized_upgrade() -> Weight {
// Proof Size summary in bytes:
// Measured: `22`
// Estimated: `1518`
// Minimum execution time: 231_554_247_000 picoseconds.
Weight::from_parts(238_428_047_000, 0)
.saturating_add(Weight::from_parts(0, 1518))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(2))
}
}