Skip to content

Commit

Permalink
feat: Open Gov for Development and Altair Runtimes (#1828)
Browse files Browse the repository at this point in the history
* chore: add OpenGov pallets to root toml

* feat: add OpenGov tracks to runtime common

* feat: add technical committee migration

tc: fix clippy

* refactor: move origins from primitives to common

common: fix typo

common: fix test after HalfOfCouncil refactor

* feat: add OpenGov to Development

fix: complete Development OpenGov

development: finalize opengov

development: add proxy calls

development: overwrite missing origins

dev: fix treasury spender

dev: remove crowdloan pallets

dev: taplo fmt

* feat: add OpenGov to Altair

fix: complete Altair OpenGov

fix: add missing technical fellowship weights Altair

altair: finalize opengov

altair: rename track tests

altair: gather imports

altair: remove crowdloan pallets

altair: taplo fmt

* feat: add OpenGov to Centrifuge chain

fix: centrifuge toml

chore: minor centrifuge chain improvements

refactor: Centrifuge OpenGov

centrifuge: finalize opengov

centrifuge: fix cargo tml

cfg: fix clippy test

* Revert "feat: add OpenGov to Centrifuge chain"

This reverts commit 4d78c10.

* fix: clippy

* tests: fix CouncilCollective import path

* fix: technical committee migrations

* altair: configure tc migration (incomplete)

* dev: configure tc migration

* chore: cleanup altair dep diff

* chore: remove unused getrandom crate from runtimes

* chore: add missing Altair TC members

* refactor: move to_ppm and to_percent to utils

* Merge remote-tracking branch 'origin/main' into feat/open-gov-2

* fix: issues after rebasing

* fmt

* fix: imports

* feat: v0.12.0 for altair RU
  • Loading branch information
wischli authored Jun 28, 2024
1 parent aaa6bb6 commit d034784
Show file tree
Hide file tree
Showing 42 changed files with 4,350 additions and 691 deletions.
19 changes: 15 additions & 4 deletions Cargo.lock

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

7 changes: 5 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ license = "LGPL-3.0"
homepage = "https://centrifuge.io/"
repository = "https://github.com/centrifuge/centrifuge-chain"
documentation = "https://reference.centrifuge.io/centrifuge_chain/index.html"
version = "0.11.3"
version = "0.12.0"

[workspace.dependencies]
hex-literal = { version = "0.4.1" }
Expand Down Expand Up @@ -188,11 +188,14 @@ 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.7.2" }
pallet-balances = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-polkadot-v1.7.2" }
pallet-collective = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-polkadot-v1.7.2" }
pallet-conviction-voting = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-polkadot-v1.7.2" }
pallet-democracy = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-polkadot-v1.7.2" }
pallet-elections-phragmen = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-polkadot-v1.7.2" }
pallet-identity = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-polkadot-v1.7.2" }
pallet-membership = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-polkadot-v1.7.2" }
pallet-message-queue = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-polkadot-v1.7.2" }
pallet-multisig = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-polkadot-v1.7.2" }
pallet-referenda = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-polkadot-v1.7.2" }
pallet-preimage = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-polkadot-v1.7.2" }
pallet-proxy = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-polkadot-v1.7.2" }
pallet-scheduler = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-polkadot-v1.7.2" }
Expand All @@ -205,7 +208,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.7.2" }
pallet-utility = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-polkadot-v1.7.2" }
pallet-vesting = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-polkadot-v1.7.2" }
pallet-message-queue = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-polkadot-v1.7.2" }
pallet-whitelist = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-polkadot-v1.7.2" }
substrate-prometheus-endpoint = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-polkadot-v1.7.2" }
substrate-frame-rpc-system = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-polkadot-v1.7.2" }
pallet-transaction-payment-rpc = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-polkadot-v1.7.2" }
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 @@ -286,6 +265,19 @@ pub mod constants {

/// Identification of the native token of the chain. Used in XCM locations.
pub const NATIVE_KEY: &[u8] = &[0, 1];

/// 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
8 changes: 7 additions & 1 deletion node/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ use runtime_common::account_conversion::AccountConverter;
use sc_chain_spec::{ChainSpecExtension, ChainSpecGroup};
use sc_service::{ChainType, Properties};
use serde::{Deserialize, Serialize};
use sp_core::{sr25519, Encode, Pair, Public};
use sp_core::{bounded_vec::BoundedVec, sr25519, Encode, Pair, Public};
use sp_runtime::{
traits::{IdentifyAccount, Verify},
FixedPointNumber,
Expand Down Expand Up @@ -451,6 +451,12 @@ fn altair_genesis(
"polkadotXcm": {
"safeXcmVersion": Some(SAFE_XCM_VERSION),
},
"techhnicalCommittee": {
"members": council_members
},
"technicalCommitteeMembership": {
"members": BoundedVec::<_, altair_runtime::TechnicalMaxMembers>::truncate_from(council_members),
}
})
}

Expand Down
Empty file.
Loading

0 comments on commit d034784

Please sign in to comment.