Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Open Gov for Development and Altair Runtimes #1828

Merged
merged 28 commits into from
Jun 28, 2024
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
bb5c278
chore: add OpenGov pallets to root toml
wischli May 13, 2024
74acbd3
feat: add OpenGov tracks to runtime common
wischli May 3, 2024
bfb36ae
feat: add technical committee migration
wischli May 3, 2024
f530ee5
refactor: move origins from primitives to common
wischli May 13, 2024
5a3e4ba
feat: add OpenGov to Development
wischli May 3, 2024
7ef53e8
feat: add OpenGov to Altair
wischli May 3, 2024
4d78c10
feat: add OpenGov to Centrifuge chain
wischli Apr 17, 2024
dd7884c
Revert "feat: add OpenGov to Centrifuge chain"
wischli May 13, 2024
d369536
fix: clippy
wischli May 13, 2024
bc41393
tests: fix CouncilCollective import path
wischli May 14, 2024
8d4a231
fix: technical committee migrations
wischli May 14, 2024
dc39024
altair: configure tc migration (incomplete)
wischli May 14, 2024
c7b1f18
dev: configure tc migration
wischli May 14, 2024
9a4950a
chore: cleanup altair dep diff
wischli May 21, 2024
bc2ae52
chore: remove unused getrandom crate from runtimes
wischli May 21, 2024
a98666b
chore: add missing Altair TC members
wischli May 21, 2024
c7be7f9
refactor: move to_ppm and to_percent to utils
wischli May 21, 2024
27ea745
Merge remote-tracking branch 'origin/main' into feat/open-gov-2
wischli May 21, 2024
7175fe9
Merge remote-tracking branch 'origin/main' into feat/open-gov-2
wischli Jun 25, 2024
4beb919
Merge remote-tracking branch 'origin/main' into feat/open-gov-2
wischli Jun 25, 2024
aef53a3
fix: issues after rebasing
wischli Jun 25, 2024
9c50dd4
fmt
wischli Jun 25, 2024
dd97b2a
Merge remote-tracking branch 'origin/main' into feat/open-gov-2
wischli Jun 25, 2024
cb9bb3b
Merge remote-tracking branch 'origin/main' into feat/open-gov-2
wischli Jun 26, 2024
05c50aa
fix: imports
wischli Jun 26, 2024
230651d
Merge remote-tracking branch 'origin/main' into feat/open-gov-2
wischli Jun 28, 2024
6b11298
feat: v0.12.0 for altair RU
wischli Jun 28, 2024
c4c78a2
Merge remote-tracking branch 'origin/main' into feat/open-gov-2
wischli Jun 28, 2024
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
14 changes: 11 additions & 3 deletions Cargo.lock

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

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -185,11 +185,13 @@ pallet-aura = { git = "https://github.com/paritytech/polkadot-sdk", default-feat
pallet-authorship = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-polkadot-v1.1.0" }
pallet-balances = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-polkadot-v1.1.0" }
pallet-collective = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-polkadot-v1.1.0" }
pallet-conviction-voting = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-polkadot-v1.1.0" }
pallet-democracy = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-polkadot-v1.1.0" }
pallet-elections-phragmen = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-polkadot-v1.1.0" }
pallet-identity = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-polkadot-v1.1.0" }
pallet-membership = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-polkadot-v1.1.0" }
pallet-multisig = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-polkadot-v1.1.0" }
pallet-referenda = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-polkadot-v1.1.0" }
pallet-preimage = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-polkadot-v1.1.0" }
pallet-proxy = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-polkadot-v1.1.0" }
pallet-scheduler = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-polkadot-v1.1.0" }
Expand All @@ -202,6 +204,7 @@ pallet-treasury = { git = "https://github.com/paritytech/polkadot-sdk", default-
pallet-uniques = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-polkadot-v1.1.0" }
pallet-utility = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-polkadot-v1.1.0" }
pallet-vesting = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-polkadot-v1.1.0" }
pallet-whitelist = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-polkadot-v1.1.0" }
substrate-prometheus-endpoint = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-polkadot-v1.1.0" }
substrate-frame-rpc-system = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-polkadot-v1.1.0" }
pallet-transaction-payment-rpc = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-polkadot-v1.1.0" }
Expand Down
4 changes: 4 additions & 0 deletions libs/primitives/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ sp-std = { workspace = true }
frame-support = { workspace = true }
frame-system = { workspace = true }
pallet-collective = { workspace = true }
pallet-membership = { workspace = true }

# cumulus primitives dependencies
cumulus-primitives-core = { workspace = true }
Expand All @@ -45,6 +46,7 @@ std = [
"frame-support/std",
"frame-system/std",
"pallet-collective/std",
"pallet-membership/std",
"scale-info/std",
"serde/std",
"sp-arithmetic/std",
Expand All @@ -60,12 +62,14 @@ runtime-benchmarks = [
"frame-support/runtime-benchmarks",
"frame-system/runtime-benchmarks",
"pallet-collective/runtime-benchmarks",
"pallet-membership/runtime-benchmarks",
"sp-runtime/runtime-benchmarks",
"staging-xcm-executor/runtime-benchmarks",
]
try-runtime = [
"frame-support/try-runtime",
"frame-system/try-runtime",
"pallet-collective/try-runtime",
"pallet-membership/try-runtime",
"sp-runtime/try-runtime",
]
34 changes: 13 additions & 21 deletions libs/primitives/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ pub use types::*;

/// Common types for all runtimes
pub mod types {
use frame_support::traits::EitherOfDiverse;
use frame_system::EnsureRoot;
use pallet_collective::EnsureProportionAtLeast;
use parity_scale_codec::{CompactAs, Decode, Encode, MaxEncodedLen};
use scale_info::TypeInfo;
#[cfg(feature = "std")]
Expand All @@ -46,24 +43,6 @@ pub mod types {
/// EpochId type we use to identify epochs in our revolving pools
pub type PoolEpochId = u32;

// Ensure that origin is either Root or fallback to use EnsureOrigin `O`
pub type EnsureRootOr<O> = EitherOfDiverse<EnsureRoot<AccountId>, O>;

/// The council
pub type CouncilCollective = pallet_collective::Instance1;

/// All council members must vote yes to create this origin.
pub type AllOfCouncil = EnsureProportionAtLeast<AccountId, CouncilCollective, 1, 1>;

/// 1/2 of all council members must vote yes to create this origin.
pub type HalfOfCouncil = EnsureProportionAtLeast<AccountId, CouncilCollective, 1, 2>;

/// 2/3 of all council members must vote yes to create this origin.
pub type TwoThirdOfCouncil = EnsureProportionAtLeast<AccountId, CouncilCollective, 2, 3>;

/// 3/4 of all council members must vote yes to create this origin.
pub type ThreeFourthOfCouncil = EnsureProportionAtLeast<AccountId, CouncilCollective, 3, 4>;

/// An index to a block.
pub type BlockNumber = u32;

Expand Down Expand Up @@ -283,6 +262,19 @@ pub mod constants {

/// The maximum number of pool fees per pool fee bucket
pub const MAX_POOL_FEES_PER_BUCKET: u32 = 100;

/// The index of the root OpenGov track
pub const TRACK_INDEX_ROOT: u16 = 0;
/// The index of the whitelisted caller OpenGov track
pub const TRACK_INDEX_WHITELISTED_CALLER: u16 = 1;
/// The index of the pool admin OpenGov track
pub const TRACK_INDEX_POOL_ADMIN: u16 = 10;
/// The index of the treasurer OpenGov track
pub const TRACK_INDEX_TREASURER: u16 = 11;
/// The index of the referendum canceller OpenGov track
pub const TRACK_INDEX_REF_CANCELLER: u16 = 20;
/// The index of the referendum killer OpenGov track
pub const TRACK_INDEX_REF_KILLER: u16 = 21;
}

/// Listing of parachains we integrate with.
Expand Down
28 changes: 28 additions & 0 deletions libs/utils/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,34 @@ pub mod math {
}
}

/// Converts the given number to percent.
///
/// # Example
///
/// ```
/// use sp_arithmetic::FixedI64;
/// use cfg_utils::math::to_percent;
///
/// assert_eq!(to_percent(3u128), FixedI64::from_rational(3, 100));
/// ```
pub const fn to_percent(x: u128) -> sp_arithmetic::FixedI64 {
sp_arithmetic::FixedI64::from_rational(x, 100)
}

/// Converts the given number to parts per million
///
/// # Example
///
/// ```
/// use sp_arithmetic::FixedI64;
/// use cfg_utils::math::to_ppm;
///
/// assert_eq!(to_ppm(3u128), FixedI64::from_rational(3, 1_000_000));
/// ```
pub const fn to_ppm(x: u128) -> sp_arithmetic::FixedI64 {
sp_arithmetic::FixedI64::from_rational(x, 1_000_000)
}

#[cfg(test)]
mod test_y_coord_in_function_with_2_points {
use super::*;
Expand Down
22 changes: 20 additions & 2 deletions node/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ use runtime_common::{account_conversion::AccountConverter, evm::precompile::H160
use sc_chain_spec::{ChainSpecExtension, ChainSpecGroup};
use sc_service::{ChainType, Properties};
use serde::{Deserialize, Serialize};
use sp_core::{crypto::UncheckedInto, sr25519, Encode, Pair, Public, H160};
use sp_core::{
bounded_vec::BoundedVec, crypto::UncheckedInto, sr25519, Encode, Pair, Public, H160,
};
use sp_runtime::{
traits::{IdentifyAccount, Verify},
FixedPointNumber,
Expand Down Expand Up @@ -513,7 +515,7 @@ fn altair_genesis(
orml_tokens: altair_runtime::OrmlTokensConfig { balances: vec![] },
elections: altair_runtime::ElectionsConfig { members: vec![] },
council: altair_runtime::CouncilConfig {
members: council_members,
members: council_members.clone(),
phantom: Default::default(),
},

Expand Down Expand Up @@ -590,6 +592,14 @@ fn altair_genesis(
safe_xcm_version: Some(SAFE_XCM_VERSION),
..Default::default()
},
technical_committee: altair_runtime::TechnicalCommitteeConfig {
members: council_members.clone(),
phantom: Default::default(),
},
technical_committee_membership: altair_runtime::TechnicalCommitteeMembershipConfig {
members: BoundedVec::truncate_from(council_members),
phantom: Default::default(),
},
}
}

Expand Down Expand Up @@ -762,6 +772,14 @@ fn development_genesis(
safe_xcm_version: Some(SAFE_XCM_VERSION),
..Default::default()
},
technical_committee: development_runtime::TechnicalCommitteeConfig {
members: Default::default(),
phantom: Default::default(),
},
technical_committee_membership: development_runtime::TechnicalCommitteeMembershipConfig {
members: Default::default(),
phantom: Default::default(),
},
}
}

Expand Down
Loading
Loading