From c2887834d13ed10d6dfdee02cfcd204ea637756c Mon Sep 17 00:00:00 2001 From: NZT48 Date: Wed, 4 May 2022 16:36:27 +0200 Subject: [PATCH 01/12] Adds multisig implementation --- runtime/Cargo.toml | 4 +++- runtime/src/lib.rs | 23 +++++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/runtime/Cargo.toml b/runtime/Cargo.toml index cbf8d03..08ce9b3 100644 --- a/runtime/Cargo.toml +++ b/runtime/Cargo.toml @@ -36,7 +36,8 @@ frame-try-runtime = { git = "https://github.com/paritytech/substrate", default-f pallet-aura = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.18" } pallet-authorship = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.18" } pallet-balances = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.18" } -pallet-scheduler = { git = "https://github.com/paritytech/substrate.git", default-features = false, branch = "polkadot-v0.9.18" } +pallet-multisig = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.18" } +pallet-scheduler = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.18" } pallet-session = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.18" } pallet-sudo = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.18" } pallet-timestamp = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.18" } @@ -101,6 +102,7 @@ std = [ "pallet-authorship/std", "pallet-balances/std", "pallet-collator-selection/std", + "pallet-multisig/std", "pallet-scheduler/std", "pallet-session/std", "pallet-sudo/std", diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index 00f9687..7a6d44b 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -200,6 +200,10 @@ pub const OTP: Balance = 1_000_000_000_000; pub const MILLIOTP: Balance = 1_000_000_000; pub const MICROOTP: Balance = 1_000_000; +pub const fn deposit(items: u32, bytes: u32) -> Balance { + items as Balance * 15 * OTP + (bytes as Balance) * 6 * OTP +} + /// The existential deposit. Set to 1/10 of the Connected Relay Chain. pub const EXISTENTIAL_DEPOSIT: Balance = OTP; @@ -476,6 +480,24 @@ impl pallet_sudo::Config for Runtime { type Call = Call; } +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 Event = Event; + type Call = Call; + type Currency = Balances; + type DepositBase = DepositBase; + type DepositFactor = DepositFactor; + type MaxSignatories = MaxSignatories; + type WeightInfo = pallet_multisig::weights::SubstrateWeight; +} + /// Configure the pallet template in pallets/template. impl pallet_template::Config for Runtime { type Event = Event; @@ -495,6 +517,7 @@ construct_runtime!( } = 1, Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent} = 2, ParachainInfo: parachain_info::{Pallet, Storage, Config} = 3, + Multisig: pallet_multisig::{Pallet, Call, Storage, Event} = 4, // Monetary stuff. Balances: pallet_balances::{Pallet, Call, Storage, Config, Event} = 10, From 9ec4230c7c8f23fc703941f4c00802f3a59850ba Mon Sep 17 00:00:00 2001 From: NZT48 Date: Mon, 9 May 2022 09:47:20 +0000 Subject: [PATCH 02/12] Increment versions for 1.0.1 runtime upgrade --- runtime/Cargo.toml | 41 ++++++++++++++++++++--------------------- runtime/src/lib.rs | 2 +- 2 files changed, 21 insertions(+), 22 deletions(-) diff --git a/runtime/Cargo.toml b/runtime/Cargo.toml index 08ce9b3..e743db2 100644 --- a/runtime/Cargo.toml +++ b/runtime/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "origintrail-parachain-runtime" -version = "1.0.0" +version = "1.0.1" authors = ["TraceLabs"] description = "OriginTrail Parachain Runtime - Cumulus FRAME-based Substrate Runtime" license = "GPL-3.0-only" @@ -15,10 +15,14 @@ targets = ["x86_64-unknown-linux-gnu"] substrate-wasm-builder = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.18" } [dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } +codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = [ + "derive", +] } hex-literal = { version = "0.3.4", optional = true } log = { version = "0.4.14", default-features = false } -scale-info = { version = "2.0.0", default-features = false, features = ["derive"] } +scale-info = { version = "2.0.0", default-features = false, features = [ + "derive", +] } serde = { version = "1.0.132", optional = true, features = ["derive"] } smallvec = "1.6.1" @@ -65,22 +69,20 @@ xcm-builder = { git = "https://github.com/paritytech/polkadot", default-features xcm-executor = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "release-v0.9.18" } # Cumulus -cumulus-pallet-aura-ext = { git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.18" } -cumulus-pallet-dmp-queue = { git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.18" } -cumulus-pallet-parachain-system = { git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.18" } -cumulus-pallet-session-benchmarking = { git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.18" } -cumulus-pallet-xcm = { git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.18" } -cumulus-pallet-xcmp-queue = { git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.18" } -cumulus-primitives-core = { git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.18" } -cumulus-primitives-timestamp = { git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.18" } -cumulus-primitives-utility = { git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.18" } -pallet-collator-selection = { git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.18" } -parachain-info = { git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.18" } +cumulus-pallet-aura-ext = { git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.18" } +cumulus-pallet-dmp-queue = { git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.18" } +cumulus-pallet-parachain-system = { git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.18" } +cumulus-pallet-session-benchmarking = { git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.18" } +cumulus-pallet-xcm = { git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.18" } +cumulus-pallet-xcmp-queue = { git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.18" } +cumulus-primitives-core = { git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.18" } +cumulus-primitives-timestamp = { git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.18" } +cumulus-primitives-utility = { git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.18" } +pallet-collator-selection = { git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.18" } +parachain-info = { git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.18" } [features] -default = [ - "std", -] +default = ["std"] std = [ "codec/std", "log/std", @@ -148,7 +150,4 @@ runtime-benchmarks = [ "cumulus-pallet-xcmp-queue/runtime-benchmarks", ] -try-runtime = [ - "frame-executive/try-runtime", - "frame-try-runtime", -] +try-runtime = ["frame-executive/try-runtime", "frame-try-runtime"] diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index 7a6d44b..af8f509 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -171,7 +171,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!("origintrail-parachain"), impl_name: create_runtime_str!("origintrail-parachain"), authoring_version: 1, - spec_version: 100, + spec_version: 101, impl_version: 0, apis: RUNTIME_API_VERSIONS, transaction_version: 1, From 15366c9a1446866c9a403ffb2d4e0890e3fedab3 Mon Sep 17 00:00:00 2001 From: NZT48 Date: Thu, 12 May 2022 10:41:32 +0000 Subject: [PATCH 03/12] Implement vesting --- Cargo.lock | 4 +++- node/src/chain_spec.rs | 1 + runtime/Cargo.toml | 5 ++++- runtime/src/lib.rs | 20 ++++++++++++++++++-- 4 files changed, 26 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f12a14b..4c52fb8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5235,7 +5235,7 @@ dependencies = [ [[package]] name = "origintrail-parachain-runtime" -version = "1.0.0" +version = "1.0.2" dependencies = [ "cumulus-pallet-aura-ext", "cumulus-pallet-dmp-queue", @@ -5259,6 +5259,7 @@ dependencies = [ "pallet-authorship", "pallet-balances", "pallet-collator-selection", + "pallet-multisig", "pallet-scheduler", "pallet-session", "pallet-sudo", @@ -5266,6 +5267,7 @@ dependencies = [ "pallet-timestamp", "pallet-transaction-payment", "pallet-transaction-payment-rpc-runtime-api", + "pallet-vesting", "pallet-xcm", "parachain-info", "parity-scale-codec", diff --git a/node/src/chain_spec.rs b/node/src/chain_spec.rs index e156c8f..1fc84cc 100644 --- a/node/src/chain_spec.rs +++ b/node/src/chain_spec.rs @@ -222,5 +222,6 @@ fn testnet_genesis( // Assign network admin rights. key: Some(root_key), }, + vesting: Default::default(), } } diff --git a/runtime/Cargo.toml b/runtime/Cargo.toml index e743db2..603e7d2 100644 --- a/runtime/Cargo.toml +++ b/runtime/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "origintrail-parachain-runtime" -version = "1.0.1" +version = "1.0.2" authors = ["TraceLabs"] description = "OriginTrail Parachain Runtime - Cumulus FRAME-based Substrate Runtime" license = "GPL-3.0-only" @@ -47,6 +47,7 @@ pallet-sudo = { git = "https://github.com/paritytech/substrate", default-feature pallet-timestamp = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.18" } pallet-transaction-payment = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.18" } pallet-transaction-payment-rpc-runtime-api = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.18" } +pallet-vesting = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.18" } sp-api = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.18" } sp-block-builder = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.18" } sp-consensus-aura = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.18" } @@ -113,6 +114,7 @@ std = [ "pallet-transaction-payment-rpc-runtime-api/std", "pallet-transaction-payment/std", "pallet-xcm/std", + "pallet-vesting/std", "parachain-info/std", "polkadot-parachain/std", "polkadot-runtime-common/std", @@ -143,6 +145,7 @@ runtime-benchmarks = [ "pallet-collator-selection/runtime-benchmarks", "pallet-template/runtime-benchmarks", "pallet-timestamp/runtime-benchmarks", + "pallet-vesting/runtime-benchmarks", "pallet-xcm/runtime-benchmarks", "sp-runtime/runtime-benchmarks", "xcm-builder/runtime-benchmarks", diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index af8f509..fdb64b6 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -13,7 +13,7 @@ use sp_api::impl_runtime_apis; use sp_core::{crypto::KeyTypeId, OpaqueMetadata}; use sp_runtime::{ create_runtime_str, generic, impl_opaque_keys, - traits::{AccountIdLookup, BlakeTwo256, Block as BlockT, IdentifyAccount, Verify}, + traits::{AccountIdLookup, BlakeTwo256, Block as BlockT, ConvertInto, IdentifyAccount, Verify}, transaction_validity::{TransactionSource, TransactionValidity}, ApplyExtrinsicResult, MultiSignature, }; @@ -171,7 +171,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!("origintrail-parachain"), impl_name: create_runtime_str!("origintrail-parachain"), authoring_version: 1, - spec_version: 101, + spec_version: 102, impl_version: 0, apis: RUNTIME_API_VERSIONS, transaction_version: 1, @@ -498,6 +498,21 @@ impl pallet_multisig::Config for Runtime { type WeightInfo = pallet_multisig::weights::SubstrateWeight; } +parameter_types! { + pub const MinVestedTransfer: Balance = 100 * OTP; +} + +impl pallet_vesting::Config for Runtime { + type Event = Event; + type Currency = Balances; + type BlockNumberToBalance = ConvertInto; + type MinVestedTransfer = MinVestedTransfer; + type WeightInfo = pallet_vesting::weights::SubstrateWeight; + // `VestingInfo` encode length is 36bytes. 28 schedules gets encoded as 1009 bytes, which is the + // highest number of schedules that encodes less than 2^10. + const MAX_VESTING_SCHEDULES: u32 = 28; +} + /// Configure the pallet template in pallets/template. impl pallet_template::Config for Runtime { type Event = Event; @@ -522,6 +537,7 @@ construct_runtime!( // Monetary stuff. Balances: pallet_balances::{Pallet, Call, Storage, Config, Event} = 10, TransactionPayment: pallet_transaction_payment::{Pallet, Storage} = 11, + Vesting: pallet_vesting::{Pallet, Call, Storage, Event, Config} = 12, // Collator support. The order of these 4 are important and shall not change. Authorship: pallet_authorship::{Pallet, Call, Storage} = 20, From d647018180e1e17c2d2bc19003b20f8bdf69502a Mon Sep 17 00:00:00 2001 From: NZT48 Date: Thu, 12 May 2022 10:46:31 +0000 Subject: [PATCH 04/12] Add shields to readme --- README.md | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index bf21c2f..e06c5b9 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,17 @@ # OriginTrail Parachain Node - -

