Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Companion for sub/7040 #1719

Merged
29 commits merged into from
Jan 20, 2021
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
47b67bf
Companion for sub/7040
kianenigma Sep 14, 2020
4b2f464
Fix duplicate type.
kianenigma Sep 14, 2020
9a623a8
Fix syntax
kianenigma Sep 14, 2020
a310f48
Sync with latest changes.
kianenigma Sep 17, 2020
58a4801
Add weight info.
kianenigma Sep 17, 2020
eabe4a9
Master.into()
kianenigma Sep 17, 2020
fd60383
Fix build
kianenigma Sep 17, 2020
8ce1e95
Fix some tests
kianenigma Sep 21, 2020
54ae9d0
Merge branch 'master' of github.com:paritytech/polkadot into kiz-comp…
kianenigma Sep 21, 2020
441bf41
Merge branch 'master' of github.com:paritytech/polkadot into kiz-comp…
kianenigma Sep 21, 2020
36b0f9f
Master.into()
kianenigma Sep 23, 2020
fc10647
Fix build again.
kianenigma Sep 23, 2020
86d7912
Master.into()
kianenigma Oct 12, 2020
e78729e
fix migration amounts.
kianenigma Oct 12, 2020
cba3e3b
Merge branch 'master' of github.com:paritytech/polkadot into kiz-comp…
kianenigma Oct 13, 2020
dd7c049
Merge branch 'master' of github.com:paritytech/polkadot into kiz-comp…
kianenigma Nov 26, 2020
bb59195
new migration
kianenigma Nov 26, 2020
45cbc3d
Builds fine with dummy weights.
kianenigma Nov 26, 2020
9a85fd8
Merge branch 'master' of github.com:paritytech/polkadot into kiz-comp…
kianenigma Nov 30, 2020
a4e30f5
fix build
kianenigma Nov 30, 2020
8e15337
Add correct weight files.
kianenigma Nov 30, 2020
fed7943
Master.into()
kianenigma Dec 2, 2020
7e7b979
Fix to latest version
kianenigma Dec 2, 2020
f9b291e
Master.into()
kianenigma Dec 17, 2020
e71b815
remove unneeded upgrade.
kianenigma Dec 17, 2020
ac842d8
Update to latest again.
kianenigma Dec 17, 2020
4f8e3fe
Merge branch 'master' of github.com:paritytech/polkadot into kiz-comp…
kianenigma Jan 20, 2021
a2081ad
Merge branch 'master' of github.com:paritytech/polkadot into kiz-comp…
kianenigma Jan 20, 2021
ba6c04b
"Update Substrate"
Jan 20, 2021
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
25 changes: 18 additions & 7 deletions runtime/kusama/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -448,13 +448,17 @@ impl pallet_collective::Config<CouncilCollective> for Runtime {

parameter_types! {
pub const CandidacyBond: Balance = 1 * DOLLARS;
pub const VotingBond: Balance = 5 * CENTS;
/// Daily council elections.
// 1 storage item created, key size is 32 bytes, value size is 16+16.
pub const VotingBondBase: Balance = deposit(1, 64);
// additional data per vote is 32 bytes (account id).
pub const VotingBondFactor: Balance = deposit(0, 32);
/// Daily council elections
pub const TermDuration: BlockNumber = 24 * HOURS;
pub const DesiredMembers: u32 = 19;
pub const DesiredRunnersUp: u32 = 19;
pub const ElectionsPhragmenModuleId: LockIdentifier = *b"phrelect";
}

// Make sure that there are no more than MaxMembers members elected via phragmen.
const_assert!(DesiredMembers::get() <= CouncilMaxMembers::get());

Expand All @@ -465,9 +469,9 @@ impl pallet_elections_phragmen::Config for Runtime {
type InitializeMembers = Council;
type CurrencyToVote = frame_support::traits::U128CurrencyToVote;
type CandidacyBond = CandidacyBond;
type VotingBond = VotingBond;
type VotingBondBase = VotingBondBase;
type VotingBondFactor = VotingBondFactor;
type LoserCandidate = Treasury;
type BadReport = Treasury;
type KickedMember = Treasury;
type DesiredMembers = DesiredMembers;
type DesiredRunnersUp = DesiredRunnersUp;
Expand Down Expand Up @@ -889,13 +893,20 @@ impl pallet_proxy::Config for Runtime {
type AnnouncementDepositFactor = AnnouncementDepositFactor;
}

pub struct CustomOnRuntimeUpgrade;
impl frame_support::traits::OnRuntimeUpgrade for CustomOnRuntimeUpgrade {
pub struct SchedulerRuntimeUpgrade;
impl frame_support::traits::OnRuntimeUpgrade for SchedulerRuntimeUpgrade {
fn on_runtime_upgrade() -> frame_support::weights::Weight {
0
}
}

pub struct PhragmenElectionDepositRuntimeUpgrade;
impl frame_support::traits::OnRuntimeUpgrade for PhragmenElectionDepositRuntimeUpgrade {
fn on_runtime_upgrade() -> frame_support::weights::Weight {
pallet_elections_phragmen::migrations_3_0_0::apply::<Runtime>(5 * CENTS, DOLLARS)
kianenigma marked this conversation as resolved.
Show resolved Hide resolved
}
}

construct_runtime! {
pub enum Runtime where
Block = Block,
Expand Down Expand Up @@ -992,7 +1003,7 @@ pub type Executive = frame_executive::Executive<
frame_system::ChainContext<Runtime>,
Runtime,
AllModules,
CustomOnRuntimeUpgrade
(SchedulerRuntimeUpgrade, PhragmenElectionDepositRuntimeUpgrade),
>;
/// The payload being signed in the transactions.
pub type SignedPayload = generic::SignedPayload<Call, SignedExtra>;
Expand Down
87 changes: 47 additions & 40 deletions runtime/kusama/src/weights/pallet_elections_phragmen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,25 @@

// You should have received a copy of the GNU General Public License
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.
//! Weights for pallet_elections_phragmen
//! Autogenerated weights for pallet_elections_phragmen
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 2.0.0
//! DATE: 2020-10-30, STEPS: [50, ], REPEAT: 20, LOW RANGE: [], HIGH RANGE: []
//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("kusama-dev"), DB CACHE: 128
//! DATE: 2020-11-30, STEPS: [50, ], REPEAT: 20, LOW RANGE: [], HIGH RANGE: []
//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("polkadot-dev"), DB CACHE: 128

// Executed Command:
// ./target/release/polkadot
// target/release/polkadot
// benchmark
// --chain
// kusama-dev
// --chain=polkadot-dev
// --steps=50
// --repeat=20
// --pallet=pallet_elections_phragmen
// --extrinsic=*
// --execution=wasm
// --wasm-execution=compiled
// --heap-pages=4096
// --header
// ./file_header.txt
// --output=./runtime/kusama/src/weights/
// --header=./file_header.txt
// --output=./runtime/polkadot/src/weights/


#![allow(unused_parens)]
Expand All @@ -44,66 +43,74 @@ use sp_std::marker::PhantomData;
/// Weight functions for pallet_elections_phragmen.
pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Config> pallet_elections_phragmen::WeightInfo for WeightInfo<T> {
fn vote(v: u32, ) -> Weight {
(83_050_000 as Weight)
.saturating_add((124_000 as Weight).saturating_mul(v as Weight))
fn vote_equal(v: u32, ) -> Weight {
(54_923_000 as Weight)
.saturating_add((324_000 as Weight).saturating_mul(v as Weight))
.saturating_add(T::DbWeight::get().reads(5 as Weight))
.saturating_add(T::DbWeight::get().writes(2 as Weight))
}
fn vote_update(v: u32, ) -> Weight {
(50_510_000 as Weight)
.saturating_add((116_000 as Weight).saturating_mul(v as Weight))
fn vote_more(v: u32, ) -> Weight {
(83_389_000 as Weight)
.saturating_add((341_000 as Weight).saturating_mul(v as Weight))
.saturating_add(T::DbWeight::get().reads(5 as Weight))
.saturating_add(T::DbWeight::get().writes(2 as Weight))
}
fn remove_voter() -> Weight {
(67_489_000 as Weight)
.saturating_add(T::DbWeight::get().reads(2 as Weight))
fn vote_less(v: u32, ) -> Weight {
(78_865_000 as Weight)
.saturating_add((343_000 as Weight).saturating_mul(v as Weight))
.saturating_add(T::DbWeight::get().reads(5 as Weight))
.saturating_add(T::DbWeight::get().writes(2 as Weight))
}
fn report_defunct_voter_correct(c: u32, v: u32, ) -> Weight {
(0 as Weight)
.saturating_add((1_722_000 as Weight).saturating_mul(c as Weight))
.saturating_add((34_302_000 as Weight).saturating_mul(v as Weight))
.saturating_add(T::DbWeight::get().reads(7 as Weight))
.saturating_add(T::DbWeight::get().writes(3 as Weight))
}
fn report_defunct_voter_incorrect(c: u32, v: u32, ) -> Weight {
(0 as Weight)
.saturating_add((1_724_000 as Weight).saturating_mul(c as Weight))
.saturating_add((34_226_000 as Weight).saturating_mul(v as Weight))
.saturating_add(T::DbWeight::get().reads(6 as Weight))
fn remove_voter() -> Weight {
(72_370_000 as Weight)
.saturating_add(T::DbWeight::get().reads(2 as Weight))
.saturating_add(T::DbWeight::get().writes(2 as Weight))
}
fn submit_candidacy(c: u32, ) -> Weight {
(67_828_000 as Weight)
.saturating_add((278_000 as Weight).saturating_mul(c as Weight))
(68_455_000 as Weight)
.saturating_add((370_000 as Weight).saturating_mul(c as Weight))
.saturating_add(T::DbWeight::get().reads(3 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight))
}
fn renounce_candidacy_candidate(c: u32, ) -> Weight {
(41_519_000 as Weight)
.saturating_add((140_000 as Weight).saturating_mul(c as Weight))
(54_009_000 as Weight)
.saturating_add((200_000 as Weight).saturating_mul(c as Weight))
.saturating_add(T::DbWeight::get().reads(1 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight))
}
fn renounce_candidacy_members() -> Weight {
(74_609_000 as Weight)
.saturating_add(T::DbWeight::get().reads(3 as Weight))
(84_797_000 as Weight)
.saturating_add(T::DbWeight::get().reads(4 as Weight))
.saturating_add(T::DbWeight::get().writes(4 as Weight))
}
fn renounce_candidacy_runners_up() -> Weight {
(45_458_000 as Weight)
(59_095_000 as Weight)
.saturating_add(T::DbWeight::get().reads(1 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight))
}
fn remove_member_with_replacement() -> Weight {
(112_762_000 as Weight)
.saturating_add(T::DbWeight::get().reads(4 as Weight))
(132_820_000 as Weight)
.saturating_add(T::DbWeight::get().reads(5 as Weight))
.saturating_add(T::DbWeight::get().writes(5 as Weight))
}
fn remove_member_wrong_refund() -> Weight {
(8_355_000 as Weight)
(8_551_000 as Weight)
.saturating_add(T::DbWeight::get().reads(1 as Weight))
}
fn clean_defunct_voters(v: u32, _d: u32, ) -> Weight {
(0 as Weight)
.saturating_add((151_754_000 as Weight).saturating_mul(v as Weight))
.saturating_add(T::DbWeight::get().reads(4 as Weight))
.saturating_add(T::DbWeight::get().reads((3 as Weight).saturating_mul(v as Weight)))
.saturating_add(T::DbWeight::get().writes((3 as Weight).saturating_mul(v as Weight)))
}
fn election_phragmen(c: u32, v: u32, e: u32, ) -> Weight {
(0 as Weight)
.saturating_add((134_602_000 as Weight).saturating_mul(c as Weight))
.saturating_add((111_037_000 as Weight).saturating_mul(v as Weight))
.saturating_add((7_150_000 as Weight).saturating_mul(e as Weight))
.saturating_add(T::DbWeight::get().reads((2 as Weight).saturating_mul(c as Weight)))
.saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(v as Weight)))
.saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(c as Weight)))
}
}
22 changes: 16 additions & 6 deletions runtime/polkadot/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,10 @@ impl pallet_collective::Config<CouncilCollective> for Runtime {

parameter_types! {
pub const CandidacyBond: Balance = 100 * DOLLARS;
pub const VotingBond: Balance = 5 * DOLLARS;
// 1 storage item created, key size is 32 bytes, value size is 16+16.
pub const VotingBondBase: Balance = deposit(1, 64);
// additional data per vote is 32 bytes (account id).
pub const VotingBondFactor: Balance = deposit(0, 32);
/// Weekly council elections; scaling up to monthly eventually.
pub const TermDuration: BlockNumber = 7 * DAYS;
/// 13 members initially, to be increased to 23 eventually.
Expand All @@ -512,9 +515,9 @@ impl pallet_elections_phragmen::Config for Runtime {
type InitializeMembers = Council;
type CurrencyToVote = frame_support::traits::U128CurrencyToVote;
type CandidacyBond = CandidacyBond;
type VotingBond = VotingBond;
type VotingBondBase = VotingBondBase;
type VotingBondFactor = VotingBondFactor;
type LoserCandidate = Treasury;
type BadReport = Treasury;
type KickedMember = Treasury;
type DesiredMembers = DesiredMembers;
type DesiredRunnersUp = DesiredRunnersUp;
Expand Down Expand Up @@ -894,13 +897,20 @@ impl pallet_proxy::Config for Runtime {
type AnnouncementDepositFactor = AnnouncementDepositFactor;
}

pub struct CustomOnRuntimeUpgrade;
impl frame_support::traits::OnRuntimeUpgrade for CustomOnRuntimeUpgrade {
pub struct PurchaseRuntimeUpgrade;
impl frame_support::traits::OnRuntimeUpgrade for PurchaseRuntimeUpgrade {
fn on_runtime_upgrade() -> frame_support::weights::Weight {
0
}
}

pub struct PhragmenElectionDepositRuntimeUpgrade;
impl frame_support::traits::OnRuntimeUpgrade for PhragmenElectionDepositRuntimeUpgrade {
fn on_runtime_upgrade() -> frame_support::weights::Weight {
pallet_elections_phragmen::migrations_3_0_0::apply::<Runtime>(5 * CENTS, DOLLARS)
}
}

construct_runtime! {
pub enum Runtime where
Block = Block,
Expand Down Expand Up @@ -988,7 +998,7 @@ pub type Executive = frame_executive::Executive<
frame_system::ChainContext<Runtime>,
Runtime,
AllModules,
CustomOnRuntimeUpgrade
(PurchaseRuntimeUpgrade, PhragmenElectionDepositRuntimeUpgrade),
>;
/// The payload being signed in transactions.
pub type SignedPayload = generic::SignedPayload<Call, SignedExtra>;
Expand Down
80 changes: 44 additions & 36 deletions runtime/polkadot/src/weights/pallet_elections_phragmen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,14 @@

// You should have received a copy of the GNU General Public License
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.
//! Weights for pallet_elections_phragmen
//! Autogenerated weights for pallet_elections_phragmen
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 2.0.0
//! DATE: 2020-10-29, STEPS: [50, ], REPEAT: 20, LOW RANGE: [], HIGH RANGE: []
//! DATE: 2020-11-30, STEPS: [50, ], REPEAT: 20, LOW RANGE: [], HIGH RANGE: []
//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("polkadot-dev"), DB CACHE: 128

// Executed Command:
// ./target/release/polkadot
// target/release/polkadot
// benchmark
// --chain=polkadot-dev
// --steps=50
Expand All @@ -29,8 +30,7 @@
// --execution=wasm
// --wasm-execution=compiled
// --heap-pages=4096
// --header
// ./file_header.txt
// --header=./file_header.txt
// --output=./runtime/polkadot/src/weights/


Expand All @@ -43,66 +43,74 @@ use sp_std::marker::PhantomData;
/// Weight functions for pallet_elections_phragmen.
pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Config> pallet_elections_phragmen::WeightInfo for WeightInfo<T> {
fn vote(v: u32, ) -> Weight {
(85_361_000 as Weight)
.saturating_add((113_000 as Weight).saturating_mul(v as Weight))
fn vote_equal(v: u32, ) -> Weight {
(54_923_000 as Weight)
.saturating_add((324_000 as Weight).saturating_mul(v as Weight))
.saturating_add(T::DbWeight::get().reads(5 as Weight))
.saturating_add(T::DbWeight::get().writes(2 as Weight))
}
fn vote_update(v: u32, ) -> Weight {
(52_021_000 as Weight)
.saturating_add((104_000 as Weight).saturating_mul(v as Weight))
fn vote_more(v: u32, ) -> Weight {
(83_389_000 as Weight)
.saturating_add((341_000 as Weight).saturating_mul(v as Weight))
.saturating_add(T::DbWeight::get().reads(5 as Weight))
.saturating_add(T::DbWeight::get().writes(2 as Weight))
}
fn remove_voter() -> Weight {
(69_513_000 as Weight)
.saturating_add(T::DbWeight::get().reads(2 as Weight))
fn vote_less(v: u32, ) -> Weight {
(78_865_000 as Weight)
.saturating_add((343_000 as Weight).saturating_mul(v as Weight))
.saturating_add(T::DbWeight::get().reads(5 as Weight))
.saturating_add(T::DbWeight::get().writes(2 as Weight))
}
fn report_defunct_voter_correct(c: u32, v: u32, ) -> Weight {
(0 as Weight)
.saturating_add((1_693_000 as Weight).saturating_mul(c as Weight))
.saturating_add((33_480_000 as Weight).saturating_mul(v as Weight))
.saturating_add(T::DbWeight::get().reads(7 as Weight))
.saturating_add(T::DbWeight::get().writes(3 as Weight))
}
fn report_defunct_voter_incorrect(c: u32, v: u32, ) -> Weight {
(0 as Weight)
.saturating_add((1_703_000 as Weight).saturating_mul(c as Weight))
.saturating_add((33_396_000 as Weight).saturating_mul(v as Weight))
.saturating_add(T::DbWeight::get().reads(6 as Weight))
fn remove_voter() -> Weight {
(72_370_000 as Weight)
.saturating_add(T::DbWeight::get().reads(2 as Weight))
.saturating_add(T::DbWeight::get().writes(2 as Weight))
}
fn submit_candidacy(c: u32, ) -> Weight {
(68_017_000 as Weight)
.saturating_add((279_000 as Weight).saturating_mul(c as Weight))
(68_455_000 as Weight)
.saturating_add((370_000 as Weight).saturating_mul(c as Weight))
.saturating_add(T::DbWeight::get().reads(3 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight))
}
fn renounce_candidacy_candidate(c: u32, ) -> Weight {
(42_371_000 as Weight)
.saturating_add((138_000 as Weight).saturating_mul(c as Weight))
(54_009_000 as Weight)
.saturating_add((200_000 as Weight).saturating_mul(c as Weight))
.saturating_add(T::DbWeight::get().reads(1 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight))
}
fn renounce_candidacy_members() -> Weight {
(74_022_000 as Weight)
.saturating_add(T::DbWeight::get().reads(3 as Weight))
(84_797_000 as Weight)
.saturating_add(T::DbWeight::get().reads(4 as Weight))
.saturating_add(T::DbWeight::get().writes(4 as Weight))
}
fn renounce_candidacy_runners_up() -> Weight {
(45_752_000 as Weight)
(59_095_000 as Weight)
.saturating_add(T::DbWeight::get().reads(1 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight))
}
fn remove_member_with_replacement() -> Weight {
(113_257_000 as Weight)
.saturating_add(T::DbWeight::get().reads(4 as Weight))
(132_820_000 as Weight)
.saturating_add(T::DbWeight::get().reads(5 as Weight))
.saturating_add(T::DbWeight::get().writes(5 as Weight))
}
fn remove_member_wrong_refund() -> Weight {
(8_688_000 as Weight)
(8_551_000 as Weight)
.saturating_add(T::DbWeight::get().reads(1 as Weight))
}
fn clean_defunct_voters(v: u32, _d: u32, ) -> Weight {
(0 as Weight)
.saturating_add((151_754_000 as Weight).saturating_mul(v as Weight))
.saturating_add(T::DbWeight::get().reads(4 as Weight))
.saturating_add(T::DbWeight::get().reads((3 as Weight).saturating_mul(v as Weight)))
.saturating_add(T::DbWeight::get().writes((3 as Weight).saturating_mul(v as Weight)))
}
fn election_phragmen(c: u32, v: u32, e: u32, ) -> Weight {
(0 as Weight)
.saturating_add((134_602_000 as Weight).saturating_mul(c as Weight))
.saturating_add((111_037_000 as Weight).saturating_mul(v as Weight))
.saturating_add((7_150_000 as Weight).saturating_mul(e as Weight))
.saturating_add(T::DbWeight::get().reads((2 as Weight).saturating_mul(c as Weight)))
.saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(v as Weight)))
.saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(c as Weight)))
}
}