Skip to content

Commit a38a75c

Browse files
authored
feat: add governance to spiritnet runtime (#255)
* fix: fast track voting period * feat: move fast-gov consts to primitives * feat: remove session.set_keys filter * feat: add governance to spiritnet * fix: clippy * fix: remove society + bump spec versions
1 parent 5dd5616 commit a38a75c

File tree

17 files changed

+1301
-348
lines changed

17 files changed

+1301
-348
lines changed

Cargo.lock

+245-159
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

nodes/parachain/Cargo.toml

+9-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,11 @@ substrate-build-script-utils = {git = "https://github.com/paritytech/substrate",
9999

100100
[features]
101101
default = []
102-
fast-gov = ["peregrine-runtime/fast-gov"]
102+
fast-gov = ["peregrine-runtime/fast-gov", "kilt-primitives/fast-gov"]
103+
rococo-native=[
104+
"polkadot-service/rococo-native",
105+
"polkadot-cli/rococo-native",
106+
]
103107
runtime-benchmarks = [
104108
"peregrine-runtime/runtime-benchmarks",
105109
"spiritnet-runtime/runtime-benchmarks",
@@ -110,3 +114,7 @@ try-runtime = [
110114
"spiritnet-runtime/try-runtime",
111115
"try-runtime-cli",
112116
]
117+
westend-native=[
118+
"polkadot-service/westend-native",
119+
"polkadot-cli/westend-native",
120+
]

nodes/parachain/src/chain_spec/peregrine.rs

-1
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,6 @@ fn testnet_genesis(
232232
phantom: Default::default(),
233233
},
234234
treasury: Default::default(),
235-
elections_phragmen: Default::default(),
236235
technical_membership: Default::default(),
237236
democracy: Default::default(),
238237
parachain_staking: ParachainStakingConfig {

nodes/parachain/src/chain_spec/spiritnet.rs

+14-2
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,9 @@ use sc_telemetry::TelemetryEndpoints;
2929
use sp_core::{crypto::UncheckedInto, sr25519};
3030
use sp_runtime::traits::Zero;
3131
use spiritnet_runtime::{
32-
BalancesConfig, GenesisConfig, InflationInfo, KiltLaunchConfig, MinCollatorStake, ParachainInfoConfig,
33-
ParachainStakingConfig, SessionConfig, SudoConfig, SystemConfig, VestingConfig, WASM_BINARY,
32+
BalancesConfig, CouncilConfig, GenesisConfig, InflationInfo, KiltLaunchConfig, MinCollatorStake,
33+
ParachainInfoConfig, ParachainStakingConfig, SessionConfig, SudoConfig, SystemConfig, TechnicalCommitteeConfig,
34+
VestingConfig, WASM_BINARY,
3435
};
3536

3637
use crate::chain_spec::{get_account_id_from_seed, get_from_seed, TELEMETRY_URL};
@@ -389,5 +390,16 @@ fn testnet_genesis(
389390
})
390391
.collect::<Vec<_>>(),
391392
},
393+
council: CouncilConfig {
394+
members: vec![],
395+
phantom: Default::default(),
396+
},
397+
technical_committee: TechnicalCommitteeConfig {
398+
members: vec![],
399+
phantom: Default::default(),
400+
},
401+
treasury: Default::default(),
402+
technical_membership: Default::default(),
403+
democracy: Default::default(),
392404
}
393405
}