+

-

+ + +[![License](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0) +[![Substrate version](https://img.shields.io/badge/Substrate-3.0.0-brightgreen?logo=Parity%20Substrate)](https://substrate.io) +[![Twitter URL](https://img.shields.io/twitter/follow/OT_Parachain?style=social)](https://twitter.com/OT_Parachain) +[![Telegram](https://img.shields.io/endpoint?color=neon&style=flat-square&url=https%3A%2F%2Ftg.sumanjay.workers.dev%2Forigintrail)](https://t.me/origintrail) +[![Medium](https://badgen.net/badge/icon/medium?icon=medium&label)](https://medium.com/origintrail) +[![Discord](https://img.shields.io/badge/Discord-gray?logo=discord)](https://discord.gg/FCgYk2S) + +
The OriginTrail Parachain is the next-generation L1 blockchain designed to tightly integrate with the OriginTrail DKG. As an OriginTrail-tailored blockchain it is optimized for maximum performance and usability in the OriginTrail consensus layer. It leverages the strong trust model and inherent interoperability of Polkadot, enabling smooth integration with other Polkadot ecosystem projects. From 167dc5e7fdb7ec627282911ef008d11261eae297 Mon Sep 17 00:00:00 2001 From: NZT48 Date: Tue, 14 Jun 2022 22:25:12 +0200 Subject: [PATCH 05/12] Revert "Implement vesting" This reverts commit 15366c9a1446866c9a403ffb2d4e0890e3fedab3. --- Cargo.lock | 4 +--- node/src/chain_spec.rs | 1 - runtime/Cargo.toml | 5 +---- runtime/src/lib.rs | 20 ++------------------ 4 files changed, 4 insertions(+), 26 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4c52fb8..f12a14b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5235,7 +5235,7 @@ dependencies = [ [[package]] name = "origintrail-parachain-runtime" -version = "1.0.2" +version = "1.0.0" dependencies = [ "cumulus-pallet-aura-ext", "cumulus-pallet-dmp-queue", @@ -5259,7 +5259,6 @@ dependencies = [ "pallet-authorship", "pallet-balances", "pallet-collator-selection", - "pallet-multisig", "pallet-scheduler", "pallet-session", "pallet-sudo", @@ -5267,7 +5266,6 @@ dependencies = [ "pallet-timestamp", "pallet-transaction-payment", "pallet-transaction-payment-rpc-runtime-api", - "pallet-vesting", "pallet-xcm", "parachain-info", "parity-scale-codec", diff --git a/node/src/chain_spec.rs b/node/src/chain_spec.rs index 1fc84cc..e156c8f 100644 --- a/node/src/chain_spec.rs +++ b/node/src/chain_spec.rs @@ -222,6 +222,5 @@ fn testnet_genesis( // Assign network admin rights. key: Some(root_key), }, - vesting: Default::default(), } } diff --git a/runtime/Cargo.toml b/runtime/Cargo.toml index 603e7d2..e743db2 100644 --- a/runtime/Cargo.toml +++ b/runtime/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "origintrail-parachain-runtime" -version = "1.0.2" +version = "1.0.1" authors = ["TraceLabs"] description = "OriginTrail Parachain Runtime - Cumulus FRAME-based Substrate Runtime" license = "GPL-3.0-only" @@ -47,7 +47,6 @@ pallet-sudo = { git = "https://github.com/paritytech/substrate", default-feature pallet-timestamp = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.18" } pallet-transaction-payment = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.18" } pallet-transaction-payment-rpc-runtime-api = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.18" } -pallet-vesting = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.18" } sp-api = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.18" } sp-block-builder = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.18" } sp-consensus-aura = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.18" } @@ -114,7 +113,6 @@ std = [ "pallet-transaction-payment-rpc-runtime-api/std", "pallet-transaction-payment/std", "pallet-xcm/std", - "pallet-vesting/std", "parachain-info/std", "polkadot-parachain/std", "polkadot-runtime-common/std", @@ -145,7 +143,6 @@ runtime-benchmarks = [ "pallet-collator-selection/runtime-benchmarks", "pallet-template/runtime-benchmarks", "pallet-timestamp/runtime-benchmarks", - "pallet-vesting/runtime-benchmarks", "pallet-xcm/runtime-benchmarks", "sp-runtime/runtime-benchmarks", "xcm-builder/runtime-benchmarks", diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index fdb64b6..af8f509 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -13,7 +13,7 @@ use sp_api::impl_runtime_apis; use sp_core::{crypto::KeyTypeId, OpaqueMetadata}; use sp_runtime::{ create_runtime_str, generic, impl_opaque_keys, - traits::{AccountIdLookup, BlakeTwo256, Block as BlockT, ConvertInto, IdentifyAccount, Verify}, + traits::{AccountIdLookup, BlakeTwo256, Block as BlockT, IdentifyAccount, Verify}, transaction_validity::{TransactionSource, TransactionValidity}, ApplyExtrinsicResult, MultiSignature, }; @@ -171,7 +171,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!("origintrail-parachain"), impl_name: create_runtime_str!("origintrail-parachain"), authoring_version: 1, - spec_version: 102, + spec_version: 101, impl_version: 0, apis: RUNTIME_API_VERSIONS, transaction_version: 1, @@ -498,21 +498,6 @@ impl pallet_multisig::Config for Runtime { type WeightInfo = pallet_multisig::weights::SubstrateWeight; } -parameter_types! { - pub const MinVestedTransfer: Balance = 100 * OTP; -} - -impl pallet_vesting::Config for Runtime { - type Event = Event; - type Currency = Balances; - type BlockNumberToBalance = ConvertInto; - type MinVestedTransfer = MinVestedTransfer; - type WeightInfo = pallet_vesting::weights::SubstrateWeight; - // `VestingInfo` encode length is 36bytes. 28 schedules gets encoded as 1009 bytes, which is the - // highest number of schedules that encodes less than 2^10. - const MAX_VESTING_SCHEDULES: u32 = 28; -} - /// Configure the pallet template in pallets/template. impl pallet_template::Config for Runtime { type Event = Event; @@ -537,7 +522,6 @@ construct_runtime!( // Monetary stuff. Balances: pallet_balances::{Pallet, Call, Storage, Config, Event} = 10, TransactionPayment: pallet_transaction_payment::{Pallet, Storage} = 11, - Vesting: pallet_vesting::{Pallet, Call, Storage, Event, Config} = 12, // Collator support. The order of these 4 are important and shall not change. Authorship: pallet_authorship::{Pallet, Call, Storage} = 20, From 0d885d9c9ebf9da857a59d29f5e47801afffe72d Mon Sep 17 00:00:00 2001 From: NZT48 Date: Tue, 14 Jun 2022 22:25:51 +0200 Subject: [PATCH 06/12] Revert "Increment versions for 1.0.1 runtime upgrade" This reverts commit 9ec4230c7c8f23fc703941f4c00802f3a59850ba. --- runtime/Cargo.toml | 41 +++++++++++++++++++++-------------------- runtime/src/lib.rs | 2 +- 2 files changed, 22 insertions(+), 21 deletions(-) diff --git a/runtime/Cargo.toml b/runtime/Cargo.toml index e743db2..08ce9b3 100644 --- a/runtime/Cargo.toml +++ b/runtime/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "origintrail-parachain-runtime" -version = "1.0.1" +version = "1.0.0" authors = ["TraceLabs"] description = "OriginTrail Parachain Runtime - Cumulus FRAME-based Substrate Runtime" license = "GPL-3.0-only" @@ -15,14 +15,10 @@ targets = ["x86_64-unknown-linux-gnu"] substrate-wasm-builder = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.18" } [dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = [ - "derive", -] } +codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } hex-literal = { version = "0.3.4", optional = true } log = { version = "0.4.14", default-features = false } -scale-info = { version = "2.0.0", default-features = false, features = [ - "derive", -] } +scale-info = { version = "2.0.0", default-features = false, features = ["derive"] } serde = { version = "1.0.132", optional = true, features = ["derive"] } smallvec = "1.6.1" @@ -69,20 +65,22 @@ xcm-builder = { git = "https://github.com/paritytech/polkadot", default-features xcm-executor = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "release-v0.9.18" } # Cumulus -cumulus-pallet-aura-ext = { git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.18" } -cumulus-pallet-dmp-queue = { git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.18" } -cumulus-pallet-parachain-system = { git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.18" } -cumulus-pallet-session-benchmarking = { git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.18" } -cumulus-pallet-xcm = { git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.18" } -cumulus-pallet-xcmp-queue = { git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.18" } -cumulus-primitives-core = { git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.18" } -cumulus-primitives-timestamp = { git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.18" } -cumulus-primitives-utility = { git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.18" } -pallet-collator-selection = { git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.18" } -parachain-info = { git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.18" } +cumulus-pallet-aura-ext = { git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.18" } +cumulus-pallet-dmp-queue = { git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.18" } +cumulus-pallet-parachain-system = { git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.18" } +cumulus-pallet-session-benchmarking = { git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.18" } +cumulus-pallet-xcm = { git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.18" } +cumulus-pallet-xcmp-queue = { git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.18" } +cumulus-primitives-core = { git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.18" } +cumulus-primitives-timestamp = { git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.18" } +cumulus-primitives-utility = { git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.18" } +pallet-collator-selection = { git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.18" } +parachain-info = { git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.18" } [features] -default = ["std"] +default = [ + "std", +] std = [ "codec/std", "log/std", @@ -150,4 +148,7 @@ runtime-benchmarks = [ "cumulus-pallet-xcmp-queue/runtime-benchmarks", ] -try-runtime = ["frame-executive/try-runtime", "frame-try-runtime"] +try-runtime = [ + "frame-executive/try-runtime", + "frame-try-runtime", +] diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index af8f509..7a6d44b 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -171,7 +171,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!("origintrail-parachain"), impl_name: create_runtime_str!("origintrail-parachain"), authoring_version: 1, - spec_version: 101, + spec_version: 100, impl_version: 0, apis: RUNTIME_API_VERSIONS, transaction_version: 1, From 7c56cf4bce78d5b8915ef96bda043d84050a1b32 Mon Sep 17 00:00:00 2001 From: NZT48 Date: Tue, 14 Jun 2022 22:26:31 +0200 Subject: [PATCH 07/12] Revert "Adds multisig implementation" This reverts commit c2887834d13ed10d6dfdee02cfcd204ea637756c. --- runtime/Cargo.toml | 4 +--- runtime/src/lib.rs | 23 ----------------------- 2 files changed, 1 insertion(+), 26 deletions(-) diff --git a/runtime/Cargo.toml b/runtime/Cargo.toml index 08ce9b3..cbf8d03 100644 --- a/runtime/Cargo.toml +++ b/runtime/Cargo.toml @@ -36,8 +36,7 @@ frame-try-runtime = { git = "https://github.com/paritytech/substrate", default-f pallet-aura = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.18" } pallet-authorship = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.18" } pallet-balances = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.18" } -pallet-multisig = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.18" } -pallet-scheduler = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.18" } +pallet-scheduler = { git = "https://github.com/paritytech/substrate.git", default-features = false, branch = "polkadot-v0.9.18" } pallet-session = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.18" } pallet-sudo = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.18" } pallet-timestamp = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.18" } @@ -102,7 +101,6 @@ std = [ "pallet-authorship/std", "pallet-balances/std", "pallet-collator-selection/std", - "pallet-multisig/std", "pallet-scheduler/std", "pallet-session/std", "pallet-sudo/std", diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index 7a6d44b..00f9687 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -200,10 +200,6 @@ pub const OTP: Balance = 1_000_000_000_000; pub const MILLIOTP: Balance = 1_000_000_000; pub const MICROOTP: Balance = 1_000_000; -pub const fn deposit(items: u32, bytes: u32) -> Balance { - items as Balance * 15 * OTP + (bytes as Balance) * 6 * OTP -} - /// The existential deposit. Set to 1/10 of the Connected Relay Chain. pub const EXISTENTIAL_DEPOSIT: Balance = OTP; @@ -480,24 +476,6 @@ impl pallet_sudo::Config for Runtime { type Call = Call; } -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 Event = Event; - type Call = Call; - type Currency = Balances; - type DepositBase = DepositBase; - type DepositFactor = DepositFactor; - type MaxSignatories = MaxSignatories; - type WeightInfo = pallet_multisig::weights::SubstrateWeight; -} - /// Configure the pallet template in pallets/template. impl pallet_template::Config for Runtime { type Event = Event; @@ -517,7 +495,6 @@ construct_runtime!( } = 1, Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent} = 2, ParachainInfo: parachain_info::{Pallet, Storage, Config} = 3, - Multisig: pallet_multisig::{Pallet, Call, Storage, Event} = 4, // Monetary stuff. Balances: pallet_balances::{Pallet, Call, Storage, Config, Event} = 10, From 79aa976a969f03c03855088cbe6c138b8569b4f5 Mon Sep 17 00:00:00 2001 From: NZT48 Date: Tue, 14 Jun 2022 21:47:16 +0000 Subject: [PATCH 08/12] Increment runtime version to 101 --- runtime/Cargo.toml | 41 ++++++++++++++++++++--------------------- runtime/src/lib.rs | 2 +- 2 files changed, 21 insertions(+), 22 deletions(-) diff --git a/runtime/Cargo.toml b/runtime/Cargo.toml index cbf8d03..cd426db 100644 --- a/runtime/Cargo.toml +++ b/runtime/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "origintrail-parachain-runtime" -version = "1.0.0" +version = "1.0.1" authors = ["TraceLabs"] description = "OriginTrail Parachain Runtime - Cumulus FRAME-based Substrate Runtime" license = "GPL-3.0-only" @@ -15,10 +15,14 @@ targets = ["x86_64-unknown-linux-gnu"] substrate-wasm-builder = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.18" } [dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } +codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = [ + "derive", +] } hex-literal = { version = "0.3.4", optional = true } log = { version = "0.4.14", default-features = false } -scale-info = { version = "2.0.0", default-features = false, features = ["derive"] } +scale-info = { version = "2.0.0", default-features = false, features = [ + "derive", +] } serde = { version = "1.0.132", optional = true, features = ["derive"] } smallvec = "1.6.1" @@ -64,22 +68,20 @@ xcm-builder = { git = "https://github.com/paritytech/polkadot", default-features xcm-executor = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "release-v0.9.18" } # Cumulus -cumulus-pallet-aura-ext = { git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.18" } -cumulus-pallet-dmp-queue = { git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.18" } -cumulus-pallet-parachain-system = { git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.18" } -cumulus-pallet-session-benchmarking = { git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.18" } -cumulus-pallet-xcm = { git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.18" } -cumulus-pallet-xcmp-queue = { git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.18" } -cumulus-primitives-core = { git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.18" } -cumulus-primitives-timestamp = { git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.18" } -cumulus-primitives-utility = { git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.18" } -pallet-collator-selection = { git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.18" } -parachain-info = { git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.18" } +cumulus-pallet-aura-ext = { git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.18" } +cumulus-pallet-dmp-queue = { git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.18" } +cumulus-pallet-parachain-system = { git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.18" } +cumulus-pallet-session-benchmarking = { git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.18" } +cumulus-pallet-xcm = { git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.18" } +cumulus-pallet-xcmp-queue = { git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.18" } +cumulus-primitives-core = { git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.18" } +cumulus-primitives-timestamp = { git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.18" } +cumulus-primitives-utility = { git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.18" } +pallet-collator-selection = { git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.18" } +parachain-info = { git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.18" } [features] -default = [ - "std", -] +default = ["std"] std = [ "codec/std", "log/std", @@ -146,7 +148,4 @@ runtime-benchmarks = [ "cumulus-pallet-xcmp-queue/runtime-benchmarks", ] -try-runtime = [ - "frame-executive/try-runtime", - "frame-try-runtime", -] +try-runtime = ["frame-executive/try-runtime", "frame-try-runtime"] diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index 00f9687..22c46be 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -171,7 +171,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!("origintrail-parachain"), impl_name: create_runtime_str!("origintrail-parachain"), authoring_version: 1, - spec_version: 100, + spec_version: 101, impl_version: 0, apis: RUNTIME_API_VERSIONS, transaction_version: 1, From 79ba531245bbc974796e902edff66027e3c9e8d6 Mon Sep 17 00:00:00 2001 From: NZT48 Date: Tue, 14 Jun 2022 21:48:17 +0000 Subject: [PATCH 09/12] Add cargo.lock --- Cargo.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index f12a14b..472e0e8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5235,7 +5235,7 @@ dependencies = [ [[package]] name = "origintrail-parachain-runtime" -version = "1.0.0" +version = "1.0.1" dependencies = [ "cumulus-pallet-aura-ext", "cumulus-pallet-dmp-queue", From 6bfc06f6a6ac3b2e2cf9eacf7bb3c1f52bc61bf4 Mon Sep 17 00:00:00 2001 From: NZT48 Date: Mon, 27 Jun 2022 23:01:19 +0000 Subject: [PATCH 10/12] Implement vesting --- node/src/chain_spec.rs | 1 + runtime/Cargo.toml | 3 +++ runtime/src/lib.rs | 18 +++++++++++++++++- 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/node/src/chain_spec.rs b/node/src/chain_spec.rs index e156c8f..1fc84cc 100644 --- a/node/src/chain_spec.rs +++ b/node/src/chain_spec.rs @@ -222,5 +222,6 @@ fn testnet_genesis( // Assign network admin rights. key: Some(root_key), }, + vesting: Default::default(), } } diff --git a/runtime/Cargo.toml b/runtime/Cargo.toml index cd426db..1c35224 100644 --- a/runtime/Cargo.toml +++ b/runtime/Cargo.toml @@ -46,6 +46,7 @@ pallet-sudo = { git = "https://github.com/paritytech/substrate", default-feature pallet-timestamp = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.18" } pallet-transaction-payment = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.18" } pallet-transaction-payment-rpc-runtime-api = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.18" } +pallet-vesting = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.18" } sp-api = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.18" } sp-block-builder = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.18" } sp-consensus-aura = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.18" } @@ -110,6 +111,7 @@ std = [ "pallet-timestamp/std", "pallet-transaction-payment-rpc-runtime-api/std", "pallet-transaction-payment/std", + "pallet-vesting/std", "pallet-xcm/std", "parachain-info/std", "polkadot-parachain/std", @@ -141,6 +143,7 @@ runtime-benchmarks = [ "pallet-collator-selection/runtime-benchmarks", "pallet-template/runtime-benchmarks", "pallet-timestamp/runtime-benchmarks", + "pallet-vesting/runtime-benchmarks", "pallet-xcm/runtime-benchmarks", "sp-runtime/runtime-benchmarks", "xcm-builder/runtime-benchmarks", diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index 22c46be..be50457 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -13,7 +13,7 @@ use sp_api::impl_runtime_apis; use sp_core::{crypto::KeyTypeId, OpaqueMetadata}; use sp_runtime::{ create_runtime_str, generic, impl_opaque_keys, - traits::{AccountIdLookup, BlakeTwo256, Block as BlockT, IdentifyAccount, Verify}, + traits::{AccountIdLookup, BlakeTwo256, Block as BlockT, ConvertInto, IdentifyAccount, Verify}, transaction_validity::{TransactionSource, TransactionValidity}, ApplyExtrinsicResult, MultiSignature, }; @@ -476,6 +476,21 @@ impl pallet_sudo::Config for Runtime { type Call = Call; } +parameter_types! { + pub const MinVestedTransfer: Balance = 15 * OTP; +} + +impl pallet_vesting::Config for Runtime { + type Event = Event; + type Currency = Balances; + type BlockNumberToBalance = ConvertInto; + type MinVestedTransfer = MinVestedTransfer; + type WeightInfo = pallet_vesting::weights::SubstrateWeight; + // `VestingInfo` encode length is 36bytes. 28 schedules gets encoded as 1009 bytes, which is the + // highest number of schedules that encodes less than 2^10. + const MAX_VESTING_SCHEDULES: u32 = 28; +} + /// Configure the pallet template in pallets/template. impl pallet_template::Config for Runtime { type Event = Event; @@ -499,6 +514,7 @@ construct_runtime!( // Monetary stuff. Balances: pallet_balances::{Pallet, Call, Storage, Config, Event} = 10, TransactionPayment: pallet_transaction_payment::{Pallet, Storage} = 11, + Vesting: pallet_vesting::{Pallet, Call, Storage, Event, Config} = 12, // Collator support. The order of these 4 are important and shall not change. Authorship: pallet_authorship::{Pallet, Call, Storage} = 20, From 8a116f006f85fd92732533548d00d7ee0ed53044 Mon Sep 17 00:00:00 2001 From: NZT48 Date: Mon, 27 Jun 2022 23:07:45 +0000 Subject: [PATCH 11/12] Implement community treasury --- node/src/chain_spec.rs | 1 + runtime/Cargo.toml | 3 +++ runtime/src/lib.rs | 29 +++++++++++++++++++++++++++++ 3 files changed, 33 insertions(+) diff --git a/node/src/chain_spec.rs b/node/src/chain_spec.rs index 1fc84cc..7043ce1 100644 --- a/node/src/chain_spec.rs +++ b/node/src/chain_spec.rs @@ -223,5 +223,6 @@ fn testnet_genesis( key: Some(root_key), }, vesting: Default::default(), + treasury: Default::default(), } } diff --git a/runtime/Cargo.toml b/runtime/Cargo.toml index 1c35224..e4b4cc9 100644 --- a/runtime/Cargo.toml +++ b/runtime/Cargo.toml @@ -46,6 +46,7 @@ pallet-sudo = { git = "https://github.com/paritytech/substrate", default-feature pallet-timestamp = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.18" } pallet-transaction-payment = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.18" } pallet-transaction-payment-rpc-runtime-api = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.18" } +pallet-treasury = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.18" } pallet-vesting = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.18" } sp-api = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.18" } sp-block-builder = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.18" } @@ -111,6 +112,7 @@ std = [ "pallet-timestamp/std", "pallet-transaction-payment-rpc-runtime-api/std", "pallet-transaction-payment/std", + "pallet-treasury/std", "pallet-vesting/std", "pallet-xcm/std", "parachain-info/std", @@ -143,6 +145,7 @@ runtime-benchmarks = [ "pallet-collator-selection/runtime-benchmarks", "pallet-template/runtime-benchmarks", "pallet-timestamp/runtime-benchmarks", + "pallet-treasury/runtime-benchmarks", "pallet-vesting/runtime-benchmarks", "pallet-xcm/runtime-benchmarks", "sp-runtime/runtime-benchmarks", diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index be50457..d694551 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -491,6 +491,34 @@ impl pallet_vesting::Config for Runtime { const MAX_VESTING_SCHEDULES: u32 = 28; } +parameter_types! { + pub const ProposalBond: Permill = Permill::from_percent(5); + pub const ProposalBondMinimum: Balance = 100 * OTP; + pub const ProposalBondMaximum: Balance = 500 * OTP; + pub const SpendPeriod: BlockNumber = 24 * DAYS; + pub const TreasuryPalletId: PalletId = PalletId(*b"otp/trea"); + pub const MaxApprovals: u32 = 100; +} + + +impl pallet_treasury::Config for Runtime { + type PalletId = TreasuryPalletId; + type Currency = Balances; + type ApproveOrigin = EnsureRoot; + type RejectOrigin = EnsureRoot; + type Event = Event; + type OnSlash = (); + type ProposalBond = ProposalBond; + type ProposalBondMinimum = ProposalBondMinimum; + type ProposalBondMaximum = ProposalBondMaximum; + type SpendPeriod = SpendPeriod; + type Burn = (); + type BurnDestination = (); + type SpendFunds = (); + type WeightInfo = pallet_treasury::weights::SubstrateWeight; + type MaxApprovals = MaxApprovals; +} + /// Configure the pallet template in pallets/template. impl pallet_template::Config for Runtime { type Event = Event; @@ -515,6 +543,7 @@ construct_runtime!( Balances: pallet_balances::{Pallet, Call, Storage, Config, Event} = 10, TransactionPayment: pallet_transaction_payment::{Pallet, Storage} = 11, Vesting: pallet_vesting::{Pallet, Call, Storage, Event, Config} = 12, + Treasury: pallet_treasury::{Pallet, Call, Storage, Config, Event} = 13, // Collator support. The order of these 4 are important and shall not change. Authorship: pallet_authorship::{Pallet, Call, Storage} = 20, From 653b93a5f7497504dd02dc2601b087a7a642e3e2 Mon Sep 17 00:00:00 2001 From: NZT48 Date: Mon, 27 Jun 2022 23:30:36 +0000 Subject: [PATCH 12/12] Implement on-chain accounts and update runtime version to 1.0.2 --- runtime/Cargo.toml | 2 +- runtime/src/lib.rs | 70 ++++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 65 insertions(+), 7 deletions(-) diff --git a/runtime/Cargo.toml b/runtime/Cargo.toml index e4b4cc9..8dfe539 100644 --- a/runtime/Cargo.toml +++ b/runtime/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "origintrail-parachain-runtime" -version = "1.0.1" +version = "1.0.2" authors = ["TraceLabs"] description = "OriginTrail Parachain Runtime - Cumulus FRAME-based Substrate Runtime" license = "GPL-3.0-only" diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index d694551..79c4156 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -25,7 +25,7 @@ use sp_version::RuntimeVersion; use frame_support::{ construct_runtime, parameter_types, - traits::Everything, + traits::{Everything, Currency as PalletCurrency, OnUnbalanced, Imbalance}, weights::{ constants::{BlockExecutionWeight, ExtrinsicBaseWeight, WEIGHT_PER_SECOND}, DispatchClass, Weight, WeightToFeeCoefficient, WeightToFeeCoefficients, @@ -38,7 +38,7 @@ use frame_system::{ EnsureRoot, }; pub use sp_consensus_aura::sr25519::AuthorityId as AuraId; -pub use sp_runtime::{MultiAddress, Perbill, Permill}; +pub use sp_runtime::{MultiAddress, Perbill, Permill, traits::AccountIdConversion }; pub use frame_support::traits::EqualPrivilegeOnly; use xcm_config::{XcmConfig, XcmOriginToTransactDispatchOrigin}; @@ -171,7 +171,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!("origintrail-parachain"), impl_name: create_runtime_str!("origintrail-parachain"), authoring_version: 1, - spec_version: 101, + spec_version: 102, impl_version: 0, apis: RUNTIME_API_VERSIONS, transaction_version: 1, @@ -250,6 +250,15 @@ parameter_types! { pub const SS58Prefix: u16 = 101; } +// Pallet accounts of runtime +parameter_types! { + pub const TreasuryPalletId: PalletId = PalletId(*b"otp/trea"); + pub const DkgIncentivesPalletId: PalletId = PalletId(*b"otp/dkgi"); + pub const FutureAuctionsPalletId: PalletId = PalletId(*b"otp/fauc"); + pub const CollatorsIncentivesPalletId: PalletId = PalletId(*b"otp/coli"); + pub const PotId: PalletId = PalletId(*b"PotStake"); +} + // Configure FRAME pallets to include in runtime. impl frame_system::Config for Runtime { @@ -345,6 +354,57 @@ impl pallet_balances::Config for Runtime { type ReserveIdentifier = [u8; 8]; } +pub struct ToStakingPot; +impl OnUnbalanced for ToStakingPot { + fn on_nonzero_unbalanced(amount: NegativeImbalance) { + let staking_pot = PotId::get().into_account(); + Balances::resolve_creating(&staking_pot, amount); + } +} + +pub struct FutureAuctionsPot; +impl OnUnbalanced for FutureAuctionsPot { + fn on_nonzero_unbalanced(amount: NegativeImbalance) { + let future_auctions_pot = FutureAuctionsPalletId::get().into_account(); + Balances::resolve_creating(&future_auctions_pot, amount); + } +} + +pub struct DkgIncentivesPot; +impl OnUnbalanced for DkgIncentivesPot { + fn on_nonzero_unbalanced(amount: NegativeImbalance) { + let dkg_incentives_pot = DkgIncentivesPalletId::get().into_account(); + Balances::resolve_creating(&dkg_incentives_pot, amount); + } +} + +type NegativeImbalance = >::NegativeImbalance; + +pub struct DealWithFees; +impl OnUnbalanced for DealWithFees { + fn on_unbalanceds(mut fees_then_tips: impl Iterator) { + if let Some(mut fees) = fees_then_tips.next() { + if let Some(tips) = fees_then_tips.next() { + tips.merge_into(&mut fees); + } + // for fees and tips: + // - 30% to DKG Incentives pool + // - 30% to Collators Incentives pool (currently staking_pot) + // - 30% to Future Auctions pool + // - 10% to Treasury + let split = fees.ration(60, 40); + let (dkg_incentives_fees, collators_incentives_fees) = split.0.ration(50, 50); + let (future_auctions_fees, treasury_fees) = split.1.ration(75, 25); + + + Treasury::on_unbalanced(treasury_fees); + >::on_unbalanced(collators_incentives_fees); + >::on_unbalanced(future_auctions_fees); + >::on_unbalanced(dkg_incentives_fees); + } + } +} + parameter_types! { /// Relay Chain `TransactionByteFee` / 10 pub const TransactionByteFee: Balance = 10 * MICROOTP; @@ -352,7 +412,7 @@ parameter_types! { } impl pallet_transaction_payment::Config for Runtime { - type OnChargeTransaction = pallet_transaction_payment::CurrencyAdapter; + type OnChargeTransaction = pallet_transaction_payment::CurrencyAdapter; type TransactionByteFee = TransactionByteFee; type WeightToFee = WeightToFee; type FeeMultiplierUpdate = SlowAdjustingFeeUpdate; @@ -423,7 +483,6 @@ impl pallet_aura::Config for Runtime { } parameter_types! { - pub const PotId: PalletId = PalletId(*b"PotStake"); pub const MaxCandidates: u32 = 1000; pub const MinCandidates: u32 = 5; pub const SessionLength: BlockNumber = 6 * HOURS; @@ -496,7 +555,6 @@ parameter_types! { pub const ProposalBondMinimum: Balance = 100 * OTP; pub const ProposalBondMaximum: Balance = 500 * OTP; pub const SpendPeriod: BlockNumber = 24 * DAYS; - pub const TreasuryPalletId: PalletId = PalletId(*b"otp/trea"); pub const MaxApprovals: u32 = 100; }