diff --git a/Cargo.lock b/Cargo.lock index 5406b0d..1071b18 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -721,21 +721,21 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chacha20" -version = "0.7.3" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f08493fa7707effc63254c66c6ea908675912493cd67952eda23c09fae2610b1" +checksum = "fee7ad89dc1128635074c268ee661f90c3f7e83d9fd12910608c36b47d6c3412" dependencies = [ "cfg-if 1.0.0", "cipher", - "cpufeatures 0.2.1", + "cpufeatures 0.1.5", "zeroize", ] [[package]] name = "chacha20poly1305" -version = "0.8.2" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6547abe025f4027edacd9edaa357aded014eecec42a5070d9b885c3c334aba2" +checksum = "1580317203210c517b6d44794abfbe600698276db18127e37ad3e69bf5e848e5" dependencies = [ "aead", "chacha20", @@ -1411,9 +1411,9 @@ dependencies = [ [[package]] name = "finality-grandpa" -version = "0.14.3" +version = "0.14.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c832d0ed507622c7cb98e9b7f10426850fc9d38527ab8071778dcc3a81d45875" +checksum = "e8ac3ff5224ef91f3c97e03eb1de2db82743427e91aaa5ac635f454f0b164f5a" dependencies = [ "either", "futures 0.3.16", @@ -1723,9 +1723,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.16" +version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74ed2411805f6e4e3d9bc904c95d5d423b89b3b25dc0250aa74729de20629ff9" +checksum = "5da6ba8c3bb3c165d3c7319fc1cc8304facf1fb8db99c5de877183c08a273888" dependencies = [ "futures-core", "futures-sink", @@ -1733,9 +1733,9 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.16" +version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af51b1b4a7fdff033703db39de8802c673eb91855f2e0d47dcf3bf2c0ef01f99" +checksum = "88d1c26957f23603395cd326b0ffe64124b818f4449552f960d815cfba83a53d" [[package]] name = "futures-executor" @@ -1751,9 +1751,9 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.16" +version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b0e06c393068f3a6ef246c75cdca793d6a46347e75286933e5e75fd2fd11582" +checksum = "522de2a0fe3e380f1bc577ba0474108faf3f6b18321dbf60b3b9c39a75073377" [[package]] name = "futures-lite" @@ -1772,9 +1772,9 @@ dependencies = [ [[package]] name = "futures-macro" -version = "0.3.16" +version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c54913bae956fb8df7f4dc6fc90362aa72e69148e3f39041fbe8742d21e0ac57" +checksum = "18e4a4b95cea4b4ccbcf1c5675ca7c4ee4e9e75eb79944d07defde18068f79bb" dependencies = [ "autocfg", "proc-macro-hack", @@ -1796,15 +1796,15 @@ dependencies = [ [[package]] name = "futures-sink" -version = "0.3.16" +version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0f30aaa67363d119812743aa5f33c201a7a66329f97d1a887022971feea4b53" +checksum = "36ea153c13024fe480590b3e3d4cad89a0cfacecc24577b68f86c6ced9c2bc11" [[package]] name = "futures-task" -version = "0.3.16" +version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbe54a98670017f3be909561f6ad13e810d9a51f3f061b902062ca3da80799f2" +checksum = "1d3d00f4eddb73e498a54394f228cd55853bdf059259e8e7bc6e69d408892e99" [[package]] name = "futures-timer" @@ -1820,9 +1820,9 @@ checksum = "e64b03909df88034c26dc1547e8970b91f98bdb65165d6a4e9110d94263dbb2c" [[package]] name = "futures-util" -version = "0.3.16" +version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67eb846bfd58e44a8481a00049e82c43e0ccb5d61f8dc071057cb19249dd4d78" +checksum = "36568465210a3a6ee45e1f165136d68671471a501e632e9a98d96872222b5481" dependencies = [ "autocfg", "futures 0.1.31", @@ -2331,6 +2331,7 @@ dependencies = [ "pallet-aura", "pallet-balances", "pallet-grandpa", + "pallet-multisig", "pallet-randomness-collective-flip", "pallet-sudo", "pallet-teerex", @@ -3851,6 +3852,20 @@ dependencies = [ "sp-std", ] +[[package]] +name = "pallet-multisig" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate.git?branch=master#b391b82954ad95a927a921035e3017c4a0aad516" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "parity-scale-codec", + "sp-io", + "sp-runtime", + "sp-std", +] + [[package]] name = "pallet-randomness-collective-flip" version = "4.0.0-dev" @@ -4451,9 +4466,9 @@ checksum = "bc881b2c22681370c6a780e47af9840ef841837bc98118431d4e1868bd0c1086" [[package]] name = "proc-macro2" -version = "1.0.28" +version = "1.0.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c7ed8b8c7b886ea3ed7dde405212185f423ab44682667c8c6dd14aa1d9f6612" +checksum = "b9f5105d4fdaab20335ca9565e106a5d9b82b6219b5ba735731124ac6711d23d" dependencies = [ "unicode-xid", ] @@ -5840,9 +5855,9 @@ dependencies = [ [[package]] name = "scale-info" -version = "0.10.0" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2e62ff266e136db561a007c84569985805f84a1d5a08278e52c36aacb6e061b" +checksum = "5c55b744399c25532d63a0d2789b109df8d46fc93752d46b0782991a931a782f" dependencies = [ "bitvec 0.20.4", "cfg-if 1.0.0", @@ -5853,9 +5868,9 @@ dependencies = [ [[package]] name = "scale-info-derive" -version = "0.7.0" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b648fa291891a4c80187a25532f6a7d96b82c70353e30b868b14632b8fe043d6" +checksum = "baeb2780690380592f86205aa4ee49815feb2acad8c2f59e6dd207148c3f1fcd" dependencies = [ "proc-macro-crate 1.0.0", "proc-macro2", @@ -6010,9 +6025,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.66" +version = "1.0.68" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "336b10da19a12ad094b59d870ebde26a45402e5b470add4b5fd03c5048a32127" +checksum = "0f690853975602e1bfe1ccbf50504d67174e3bcf340f23b5ea9992e0587a52d8" dependencies = [ "itoa", "ryu", @@ -8050,9 +8065,9 @@ dependencies = [ [[package]] name = "zeroize" -version = "1.3.0" +version = "1.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4756f7db3f7b5574938c3eb1c117038b8e07f95ee6718c0efad4ac21508f1efd" +checksum = "bf68b08513768deaa790264a7fac27a58cbf2705cfcdc9448362229217d7e970" dependencies = [ "zeroize_derive", ] diff --git a/node/src/chain_spec.rs b/node/src/chain_spec.rs index 56196b3..ed4bd39 100644 --- a/node/src/chain_spec.rs +++ b/node/src/chain_spec.rs @@ -1,4 +1,4 @@ -use integritee_node_runtime::{AccountId, AuraConfig, BalancesConfig, GenesisConfig, GrandpaConfig, Signature, SudoConfig, SystemConfig, WASM_BINARY, TreasuryPalletId}; +use integritee_node_runtime::{AccountId, AuraConfig, BalancesConfig, GenesisConfig, GrandpaConfig, Signature, SudoConfig, SystemConfig, WASM_BINARY, TreasuryPalletId, Multisig}; use sc_service::ChainType; use sp_consensus_aura::sr25519::AuthorityId as AuraId; use sp_core::{sr25519, Pair, Public}; @@ -57,9 +57,17 @@ pub fn development_config() -> Result { vec![ get_account_id_from_seed::("Alice"), get_account_id_from_seed::("Bob"), + get_account_id_from_seed::("Dave"), get_account_id_from_seed::("Alice//stash"), get_account_id_from_seed::("Bob//stash"), treasury_account_id(), + // The address of a multi-signature account is deterministically generated from the signers and threshold of the multisig wallet. + // Creating a multi-sig account from Polkadot-JS Apps UI, always sort the accounts according to the keys. Here we do the same + Multisig::multi_account_id(&[ + get_account_id_from_seed::("Dave"), + get_account_id_from_seed::("Bob"), + get_account_id_from_seed::("Alice"), + ], 2), ], true, ) @@ -107,6 +115,12 @@ pub fn local_testnet_config() -> Result { get_account_id_from_seed::("Eve//stash"), get_account_id_from_seed::("Ferdie//stash"), treasury_account_id(), + Multisig::multi_account_id(&[ + get_account_id_from_seed::("Alice"), + get_account_id_from_seed::("Bob"), + get_account_id_from_seed::("Charlie"), + get_account_id_from_seed::("Dave"), + ], 3), ], true, ) diff --git a/runtime/Cargo.toml b/runtime/Cargo.toml index 7cf0374..17e4b55 100644 --- a/runtime/Cargo.toml +++ b/runtime/Cargo.toml @@ -28,6 +28,7 @@ pallet-sudo = { version = "4.0.0-dev", default-features = false, git = "https:// pallet-timestamp = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "master" } pallet-transaction-payment = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "master" } pallet-treasury = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "master" } +pallet-multisig = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "master" } sp-api = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "master" } sp-block-builder = { default-features = false, version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "master" } @@ -76,6 +77,7 @@ std = [ "pallet-transaction-payment-rpc-runtime-api/std", "pallet-transaction-payment/std", "pallet-treasury/std", + "pallet-multisig/std", "sp-api/std", "sp-block-builder/std", "sp-consensus-aura/std", @@ -98,5 +100,6 @@ runtime-benchmarks = [ "pallet-balances/runtime-benchmarks", "pallet-timestamp/runtime-benchmarks", "pallet-treasury/runtime-benchmarks", + "pallet-multisig/runtime-benchmarks", "sp-runtime/runtime-benchmarks", ] diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index 6c7dfc8..8e422b1 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -161,6 +161,11 @@ pub const TEER: Balance = 1_000_000_000_000; pub const MILLITEER: Balance = 1_000_000_000; pub const MICROTEER: Balance = 1_000_000; +//Logic from polkaodt/kusuma +pub const fn deposit(items: u32, bytes: u32) -> Balance { + items as Balance * 20 * TEER + (bytes as Balance) * 1_000 * MICROTEER +} + /// added by Integritee /// A timestamp: milliseconds since the unix epoch. pub type Moment = u64; @@ -379,6 +384,24 @@ impl pallet_treasury::Config for Runtime { type WeightInfo = (); } +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 = 10; //100 +} + +impl pallet_multisig::Config for Runtime { + type Event = Event; + type Call = Call; + type Currency = Balances; + type DepositBase = DepositBase; + type DepositFactor = DepositFactor; + type MaxSignatories = MaxSignatories; + type WeightInfo = (); +} + // Create the runtime by composing the FRAME pallets that were previously configured. construct_runtime!( pub enum Runtime where @@ -397,6 +420,7 @@ construct_runtime!( // added by Integritee Teerex: pallet_teerex::{Pallet, Call, Storage, Event}, Treasury: pallet_treasury::{Pallet, Call, Storage, Config, Event}, + Multisig: pallet_multisig::{Pallet, Call, Storage, Event}, } ); @@ -574,7 +598,7 @@ impl_runtime_apis! { list_benchmark!(list, extra, pallet_balances, Balances); list_benchmark!(list, extra, pallet_timestamp, Timestamp); list_benchmark!(list, extra, pallet_treasury, Treasury); - + list_benchmark!(list, extra, pallet_multisig, Multisig); let storage_info = AllPalletsWithSystem::storage_info(); return (list, storage_info) @@ -610,6 +634,7 @@ impl_runtime_apis! { add_benchmark!(params, batches, pallet_balances, Balances); add_benchmark!(params, batches, pallet_timestamp, Timestamp); add_benchmark!(params, batches, pallet_treasury, Treasury); + add_benchmark!(params, batches, pallet_multisig, Multisig); if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) } Ok(batches)