Skip to content

Commit

Permalink
fastnet changes
Browse files Browse the repository at this point in the history
  • Loading branch information
kkast committed Sep 13, 2023
1 parent a51c7cb commit a8d1ee7
Show file tree
Hide file tree
Showing 5 changed files with 139 additions and 46 deletions.
25 changes: 25 additions & 0 deletions code/parachain/runtime/common/src/governance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,29 @@ pub mod native {
collective::EnsureProportionAtLeast<AccountId, NativeCouncilCollective, 2, 3>,
>,
>;

pub type EnsureRootOrOneSixthNativeTechnical = EitherOfDiverse<
EnsureRoot<AccountId>,
collective::EnsureProportionAtLeast<AccountId, NativeTechnicalCollective, 1, 6>,
>;
pub type EnsureRootOrOneSixthNativeCouncil = EitherOfDiverse<
EnsureRoot<AccountId>,
collective::EnsureProportionAtLeast<AccountId, NativeCouncilCollective, 1, 6>,
>;

pub type EnsureRootOrOneThirdNativeCouncilOrTechnical = EitherOfDiverse<
EnsureRoot<AccountId>,
EitherOfDiverse<
collective::EnsureProportionAtLeast<AccountId, NativeTechnicalCollective, 1, 3>,
collective::EnsureProportionAtLeast<AccountId, NativeCouncilCollective, 1, 3>,
>,
>;

pub type EnsureRootOrOneSixthNativeCouncilOrTechnical = EitherOfDiverse<
EnsureRoot<AccountId>,
EitherOfDiverse<
collective::EnsureProportionAtLeast<AccountId, NativeTechnicalCollective, 1, 6>,
collective::EnsureProportionAtLeast<AccountId, NativeCouncilCollective, 1, 6>,
>,
>;
}
13 changes: 11 additions & 2 deletions code/parachain/runtime/composable/src/governance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,16 @@ impl pallet_referenda::Config for Runtime {
system::EnsureSignedBy<TechnicalCommitteeMembership, Self::AccountId>,
system::EnsureSignedBy<CouncilMembership, Self::AccountId>,
>;


#[cfg(not(feature = "fastnet"))]
type CancelOrigin = EnsureRootOrOneThirdNativeTechnical;
#[cfg(feature = "fastnet")]
type CancelOrigin = EnsureRootOrOneSixthNativeTechnical;

#[cfg(not(feature = "fastnet"))]
type KillOrigin = EnsureRootOrMoreThenHalfNativeCouncil;
#[cfg(feature = "fastnet")]
type KillOrigin = EnsureRootOrOneSixthNativeCouncil;

type Slash = ();

Expand Down Expand Up @@ -130,7 +136,10 @@ impl pallet_whitelist::Config for Runtime {
type WeightInfo = weights::whitelist::WeightInfo<Self>;
type RuntimeCall = RuntimeCall;
type RuntimeEvent = RuntimeEvent;
type WhitelistOrigin = EnsureRootOrOneThirdNativeTechnical;
#[cfg(not(feature = "fastnet"))]
type WhitelistOrigin = EnsureRootOrOneThirdNativeCouncilOrTechnical;
#[cfg(feature = "fastnet")]
type WhitelistOrigin = EnsureRootOrOneSixthNativeCouncilOrTechnical;
type DispatchWhitelistedOrigin = EitherOf<EnsureRoot<Self::AccountId>, WhitelistedCaller>;
type Preimages = Preimage;
}
Expand Down
67 changes: 44 additions & 23 deletions code/parachain/runtime/composable/src/tracks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@ use super::*;
const fn percent(x: i32) -> sp_runtime::FixedI64 {
sp_runtime::FixedI64::from_rational(x as u128, 100)
}
const fn permill(x: i32) -> sp_runtime::FixedI64 {
sp_runtime::FixedI64::from_rational(x as u128, 1000)
}
pub const ONE_PICA: Balance = 1_000_000_000_000;

use common::MINUTES;
use pallet_referenda::Curve;
Expand All @@ -40,28 +36,38 @@ const TRACKS_DATA: [(u16, pallet_referenda::TrackInfo<Balance, BlockNumber>); 2]
// Amount that must be placed on deposit before a decision can be made.
decision_deposit: 0,
// Amount of time this must be submitted for before a decision can be made.
#[cfg(feature = "testnet")]
prepare_period: 1 * MINUTES,
#[cfg(not(feature = "testnet"))]
#[cfg(feature = "fastnet")]
prepare_period: 2 * MINUTES,
#[cfg(not(feature = "fastnet"))]
prepare_period: 2 * HOURS,
// Amount of time that a decision may take to be approved prior to cancellation.
#[cfg(feature = "fastnet")]
decision_period: 1 * HOURS,
#[cfg(not(feature = "fastnet"))]
decision_period: 7 * DAYS,
// Amount of time that the approval criteria must hold before it can be approved.
#[cfg(feature = "testnet")]
confirm_period: 1 * MINUTES,
#[cfg(not(feature = "testnet"))]
#[cfg(feature = "fastnet")]
confirm_period: 15 * MINUTES,
#[cfg(not(feature = "fastnet"))]
confirm_period: 1 * DAYS,
// Minimum amount of time that an approved proposal must be in the dispatch queue.
#[cfg(feature = "testnet")]
min_enactment_period: 1 * MINUTES,
#[cfg(not(feature = "testnet"))]
#[cfg(feature = "fastnet")]
min_enactment_period: 5 * MINUTES,
#[cfg(not(feature = "fastnet"))]
min_enactment_period: 1 * DAYS,
// Minimum aye votes as percentage of overall conviction-weighted votes needed for
// approval as a function of time into decision period.
#[cfg(feature = "fastnet")]
min_approval: Curve::make_reciprocal(4, 30, percent(80), percent(50), percent(100)),
#[cfg(not(feature = "fastnet"))]
min_approval: Curve::make_reciprocal(4, 28, percent(80), percent(50), percent(100)),
// Minimum pre-conviction aye-votes ("support") as percentage of overall population that
// is needed for approval as a function of time into decision period.
#[cfg(feature = "fastnet")]
min_support: Curve::make_linear(30, 30, percent(0), percent(50)),
#[cfg(not(feature = "fastnet"))]
min_support: Curve::make_linear(28, 28, percent(0), percent(50)),

},
),
(
Expand All @@ -70,26 +76,41 @@ const TRACKS_DATA: [(u16, pallet_referenda::TrackInfo<Balance, BlockNumber>); 2]
name: "whitelisted_caller",
max_deciding: 2,
decision_deposit: 0,
#[cfg(feature = "testnet")]
prepare_period: 1 * MINUTES,
#[cfg(not(feature = "testnet"))]
#[cfg(feature = "fastnet")]
prepare_period: 2 * MINUTES,
#[cfg(not(feature = "fastnet"))]
prepare_period: 30 * MINUTES,
#[cfg(feature = "fastnet")]
decision_period: 30 * MINUTES,
#[cfg(not(feature = "fastnet"))]
decision_period: 4 * DAYS,
#[cfg(feature = "testnet")]
confirm_period: 1 * MINUTES,
#[cfg(not(feature = "testnet"))]
#[cfg(feature = "fastnet")]
confirm_period: 5 * MINUTES,
#[cfg(not(feature = "fastnet"))]
confirm_period: 10 * MINUTES,
#[cfg(feature = "testnet")]
min_enactment_period: 1 * MINUTES,
#[cfg(not(feature = "testnet"))]
#[cfg(feature = "fastnet")]
min_enactment_period: 2 * MINUTES,
#[cfg(not(feature = "fastnet"))]
min_enactment_period: 10 * MINUTES,
#[cfg(feature = "fastnet")]
min_approval: Curve::make_reciprocal(
1,
30,
percent(96),
percent(50),
percent(100),
),
#[cfg(not(feature = "fastnet"))]
min_approval: Curve::make_reciprocal(
16,
28 * 24,
percent(96),
percent(50),
percent(100),
),
#[cfg(feature = "fastnet")]
min_support: Curve::make_reciprocal(1, 30, percent(20), percent(5), percent(50)),
#[cfg(not(feature = "fastnet"))]
min_support: Curve::make_reciprocal(1, 28, percent(20), percent(5), percent(50)),
},
),
Expand All @@ -116,4 +137,4 @@ impl pallet_referenda::TracksInfo<Balance, BlockNumber> for TracksInfo {
Err(())
}
}
}
}
12 changes: 10 additions & 2 deletions code/parachain/runtime/picasso/src/governance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,15 @@ impl pallet_referenda::Config for Runtime {
system::EnsureSignedBy<TechnicalCommitteeMembership, Self::AccountId>,
system::EnsureSignedBy<CouncilMembership, Self::AccountId>,
>;

#[cfg(not(feature = "fastnet"))]
type CancelOrigin = EnsureRootOrOneThirdNativeTechnical;
#[cfg(feature = "fastnet")]
type CancelOrigin = EnsureRootOrOneSixthNativeTechnical;

#[cfg(not(feature = "fastnet"))]
type KillOrigin = EnsureRootOrMoreThenHalfNativeCouncil;
#[cfg(feature = "fastnet")]
type KillOrigin = EnsureRootOrOneSixthNativeCouncil;

type Slash = ();

Expand Down Expand Up @@ -139,7 +144,10 @@ impl pallet_whitelist::Config for Runtime {
type WeightInfo = weights::whitelist::WeightInfo<Self>;
type RuntimeCall = RuntimeCall;
type RuntimeEvent = RuntimeEvent;
type WhitelistOrigin = EnsureRootOrOneThirdNativeTechnical;
#[cfg(not(feature = "fastnet"))]
type WhitelistOrigin = EnsureRootOrOneThirdNativeCouncilOrTechnical;
#[cfg(feature = "fastnet")]
type WhitelistOrigin = EnsureRootOrOneSixthNativeCouncilOrTechnical;
type DispatchWhitelistedOrigin = EitherOf<EnsureRoot<Self::AccountId>, WhitelistedCaller>;
type Preimages = Preimage;
}
Expand Down
68 changes: 49 additions & 19 deletions code/parachain/runtime/picasso/src/tracks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,29 +35,41 @@ const TRACKS_DATA: [(u16, pallet_referenda::TrackInfo<Balance, BlockNumber>); 2]
// For Root origin this should generally be just one.
max_deciding: 1,
// Amount that must be placed on deposit before a decision can be made.
#[cfg(feature = "fastnet")]
decision_deposit: 50 * ONE_PICA,
#[cfg(not(feature = "fastnet"))]
decision_deposit: 500_000 * ONE_PICA,
// Amount of time this must be submitted for before a decision can be made.
#[cfg(feature = "testnet")]
prepare_period: 1 * MINUTES,
#[cfg(not(feature = "testnet"))]
#[cfg(feature = "fastnet")]
prepare_period: 2 * MINUTES,
#[cfg(not(feature = "fastnet"))]
prepare_period: 2 * HOURS,
// Amount of time that a decision may take to be approved prior to cancellation.
#[cfg(feature = "fastnet")]
decision_period: 1 * HOURS,
#[cfg(not(feature = "fastnet"))]
decision_period: 7 * DAYS,
// Amount of time that the approval criteria must hold before it can be approved.
#[cfg(feature = "testnet")]
confirm_period: 1 * MINUTES,
#[cfg(not(feature = "testnet"))]
#[cfg(feature = "fastnet")]
confirm_period: 15 * MINUTES,
#[cfg(not(feature = "fastnet"))]
confirm_period: 1 * DAYS,
// Minimum amount of time that an approved proposal must be in the dispatch queue.
#[cfg(feature = "testnet")]
min_enactment_period: 1 * MINUTES,
#[cfg(not(feature = "testnet"))]
#[cfg(feature = "fastnet")]
min_enactment_period: 5 * MINUTES,
#[cfg(not(feature = "fastnet"))]
min_enactment_period: 1 * DAYS,
// Minimum aye votes as percentage of overall conviction-weighted votes needed for
// approval as a function of time into decision period.
#[cfg(feature = "fastnet")]
min_approval: Curve::make_reciprocal(4, 30, percent(80), percent(50), percent(100)),
#[cfg(not(feature = "fastnet"))]
min_approval: Curve::make_reciprocal(4, 28, percent(80), percent(50), percent(100)),
// Minimum pre-conviction aye-votes ("support") as percentage of overall population that
// is needed for approval as a function of time into decision period.
#[cfg(feature = "fastnet")]
min_support: Curve::make_linear(30, 30, percent(0), percent(50)),
#[cfg(not(feature = "fastnet"))]
min_support: Curve::make_linear(28, 28, percent(0), percent(50)),
},
),
Expand All @@ -66,27 +78,45 @@ const TRACKS_DATA: [(u16, pallet_referenda::TrackInfo<Balance, BlockNumber>); 2]
pallet_referenda::TrackInfo {
name: "whitelisted_caller",
max_deciding: 2,
#[cfg(feature = "fastnet")]
decision_deposit: 5 * ONE_PICA,
#[cfg(not(feature = "fastnet"))]
decision_deposit: 50_000 * ONE_PICA,
#[cfg(feature = "testnet")]
prepare_period: 1 * MINUTES,
#[cfg(not(feature = "testnet"))]
#[cfg(feature = "fastnet")]
prepare_period: 2 * MINUTES,
#[cfg(not(feature = "fastnet"))]
prepare_period: 30 * MINUTES,
#[cfg(feature = "fastnet")]
decision_period: 30 * MINUTES,
#[cfg(not(feature = "fastnet"))]
decision_period: 4 * DAYS,
#[cfg(feature = "testnet")]
confirm_period: 1 * MINUTES,
#[cfg(not(feature = "testnet"))]
#[cfg(feature = "fastnet")]
confirm_period: 5 * MINUTES,
#[cfg(not(feature = "fastnet"))]
confirm_period: 10 * MINUTES,
#[cfg(feature = "testnet")]
min_enactment_period: 1 * MINUTES,
#[cfg(not(feature = "testnet"))]
#[cfg(feature = "fastnet")]
min_enactment_period: 2 * MINUTES,
#[cfg(not(feature = "fastnet"))]
min_enactment_period: 10 * MINUTES,
#[cfg(feature = "fastnet")]
min_approval: Curve::make_reciprocal(
1,
30,
percent(96),
percent(50),
percent(100),
),
#[cfg(not(feature = "fastnet"))]
min_approval: Curve::make_reciprocal(
16,
28 * 24,
percent(96),
percent(50),
percent(100),
),
#[cfg(feature = "fastnet")]
min_support: Curve::make_reciprocal(1, 30, percent(20), percent(5), percent(50)),
#[cfg(not(feature = "fastnet"))]
min_support: Curve::make_reciprocal(1, 28, percent(20), percent(5), percent(50)),
},
),
Expand All @@ -113,4 +143,4 @@ impl pallet_referenda::TracksInfo<Balance, BlockNumber> for TracksInfo {
Err(())
}
}
}
}

0 comments on commit a8d1ee7

Please sign in to comment.