mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 10:31:03 +00:00
5d2f81035f
* First bits * Create new origins * Repot governance configs * Tests for treasury spends * Integrate treasury spend threshold origins * Bump deps * Add whitelist, configure treasury spend origins * Add governance curves * Enable curve's ceil to be configured * Make compile * Rest of new governance params * Build fixes * Fixes * Fix warning * Use new EnsureOrigin::try_successful_origin * Some repotting * Add files * Ready for initial review * Fixes * Formatting * Bump * rename * Derive MEL for Origin enum Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Add benchmarks Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * ".git/.scripts/bench-bot.sh" runtime kusama-dev pallet_conviction_voting * Update Cargo.lock * Update runtime/kusama/src/governance/origins.rs Co-authored-by: Xiliang Chen <xlchen1291@gmail.com> * allow root to demote and promote, fixing benchmarks * fix whitelist origin benchmarks * typo * cargo update -p sp-io * add second referenda instance to benchmarks * allow root to act as a 9th dan in track * feature flag it * cargo update -p sp-io * fix merge * ".git/.scripts/bench-bot.sh" runtime kusama-dev pallet_referenda * ".git/.scripts/bench-bot.sh" runtime kusama-dev pallet_conviction_voting * allow root to create auction * Update mod.rs * more origin fixes * root isnt needed actually * cargo update -p sp-io * allow root to cancel slash * initial stuff * make copy data from kusama * ".git/.scripts/bench-bot.sh" runtime kusama-dev pallet_referenda * Update Cargo.lock * commit new weight files * more files * use weight files * ".git/.scripts/bench-bot.sh" runtime kusama-dev pallet_referenda * Update Cargo.lock * Update to latest master * Formatting * ".git/.scripts/bench-bot.sh" runtime kusama-dev pallet_ranked_collective * ".git/.scripts/bench-bot.sh" runtime kusama-dev pallet_conviction_voting * ".git/.scripts/bench-bot.sh" runtime kusama-dev pallet_conviction_voting * ".git/.scripts/bench-bot.sh" runtime kusama-dev pallet_whitelist * Rename Origin -> RuntimeOrigin This was done in Substrate and is now needed here as well. Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * cargo update -p sp-io Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Tech Committee can promote to VI Dan * Update runtime/kusama/src/governance/mod.rs Co-authored-by: Amar Singh <asinghchrony@protonmail.com> * Formatting * Update runtime/kusama/src/governance/fellowship.rs Co-authored-by: Amar Singh <asinghchrony@protonmail.com> * Fixes * Avoid updating extraneous deps * Fix broken stuff * ".git/.scripts/bench-bot.sh" runtime kusama-dev pallet_referenda * Update runtime/kusama/src/governance/fellowship.rs * Reorder EitherOf origins Zero logic change to make the benchmarking work. It uses the first successful origin which can only promote to rank 6. By swapping the order we use Root which can always promote. Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Revert param change and update doc Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> Co-authored-by: command-bot <> Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com> Co-authored-by: Xiliang Chen <xlchen1291@gmail.com> Co-authored-by: Keith Yeung <kungfukeith11@gmail.com> Co-authored-by: Amar Singh <asinghchrony@protonmail.com>
321 lines
10 KiB
Rust
321 lines
10 KiB
Rust
// Copyright 2022 Parity Technologies (UK) Ltd.
|
|
// This file is part of Polkadot.
|
|
|
|
// Polkadot is free software: you can redistribute it and/or modify
|
|
// it under the terms of the GNU General Public License as published by
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
// (at your option) any later version.
|
|
|
|
// Polkadot is distributed in the hope that it will be useful,
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
// GNU General Public License for more details.
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
//! Track configurations for governance.
|
|
|
|
use super::*;
|
|
|
|
const fn percent(x: i32) -> sp_arithmetic::FixedI64 {
|
|
sp_arithmetic::FixedI64::from_rational(x as u128, 100)
|
|
}
|
|
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_STAKING_ADMIN: Curve = Curve::make_linear(17, 28, percent(50), percent(100));
|
|
const SUP_STAKING_ADMIN: Curve =
|
|
Curve::make_reciprocal(12, 28, percent(1), percent(0), percent(50));
|
|
const APP_TREASURER: Curve = Curve::make_reciprocal(4, 28, percent(80), percent(50), percent(100));
|
|
const SUP_TREASURER: Curve = Curve::make_linear(28, 28, percent(0), percent(50));
|
|
const APP_FELLOWSHIP_ADMIN: Curve = Curve::make_linear(17, 28, percent(50), percent(100));
|
|
const SUP_FELLOWSHIP_ADMIN: Curve =
|
|
Curve::make_reciprocal(12, 28, percent(1), percent(0), percent(50));
|
|
const APP_GENERAL_ADMIN: Curve =
|
|
Curve::make_reciprocal(4, 28, percent(80), percent(50), percent(100));
|
|
const SUP_GENERAL_ADMIN: Curve =
|
|
Curve::make_reciprocal(7, 28, percent(10), percent(0), percent(50));
|
|
const APP_AUCTION_ADMIN: Curve =
|
|
Curve::make_reciprocal(4, 28, percent(80), percent(50), percent(100));
|
|
const SUP_AUCTION_ADMIN: Curve =
|
|
Curve::make_reciprocal(7, 28, percent(10), percent(0), percent(50));
|
|
const APP_LEASE_ADMIN: Curve = Curve::make_linear(17, 28, percent(50), percent(100));
|
|
const SUP_LEASE_ADMIN: Curve = Curve::make_reciprocal(12, 28, percent(1), percent(0), percent(50));
|
|
const APP_REFERENDUM_CANCELLER: Curve = Curve::make_linear(17, 28, percent(50), percent(100));
|
|
const SUP_REFERENDUM_CANCELLER: Curve =
|
|
Curve::make_reciprocal(12, 28, percent(1), percent(0), percent(50));
|
|
const APP_REFERENDUM_KILLER: Curve = Curve::make_linear(17, 28, percent(50), percent(100));
|
|
const SUP_REFERENDUM_KILLER: Curve =
|
|
Curve::make_reciprocal(12, 28, percent(1), percent(0), percent(50));
|
|
const APP_SMALL_TIPPER: Curve = Curve::make_linear(10, 28, percent(50), percent(100));
|
|
const SUP_SMALL_TIPPER: Curve = Curve::make_reciprocal(1, 28, percent(4), percent(0), percent(50));
|
|
const APP_BIG_TIPPER: Curve = Curve::make_linear(10, 28, percent(50), percent(100));
|
|
const SUP_BIG_TIPPER: Curve = Curve::make_reciprocal(8, 28, percent(1), percent(0), percent(50));
|
|
const APP_SMALL_SPENDER: Curve = Curve::make_linear(17, 28, percent(50), percent(100));
|
|
const SUP_SMALL_SPENDER: Curve =
|
|
Curve::make_reciprocal(12, 28, percent(1), percent(0), percent(50));
|
|
const APP_MEDIUM_SPENDER: Curve = Curve::make_linear(23, 28, percent(50), percent(100));
|
|
const SUP_MEDIUM_SPENDER: Curve =
|
|
Curve::make_reciprocal(16, 28, percent(1), percent(0), percent(50));
|
|
const APP_BIG_SPENDER: Curve = Curve::make_linear(28, 28, percent(50), percent(100));
|
|
const SUP_BIG_SPENDER: Curve = Curve::make_reciprocal(20, 28, percent(1), percent(0), percent(50));
|
|
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(10), percent(50));
|
|
|
|
const TRACKS_DATA: [(u16, pallet_referenda::TrackInfo<Balance, BlockNumber>); 15] = [
|
|
(
|
|
0,
|
|
pallet_referenda::TrackInfo {
|
|
name: "root",
|
|
max_deciding: 1,
|
|
decision_deposit: 1_000 * GRAND,
|
|
prepare_period: 3 * HOURS,
|
|
decision_period: 28 * DAYS,
|
|
confirm_period: 3 * HOURS,
|
|
min_enactment_period: 3 * HOURS,
|
|
min_approval: APP_ROOT,
|
|
min_support: SUP_ROOT,
|
|
},
|
|
),
|
|
(
|
|
1,
|
|
pallet_referenda::TrackInfo {
|
|
name: "whitelisted_caller",
|
|
max_deciding: 10,
|
|
decision_deposit: 10_000 * GRAND,
|
|
prepare_period: 3 * HOURS,
|
|
decision_period: 28 * DAYS,
|
|
confirm_period: 10 * MINUTES,
|
|
min_enactment_period: 30 * MINUTES,
|
|
min_approval: APP_WHITELISTED_CALLER,
|
|
min_support: SUP_WHITELISTED_CALLER,
|
|
},
|
|
),
|
|
(
|
|
10,
|
|
pallet_referenda::TrackInfo {
|
|
name: "staking_admin",
|
|
max_deciding: 10,
|
|
decision_deposit: 5 * GRAND,
|
|
prepare_period: 4,
|
|
decision_period: 28 * DAYS,
|
|
confirm_period: 3 * HOURS,
|
|
min_enactment_period: 2 * DAYS,
|
|
min_approval: APP_STAKING_ADMIN,
|
|
min_support: SUP_STAKING_ADMIN,
|
|
},
|
|
),
|
|
(
|
|
11,
|
|
pallet_referenda::TrackInfo {
|
|
name: "treasurer",
|
|
max_deciding: 10,
|
|
decision_deposit: 5 * GRAND,
|
|
prepare_period: 4,
|
|
decision_period: 28 * DAYS,
|
|
confirm_period: 3 * HOURS,
|
|
min_enactment_period: 2 * DAYS,
|
|
min_approval: APP_TREASURER,
|
|
min_support: SUP_TREASURER,
|
|
},
|
|
),
|
|
(
|
|
12,
|
|
pallet_referenda::TrackInfo {
|
|
name: "lease_admin",
|
|
max_deciding: 10,
|
|
decision_deposit: 5 * GRAND,
|
|
prepare_period: 4,
|
|
decision_period: 28 * DAYS,
|
|
confirm_period: 3 * HOURS,
|
|
min_enactment_period: 2 * DAYS,
|
|
min_approval: APP_LEASE_ADMIN,
|
|
min_support: SUP_LEASE_ADMIN,
|
|
},
|
|
),
|
|
(
|
|
13,
|
|
pallet_referenda::TrackInfo {
|
|
name: "fellowship_admin",
|
|
max_deciding: 10,
|
|
decision_deposit: 5 * GRAND,
|
|
prepare_period: 4,
|
|
decision_period: 28 * DAYS,
|
|
confirm_period: 3 * HOURS,
|
|
min_enactment_period: 2 * DAYS,
|
|
min_approval: APP_FELLOWSHIP_ADMIN,
|
|
min_support: SUP_FELLOWSHIP_ADMIN,
|
|
},
|
|
),
|
|
(
|
|
14,
|
|
pallet_referenda::TrackInfo {
|
|
name: "general_admin",
|
|
max_deciding: 10,
|
|
decision_deposit: 5 * GRAND,
|
|
prepare_period: 4,
|
|
decision_period: 28 * DAYS,
|
|
confirm_period: 3 * HOURS,
|
|
min_enactment_period: 2 * DAYS,
|
|
min_approval: APP_GENERAL_ADMIN,
|
|
min_support: SUP_GENERAL_ADMIN,
|
|
},
|
|
),
|
|
(
|
|
15,
|
|
pallet_referenda::TrackInfo {
|
|
name: "auction_admin",
|
|
max_deciding: 10,
|
|
decision_deposit: 5 * GRAND,
|
|
prepare_period: 4,
|
|
decision_period: 28 * DAYS,
|
|
confirm_period: 3 * HOURS,
|
|
min_enactment_period: 2 * DAYS,
|
|
min_approval: APP_AUCTION_ADMIN,
|
|
min_support: SUP_AUCTION_ADMIN,
|
|
},
|
|
),
|
|
(
|
|
20,
|
|
pallet_referenda::TrackInfo {
|
|
name: "referendum_canceller",
|
|
max_deciding: 1_000,
|
|
decision_deposit: 50 * GRAND,
|
|
prepare_period: 4,
|
|
decision_period: 28 * DAYS,
|
|
confirm_period: 3 * HOURS,
|
|
min_enactment_period: 10 * MINUTES,
|
|
min_approval: APP_REFERENDUM_CANCELLER,
|
|
min_support: SUP_REFERENDUM_CANCELLER,
|
|
},
|
|
),
|
|
(
|
|
21,
|
|
pallet_referenda::TrackInfo {
|
|
name: "referendum_killer",
|
|
max_deciding: 1_000,
|
|
decision_deposit: 50 * GRAND,
|
|
prepare_period: 4,
|
|
decision_period: 28 * DAYS,
|
|
confirm_period: 3 * HOURS,
|
|
min_enactment_period: 10 * MINUTES,
|
|
min_approval: APP_REFERENDUM_KILLER,
|
|
min_support: SUP_REFERENDUM_KILLER,
|
|
},
|
|
),
|
|
(
|
|
30,
|
|
pallet_referenda::TrackInfo {
|
|
name: "small_tipper",
|
|
max_deciding: 200,
|
|
decision_deposit: 5 * QUID,
|
|
prepare_period: 4,
|
|
decision_period: 28 * DAYS,
|
|
confirm_period: 3 * HOURS,
|
|
min_enactment_period: 28 * DAYS,
|
|
min_approval: APP_SMALL_TIPPER,
|
|
min_support: SUP_SMALL_TIPPER,
|
|
},
|
|
),
|
|
(
|
|
31,
|
|
pallet_referenda::TrackInfo {
|
|
name: "big_tipper",
|
|
max_deciding: 100,
|
|
decision_deposit: 50 * QUID,
|
|
prepare_period: 4,
|
|
decision_period: 28 * DAYS,
|
|
confirm_period: 6 * HOURS,
|
|
min_enactment_period: 28 * DAYS,
|
|
min_approval: APP_BIG_TIPPER,
|
|
min_support: SUP_BIG_TIPPER,
|
|
},
|
|
),
|
|
(
|
|
32,
|
|
pallet_referenda::TrackInfo {
|
|
name: "small_spender",
|
|
max_deciding: 50,
|
|
decision_deposit: 500 * QUID,
|
|
prepare_period: 4,
|
|
decision_period: 28 * DAYS,
|
|
confirm_period: 12 * HOURS,
|
|
min_enactment_period: 28 * DAYS,
|
|
min_approval: APP_SMALL_SPENDER,
|
|
min_support: SUP_SMALL_SPENDER,
|
|
},
|
|
),
|
|
(
|
|
33,
|
|
pallet_referenda::TrackInfo {
|
|
name: "medium_spender",
|
|
max_deciding: 20,
|
|
decision_deposit: 1_500 * QUID,
|
|
prepare_period: 4,
|
|
decision_period: 28 * DAYS,
|
|
confirm_period: 24 * HOURS,
|
|
min_enactment_period: 28 * DAYS,
|
|
min_approval: APP_MEDIUM_SPENDER,
|
|
min_support: SUP_MEDIUM_SPENDER,
|
|
},
|
|
),
|
|
(
|
|
34,
|
|
pallet_referenda::TrackInfo {
|
|
name: "big_spender",
|
|
max_deciding: 10,
|
|
decision_deposit: 5 * GRAND,
|
|
prepare_period: 4,
|
|
decision_period: 28 * DAYS,
|
|
confirm_period: 48 * HOURS,
|
|
min_enactment_period: 28 * DAYS,
|
|
min_approval: APP_BIG_SPENDER,
|
|
min_support: SUP_BIG_SPENDER,
|
|
},
|
|
),
|
|
];
|
|
|
|
pub struct TracksInfo;
|
|
impl pallet_referenda::TracksInfo<Balance, BlockNumber> for TracksInfo {
|
|
type Id = u16;
|
|
type RuntimeOrigin = <RuntimeOrigin as frame_support::traits::OriginTrait>::PalletsOrigin;
|
|
fn tracks() -> &'static [(Self::Id, pallet_referenda::TrackInfo<Balance, BlockNumber>)] {
|
|
&TRACKS_DATA[..]
|
|
}
|
|
fn track_for(id: &Self::RuntimeOrigin) -> Result<Self::Id, ()> {
|
|
if let Ok(system_origin) = frame_system::RawOrigin::try_from(id.clone()) {
|
|
match system_origin {
|
|
frame_system::RawOrigin::Root => Ok(0),
|
|
_ => Err(()),
|
|
}
|
|
} else if let Ok(custom_origin) = origins::Origin::try_from(id.clone()) {
|
|
match custom_origin {
|
|
origins::Origin::WhitelistedCaller => Ok(1),
|
|
// General admin
|
|
origins::Origin::StakingAdmin => Ok(10),
|
|
origins::Origin::Treasurer => Ok(11),
|
|
origins::Origin::LeaseAdmin => Ok(12),
|
|
origins::Origin::FellowshipAdmin => Ok(13),
|
|
origins::Origin::GeneralAdmin => Ok(14),
|
|
origins::Origin::AuctionAdmin => Ok(15),
|
|
// Referendum admins
|
|
origins::Origin::ReferendumCanceller => Ok(20),
|
|
origins::Origin::ReferendumKiller => Ok(21),
|
|
// Limited treasury spenders
|
|
origins::Origin::SmallTipper => Ok(30),
|
|
origins::Origin::BigTipper => Ok(31),
|
|
origins::Origin::SmallSpender => Ok(32),
|
|
origins::Origin::MediumSpender => Ok(33),
|
|
origins::Origin::BigSpender => Ok(34),
|
|
_ => Err(()),
|
|
}
|
|
} else {
|
|
Err(())
|
|
}
|
|
}
|
|
}
|
|
pallet_referenda::impl_tracksinfo_get!(TracksInfo, Balance, BlockNumber);
|