Skip to content

Commit 43869a2

Browse files
authored
feat: add multisig pallet to runtime (#498)
1 parent fef9f13 commit 43869a2

File tree

13 files changed

+316
-7
lines changed

13 files changed

+316
-7
lines changed

Cargo.lock

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ pallet-transaction-payment-rpc-runtime-api = {git = "https://github.com/parityte
115115
pallet-treasury = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.38"}
116116
pallet-utility = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.38"}
117117
pallet-vesting = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.38"}
118+
pallet-multisig = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.38"}
118119
sp-api = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.38"}
119120
sp-block-builder = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.38"}
120121
sp-consensus-aura = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.38"}

runtimes/common/src/constants.rs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,11 @@ pub const MICRO_KILT: Balance = 10u128.pow(9);
5757

5858
pub const EXISTENTIAL_DEPOSIT: Balance = 10 * MILLI_KILT;
5959

60+
/// Deposit that must be provided for each occupied storage item.
61+
pub const DEPOSIT_STORAGE_ITEM: Balance = 56 * MILLI_KILT;
62+
63+
/// Deposit that must be provided for each occupied storage byte.
64+
pub const DEPOSIT_STORAGE_BYTE: Balance = 50 * MILLI_KILT;
6065
// 1 in 4 blocks (on average, not counting collisions) will be primary babe
6166
// blocks.
6267
pub const PRIMARY_PROBABILITY: (u64, u64) = (1, 4);
@@ -102,7 +107,7 @@ pub fn kilt_inflation_config() -> InflationInfo {
102107
/// Calculate the storage deposit based on the number of storage items and the
103108
/// combined byte size of those items.
104109
pub const fn deposit(items: u32, bytes: u32) -> Balance {
105-
items as Balance * 56 * MILLI_KILT + (bytes as Balance) * 50 * MICRO_KILT
110+
items as Balance * DEPOSIT_STORAGE_ITEM + (bytes as Balance) * DEPOSIT_STORAGE_BYTE
106111
}
107112

108113
/// The size of an index in the index pallet.
@@ -303,6 +308,16 @@ pub mod governance {
303308
}
304309
}
305310

311+
pub mod multisig {
312+
use super::*;
313+
314+
parameter_types! {
315+
pub const MaxSignitors: u32 = 64;
316+
pub const DepositBase: Balance = DEPOSIT_STORAGE_ITEM;
317+
pub const DepositFactor: Balance = DEPOSIT_STORAGE_BYTE;
318+
}
319+
}
320+
306321
pub mod did {
307322
use super::*;
308323

runtimes/peregrine/Cargo.toml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
[package]
22
authors.workspace = true
3+
description = "Parachain runtime for KILT Testnets."
34
documentation.workspace = true
45
edition.workspace = true
56
homepage.workspace = true
67
license-file.workspace = true
8+
name = "peregrine-runtime"
79
readme.workspace = true
810
repository.workspace = true
911
version.workspace = true
10-
name = "peregrine-runtime"
11-
description = "Parachain runtime for KILT Testnets."
1212

1313
[build-dependencies]
1414
substrate-wasm-builder.workspace = true
@@ -68,6 +68,7 @@ pallet-collective.workspace = true
6868
pallet-democracy.workspace = true
6969
pallet-indices.workspace = true
7070
pallet-membership.workspace = true
71+
pallet-multisig.workspace = true
7172
pallet-preimage.workspace = true
7273
pallet-proxy.workspace = true
7374
pallet-randomness-collective-flip.workspace = true
@@ -130,6 +131,7 @@ runtime-benchmarks = [
130131
"pallet-indices/runtime-benchmarks",
131132
"pallet-inflation/runtime-benchmarks",
132133
"pallet-membership/runtime-benchmarks",
134+
"pallet-multisig/runtime-benchmarks",
133135
"pallet-preimage/runtime-benchmarks",
134136
"pallet-proxy/runtime-benchmarks",
135137
"pallet-scheduler/runtime-benchmarks",
@@ -184,6 +186,7 @@ std = [
184186
"pallet-indices/std",
185187
"pallet-inflation/std",
186188
"pallet-membership/std",
189+
"pallet-multisig/std",
187190
"pallet-preimage/std",
188191
"pallet-proxy/std",
189192
"pallet-randomness-collective-flip/std",
@@ -244,6 +247,7 @@ try-runtime = [
244247
"pallet-indices/try-runtime",
245248
"pallet-inflation/try-runtime",
246249
"pallet-membership/try-runtime",
250+
"pallet-multisig/try-runtime",
247251
"pallet-preimage/try-runtime",
248252
"pallet-proxy/try-runtime",
249253
"pallet-randomness-collective-flip/try-runtime",

runtimes/peregrine/src/lib.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,16 @@ parameter_types! {
192192
pub const MaxReserves: u32 = 50;
193193
}
194194

195+
impl pallet_multisig::Config for Runtime {
196+
type RuntimeEvent = RuntimeEvent;
197+
type RuntimeCall = RuntimeCall;
198+
type Currency = Balances;
199+
type DepositBase = constants::multisig::DepositBase;
200+
type DepositFactor = constants::multisig::DepositFactor;
201+
type MaxSignatories = constants::multisig::MaxSignitors;
202+
type WeightInfo = weights::pallet_multisig::WeightInfo<Runtime>;
203+
}
204+
195205
impl pallet_indices::Config for Runtime {
196206
type AccountIndex = Index;
197207
type Currency = pallet_balances::Pallet<Runtime>;
@@ -965,6 +975,8 @@ construct_runtime! {
965975
TipsMembership: pallet_membership::<Instance2> = 45,
966976
Tips: pallet_tips::{Pallet, Call, Storage, Event<T>} = 46,
967977

978+
Multisig: pallet_multisig = 47,
979+
968980
// KILT Pallets. Start indices 60 to leave room
969981
// DELETED: KiltLaunch: kilt_launch = 60,
970982
Ctype: ctype = 61,
@@ -1110,6 +1122,7 @@ mod benches {
11101122
[pallet_vesting, Vesting]
11111123
[pallet_proxy, Proxy]
11121124
[pallet_xcm, PolkadotXcm]
1125+
[pallet_multisig, Multisig]
11131126
);
11141127
}
11151128

runtimes/peregrine/src/weights/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ pub mod pallet_did_lookup;
2828
pub mod pallet_indices;
2929
pub mod pallet_inflation;
3030
pub mod pallet_membership;
31+
pub mod pallet_multisig;
3132
pub mod pallet_preimage;
3233
pub mod pallet_proxy;
3334
pub mod pallet_scheduler;
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
// KILT Blockchain – https://botlabs.org
2+
// Copyright (C) 2019-2023 BOTLabs GmbH
3+
4+
// The KILT Blockchain is free software: you can redistribute it and/or modify
5+
// it under the terms of the GNU General Public License as published by
6+
// the Free Software Foundation, either version 3 of the License, or
7+
// (at your option) any later version.
8+
9+
// The KILT Blockchain is distributed in the hope that it will be useful,
10+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
// GNU General Public License for more details.
13+
14+
// You should have received a copy of the GNU General Public License
15+
// along with this program. If not, see <https://www.gnu.org/licenses/>.
16+
17+
// If you feel like getting in touch with us, you can do so at [email protected]
18+
19+
//! Autogenerated weights for pallet_multisig
20+
//!
21+
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
22+
//! DATE: 2023-04-04, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
23+
//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024
24+
25+
// Executed Command:
26+
// ./target/release/kilt-parachain
27+
// benchmark
28+
// pallet
29+
// --chain=dev
30+
// --steps=50
31+
// --repeat=20
32+
// --pallet=pallet_multisig
33+
// --execution=wasm
34+
// --wasm-execution=compiled
35+
// --extrinsic=*
36+
// --heap-pages=4096
37+
// --output=./runtimes/peregrine/src/weights/pallet_multisig.rs
38+
// --template=.maintain/runtime-weight-template.hbs
39+
40+
#![cfg_attr(rustfmt, rustfmt_skip)]
41+
#![allow(unused_parens)]
42+
#![allow(unused_imports)]
43+
#![allow(clippy::unnecessary_cast)]
44+
45+
use frame_support::{traits::Get, weights::Weight};
46+
use sp_std::marker::PhantomData;
47+
48+
/// Weights for `pallet_multisig`.
49+
pub struct WeightInfo<T>(PhantomData<T>);
50+
impl<T: frame_system::Config> pallet_multisig::WeightInfo for WeightInfo<T> {
51+
fn as_multi_threshold_1(z: u32, ) -> Weight {
52+
Weight::from_ref_time(8_364_882 as u64)
53+
// Standard Error: 79
54+
.saturating_add(Weight::from_ref_time(849 as u64).saturating_mul(z as u64))
55+
}
56+
// Storage: Multisig Multisigs (r:1 w:1)
57+
// Proof: Multisig Multisigs (max_values: None, max_size: Some(2198), added: 4673, mode: MaxEncodedLen)
58+
fn as_multi_create(s: u32, z: u32, ) -> Weight {
59+
Weight::from_ref_time(20_285_811 as u64)
60+
// Standard Error: 5_408
61+
.saturating_add(Weight::from_ref_time(80_065 as u64).saturating_mul(s as u64))
62+
// Standard Error: 33
63+
.saturating_add(Weight::from_ref_time(986 as u64).saturating_mul(z as u64))
64+
.saturating_add(T::DbWeight::get().reads(1 as u64))
65+
.saturating_add(T::DbWeight::get().writes(1 as u64))
66+
}
67+
// Storage: Multisig Multisigs (r:1 w:1)
68+
// Proof: Multisig Multisigs (max_values: None, max_size: Some(2198), added: 4673, mode: MaxEncodedLen)
69+
fn as_multi_approve(s: u32, z: u32, ) -> Weight {
70+
Weight::from_ref_time(12_705_025 as u64)
71+
// Standard Error: 30_300
72+
.saturating_add(Weight::from_ref_time(20_431 as u64).saturating_mul(s as u64))
73+
// Standard Error: 186
74+
.saturating_add(Weight::from_ref_time(3_373 as u64).saturating_mul(z as u64))
75+
.saturating_add(T::DbWeight::get().reads(1 as u64))
76+
.saturating_add(T::DbWeight::get().writes(1 as u64))
77+
}
78+
// Storage: Multisig Multisigs (r:1 w:1)
79+
// Proof: Multisig Multisigs (max_values: None, max_size: Some(2198), added: 4673, mode: MaxEncodedLen)
80+
// Storage: System Account (r:1 w:1)
81+
// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen)
82+
fn as_multi_complete(s: u32, z: u32, ) -> Weight {
83+
Weight::from_ref_time(20_642_060 as u64)
84+
// Standard Error: 5_511
85+
.saturating_add(Weight::from_ref_time(104_693 as u64).saturating_mul(s as u64))
86+
// Standard Error: 34
87+
.saturating_add(Weight::from_ref_time(1_132 as u64).saturating_mul(z as u64))
88+
.saturating_add(T::DbWeight::get().reads(2 as u64))
89+
.saturating_add(T::DbWeight::get().writes(2 as u64))
90+
}
91+
// Storage: Multisig Multisigs (r:1 w:1)
92+
// Proof: Multisig Multisigs (max_values: None, max_size: Some(2198), added: 4673, mode: MaxEncodedLen)
93+
fn approve_as_multi_create(s: u32, ) -> Weight {
94+
Weight::from_ref_time(17_036_891 as u64)
95+
// Standard Error: 4_200
96+
.saturating_add(Weight::from_ref_time(122_554 as u64).saturating_mul(s as u64))
97+
.saturating_add(T::DbWeight::get().reads(1 as u64))
98+
.saturating_add(T::DbWeight::get().writes(1 as u64))
99+
}
100+
// Storage: Multisig Multisigs (r:1 w:1)
101+
// Proof: Multisig Multisigs (max_values: None, max_size: Some(2198), added: 4673, mode: MaxEncodedLen)
102+
fn approve_as_multi_approve(s: u32, ) -> Weight {
103+
Weight::from_ref_time(12_421_505 as u64)
104+
// Standard Error: 7_770
105+
.saturating_add(Weight::from_ref_time(81_668 as u64).saturating_mul(s as u64))
106+
.saturating_add(T::DbWeight::get().reads(1 as u64))
107+
.saturating_add(T::DbWeight::get().writes(1 as u64))
108+
}
109+
// Storage: Multisig Multisigs (r:1 w:1)
110+
// Proof: Multisig Multisigs (max_values: None, max_size: Some(2198), added: 4673, mode: MaxEncodedLen)
111+
fn cancel_as_multi(s: u32, ) -> Weight {
112+
Weight::from_ref_time(19_681_233 as u64)
113+
// Standard Error: 4_292
114+
.saturating_add(Weight::from_ref_time(70_945 as u64).saturating_mul(s as u64))
115+
.saturating_add(T::DbWeight::get().reads(1 as u64))
116+
.saturating_add(T::DbWeight::get().writes(1 as u64))
117+
}
118+
}

runtimes/spiritnet/Cargo.toml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
[package]
22
authors.workspace = true
3+
description = "Parachain runtime for KILT Mainnet on Polkadot."
34
documentation.workspace = true
45
edition.workspace = true
56
homepage.workspace = true
67
license-file.workspace = true
8+
name = "spiritnet-runtime"
79
readme.workspace = true
810
repository.workspace = true
911
version.workspace = true
10-
name = "spiritnet-runtime"
11-
description = "Parachain runtime for KILT Mainnet on Polkadot."
1212

1313
[build-dependencies]
1414
substrate-wasm-builder.workspace = true
@@ -68,6 +68,7 @@ pallet-collective.workspace = true
6868
pallet-democracy.workspace = true
6969
pallet-indices.workspace = true
7070
pallet-membership.workspace = true
71+
pallet-multisig.workspace = true
7172
pallet-preimage.workspace = true
7273
pallet-proxy.workspace = true
7374
pallet-randomness-collective-flip.workspace = true
@@ -139,6 +140,7 @@ runtime-benchmarks = [
139140
"pallet-vesting/runtime-benchmarks",
140141
"pallet-web3-names/runtime-benchmarks",
141142
"pallet-xcm/runtime-benchmarks",
143+
"pallet-multisig/runtime-benchmarks",
142144
"parachain-staking/runtime-benchmarks",
143145
"public-credentials/runtime-benchmarks",
144146
"runtime-common/runtime-benchmarks",
@@ -187,6 +189,7 @@ std = [
187189
"pallet-randomness-collective-flip/std",
188190
"pallet-scheduler/std",
189191
"pallet-session/std",
192+
"pallet-multisig/std",
190193
"pallet-timestamp/std",
191194
"pallet-tips/std",
192195
"pallet-transaction-payment-rpc-runtime-api/std",
@@ -231,6 +234,7 @@ try-runtime = [
231234
"frame-support/try-runtime",
232235
"frame-system/try-runtime",
233236
"frame-try-runtime",
237+
"pallet-multisig/try-runtime",
234238
"kilt-support/try-runtime",
235239
"pallet-aura/try-runtime",
236240
"pallet-authorship/try-runtime",

runtimes/spiritnet/src/lib.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,16 @@ parameter_types! {
192192
pub const MaxReserves: u32 = 50;
193193
}
194194

195+
impl pallet_multisig::Config for Runtime {
196+
type RuntimeEvent = RuntimeEvent;
197+
type RuntimeCall = RuntimeCall;
198+
type Currency = Balances;
199+
type DepositBase = constants::multisig::DepositBase;
200+
type DepositFactor = constants::multisig::DepositFactor;
201+
type MaxSignatories = constants::multisig::MaxSignitors;
202+
type WeightInfo = weights::pallet_multisig::WeightInfo<Runtime>;
203+
}
204+
195205
impl pallet_indices::Config for Runtime {
196206
type AccountIndex = Index;
197207
type Currency = pallet_balances::Pallet<Runtime>;
@@ -961,6 +971,8 @@ construct_runtime! {
961971
TipsMembership: pallet_membership::<Instance2> = 45,
962972
Tips: pallet_tips::{Pallet, Call, Storage, Event<T>} = 46,
963973

974+
Multisig: pallet_multisig = 47,
975+
964976
// KILT Pallets. Start indices 60 to leave room
965977
// DELETED: KiltLaunch: kilt_launch = 60,
966978
Ctype: ctype = 61,
@@ -1104,6 +1116,7 @@ mod benches {
11041116
[pallet_vesting, Vesting]
11051117
[pallet_proxy, Proxy]
11061118
[pallet_xcm, PolkadotXcm]
1119+
[pallet_multisig, Multisig]
11071120
);
11081121
}
11091122

runtimes/spiritnet/src/weights/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ pub mod pallet_did_lookup;
2828
pub mod pallet_indices;
2929
pub mod pallet_inflation;
3030
pub mod pallet_membership;
31+
pub mod pallet_multisig;
3132
pub mod pallet_preimage;
3233
pub mod pallet_proxy;
3334
pub mod pallet_scheduler;

0 commit comments

Comments
 (0)