Skip to content

Commit

Permalink
feat: add multisig pallet to runtime (#498)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ad96el authored Apr 12, 2023
1 parent 5ef42ef commit e3f21c4
Show file tree
Hide file tree
Showing 13 changed files with 316 additions and 7 deletions.
3 changes: 3 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ pallet-transaction-payment-rpc-runtime-api = {git = "https://github.com/parityte
pallet-treasury = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.38"}
pallet-utility = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.38"}
pallet-vesting = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.38"}
pallet-multisig = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.38"}
sp-api = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.38"}
sp-block-builder = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.38"}
sp-consensus-aura = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.38"}
Expand Down
17 changes: 16 additions & 1 deletion runtimes/common/src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ pub const MICRO_KILT: Balance = 10u128.pow(9);

pub const EXISTENTIAL_DEPOSIT: Balance = 10 * MILLI_KILT;

/// Deposit that must be provided for each occupied storage item.
pub const DEPOSIT_STORAGE_ITEM: Balance = 56 * MILLI_KILT;

/// Deposit that must be provided for each occupied storage byte.
pub const DEPOSIT_STORAGE_BYTE: Balance = 50 * MILLI_KILT;
// 1 in 4 blocks (on average, not counting collisions) will be primary babe
// blocks.
pub const PRIMARY_PROBABILITY: (u64, u64) = (1, 4);
Expand Down Expand Up @@ -102,7 +107,7 @@ pub fn kilt_inflation_config() -> InflationInfo {
/// Calculate the storage deposit based on the number of storage items and the
/// combined byte size of those items.
pub const fn deposit(items: u32, bytes: u32) -> Balance {
items as Balance * 56 * MILLI_KILT + (bytes as Balance) * 50 * MICRO_KILT
items as Balance * DEPOSIT_STORAGE_ITEM + (bytes as Balance) * DEPOSIT_STORAGE_BYTE
}

/// The size of an index in the index pallet.
Expand Down Expand Up @@ -303,6 +308,16 @@ pub mod governance {
}
}

pub mod multisig {
use super::*;

parameter_types! {
pub const MaxSignitors: u32 = 64;
pub const DepositBase: Balance = DEPOSIT_STORAGE_ITEM;
pub const DepositFactor: Balance = DEPOSIT_STORAGE_BYTE;
}
}

pub mod did {
use super::*;

Expand Down
8 changes: 6 additions & 2 deletions runtimes/peregrine/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
[package]
authors.workspace = true
description = "Parachain runtime for KILT Testnets."
documentation.workspace = true
edition.workspace = true
homepage.workspace = true
license-file.workspace = true
name = "peregrine-runtime"
readme.workspace = true
repository.workspace = true
version.workspace = true
name = "peregrine-runtime"
description = "Parachain runtime for KILT Testnets."

[build-dependencies]
substrate-wasm-builder.workspace = true
Expand Down Expand Up @@ -68,6 +68,7 @@ pallet-collective.workspace = true
pallet-democracy.workspace = true
pallet-indices.workspace = true
pallet-membership.workspace = true
pallet-multisig.workspace = true
pallet-preimage.workspace = true
pallet-proxy.workspace = true
pallet-randomness-collective-flip.workspace = true
Expand Down Expand Up @@ -130,6 +131,7 @@ runtime-benchmarks = [
"pallet-indices/runtime-benchmarks",
"pallet-inflation/runtime-benchmarks",
"pallet-membership/runtime-benchmarks",
"pallet-multisig/runtime-benchmarks",
"pallet-preimage/runtime-benchmarks",
"pallet-proxy/runtime-benchmarks",
"pallet-scheduler/runtime-benchmarks",
Expand Down Expand Up @@ -184,6 +186,7 @@ std = [
"pallet-indices/std",
"pallet-inflation/std",
"pallet-membership/std",
"pallet-multisig/std",
"pallet-preimage/std",
"pallet-proxy/std",
"pallet-randomness-collective-flip/std",
Expand Down Expand Up @@ -244,6 +247,7 @@ try-runtime = [
"pallet-indices/try-runtime",
"pallet-inflation/try-runtime",
"pallet-membership/try-runtime",
"pallet-multisig/try-runtime",
"pallet-preimage/try-runtime",
"pallet-proxy/try-runtime",
"pallet-randomness-collective-flip/try-runtime",
Expand Down
13 changes: 13 additions & 0 deletions runtimes/peregrine/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,16 @@ parameter_types! {
pub const MaxReserves: u32 = 50;
}

impl pallet_multisig::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type RuntimeCall = RuntimeCall;
type Currency = Balances;
type DepositBase = constants::multisig::DepositBase;
type DepositFactor = constants::multisig::DepositFactor;
type MaxSignatories = constants::multisig::MaxSignitors;
type WeightInfo = weights::pallet_multisig::WeightInfo<Runtime>;
}

impl pallet_indices::Config for Runtime {
type AccountIndex = Index;
type Currency = pallet_balances::Pallet<Runtime>;
Expand Down Expand Up @@ -965,6 +975,8 @@ construct_runtime! {
TipsMembership: pallet_membership::<Instance2> = 45,
Tips: pallet_tips::{Pallet, Call, Storage, Event<T>} = 46,

Multisig: pallet_multisig = 47,

// KILT Pallets. Start indices 60 to leave room
// DELETED: KiltLaunch: kilt_launch = 60,
Ctype: ctype = 61,
Expand Down Expand Up @@ -1110,6 +1122,7 @@ mod benches {
[pallet_vesting, Vesting]
[pallet_proxy, Proxy]
[pallet_xcm, PolkadotXcm]
[pallet_multisig, Multisig]
);
}

Expand Down
1 change: 1 addition & 0 deletions runtimes/peregrine/src/weights/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ pub mod pallet_did_lookup;
pub mod pallet_indices;
pub mod pallet_inflation;
pub mod pallet_membership;
pub mod pallet_multisig;
pub mod pallet_preimage;
pub mod pallet_proxy;
pub mod pallet_scheduler;
Expand Down
118 changes: 118 additions & 0 deletions runtimes/peregrine/src/weights/pallet_multisig.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
// KILT Blockchain – https://botlabs.org
// Copyright (C) 2019-2023 BOTLabs GmbH

// The KILT Blockchain is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

// The KILT Blockchain 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 General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

// If you feel like getting in touch with us, you can do so at info@botlabs.org

//! Autogenerated weights for pallet_multisig
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
//! DATE: 2023-04-04, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024
// Executed Command:
// ./target/release/kilt-parachain
// benchmark
// pallet
// --chain=dev
// --steps=50
// --repeat=20
// --pallet=pallet_multisig
// --execution=wasm
// --wasm-execution=compiled
// --extrinsic=*
// --heap-pages=4096
// --output=./runtimes/peregrine/src/weights/pallet_multisig.rs
// --template=.maintain/runtime-weight-template.hbs

#![cfg_attr(rustfmt, rustfmt_skip)]
#![allow(unused_parens)]
#![allow(unused_imports)]
#![allow(clippy::unnecessary_cast)]

use frame_support::{traits::Get, weights::Weight};
use sp_std::marker::PhantomData;

/// Weights for `pallet_multisig`.
pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Config> pallet_multisig::WeightInfo for WeightInfo<T> {
fn as_multi_threshold_1(z: u32, ) -> Weight {
Weight::from_ref_time(8_364_882 as u64)
// Standard Error: 79
.saturating_add(Weight::from_ref_time(849 as u64).saturating_mul(z as u64))
}
// Storage: Multisig Multisigs (r:1 w:1)
// Proof: Multisig Multisigs (max_values: None, max_size: Some(2198), added: 4673, mode: MaxEncodedLen)
fn as_multi_create(s: u32, z: u32, ) -> Weight {
Weight::from_ref_time(20_285_811 as u64)
// Standard Error: 5_408
.saturating_add(Weight::from_ref_time(80_065 as u64).saturating_mul(s as u64))
// Standard Error: 33
.saturating_add(Weight::from_ref_time(986 as u64).saturating_mul(z as u64))
.saturating_add(T::DbWeight::get().reads(1 as u64))
.saturating_add(T::DbWeight::get().writes(1 as u64))
}
// Storage: Multisig Multisigs (r:1 w:1)
// Proof: Multisig Multisigs (max_values: None, max_size: Some(2198), added: 4673, mode: MaxEncodedLen)
fn as_multi_approve(s: u32, z: u32, ) -> Weight {
Weight::from_ref_time(12_705_025 as u64)
// Standard Error: 30_300
.saturating_add(Weight::from_ref_time(20_431 as u64).saturating_mul(s as u64))
// Standard Error: 186
.saturating_add(Weight::from_ref_time(3_373 as u64).saturating_mul(z as u64))
.saturating_add(T::DbWeight::get().reads(1 as u64))
.saturating_add(T::DbWeight::get().writes(1 as u64))
}
// Storage: Multisig Multisigs (r:1 w:1)
// Proof: Multisig Multisigs (max_values: None, max_size: Some(2198), added: 4673, mode: MaxEncodedLen)
// Storage: System Account (r:1 w:1)
// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen)
fn as_multi_complete(s: u32, z: u32, ) -> Weight {
Weight::from_ref_time(20_642_060 as u64)
// Standard Error: 5_511
.saturating_add(Weight::from_ref_time(104_693 as u64).saturating_mul(s as u64))
// Standard Error: 34
.saturating_add(Weight::from_ref_time(1_132 as u64).saturating_mul(z as u64))
.saturating_add(T::DbWeight::get().reads(2 as u64))
.saturating_add(T::DbWeight::get().writes(2 as u64))
}
// Storage: Multisig Multisigs (r:1 w:1)
// Proof: Multisig Multisigs (max_values: None, max_size: Some(2198), added: 4673, mode: MaxEncodedLen)
fn approve_as_multi_create(s: u32, ) -> Weight {
Weight::from_ref_time(17_036_891 as u64)
// Standard Error: 4_200
.saturating_add(Weight::from_ref_time(122_554 as u64).saturating_mul(s as u64))
.saturating_add(T::DbWeight::get().reads(1 as u64))
.saturating_add(T::DbWeight::get().writes(1 as u64))
}
// Storage: Multisig Multisigs (r:1 w:1)
// Proof: Multisig Multisigs (max_values: None, max_size: Some(2198), added: 4673, mode: MaxEncodedLen)
fn approve_as_multi_approve(s: u32, ) -> Weight {
Weight::from_ref_time(12_421_505 as u64)
// Standard Error: 7_770
.saturating_add(Weight::from_ref_time(81_668 as u64).saturating_mul(s as u64))
.saturating_add(T::DbWeight::get().reads(1 as u64))
.saturating_add(T::DbWeight::get().writes(1 as u64))
}
// Storage: Multisig Multisigs (r:1 w:1)
// Proof: Multisig Multisigs (max_values: None, max_size: Some(2198), added: 4673, mode: MaxEncodedLen)
fn cancel_as_multi(s: u32, ) -> Weight {
Weight::from_ref_time(19_681_233 as u64)
// Standard Error: 4_292
.saturating_add(Weight::from_ref_time(70_945 as u64).saturating_mul(s as u64))
.saturating_add(T::DbWeight::get().reads(1 as u64))
.saturating_add(T::DbWeight::get().writes(1 as u64))
}
}
8 changes: 6 additions & 2 deletions runtimes/spiritnet/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
[package]
authors.workspace = true
description = "Parachain runtime for KILT Mainnet on Polkadot."
documentation.workspace = true
edition.workspace = true
homepage.workspace = true
license-file.workspace = true
name = "spiritnet-runtime"
readme.workspace = true
repository.workspace = true
version.workspace = true
name = "spiritnet-runtime"
description = "Parachain runtime for KILT Mainnet on Polkadot."

[build-dependencies]
substrate-wasm-builder.workspace = true
Expand Down Expand Up @@ -68,6 +68,7 @@ pallet-collective.workspace = true
pallet-democracy.workspace = true
pallet-indices.workspace = true
pallet-membership.workspace = true
pallet-multisig.workspace = true
pallet-preimage.workspace = true
pallet-proxy.workspace = true
pallet-randomness-collective-flip.workspace = true
Expand Down Expand Up @@ -139,6 +140,7 @@ runtime-benchmarks = [
"pallet-vesting/runtime-benchmarks",
"pallet-web3-names/runtime-benchmarks",
"pallet-xcm/runtime-benchmarks",
"pallet-multisig/runtime-benchmarks",
"parachain-staking/runtime-benchmarks",
"public-credentials/runtime-benchmarks",
"runtime-common/runtime-benchmarks",
Expand Down Expand Up @@ -187,6 +189,7 @@ std = [
"pallet-randomness-collective-flip/std",
"pallet-scheduler/std",
"pallet-session/std",
"pallet-multisig/std",
"pallet-timestamp/std",
"pallet-tips/std",
"pallet-transaction-payment-rpc-runtime-api/std",
Expand Down Expand Up @@ -231,6 +234,7 @@ try-runtime = [
"frame-support/try-runtime",
"frame-system/try-runtime",
"frame-try-runtime",
"pallet-multisig/try-runtime",
"kilt-support/try-runtime",
"pallet-aura/try-runtime",
"pallet-authorship/try-runtime",
Expand Down
13 changes: 13 additions & 0 deletions runtimes/spiritnet/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,16 @@ parameter_types! {
pub const MaxReserves: u32 = 50;
}

impl pallet_multisig::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type RuntimeCall = RuntimeCall;
type Currency = Balances;
type DepositBase = constants::multisig::DepositBase;
type DepositFactor = constants::multisig::DepositFactor;
type MaxSignatories = constants::multisig::MaxSignitors;
type WeightInfo = weights::pallet_multisig::WeightInfo<Runtime>;
}

impl pallet_indices::Config for Runtime {
type AccountIndex = Index;
type Currency = pallet_balances::Pallet<Runtime>;
Expand Down Expand Up @@ -961,6 +971,8 @@ construct_runtime! {
TipsMembership: pallet_membership::<Instance2> = 45,
Tips: pallet_tips::{Pallet, Call, Storage, Event<T>} = 46,

Multisig: pallet_multisig = 47,

// KILT Pallets. Start indices 60 to leave room
// DELETED: KiltLaunch: kilt_launch = 60,
Ctype: ctype = 61,
Expand Down Expand Up @@ -1104,6 +1116,7 @@ mod benches {
[pallet_vesting, Vesting]
[pallet_proxy, Proxy]
[pallet_xcm, PolkadotXcm]
[pallet_multisig, Multisig]
);
}

Expand Down
1 change: 1 addition & 0 deletions runtimes/spiritnet/src/weights/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ pub mod pallet_did_lookup;
pub mod pallet_indices;
pub mod pallet_inflation;
pub mod pallet_membership;
pub mod pallet_multisig;
pub mod pallet_preimage;
pub mod pallet_proxy;
pub mod pallet_scheduler;
Expand Down
Loading

0 comments on commit e3f21c4

Please sign in to comment.