Skip to content

Commit

Permalink
Fix: Added fast-net feature flag to the runtime and removed CouncilAd…
Browse files Browse the repository at this point in the history
…min track
  • Loading branch information
Anny0nn committed Nov 13, 2024
1 parent c396704 commit 672f5ee
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 107 deletions.
2 changes: 2 additions & 0 deletions invarch/runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ parachain-info = { workspace = true }

[features]

fast-net = []

metadata-hash = ["substrate-wasm-builder/metadata-hash"]

default = ["std"]
Expand Down
6 changes: 3 additions & 3 deletions invarch/runtime/src/governance/councils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
use super::*;

pub type TinkerCouncil = pallet_collective::Instance1;
pub type Council = pallet_collective::Instance1;

parameter_types! {
pub MaxProposalWeight: Weight = Perbill::from_percent(50) * RuntimeBlockWeights::get().max_block;
Expand All @@ -12,7 +12,7 @@ parameter_types! {

}

impl pallet_collective::Config<TinkerCouncil> for Runtime {
impl pallet_collective::Config<Council> for Runtime {
type RuntimeOrigin = RuntimeOrigin;
type RuntimeEvent = RuntimeEvent;
type Proposal = RuntimeCall;
Expand All @@ -25,6 +25,6 @@ impl pallet_collective::Config<TinkerCouncil> for Runtime {
type MaxMembers = MaxMembers;
type DefaultVote = pallet_collective::MoreThanMajorityThenPrimeDefaultVote;
type WeightInfo = pallet_collective::weights::SubstrateWeight<Runtime>;
type SetMembersOrigin = EitherOf<CouncilApproveOrigin, CouncilAdmin>;
type SetMembersOrigin = CouncilApproveOrigin;
type MaxProposalWeight = MaxProposalWeight;
}
15 changes: 7 additions & 8 deletions invarch/runtime/src/governance/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use self::councils::TinkerCouncil;
use self::councils::Council;

use super::*;
// use crate::xcm_config::CollectivesLocation;
Expand All @@ -8,8 +8,8 @@ use frame_system::EnsureRootWithSuccess;

mod origins;
pub use origins::{
pallet_custom_origins, CouncilAdmin, GeneralManagement, ReferendumCanceller, ReferendumKiller,
Spender, WhitelistedCaller,
pallet_custom_origins, GeneralManagement, ReferendumCanceller, ReferendumKiller, Spender,
WhitelistedCaller,
};
mod tracks;
pub use tracks::TracksInfo;
Expand Down Expand Up @@ -41,12 +41,11 @@ parameter_types! {
pub const MaxBalance: Balance = Balance::max_value();
}

pub type AllCouncil = pallet_collective::EnsureProportionAtLeast<AccountId, TinkerCouncil, 1, 1>;
pub type AllCouncil = pallet_collective::EnsureProportionAtLeast<AccountId, Council, 1, 1>;
pub type CouncilMoreThanApprove =
pallet_collective::EnsureProportionMoreThan<AccountId, TinkerCouncil, 3, 5>;
pub type ConcilHalf = pallet_collective::EnsureProportionAtLeast<AccountId, TinkerCouncil, 1, 2>;
pub type CouncilThreeFifths =
pallet_collective::EnsureProportionAtLeast<AccountId, TinkerCouncil, 3, 5>;
pallet_collective::EnsureProportionMoreThan<AccountId, Council, 3, 5>;
pub type ConcilHalf = pallet_collective::EnsureProportionAtLeast<AccountId, Council, 1, 2>;
pub type CouncilThreeFifths = pallet_collective::EnsureProportionAtLeast<AccountId, Council, 3, 5>;

pub type TreasurySpender = EitherOf<EnsureRootWithSuccess<AccountId, MaxBalance>, Spender>;
pub type RootOrGeneralManagement = EitherOf<EnsureRoot<AccountId>, GeneralManagement>;
Expand Down
7 changes: 2 additions & 5 deletions invarch/runtime/src/governance/origins.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ pub mod pallet_custom_origins {
#[derive(PartialEq, Eq, Clone, MaxEncodedLen, Encode, Decode, TypeInfo, RuntimeDebug)]
#[pallet::origin]
pub enum Origin {
/// Origin for managing the composition of the council.
CouncilAdmin,
/// Origin able to cancel a referenda.
ReferendumCanceller,
/// Origin able to kill referenda.
Expand All @@ -26,9 +24,9 @@ pub mod pallet_custom_origins {
WhitelistedCaller,
/// Origin for general management that does not require a runtime upgrade.
GeneralManagement,
/// Origin able to spend around $??? from the treasury at once.
/// Origin able to spend around 10K from the treasury at once.
SmallSpender,
/// Origin able to spend up to $??? from the treasury at once.
/// Origin able to spend up to 1MIL from the treasury at once.
BigSpender,
}

Expand Down Expand Up @@ -63,7 +61,6 @@ pub mod pallet_custom_origins {
() => {}
}
decl_unit_ensures!(
CouncilAdmin,
ReferendumCanceller,
ReferendumKiller,
WhitelistedCaller,
Expand Down
145 changes: 57 additions & 88 deletions invarch/runtime/src/governance/tracks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ const fn percent(x: i32) -> sp_arithmetic::FixedI64 {
use pallet_referenda::Curve;
const APP_ROOT: Curve = Curve::make_reciprocal(4, 28, percent(80), percent(50), percent(100));
const SUP_ROOT: Curve = Curve::make_linear(28, 28, percent(0), percent(50));
const APP_COUNCIL_ADMIN: Curve = Curve::make_linear(17, 28, percent(50), percent(100));
const SUP_COUNCIL_ADMIN: Curve =
Curve::make_reciprocal(12, 28, percent(1), percent(0), percent(50));
const APP_GENERAL_MANAGEMENT: Curve =
Curve::make_reciprocal(4, 28, percent(80), percent(50), percent(100));
const SUP_GENERAL_MANAGEMENT: Curve =
Expand All @@ -30,28 +27,28 @@ const APP_WHITELISTED_CALLER: Curve =
Curve::make_reciprocal(16, 28 * 24, percent(96), percent(50), percent(100));
const SUP_WHITELISTED_CALLER: Curve =
Curve::make_reciprocal(1, 28, percent(20), percent(5), percent(50));
const TRACKS_DATA: [(u16, pallet_referenda::TrackInfo<Balance, BlockNumber>); 8] = [
const TRACKS_DATA: [(u16, pallet_referenda::TrackInfo<Balance, BlockNumber>); 7] = [
(
0,
pallet_referenda::TrackInfo {
name: "root",
max_deciding: 1,
decision_deposit: 100 * GRAND,
#[cfg(not(feature = "on-chain-release-build"))]
#[cfg(feature = "fast-net")]
prepare_period: 4 * MINUTES,
#[cfg(feature = "on-chain-release-build")]
#[cfg(not(feature = "fast-net"))]
prepare_period: 2 * HOURS,
#[cfg(not(feature = "on-chain-release-build"))]
#[cfg(feature = "fast-net")]
decision_period: 10 * MINUTES,
#[cfg(feature = "on-chain-release-build")]
#[cfg(not(feature = "fast-net"))]
decision_period: 28 * DAYS,
#[cfg(not(feature = "on-chain-release-build"))]
#[cfg(feature = "fast-net")]
confirm_period: 5 * MINUTES,
#[cfg(feature = "on-chain-release-build")]
#[cfg(not(feature = "fast-net"))]
confirm_period: 7 * DAYS,
#[cfg(not(feature = "on-chain-release-build"))]
#[cfg(feature = "fast-net")]
min_enactment_period: 5 * MINUTES,
#[cfg(feature = "on-chain-release-build")]
#[cfg(not(feature = "fast-net"))]
min_enactment_period: 24 * HOURS,
min_approval: APP_ROOT,
min_support: SUP_ROOT,
Expand All @@ -63,21 +60,21 @@ const TRACKS_DATA: [(u16, pallet_referenda::TrackInfo<Balance, BlockNumber>); 8]
name: "whitelisted_caller",
max_deciding: 100,
decision_deposit: 10 * GRAND,
#[cfg(not(feature = "on-chain-release-build"))]
#[cfg(feature = "fast-net")]
prepare_period: 2 * MINUTES,
#[cfg(feature = "on-chain-release-build")]
#[cfg(not(feature = "fast-net"))]
prepare_period: 30 * MINUTES,
#[cfg(not(feature = "on-chain-release-build"))]
#[cfg(feature = "fast-net")]
decision_period: 10 * MINUTES,
#[cfg(feature = "on-chain-release-build")]
#[cfg(not(feature = "fast-net"))]
decision_period: 28 * DAYS,
#[cfg(not(feature = "on-chain-release-build"))]
#[cfg(feature = "fast-net")]
confirm_period: 5 * MINUTES,
#[cfg(feature = "on-chain-release-build")]
#[cfg(not(feature = "fast-net"))]
confirm_period: 10 * MINUTES,
#[cfg(not(feature = "on-chain-release-build"))]
#[cfg(feature = "fast-net")]
min_enactment_period: 5 * MINUTES,
#[cfg(feature = "on-chain-release-build")]
#[cfg(not(feature = "fast-net"))]
min_enactment_period: 10 * MINUTES,
min_approval: APP_WHITELISTED_CALLER,
min_support: SUP_WHITELISTED_CALLER,
Expand All @@ -89,73 +86,47 @@ const TRACKS_DATA: [(u16, pallet_referenda::TrackInfo<Balance, BlockNumber>); 8]
name: "general_management",
max_deciding: 10,
decision_deposit: 10 * GRAND,
#[cfg(not(feature = "on-chain-release-build"))]
#[cfg(feature = "fast-net")]
prepare_period: 4 * MINUTES,
#[cfg(feature = "on-chain-release-build")]
#[cfg(not(feature = "fast-net"))]
prepare_period: 2 * HOURS,
#[cfg(not(feature = "on-chain-release-build"))]
#[cfg(feature = "fast-net")]
decision_period: 10 * MINUTES,
#[cfg(feature = "on-chain-release-build")]
#[cfg(not(feature = "fast-net"))]
decision_period: 28 * DAYS,
#[cfg(not(feature = "on-chain-release-build"))]
#[cfg(feature = "fast-net")]
confirm_period: 5 * MINUTES,
#[cfg(feature = "on-chain-release-build")]
#[cfg(not(feature = "fast-net"))]
confirm_period: 24 * HOURS,
#[cfg(not(feature = "on-chain-release-build"))]
#[cfg(feature = "fast-net")]
min_enactment_period: 5 * MINUTES,
#[cfg(feature = "on-chain-release-build")]
#[cfg(not(feature = "fast-net"))]
min_enactment_period: 10 * MINUTES,
min_approval: APP_GENERAL_MANAGEMENT,
min_support: SUP_GENERAL_MANAGEMENT,
},
),
(
13,
pallet_referenda::TrackInfo {
name: "council_admin",
max_deciding: 10,
decision_deposit: 10 * GRAND,
#[cfg(not(feature = "on-chain-release-build"))]
prepare_period: 4 * MINUTES,
#[cfg(feature = "on-chain-release-build")]
prepare_period: 2 * HOURS,
#[cfg(not(feature = "on-chain-release-build"))]
decision_period: 10 * MINUTES,
#[cfg(feature = "on-chain-release-build")]
decision_period: 28 * DAYS,
#[cfg(not(feature = "on-chain-release-build"))]
confirm_period: 5 * MINUTES,
#[cfg(feature = "on-chain-release-build")]
confirm_period: 3 * HOURS,
#[cfg(not(feature = "on-chain-release-build"))]
min_enactment_period: 5 * MINUTES,
#[cfg(feature = "on-chain-release-build")]
min_enactment_period: 10 * MINUTES,
min_approval: APP_COUNCIL_ADMIN,
min_support: SUP_COUNCIL_ADMIN,
},
),
(
20,
pallet_referenda::TrackInfo {
name: "referendum_canceller",
max_deciding: 1_000,
decision_deposit: 10 * GRAND,
#[cfg(not(feature = "on-chain-release-build"))]
#[cfg(feature = "fast-net")]
prepare_period: 4 * MINUTES,
#[cfg(feature = "on-chain-release-build")]
#[cfg(not(feature = "fast-net"))]
prepare_period: 2 * HOURS,
#[cfg(not(feature = "on-chain-release-build"))]
#[cfg(feature = "fast-net")]
decision_period: 10 * MINUTES,
#[cfg(feature = "on-chain-release-build")]
#[cfg(not(feature = "fast-net"))]
decision_period: 7 * DAYS,
#[cfg(not(feature = "on-chain-release-build"))]
#[cfg(feature = "fast-net")]
confirm_period: 5 * MINUTES,
#[cfg(feature = "on-chain-release-build")]
#[cfg(not(feature = "fast-net"))]
confirm_period: 3 * HOURS,
#[cfg(not(feature = "on-chain-release-build"))]
#[cfg(feature = "fast-net")]
min_enactment_period: 5 * MINUTES,
#[cfg(feature = "on-chain-release-build")]
#[cfg(not(feature = "fast-net"))]
min_enactment_period: 10 * MINUTES,
min_approval: APP_REFERENDUM_CANCELLER,
min_support: SUP_REFERENDUM_CANCELLER,
Expand All @@ -167,21 +138,21 @@ const TRACKS_DATA: [(u16, pallet_referenda::TrackInfo<Balance, BlockNumber>); 8]
name: "referendum_killer",
max_deciding: 1_000,
decision_deposit: 50 * GRAND,
#[cfg(not(feature = "on-chain-release-build"))]
#[cfg(feature = "fast-net")]
prepare_period: 4 * MINUTES,
#[cfg(feature = "on-chain-release-build")]
#[cfg(not(feature = "fast-net"))]
prepare_period: 2 * HOURS,
#[cfg(not(feature = "on-chain-release-build"))]
#[cfg(feature = "fast-net")]
decision_period: 10 * MINUTES,
#[cfg(feature = "on-chain-release-build")]
#[cfg(not(feature = "fast-net"))]
decision_period: 28 * DAYS,
#[cfg(not(feature = "on-chain-release-build"))]
#[cfg(feature = "fast-net")]
confirm_period: 5 * MINUTES,
#[cfg(feature = "on-chain-release-build")]
#[cfg(not(feature = "fast-net"))]
confirm_period: 3 * HOURS,
#[cfg(not(feature = "on-chain-release-build"))]
#[cfg(feature = "fast-net")]
min_enactment_period: 5 * MINUTES,
#[cfg(feature = "on-chain-release-build")]
#[cfg(not(feature = "fast-net"))]
min_enactment_period: 10 * MINUTES,
min_approval: APP_REFERENDUM_KILLER,
min_support: SUP_REFERENDUM_KILLER,
Expand All @@ -193,21 +164,21 @@ const TRACKS_DATA: [(u16, pallet_referenda::TrackInfo<Balance, BlockNumber>); 8]
name: "small_spender",
max_deciding: 50,
decision_deposit: 100 * UNIT,
#[cfg(not(feature = "on-chain-release-build"))]
#[cfg(feature = "fast-net")]
prepare_period: 5 * MINUTES,
#[cfg(feature = "on-chain-release-build")]
#[cfg(not(feature = "fast-net"))]
prepare_period: 4 * HOURS,
#[cfg(not(feature = "on-chain-release-build"))]
#[cfg(feature = "fast-net")]
decision_period: 10 * MINUTES,
#[cfg(feature = "on-chain-release-build")]
#[cfg(not(feature = "fast-net"))]
decision_period: 28 * DAYS,
#[cfg(not(feature = "on-chain-release-build"))]
#[cfg(feature = "fast-net")]
confirm_period: 5 * MINUTES,
#[cfg(feature = "on-chain-release-build")]
#[cfg(not(feature = "fast-net"))]
confirm_period: 2 * DAYS,
#[cfg(not(feature = "on-chain-release-build"))]
#[cfg(feature = "fast-net")]
min_enactment_period: 5 * MINUTES,
#[cfg(feature = "on-chain-release-build")]
#[cfg(not(feature = "fast-net"))]
min_enactment_period: 24 * HOURS,
min_approval: APP_SMALL_SPENDER,
min_support: SUP_SMALL_SPENDER,
Expand All @@ -219,21 +190,21 @@ const TRACKS_DATA: [(u16, pallet_referenda::TrackInfo<Balance, BlockNumber>); 8]
name: "big_spender",
max_deciding: 50,
decision_deposit: 400 * UNIT,
#[cfg(not(feature = "on-chain-release-build"))]
#[cfg(feature = "fast-net")]
prepare_period: 5 * MINUTES,
#[cfg(feature = "on-chain-release-build")]
#[cfg(not(feature = "fast-net"))]
prepare_period: 4 * HOURS,
#[cfg(not(feature = "on-chain-release-build"))]
#[cfg(feature = "fast-net")]
decision_period: 10 * MINUTES,
#[cfg(feature = "on-chain-release-build")]
#[cfg(not(feature = "fast-net"))]
decision_period: 28 * DAYS,
#[cfg(not(feature = "on-chain-release-build"))]
#[cfg(feature = "fast-net")]
confirm_period: 5 * MINUTES,
#[cfg(feature = "on-chain-release-build")]
#[cfg(not(feature = "fast-net"))]
confirm_period: 7 * DAYS,
#[cfg(not(feature = "on-chain-release-build"))]
#[cfg(feature = "fast-net")]
min_enactment_period: 5 * MINUTES,
#[cfg(feature = "on-chain-release-build")]
#[cfg(not(feature = "fast-net"))]
min_enactment_period: 24 * HOURS,
min_approval: APP_BIG_SPENDER,
min_support: SUP_BIG_SPENDER,
Expand All @@ -258,8 +229,6 @@ impl pallet_referenda::TracksInfo<Balance, BlockNumber> for TracksInfo {
match custom_origin {
origins::Origin::WhitelistedCaller => Ok(1),
origins::Origin::GeneralManagement => Ok(2),
// General admin
origins::Origin::CouncilAdmin => Ok(13),
// Referendum admins
origins::Origin::ReferendumCanceller => Ok(20),
origins::Origin::ReferendumKiller => Ok(21),
Expand Down
6 changes: 3 additions & 3 deletions invarch/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ use frame_system::{
};
mod governance;
pub use governance::{
pallet_custom_origins, CouncilAdmin, CouncilApproveOrigin, CouncilRejectOrigin,
GeneralManagement, ReferendumCanceller, ReferendumKiller, RootOrGeneralManagement,
TreasurySpender, WhitelistedCaller,
pallet_custom_origins, CouncilApproveOrigin, CouncilRejectOrigin, GeneralManagement,
ReferendumCanceller, ReferendumKiller, RootOrGeneralManagement, TreasurySpender,
WhitelistedCaller,
};
use pallet_identity::legacy::IdentityInfo;
use polkadot_runtime_common::BlockHashCount;
Expand Down

0 comments on commit 672f5ee

Please sign in to comment.