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 all 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
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
Loading