Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Add pallet-society and pallet-recovery to substrate node #4622

Merged
merged 3 commits into from
Jan 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions bin/node/runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,16 @@ 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" }
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" }
Expand Down Expand Up @@ -91,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",
Expand Down Expand Up @@ -119,4 +121,6 @@ std = [
"sp-transaction-pool/std",
"pallet-utility/std",
"sp-version/std",
"pallet-society/std",
"pallet-recovery/std",
]
73 changes: 61 additions & 12 deletions bin/node/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};

Expand Down Expand Up @@ -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 = ();
Expand Down Expand Up @@ -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<AccountId, CouncilCollective>;
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<Runtime, UncheckedExtrinsic> for Runtime {
Expand Down Expand Up @@ -543,6 +546,50 @@ impl frame_system::offchain::CreateTransaction<Runtime, UncheckedExtrinsic> 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<Runtime>;
type ChallengePeriod = ChallengePeriod;
}

construct_runtime!(
pub enum Runtime where
Block = Block,
Expand Down Expand Up @@ -573,7 +620,9 @@ 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<T>},
Identity: pallet_identity::{Module, Call, Storage, Event<T>},
Society: pallet_society::{Module, Call, Storage, Event<T>},
Recovery: pallet_recovery::{Module, Call, Storage, Event<T>},
}
);

Expand Down