diff --git a/Cargo.lock b/Cargo.lock index 30a1c65..ce4babd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7380,6 +7380,7 @@ dependencies = [ "pallet-authorship", "pallet-balances", "pallet-collator-selection", + "pallet-multisig", "pallet-parachain-template", "pallet-session", "pallet-sudo", diff --git a/runtime/Cargo.toml b/runtime/Cargo.toml index b589f16..30436bd 100644 --- a/runtime/Cargo.toml +++ b/runtime/Cargo.toml @@ -39,6 +39,7 @@ frame-try-runtime = { git = "https://github.com/paritytech/polkadot-sdk", branch pallet-aura = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } pallet-authorship = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } pallet-balances = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } +pallet-multisig = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } pallet-session = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } pallet-sudo = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } pallet-timestamp = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false } @@ -104,6 +105,7 @@ std = [ "pallet-balances/std", "pallet-collator-selection/std", "pallet-parachain-template/std", + "pallet-multisig/std", "pallet-session/std", "pallet-sudo/std", "pallet-timestamp/std", @@ -144,6 +146,7 @@ runtime-benchmarks = [ "hex-literal", "pallet-balances/runtime-benchmarks", "pallet-collator-selection/runtime-benchmarks", + "pallet-multisig/runtime-benchmarks", "pallet-parachain-template/runtime-benchmarks", "pallet-sudo/runtime-benchmarks", "pallet-timestamp/runtime-benchmarks", @@ -169,6 +172,7 @@ try-runtime = [ "pallet-authorship/try-runtime", "pallet-balances/try-runtime", "pallet-collator-selection/try-runtime", + "pallet-multisig/try-runtime", "pallet-parachain-template/try-runtime", "pallet-session/try-runtime", "pallet-sudo/try-runtime", diff --git a/runtime/src/constants.rs b/runtime/src/constants.rs new file mode 100644 index 0000000..f1833cf --- /dev/null +++ b/runtime/src/constants.rs @@ -0,0 +1,11 @@ +pub mod currency { + use crate::Balance; + + pub const MILLICENTS: Balance = 1_000_000_000; + pub const CENTS: Balance = 1_000 * MILLICENTS; // assume this is worth about a cent. + pub const DOLLARS: Balance = 100 * CENTS; + + pub const fn deposit(items: u32, bytes: u32) -> Balance { + items as Balance * 15 * CENTS + (bytes as Balance) * 6 * CENTS + } +} diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index 706f056..3650554 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -6,6 +6,8 @@ #[cfg(feature = "std")] include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs")); +pub mod constants; +use constants::currency::*; mod weights; pub mod xcm_config; @@ -27,6 +29,7 @@ use frame_system::{ limits::{BlockLength, BlockWeights}, EnsureRoot, }; +pub use pallet_multisig; /// Import the template pallet. pub use pallet_parachain_template; use pallet_xcm::{EnsureXcm, IsVoiceOfBody}; @@ -426,6 +429,24 @@ impl cumulus_pallet_dmp_queue::Config for Runtime { type XcmExecutor = XcmExecutor; } +parameter_types! { + // One storage item; key size is 32; value is size 4+4+16+32 bytes = 56 bytes. + pub const DepositBase: Balance = deposit(1, 88); + // Additional storage item size of 32 bytes. + pub const DepositFactor: Balance = deposit(0, 32); + pub const MaxSignatories: u16 = 100; +} + +impl pallet_multisig::Config for 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; // TODO: others should check too, I copied this from: https://github.com/paritytech/statemint/blob/master/runtime/statemine/src/weights/pallet_multisig.rs +} + parameter_types! { pub const Period: u32 = 6 * HOURS; pub const Offset: u32 = 0; @@ -506,6 +527,7 @@ construct_runtime!( // Governance Sudo: pallet_sudo = 15, + Multisig: pallet_multisig, // Collator support. The order of these 4 are important and shall not change. Authorship: pallet_authorship = 20, diff --git a/runtime/src/weights/mod.rs b/runtime/src/weights/mod.rs index b473d49..599032a 100644 --- a/runtime/src/weights/mod.rs +++ b/runtime/src/weights/mod.rs @@ -19,6 +19,7 @@ pub mod block_weights; pub mod extrinsic_weights; +pub mod pallet_multisig; pub mod paritydb_weights; pub mod rocksdb_weights; diff --git a/runtime/src/weights/pallet_multisig.rs b/runtime/src/weights/pallet_multisig.rs new file mode 100644 index 0000000..b86be4f --- /dev/null +++ b/runtime/src/weights/pallet_multisig.rs @@ -0,0 +1,89 @@ +//! Autogenerated weights for pallet_multisig +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 3.0.0 +//! DATE: 2021-05-31, STEPS: `[50, ]`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: +//! `[]` EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: +//! Some("statemine-dev"), DB CACHE: 128 + +// Executed Command: +// ./target/release/statemint +// benchmark +// --chain=statemine-dev +// --execution=wasm +// --wasm-execution=compiled +// --pallet=pallet_multisig +// --extrinsic=* +// --steps=50 +// --repeat=20 +// --raw +// --output=./runtime/statemine/src/weights/ + +#![allow(unused_parens)] +#![allow(unused_imports)] + +use frame_support::{traits::Get, weights::Weight}; +use sp_std::marker::PhantomData; + +/// Weight functions for pallet_multisig. +pub struct WeightInfo(PhantomData); +impl pallet_multisig::WeightInfo for WeightInfo { + fn as_multi_threshold_1(z: u32) -> Weight { + Weight::from(15_911_000) + // Standard Error: 0 + .saturating_add((Weight::from(1_000)).saturating_mul(z.into())) + } + + fn as_multi_create(s: u32, z: u32) -> Weight { + Weight::from(55_326_000) + // Standard Error: 0 + .saturating_add(Weight::from(133_000).saturating_mul(s.into())) + // Standard Error: 0 + .saturating_add(Weight::from(1_000).saturating_mul(z.into())) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(1)) + } + + fn as_multi_approve(s: u32, z: u32) -> Weight { + Weight::from(32_430_000) + // Standard Error: 0 + .saturating_add(Weight::from(148_000).saturating_mul(s.into())) + // Standard Error: 0 + .saturating_add(Weight::from(1_000).saturating_mul(z.into())) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) + } + + fn as_multi_complete(s: u32, z: u32) -> Weight { + Weight::from(80_926_000) + // Standard Error: 0 + .saturating_add(Weight::from(276_000).saturating_mul(s.into())) + // Standard Error: 0 + .saturating_add(Weight::from(5_000).saturating_mul(z.into())) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(3)) + } + + fn approve_as_multi_create(s: u32) -> Weight { + Weight::from(54_860_000) + // Standard Error: 0 + .saturating_add(Weight::from(134_000).saturating_mul(s.into())) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(1)) + } + + fn approve_as_multi_approve(s: u32) -> Weight { + Weight::from(31_924_000) + // Standard Error: 0 + .saturating_add(Weight::from(154_000).saturating_mul(s.into())) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) + } + + fn cancel_as_multi(s: u32) -> Weight { + Weight::from(103_770_000) + // Standard Error: 0 + .saturating_add(Weight::from(130_000).saturating_mul(s.into())) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(2)) + } +}