From 63ec4c732d86a22d326899cac1a9e75035997180 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20K=C3=B6cher?= Date: Tue, 14 Jan 2020 18:04:10 +0100 Subject: [PATCH 1/3] Add `pallet-society` and `pallet-recovery` to substrate node --- Cargo.lock | 2 ++ bin/node/runtime/Cargo.toml | 4 +++ bin/node/runtime/src/lib.rs | 50 +++++++++++++++++++++++++++++++++++-- 3 files changed, 54 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 086df23fd2a57..3c34ebbdbcea8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3180,7 +3180,9 @@ dependencies = [ "pallet-nicks 2.0.0", "pallet-offences 2.0.0", "pallet-randomness-collective-flip 2.0.0", + "pallet-recovery 2.0.0", "pallet-session 2.0.0", + "pallet-society 2.0.0", "pallet-staking 2.0.0", "pallet-staking-reward-curve 2.0.0", "pallet-sudo 2.0.0", diff --git a/bin/node/runtime/Cargo.toml b/bin/node/runtime/Cargo.toml index a8f26d13cba40..e0873dfc3374a 100644 --- a/bin/node/runtime/Cargo.toml +++ b/bin/node/runtime/Cargo.toml @@ -52,10 +52,12 @@ pallet-membership = { version = "2.0.0", default-features = false, path = "../.. pallet-nicks = { version = "2.0.0", default-features = false, path = "../../../frame/nicks" } pallet-offences = { version = "2.0.0", default-features = false, path = "../../../frame/offences" } pallet-randomness-collective-flip = { version = "2.0.0", default-features = false, path = "../../../frame/randomness-collective-flip" } +pallet-recovery = { version = "2.0.0", default-features = false, path = "../../../frame/recovery" } pallet-session = { version = "2.0.0", features = ["historical"], path = "../../../frame/session", default-features = false } pallet-staking = { version = "2.0.0", features = ["migrate"], path = "../../../frame/staking", default-features = false } pallet-staking-reward-curve = { version = "2.0.0", path = "../../../frame/staking/reward-curve" } pallet-sudo = { version = "2.0.0", default-features = false, path = "../../../frame/sudo" } +pallet-society = { version = "2.0.0", default-features = false, path = "../../../frame/society" } pallet-timestamp = { version = "2.0.0", default-features = false, path = "../../../frame/timestamp" } pallet-treasury = { version = "2.0.0", default-features = false, path = "../../../frame/treasury" } pallet-utility = { version = "2.0.0", default-features = false, path = "../../../frame/utility" } @@ -119,4 +121,6 @@ std = [ "sp-transaction-pool/std", "pallet-utility/std", "sp-version/std", + "pallet-society/std", + "pallet-recovery/std", ] diff --git a/bin/node/runtime/src/lib.rs b/bin/node/runtime/src/lib.rs index 4266ad7459e65..43fd250c1f644 100644 --- a/bin/node/runtime/src/lib.rs +++ b/bin/node/runtime/src/lib.rs @@ -80,8 +80,8 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { // and set impl_version to equal spec_version. If only runtime // implementation changes and behavior does not, then leave spec_version as // is and increment impl_version. - spec_version: 203, - impl_version: 203, + spec_version: 204, + impl_version: 204, apis: RUNTIME_API_VERSIONS, }; @@ -543,6 +543,50 @@ impl frame_system::offchain::CreateTransaction for } } +parameter_types! { + pub const ConfigDepositBase: Balance = 5 * DOLLARS; + pub const FriendDepositFactor: Balance = 50 * CENTS; + pub const MaxFriends: u16 = 9; + pub const RecoveryDeposit: Balance = 5 * DOLLARS; +} + +impl pallet_recovery::Trait for Runtime { + type Event = Event; + type Call = Call; + type Currency = Balances; + type ConfigDepositBase = ConfigDepositBase; + type FriendDepositFactor = FriendDepositFactor; + type MaxFriends = MaxFriends; + type RecoveryDeposit = RecoveryDeposit; +} + +parameter_types! { + pub const CandidateDeposit: Balance = 10 * DOLLARS; + pub const WrongSideDeduction: Balance = 2 * DOLLARS; + pub const MaxStrikes: u32 = 10; + pub const RotationPeriod: BlockNumber = 80 * HOURS; + pub const PeriodSpend: Balance = 500 * DOLLARS; + pub const MaxLockDuration: BlockNumber = 36 * 30 * DAYS; + pub const ChallengePeriod: BlockNumber = 7 * DAYS; + pub const MaxMembers: u32 = 999; +} + +impl pallet_society::Trait for Runtime { + type Event = Event; + type Currency = Balances; + type Randomness = RandomnessCollectiveFlip; + type CandidateDeposit = CandidateDeposit; + type WrongSideDeduction = WrongSideDeduction; + type MaxStrikes = MaxStrikes; + type PeriodSpend = PeriodSpend; + type MembershipChanged = (); + type RotationPeriod = RotationPeriod; + type MaxLockDuration = MaxLockDuration; + type FounderSetOrigin = pallet_collective::EnsureProportionMoreThan<_1, _2, AccountId, CouncilCollective>; + type SuspensionJudgementOrigin = pallet_society::EnsureFounder; + type ChallengePeriod = ChallengePeriod; +} + construct_runtime!( pub enum Runtime where Block = Block, @@ -574,6 +618,8 @@ construct_runtime!( Offences: pallet_offences::{Module, Call, Storage, Event}, RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Module, Call, Storage}, Nicks: pallet_nicks::{Module, Call, Storage, Event}, + Society: pallet_society::{Module, Call, Storage, Event}, + Recovery: pallet_recovery::{Module, Call, Storage, Event}, } ); From 1e0e073158797ba3929cd3412210458451fffb04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20K=C3=B6cher?= Date: Tue, 14 Jan 2020 18:15:26 +0100 Subject: [PATCH 2/3] Add `OnReapAccount` --- bin/node/runtime/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/node/runtime/src/lib.rs b/bin/node/runtime/src/lib.rs index 43fd250c1f644..d21b7183b78ea 100644 --- a/bin/node/runtime/src/lib.rs +++ b/bin/node/runtime/src/lib.rs @@ -174,7 +174,7 @@ parameter_types! { impl pallet_balances::Trait for Runtime { type Balance = Balance; type OnFreeBalanceZero = ((Staking, Contracts), Session); - type OnReapAccount = System; + type OnReapAccount = (System, Recovery); type OnNewAccount = Indices; type Event = Event; type DustRemoval = (); From dccb255b315dc4bdc1145d9f8238c447e2930137 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20K=C3=B6cher?= Date: Tue, 14 Jan 2020 18:19:25 +0100 Subject: [PATCH 3/3] Fixes and replaces nicks with identity --- Cargo.lock | 2 +- bin/node/runtime/Cargo.toml | 4 ++-- bin/node/runtime/src/lib.rs | 21 ++++++++++++--------- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3c34ebbdbcea8..e5648c89d9354 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3174,10 +3174,10 @@ dependencies = [ "pallet-elections-phragmen 2.0.0", "pallet-finality-tracker 2.0.0", "pallet-grandpa 2.0.0", + "pallet-identity 2.0.0", "pallet-im-online 2.0.0", "pallet-indices 2.0.0", "pallet-membership 2.0.0", - "pallet-nicks 2.0.0", "pallet-offences 2.0.0", "pallet-randomness-collective-flip 2.0.0", "pallet-recovery 2.0.0", diff --git a/bin/node/runtime/Cargo.toml b/bin/node/runtime/Cargo.toml index e0873dfc3374a..c434c72120271 100644 --- a/bin/node/runtime/Cargo.toml +++ b/bin/node/runtime/Cargo.toml @@ -48,8 +48,8 @@ pallet-finality-tracker = { version = "2.0.0", default-features = false, path = pallet-grandpa = { version = "2.0.0", default-features = false, path = "../../../frame/grandpa" } pallet-im-online = { version = "2.0.0", default-features = false, path = "../../../frame/im-online" } pallet-indices = { version = "2.0.0", default-features = false, path = "../../../frame/indices" } +pallet-identity = { version = "2.0.0", default-features = false, path = "../../../frame/identity" } pallet-membership = { version = "2.0.0", default-features = false, path = "../../../frame/membership" } -pallet-nicks = { version = "2.0.0", default-features = false, path = "../../../frame/nicks" } pallet-offences = { version = "2.0.0", default-features = false, path = "../../../frame/offences" } pallet-randomness-collective-flip = { version = "2.0.0", default-features = false, path = "../../../frame/randomness-collective-flip" } pallet-recovery = { version = "2.0.0", default-features = false, path = "../../../frame/recovery" } @@ -93,7 +93,7 @@ std = [ "pallet-indices/std", "sp-inherents/std", "pallet-membership/std", - "pallet-nicks/std", + "pallet-identity/std", "node-primitives/std", "sp-offchain/std", "pallet-offences/std", diff --git a/bin/node/runtime/src/lib.rs b/bin/node/runtime/src/lib.rs index d21b7183b78ea..e5e453fcaff04 100644 --- a/bin/node/runtime/src/lib.rs +++ b/bin/node/runtime/src/lib.rs @@ -488,19 +488,22 @@ impl pallet_finality_tracker::Trait for Runtime { } parameter_types! { - pub const ReservationFee: Balance = 1 * DOLLARS; - pub const MinLength: usize = 3; - pub const MaxLength: usize = 16; + pub const BasicDeposit: Balance = 10 * DOLLARS; // 258 bytes on-chain + pub const FieldDeposit: Balance = 250 * CENTS; // 66 bytes on-chain + pub const SubAccountDeposit: Balance = 2 * DOLLARS; // 53 bytes on-chain + pub const MaximumSubAccounts: u32 = 100; } -impl pallet_nicks::Trait for Runtime { +impl pallet_identity::Trait for Runtime { type Event = Event; type Currency = Balances; - type ReservationFee = ReservationFee; type Slashed = Treasury; - type ForceOrigin = pallet_collective::EnsureMember; - type MinLength = MinLength; - type MaxLength = MaxLength; + type BasicDeposit = BasicDeposit; + type FieldDeposit = FieldDeposit; + type SubAccountDeposit = SubAccountDeposit; + type MaximumSubAccounts = MaximumSubAccounts; + type RegistrarOrigin = pallet_collective::EnsureProportionMoreThan<_1, _2, AccountId, CouncilCollective>; + type ForceOrigin = pallet_collective::EnsureProportionMoreThan<_1, _2, AccountId, CouncilCollective>; } impl frame_system::offchain::CreateTransaction for Runtime { @@ -617,7 +620,7 @@ construct_runtime!( AuthorityDiscovery: pallet_authority_discovery::{Module, Call, Config}, Offences: pallet_offences::{Module, Call, Storage, Event}, RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Module, Call, Storage}, - Nicks: pallet_nicks::{Module, Call, Storage, Event}, + Identity: pallet_identity::{Module, Call, Storage, Event}, Society: pallet_society::{Module, Call, Storage, Event}, Recovery: pallet_recovery::{Module, Call, Storage, Event}, }