primitives/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ sp-consensus-aura = {git = "https://github.com/paritytech/substrate", default-fe
1616

1717
[features]
1818
default = ["std"]
19+
fast-gov = []
1920
std = [
2021
"codec/std",
2122
"frame-support/std",

primitives/src/constants.rs

+95
Original file line numberDiff line numberDiff line change
@@ -74,3 +74,98 @@ pub const INFLATION_CONFIG: (Perquintill, Perquintill, Perquintill, Perquintill)
7474
// delegator reward rate
7575
Perquintill::from_percent(8),
7676
);
77+
78+
pub mod staking {
79+
#[cfg(not(feature = "fast-gov"))]
80+
use super::{DAYS, HOURS};
81+
use crate::BlockNumber;
82+
83+
// Minimum round length is 1 hour (600 * 6 second block times)
84+
#[cfg(feature = "fast-gov")]
85+
pub const MIN_BLOCKS_PER_ROUND: BlockNumber = 10;
86+
#[cfg(not(feature = "fast-gov"))]
87+
pub const MIN_BLOCKS_PER_ROUND: BlockNumber = HOURS;
88+
89+
#[cfg(feature = "fast-gov")]
90+
pub const DEFAULT_BLOCKS_PER_ROUND: BlockNumber = 20;
91+
#[cfg(not(feature = "fast-gov"))]
92+
pub const DEFAULT_BLOCKS_PER_ROUND: BlockNumber = 2 * HOURS;
93+
94+
#[cfg(feature = "fast-gov")]
95+
pub const STAKE_DURATION: BlockNumber = 30;
96+
#[cfg(not(feature = "fast-gov"))]
97+
pub const STAKE_DURATION: BlockNumber = 7 * DAYS;
98+
99+
#[cfg(feature = "fast-gov")]
100+
pub const MIN_COLLATORS: u32 = 4;
101+
#[cfg(not(feature = "fast-gov"))]
102+
pub const MIN_COLLATORS: u32 = 16;
103+
104+
#[cfg(feature = "fast-gov")]
105+
pub const MAX_CANDIDATES: u32 = 16;
106+
#[cfg(not(feature = "fast-gov"))]
107+
pub const MAX_CANDIDATES: u32 = 75;
108+
}
109+
110+
pub mod governance {
111+
#[cfg(feature = "fast-gov")]
112+
use super::MINUTES;
113+
#[cfg(not(feature = "fast-gov"))]
114+
use super::{DAYS, HOURS};
115+
use crate::BlockNumber;
116+
117+
#[cfg(feature = "fast-gov")]
118+
pub const LAUNCH_PERIOD: BlockNumber = 7 * MINUTES;
119+
#[cfg(not(feature = "fast-gov"))]
120+
pub const LAUNCH_PERIOD: BlockNumber = 7 * DAYS;
121+
122+
#[cfg(feature = "fast-gov")]
123+
pub const VOTING_PERIOD: BlockNumber = 7 * MINUTES;
124+
#[cfg(not(feature = "fast-gov"))]
125+
pub const VOTING_PERIOD: BlockNumber = 7 * DAYS;
126+
127+
#[cfg(feature = "fast-gov")]
128+
pub const FAST_TRACK_VOTING_PERIOD: BlockNumber = 3 * MINUTES;
129+
#[cfg(not(feature = "fast-gov"))]
130+
pub const FAST_TRACK_VOTING_PERIOD: BlockNumber = 3 * HOURS;
131+
132+
#[cfg(feature = "fast-gov")]
133+
pub const ENACTMENT_PERIOD: BlockNumber = 8 * MINUTES;
134+
#[cfg(not(feature = "fast-gov"))]
135+
pub const ENACTMENT_PERIOD: BlockNumber = 8 * DAYS;
136+
137+
#[cfg(feature = "fast-gov")]
138+
pub const COOLOFF_PERIOD: BlockNumber = 7 * MINUTES;
139+
#[cfg(not(feature = "fast-gov"))]
140+
pub const COOLOFF_PERIOD: BlockNumber = 7 * DAYS;
141+
142+
#[cfg(feature = "fast-gov")]
143+
pub const SPEND_PERIOD: BlockNumber = 6 * MINUTES;
144+
#[cfg(not(feature = "fast-gov"))]
145+
pub const SPEND_PERIOD: BlockNumber = 6 * DAYS;
146+
147+
#[cfg(feature = "fast-gov")]
148+
pub const ROTATION_PERIOD: BlockNumber = 80 * MINUTES;
149+
#[cfg(not(feature = "fast-gov"))]
150+
pub const ROTATION_PERIOD: BlockNumber = 80 * HOURS;
151+
152+
#[cfg(feature = "fast-gov")]
153+
pub const CHALLENGE_PERIOD: BlockNumber = 7 * MINUTES;
154+
#[cfg(not(feature = "fast-gov"))]
155+
pub const CHALLENGE_PERIOD: BlockNumber = 7 * DAYS;
156+
157+
#[cfg(feature = "fast-gov")]
158+
pub const TERM_DURATION: BlockNumber = 15 * MINUTES;
159+
#[cfg(not(feature = "fast-gov"))]
160+
pub const TERM_DURATION: BlockNumber = DAYS;
161+
162+
#[cfg(feature = "fast-gov")]
163+
pub const COUNCIL_MOTION_DURATION: BlockNumber = 4 * MINUTES;
164+
#[cfg(not(feature = "fast-gov"))]
165+
pub const COUNCIL_MOTION_DURATION: BlockNumber = 3 * DAYS;
166+
167+
#[cfg(feature = "fast-gov")]
168+
pub const TECHNICAL_MOTION_DURATION: BlockNumber = 4 * MINUTES;
169+
#[cfg(not(feature = "fast-gov"))]
170+
pub const TECHNICAL_MOTION_DURATION: BlockNumber = 3 * DAYS;
171+
}

runtimes/peregrine/Cargo.toml

+4-5
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ pallet-membership = {git = "https://github.com/paritytech/substrate", default-fe
5555
pallet-randomness-collective-flip = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.9"}
5656
pallet-scheduler = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.9"}
5757
pallet-session = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.9"}
58-
pallet-society = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.9"}
5958
pallet-sudo = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.9"}
6059
pallet-timestamp = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.9"}
6160
pallet-transaction-payment = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.9"}
@@ -81,6 +80,8 @@ frame-benchmarking = {git = "https://github.com/paritytech/substrate", default-f
8180
frame-system-benchmarking = {git = "https://github.com/paritytech/substrate", default-features = false, optional = true, branch = "polkadot-v0.9.9"}
8281
hex-literal = {version = "0.3.1", optional = true}
8382
rococo-runtime = {git = "https://github.com/paritytech/polkadot", default-features = false, optional = true, branch = "release-v0.9.9"}
83+
pallet-society = {git = "https://github.com/paritytech/substrate", default-features = false, optional = true, branch = "polkadot-v0.9.9"}
84+
# cumulus-pallet-session-benchmarking = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.9", default-features = false, optional = true }
8485

8586
# Runtime tests
8687
frame-try-runtime = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.9", optional = true}
@@ -90,7 +91,7 @@ substrate-wasm-builder = {git = "https://github.com/paritytech/substrate", branc
9091

9192
[features]
9293
default = ["std"]
93-
fast-gov = []
94+
fast-gov = ["kilt-primitives/fast-gov"]
9495
runtime-benchmarks = [
9596
"attestation/runtime-benchmarks",
9697
"ctype/runtime-benchmarks",
@@ -108,8 +109,8 @@ runtime-benchmarks = [
108109
"pallet-indices/runtime-benchmarks",
109110
"pallet-membership/runtime-benchmarks",
110111
"pallet-scheduler/runtime-benchmarks",
111-
# "pallet-session/runtime-benchmarks",
112112
"pallet-society/runtime-benchmarks",
113+
# "cumulus-pallet-session-benchmarking",
113114
"pallet-timestamp/runtime-benchmarks",
114115
"pallet-treasury/runtime-benchmarks",
115116
"pallet-vesting/runtime-benchmarks",
@@ -149,7 +150,6 @@ std = [
149150
"pallet-randomness-collective-flip/std",
150151
"pallet-scheduler/std",
151152
"pallet-session/std",
152-
"pallet-society/std",
153153
"pallet-sudo/std",
154154
"pallet-timestamp/std",
155155
"pallet-transaction-payment/std",
@@ -197,7 +197,6 @@ try-runtime = [
197197
"pallet-randomness-collective-flip/try-runtime",
198198
"pallet-scheduler/try-runtime",
199199
"pallet-session/try-runtime",
200-
"pallet-society/try-runtime",
201200
"pallet-sudo/try-runtime",
202201
"pallet-timestamp/try-runtime",
203202
"pallet-transaction-payment/try-runtime",

0 commit comments

Comments
 (0)