From 353a2fdcdb8cb2598b5590b99083f04dfb6b243a Mon Sep 17 00:00:00 2001 From: kianenigma Date: Thu, 14 Oct 2021 10:45:12 +0200 Subject: [PATCH 1/7] Enable bags-list pallet in polkadot --- Cargo.lock | 1 + runtime/kusama/Cargo.toml | 4 +- runtime/kusama/src/lib.rs | 27 +--- runtime/kusama/src/voter_bags.rs | 234 ------------------------------ runtime/polkadot/Cargo.toml | 2 + runtime/polkadot/src/lib.rs | 43 +++++- runtime/westend/src/lib.rs | 27 +--- runtime/westend/src/voter_bags.rs | 234 ------------------------------ 8 files changed, 51 insertions(+), 521 deletions(-) delete mode 100644 runtime/kusama/src/voter_bags.rs delete mode 100644 runtime/westend/src/voter_bags.rs diff --git a/Cargo.lock b/Cargo.lock index bad2edc33a7e..80b0b34edc45 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6675,6 +6675,7 @@ dependencies = [ "pallet-authority-discovery", "pallet-authorship", "pallet-babe", + "pallet-bags-list", "pallet-balances", "pallet-bounties", "pallet-collective", diff --git a/runtime/kusama/Cargo.toml b/runtime/kusama/Cargo.toml index 1e04a113bdfa..07dd2369085b 100644 --- a/runtime/kusama/Cargo.toml +++ b/runtime/kusama/Cargo.toml @@ -37,6 +37,7 @@ sp-npos-elections = { git = "https://github.com/paritytech/substrate", branch = pallet-authority-discovery = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } pallet-authorship = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } pallet-babe = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } +pallet-bags-list = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } pallet-bounties = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } pallet-transaction-payment = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } @@ -72,7 +73,6 @@ pallet-treasury = { git = "https://github.com/paritytech/substrate", branch = "m pallet-utility = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } pallet-vesting = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } pallet-xcm = { path = "../../xcm/pallet-xcm", default-features = false } -pallet-bags-list = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } frame-election-provider-support = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } frame-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false, optional = true } @@ -124,6 +124,7 @@ std = [ "frame-executive/std", "pallet-authority-discovery/std", "pallet-authorship/std", + "pallet-bags-list/std", "pallet-balances/std", "pallet-bounties/std", "pallet-transaction-payment/std", @@ -175,7 +176,6 @@ std = [ "xcm-executor/std", "xcm-builder/std", "frame-election-provider-support/std", - "pallet-bags-list/std", ] runtime-benchmarks = [ "runtime-common/runtime-benchmarks", diff --git a/runtime/kusama/src/lib.rs b/runtime/kusama/src/lib.rs index d596769dd2e6..a80f93c525de 100644 --- a/runtime/kusama/src/lib.rs +++ b/runtime/kusama/src/lib.rs @@ -104,7 +104,7 @@ use constants::{currency::*, fee::*, time::*}; mod weights; // Voter bag threshold definitions. -mod voter_bags; +mod bag_thresholds; #[cfg(test)] mod tests; @@ -412,7 +412,7 @@ impl pallet_election_provider_multi_phase::Config for Runtime { } parameter_types! { - pub const BagThresholds: &'static [u64] = &voter_bags::THRESHOLDS; + pub const BagThresholds: &'static [u64] = &bag_thresholds::THRESHOLDS; } impl pallet_bags_list::Config for Runtime { @@ -528,8 +528,7 @@ impl pallet_staking::Config for Runtime { type NextNewSession = Session; type MaxNominatorRewardedPerValidator = MaxNominatorRewardedPerValidator; type OffendingValidatorsThreshold = OffendingValidatorsThreshold; - // Use the nominators map to iter voters, but also perform the bags-list migration and keep - // it up-to-date. + // Use the nominators map to iter voters, but also keep bags-list up-to-date. type SortedListProvider = runtime_common::elections::UseNominatorsAndUpdateBagsList; type WeightInfo = weights::pallet_staking::WeightInfo; } @@ -1563,7 +1562,6 @@ pub type Executive = frame_executive::Executive< TechnicalMembershipStoragePrefixMigration, MigrateTipsPalletPrefix, BountiesPrefixMigration, - StakingBagsListMigrationV8, ), >; /// The payload being signed in the transactions. @@ -1718,25 +1716,6 @@ impl OnRuntimeUpgrade for MigrateTipsPalletPrefix { } } -// Migration to generate pallet staking's `SortedListProvider` from pre-existing nominators. -pub struct StakingBagsListMigrationV8; - -impl OnRuntimeUpgrade for StakingBagsListMigrationV8 { - fn on_runtime_upgrade() -> frame_support::weights::Weight { - pallet_staking::migrations::v8::migrate::() - } - - #[cfg(feature = "try-runtime")] - fn pre_upgrade() -> Result<(), &'static str> { - pallet_staking::migrations::v8::pre_migrate::() - } - - #[cfg(feature = "try-runtime")] - fn post_upgrade() -> Result<(), &'static str> { - pallet_staking::migrations::v8::post_migrate::() - } -} - #[cfg(not(feature = "disable-runtime-api"))] sp_api::impl_runtime_apis! { impl sp_api::Core for Runtime { diff --git a/runtime/kusama/src/voter_bags.rs b/runtime/kusama/src/voter_bags.rs deleted file mode 100644 index 52f4a9d5c33a..000000000000 --- a/runtime/kusama/src/voter_bags.rs +++ /dev/null @@ -1,234 +0,0 @@ -// Copyright 2021 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 . - -//! Autogenerated voter bag thresholds. -//! -//! Generated on 2021-07-05T14:34:44.453491278+00:00 -//! for the kusama runtime. - -/// Existential weight for this runtime. -#[cfg(any(test, feature = "std"))] -#[allow(unused)] -pub const EXISTENTIAL_WEIGHT: u64 = 33_333_333; - -/// Constant ratio between bags for this runtime. -#[cfg(any(test, feature = "std"))] -#[allow(unused)] -pub const CONSTANT_RATIO: f64 = 1.1455399939091000; - -/// Upper thresholds delimiting the bag list. -pub const THRESHOLDS: [u64; 200] = [ - 33_333_333, - 38_184_666, - 43_742_062, - 50_108_281, - 57_401_040, - 65_755_187, - 75_325_197, - 86_288_026, - 98_846_385, - 113_232_487, - 129_712_342, - 148_590_675, - 170_216_561, - 194_989_878, - 223_368_704, - 255_877_784, - 293_118_235, - 335_778_661, - 384_647_885, - 440_629_536, - 504_758_756, - 578_221_342, - 662_375_673, - 758_777_824, - 869_210_344, - 995_715_212, - 1_140_631_598, - 1_306_639_114, - 1_496_807_363, - 1_714_652_697, - 1_964_203_240, - 2_250_073_368, - 2_577_549_032, - 2_952_685_502, - 3_382_419_332, - 3_874_696_621, - 4_438_619_944, - 5_084_616_664, - 5_824_631_742, - 6_672_348_610, - 7_643_442_186, - 8_755_868_715, - 10_030_197_794, - 11_489_992_720, - 13_162_246_190, - 15_077_879_420, - 17_272_313_899, - 19_786_126_359, - 22_665_799_069, - 25_964_579_327, - 29_743_464_044, - 34_072_327_620, - 39_031_213_974, - 44_711_816_618, - 51_219_174_136, - 58_673_612_428, - 67_212_969_623, - 76_995_144_813, - 88_201_017_720, - 101_037_793_302, - 115_742_833_124, - 132_588_044_352, - 151_884_907_519, - 173_990_236_034, - 199_312_773_927, - 228_320_753_830, - 261_550_554_952, - 299_616_621_127, - 343_222_822_341, - 393_175_469_814, - 450_398_225_296, - 515_949_180_262, - 591_040_420_815, - 677_060_440_060, - 775_599_812_382, - 888_480_604_352, - 1_017_790_066_098, - 1_165_919_226_119, - 1_335_607_103_187, - 1_529_991_352_850, - 1_752_666_285_025, - 2_007_749_325_472, - 2_299_957_150_072, - 2_634_692_899_685, - 3_018_146_088_258, - 3_457_407_051_560, - 3_960_598_052_785, - 4_537_023_469_264, - 5_197_341_837_346, - 5_953_762_936_697, - 6_820_273_558_240, - 7_812_896_130_365, - 8_949_984_985_591, - 10_252_565_745_880, - 11_744_724_102_088, - 13_454_051_176_370, - 15_412_153_702_632, - 17_655_238_458_639, - 20_224_781_756_373, - 23_168_296_370_008, - 26_540_210_082_583, - 30_402_872_096_348, - 34_827_705_916_070, - 39_896_530_022_963, - 45_703_070_759_499, - 52_354_695_399_464, - 59_974_397_449_015, - 68_703_070_888_447, - 78_702_115_407_088, - 90_156_420_804_069, - 103_277_785_738_759, - 118_308_834_046_123, - 135_527_501_032_588, - 155_252_172_707_386, - 177_847_572_977_594, - 203_731_507_665_501, - 233_382_590_050_230, - 267_349_090_784_630, - 306_259_075_829_029, - 350_832_019_859_793, - 401_892_109_893_305, - 460_383_485_119_292, - 527_387_694_739_404, - 604_143_696_619_511, - 692_070_766_545_736, - 792_794_741_693_469, - 908_178_083_570_703, - 1_040_354_316_321_961, - 1_191_767_477_182_765, - 1_365_217_308_553_008, - 1_563_911_027_324_411, - 1_791_522_628_715_580, - 2_052_260_821_186_860, - 2_350_946_848_602_280, - 2_693_103_638_628_474, - 3_085_057_925_791_037, - 3_534_057_237_519_885, - 4_048_403_906_342_940, - 4_637_608_586_213_668, - 5_312_566_111_603_995, - 6_085_756_951_128_531, - 6_971_477_980_728_040, - 7_986_106_843_580_624, - 9_148_404_784_952_770, - 10_479_863_561_632_778, - 12_005_102_840_561_012, - 13_752_325_434_854_380, - 15_753_838_794_879_048, - 18_046_652_397_130_688, - 20_673_162_077_088_732, - 23_681_933_959_870_064, - 27_128_602_484_145_260, - 31_076_899_124_450_156, - 35_599_830_833_736_348, - 40_781_029_996_443_328, - 46_716_300_853_732_512, - 53_515_390_995_440_424, - 61_304_020_674_959_928, - 70_226_207_470_596_936, - 80_446_929_278_126_800, - 92_155_174_875_271_168, - 105_567_438_465_310_176, - 120_931_722_816_550_704, - 138_532_125_018_688_464, - 158_694_089_650_123_072, - 181_790_426_491_212_160, - 208_248_204_055_475_872, - 238_556_646_405_290_848, - 273_276_179_270_092_192, - 313_048_792_736_563_520, - 358_609_912_124_694_080, - 410_801_996_551_064_960, - 470_590_116_626_953_088, - 539_079_799_334_522_496, - 617_537_470_046_187_776, - 707_413_869_675_350_912, - 810_370_879_959_114_368, - 928_312_252_892_475_904, - 1_063_418_812_524_189_696, - 1_218_188_780_021_782_528, - 1_395_483_967_646_286_592, - 1_598_582_695_797_773_824, - 1_831_240_411_607_374_592, - 2_097_759_129_958_809_600, - 2_403_066_980_955_773_440, - 2_752_809_334_727_236_096, - 3_153_453_188_536_351_744, - 3_612_406_746_388_564_480, - 4_138_156_402_255_148_032, - 4_740_423_659_834_265_600, - 5_430_344_890_413_097_984, - 6_220_677_252_688_132_096, - 7_126_034_582_154_840_064, - 8_163_157_611_837_691_904, - 9_351_223_520_943_572_992, - 10_712_200_535_224_332_288, - 12_271_254_135_873_939_456, - 14_057_212_388_066_050_048, - 16_103_098_993_404_108_800, - 18_446_744_073_709_551_615, -]; diff --git a/runtime/polkadot/Cargo.toml b/runtime/polkadot/Cargo.toml index 07558ef8881d..f4f4293fb471 100644 --- a/runtime/polkadot/Cargo.toml +++ b/runtime/polkadot/Cargo.toml @@ -36,6 +36,7 @@ sp-npos-elections = { git = "https://github.com/paritytech/substrate", branch = pallet-authority-discovery = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } pallet-authorship = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } pallet-babe = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } +pallet-bags-list = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } pallet-bounties = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } pallet-transaction-payment = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } @@ -114,6 +115,7 @@ std = [ "frame-executive/std", "pallet-authority-discovery/std", "pallet-authorship/std", + "pallet-bags-list/std", "pallet-balances/std", "pallet-bounties/std", "pallet-transaction-payment/std", diff --git a/runtime/polkadot/src/lib.rs b/runtime/polkadot/src/lib.rs index c43fbcb85393..0a6322c573c9 100644 --- a/runtime/polkadot/src/lib.rs +++ b/runtime/polkadot/src/lib.rs @@ -95,6 +95,8 @@ use frame_support::traits::InstanceFilter; // Weights used in the runtime. mod weights; +mod bag_thresholds; + // Make the WASM binary available. #[cfg(feature = "std")] include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs")); @@ -435,6 +437,17 @@ impl pallet_election_provider_multi_phase::Config for Runtime { type VoterSnapshotPerBlock = VoterSnapshotPerBlock; } +parameter_types! { + pub const BagThresholds: &'static [u64] = &bag_thresholds::THRESHOLDS; +} + +impl pallet_bags_list::Config for Runtime { + type Event = Event; + type VoteWeightProvider = Staking; + type WeightInfo = weights::pallet_bags_list::WeightInfo; + type BagThresholds = BagThresholds; +} + // TODO #6469: This shouldn't be static, but a lazily cached value, not built unless needed, and // re-built in case input parameters have changed. The `ideal_stake` should be determined by the // amount of parachain slots being bid on: this should be around `(75 - 25.min(slots / 4))%`. @@ -495,9 +508,8 @@ impl pallet_staking::Config for Runtime { type NextNewSession = Session; type ElectionProvider = ElectionProviderMultiPhase; type GenesisElectionProvider = runtime_common::elections::GenesisElectionOf; - // Use the nominator map to iter voter AND no-ops for all SortedListProvider hooks. The migration - // to bags-list is a no-op, but the storage version will be updated. - type SortedListProvider = pallet_staking::UseNominatorsMap; + // Use the nominators map to iter voters, but also keep bags-list up-to-date. + type SortedListProvider = runtime_common::elections::UseNominatorsAndUpdateBagsList;; type WeightInfo = weights::pallet_staking::WeightInfo; } @@ -1297,6 +1309,9 @@ construct_runtime! { // Election pallet. Only works with staking, but placed here to maintain indices. ElectionProviderMultiPhase: pallet_election_provider_multi_phase::{Pallet, Call, Storage, Event, ValidateUnsigned} = 36, + // Provides a semi-sorted list of nominators for staking. + BagsList: pallet_bags_list::{Pallet, Call, Storage, Event} = 37, + // Parachains pallets. Start indices at 50 to leave room. ParachainsOrigin: parachains_origin::{Pallet, Origin} = 50, Configuration: parachains_configuration::{Pallet, Call, Storage, Config} = 51, @@ -1350,6 +1365,7 @@ pub type Executive = frame_executive::Executive< Runtime, AllPallets, ( + StakingBagsListMigrationV8, SetInitialHostConfiguration, BountiesPrefixMigration, CouncilStoragePrefixMigration, @@ -1361,6 +1377,25 @@ pub type Executive = frame_executive::Executive< /// The payload being signed in transactions. pub type SignedPayload = generic::SignedPayload; +// Migration to generate pallet staking's `SortedListProvider` from pre-existing nominators. +pub struct StakingBagsListMigrationV8; + +impl OnRuntimeUpgrade for StakingBagsListMigrationV8 { + fn on_runtime_upgrade() -> frame_support::weights::Weight { + pallet_staking::migrations::v8::migrate::() + } + + #[cfg(feature = "try-runtime")] + fn pre_upgrade() -> Result<(), &'static str> { + pallet_staking::migrations::v8::pre_migrate::() + } + + #[cfg(feature = "try-runtime")] + fn post_upgrade() -> Result<(), &'static str> { + pallet_staking::migrations::v8::post_migrate::() + } +} + const BOUNTIES_OLD_PREFIX: &str = "Treasury"; /// Migrate from 'Treasury' to the new prefix 'Bounties' @@ -1917,6 +1952,7 @@ sp_api::impl_runtime_apis! { list_benchmark!(list, extra, runtime_parachains::initializer, Initializer); list_benchmark!(list, extra, runtime_parachains::paras, Paras); // Substrate + list_benchmark!(list, extra, pallet_bags_list, BagsList); list_benchmark!(list, extra, pallet_balances, Balances); list_benchmark!(list, extra, pallet_bounties, Bounties); list_benchmark!(list, extra, pallet_collective, Council); @@ -1992,6 +2028,7 @@ sp_api::impl_runtime_apis! { add_benchmark!(params, batches, runtime_parachains::initializer, Initializer); add_benchmark!(params, batches, runtime_parachains::paras, Paras); // Substrate + list_benchmark!(list, extra, pallet_bags_list, BagsList); add_benchmark!(params, batches, pallet_balances, Balances); add_benchmark!(params, batches, pallet_bounties, Bounties); add_benchmark!(params, batches, pallet_collective, Council); diff --git a/runtime/westend/src/lib.rs b/runtime/westend/src/lib.rs index 55ef0c129c2a..963d60b463ff 100644 --- a/runtime/westend/src/lib.rs +++ b/runtime/westend/src/lib.rs @@ -102,7 +102,7 @@ use constants::{currency::*, fee::*, time::*}; mod weights; // Voter bag threshold definitions. -mod voter_bags; +mod bag_thresholds; #[cfg(test)] mod tests; @@ -394,7 +394,7 @@ impl pallet_election_provider_multi_phase::Config for Runtime { } parameter_types! { - pub const BagThresholds: &'static [u64] = &voter_bags::THRESHOLDS; + pub const BagThresholds: &'static [u64] = &bag_thresholds::THRESHOLDS; } impl pallet_bags_list::Config for Runtime { @@ -454,8 +454,7 @@ impl pallet_staking::Config for Runtime { type NextNewSession = Session; type ElectionProvider = ElectionProviderMultiPhase; type GenesisElectionProvider = runtime_common::elections::GenesisElectionOf; - // Use the nominators map to iter voters, but also perform the bags-list migration and keep - // it up-to-date. + // Use the nominators map to iter voters, but also keep bags-list up-to-date. type SortedListProvider = runtime_common::elections::UseNominatorsAndUpdateBagsList; type WeightInfo = weights::pallet_staking::WeightInfo; } @@ -1135,30 +1134,10 @@ pub type Executive = frame_executive::Executive< frame_system::ChainContext, Runtime, AllPallets, - (StakingBagsListMigrationV8,), >; /// The payload being signed in transactions. pub type SignedPayload = generic::SignedPayload; -// Migration to generate pallet staking's `SortedListProvider` from pre-existing nominators. -pub struct StakingBagsListMigrationV8; - -impl OnRuntimeUpgrade for StakingBagsListMigrationV8 { - fn on_runtime_upgrade() -> frame_support::weights::Weight { - pallet_staking::migrations::v8::migrate::() - } - - #[cfg(feature = "try-runtime")] - fn pre_upgrade() -> Result<(), &'static str> { - pallet_staking::migrations::v8::pre_migrate::() - } - - #[cfg(feature = "try-runtime")] - fn post_upgrade() -> Result<(), &'static str> { - pallet_staking::migrations::v8::post_migrate::() - } -} - #[cfg(not(feature = "disable-runtime-api"))] sp_api::impl_runtime_apis! { impl sp_api::Core for Runtime { diff --git a/runtime/westend/src/voter_bags.rs b/runtime/westend/src/voter_bags.rs deleted file mode 100644 index d88f469f6b1c..000000000000 --- a/runtime/westend/src/voter_bags.rs +++ /dev/null @@ -1,234 +0,0 @@ -// Copyright 2021 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 . - -//! Autogenerated voter bag thresholds. -//! -//! Generated on 2021-07-05T14:35:50.538338181+00:00 -//! for the westend runtime. - -/// Existential weight for this runtime. -#[cfg(any(test, feature = "std"))] -#[allow(unused)] -pub const EXISTENTIAL_WEIGHT: u64 = 10_000_000_000; - -/// Constant ratio between bags for this runtime. -#[cfg(any(test, feature = "std"))] -#[allow(unused)] -pub const CONSTANT_RATIO: f64 = 1.1131723507077667; - -/// Upper thresholds delimiting the bag list. -pub const THRESHOLDS: [u64; 200] = [ - 10_000_000_000, - 11_131_723_507, - 12_391_526_824, - 13_793_905_044, - 15_354_993_703, - 17_092_754_435, - 19_027_181_634, - 21_180_532_507, - 23_577_583_160, - 26_245_913_670, - 29_216_225_417, - 32_522_694_326, - 36_203_364_094, - 40_300_583_912, - 44_861_495_728, - 49_938_576_656, - 55_590_242_767, - 61_881_521_217, - 68_884_798_439, - 76_680_653_006, - 85_358_782_760, - 95_019_036_859, - 105_772_564_622, - 117_743_094_401, - 131_068_357_174, - 145_901_671_259, - 162_413_706_368, - 180_794_447_305, - 201_255_379_901, - 224_031_924_337, - 249_386_143_848, - 277_609_759_981, - 309_027_509_097, - 344_000_878_735, - 382_932_266_827, - 426_269_611_626, - 474_511_545_609, - 528_213_132_664, - 587_992_254_562, - 654_536_720_209, - 728_612_179_460, - 811_070_932_564, - 902_861_736_593, - 1_005_040_721_687, - 1_118_783_542_717, - 1_245_398_906_179, - 1_386_343_627_960, - 1_543_239_395_225, - 1_717_891_425_287, - 1_912_309_236_147, - 2_128_729_767_682, - 2_369_643_119_512, - 2_637_821_201_686, - 2_936_349_627_828, - 3_268_663_217_709, - 3_638_585_517_729, - 4_050_372_794_022, - 4_508_763_004_364, - 5_019_030_312_352, - 5_587_045_771_074, - 6_219_344_874_498, - 6_923_202_753_807, - 7_706_717_883_882, - 8_578_905_263_043, - 9_549_800_138_161, - 10_630_573_468_586, - 11_833_660_457_397, - 13_172_903_628_838, - 14_663_712_098_160, - 16_323_238_866_411, - 18_170_578_180_087, - 20_226_985_226_447, - 22_516_120_692_255, - 25_064_322_999_817, - 27_900_911_352_605, - 31_058_523_077_268, - 34_573_489_143_434, - 38_486_252_181_966, - 42_841_831_811_331, - 47_690_342_626_046, - 53_087_570_807_094, - 59_095_615_988_698, - 65_783_605_766_662, - 73_228_491_069_308, - 81_515_931_542_404, - 90_741_281_135_191, - 101_010_685_227_495, - 112_442_301_921_293, - 125_167_661_548_718, - 139_333_180_038_781, - 155_101_843_555_358, - 172_655_083_789_626, - 192_194_865_483_744, - 213_946_010_204_502, - 238_158_783_103_893, - 265_111_772_429_462, - 295_115_094_915_607, - 328_513_963_936_552, - 365_692_661_475_578, - 407_078_959_611_349, - 453_149_042_394_237, - 504_432_984_742_966, - 561_520_851_400_862, - 625_069_486_125_324, - 695_810_069_225_823, - 774_556_530_406_243, - 862_214_913_708_369, - 959_793_802_308_039, - 1_068_415_923_109_985, - 1_189_331_064_661_951, - 1_323_930_457_019_515, - 1_473_762_779_014_021, - 1_640_551_977_100_649, - 1_826_217_100_807_404, - 2_032_894_383_008_501, - 2_262_961_819_074_188, - 2_519_066_527_700_738, - 2_804_155_208_229_882, - 3_121_508_044_894_685, - 3_474_776_448_088_622, - 3_868_025_066_902_796, - 4_305_778_556_320_752, - 4_793_073_637_166_665, - 5_335_517_047_800_242, - 5_939_350_054_341_159, - 6_611_520_261_667_250, - 7_359_761_551_432_161, - 8_192_683_066_856_378, - 9_119_868_268_136_230, - 10_151_985_198_186_376, - 11_300_909_227_415_580, - 12_579_859_689_817_292, - 14_003_551_982_487_792, - 15_588_366_878_604_342, - 17_352_539_001_951_086, - 19_316_366_631_550_092, - 21_502_445_250_375_680, - 23_935_927_525_325_748, - 26_644_812_709_737_600, - 29_660_268_798_266_784, - 33_016_991_140_790_860, - 36_753_601_641_491_664, - 40_913_093_136_236_104, - 45_543_324_061_189_736, - 50_697_569_104_240_168, - 56_435_132_174_936_472, - 62_822_028_745_677_552, - 69_931_745_415_056_768, - 77_846_085_432_775_824, - 86_656_109_914_600_688, - 96_463_185_576_826_656, - 107_380_151_045_315_664, - 119_532_615_158_469_088, - 133_060_402_202_199_856, - 148_119_160_705_543_712, - 164_882_154_307_451_552, - 183_542_255_300_186_560, - 204_314_163_786_713_728, - 227_436_877_985_347_776, - 253_176_444_104_585_088, - 281_829_017_427_734_464, - 313_724_269_827_691_328, - 349_229_182_918_168_832, - 388_752_270_484_770_624, - 432_748_278_778_513_664, - 481_723_418_752_617_984, - 536_241_190_443_833_600, - 596_928_866_512_693_376, - 664_484_709_541_257_600, - 739_686_006_129_409_280, - 823_398_010_228_713_984, - 916_583_898_614_395_264, - 1_020_315_853_041_475_584, - 1_135_787_396_594_579_584, - 1_264_327_126_171_442_688, - 1_407_413_999_103_859_968, - 1_566_694_349_801_462_272, - 1_744_000_832_209_069_824, - 1_941_373_506_026_471_680, - 2_161_083_309_305_266_176, - 2_405_658_187_494_662_656, - 2_677_912_179_572_818_944, - 2_980_977_795_924_034_048, - 3_318_342_060_496_414_208, - 3_693_886_631_935_247_360, - 4_111_932_465_319_354_368, - 4_577_289_528_371_127_808, - 5_095_312_144_166_932_480, - 5_671_960_597_112_134_656, - 6_313_869_711_009_142_784, - 7_028_425_188_266_614_784, - 7_823_848_588_596_424_704, - 8_709_291_924_949_524_480, - 9_694_942_965_096_232_960, - 10_792_142_450_433_898_496, - 12_013_514_580_722_579_456, - 13_373_112_266_084_982_784, - 14_886_578_817_516_689_408, - 16_571_327_936_291_497_984, - 18_446_744_073_709_551_615, -]; From 398fd477c4a75ef0a2a3328b184b68fa69291143 Mon Sep 17 00:00:00 2001 From: kianenigma Date: Thu, 14 Oct 2021 10:47:01 +0200 Subject: [PATCH 2/7] add files --- runtime/kusama/src/bag_thresholds.rs | 234 +++++++++++++++++++++++++ runtime/polkadot/src/bag_thresholds.rs | 234 +++++++++++++++++++++++++ runtime/westend/src/bag_thresholds.rs | 234 +++++++++++++++++++++++++ 3 files changed, 702 insertions(+) create mode 100644 runtime/kusama/src/bag_thresholds.rs create mode 100644 runtime/polkadot/src/bag_thresholds.rs create mode 100644 runtime/westend/src/bag_thresholds.rs diff --git a/runtime/kusama/src/bag_thresholds.rs b/runtime/kusama/src/bag_thresholds.rs new file mode 100644 index 000000000000..52f4a9d5c33a --- /dev/null +++ b/runtime/kusama/src/bag_thresholds.rs @@ -0,0 +1,234 @@ +// Copyright 2021 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 . + +//! Autogenerated voter bag thresholds. +//! +//! Generated on 2021-07-05T14:34:44.453491278+00:00 +//! for the kusama runtime. + +/// Existential weight for this runtime. +#[cfg(any(test, feature = "std"))] +#[allow(unused)] +pub const EXISTENTIAL_WEIGHT: u64 = 33_333_333; + +/// Constant ratio between bags for this runtime. +#[cfg(any(test, feature = "std"))] +#[allow(unused)] +pub const CONSTANT_RATIO: f64 = 1.1455399939091000; + +/// Upper thresholds delimiting the bag list. +pub const THRESHOLDS: [u64; 200] = [ + 33_333_333, + 38_184_666, + 43_742_062, + 50_108_281, + 57_401_040, + 65_755_187, + 75_325_197, + 86_288_026, + 98_846_385, + 113_232_487, + 129_712_342, + 148_590_675, + 170_216_561, + 194_989_878, + 223_368_704, + 255_877_784, + 293_118_235, + 335_778_661, + 384_647_885, + 440_629_536, + 504_758_756, + 578_221_342, + 662_375_673, + 758_777_824, + 869_210_344, + 995_715_212, + 1_140_631_598, + 1_306_639_114, + 1_496_807_363, + 1_714_652_697, + 1_964_203_240, + 2_250_073_368, + 2_577_549_032, + 2_952_685_502, + 3_382_419_332, + 3_874_696_621, + 4_438_619_944, + 5_084_616_664, + 5_824_631_742, + 6_672_348_610, + 7_643_442_186, + 8_755_868_715, + 10_030_197_794, + 11_489_992_720, + 13_162_246_190, + 15_077_879_420, + 17_272_313_899, + 19_786_126_359, + 22_665_799_069, + 25_964_579_327, + 29_743_464_044, + 34_072_327_620, + 39_031_213_974, + 44_711_816_618, + 51_219_174_136, + 58_673_612_428, + 67_212_969_623, + 76_995_144_813, + 88_201_017_720, + 101_037_793_302, + 115_742_833_124, + 132_588_044_352, + 151_884_907_519, + 173_990_236_034, + 199_312_773_927, + 228_320_753_830, + 261_550_554_952, + 299_616_621_127, + 343_222_822_341, + 393_175_469_814, + 450_398_225_296, + 515_949_180_262, + 591_040_420_815, + 677_060_440_060, + 775_599_812_382, + 888_480_604_352, + 1_017_790_066_098, + 1_165_919_226_119, + 1_335_607_103_187, + 1_529_991_352_850, + 1_752_666_285_025, + 2_007_749_325_472, + 2_299_957_150_072, + 2_634_692_899_685, + 3_018_146_088_258, + 3_457_407_051_560, + 3_960_598_052_785, + 4_537_023_469_264, + 5_197_341_837_346, + 5_953_762_936_697, + 6_820_273_558_240, + 7_812_896_130_365, + 8_949_984_985_591, + 10_252_565_745_880, + 11_744_724_102_088, + 13_454_051_176_370, + 15_412_153_702_632, + 17_655_238_458_639, + 20_224_781_756_373, + 23_168_296_370_008, + 26_540_210_082_583, + 30_402_872_096_348, + 34_827_705_916_070, + 39_896_530_022_963, + 45_703_070_759_499, + 52_354_695_399_464, + 59_974_397_449_015, + 68_703_070_888_447, + 78_702_115_407_088, + 90_156_420_804_069, + 103_277_785_738_759, + 118_308_834_046_123, + 135_527_501_032_588, + 155_252_172_707_386, + 177_847_572_977_594, + 203_731_507_665_501, + 233_382_590_050_230, + 267_349_090_784_630, + 306_259_075_829_029, + 350_832_019_859_793, + 401_892_109_893_305, + 460_383_485_119_292, + 527_387_694_739_404, + 604_143_696_619_511, + 692_070_766_545_736, + 792_794_741_693_469, + 908_178_083_570_703, + 1_040_354_316_321_961, + 1_191_767_477_182_765, + 1_365_217_308_553_008, + 1_563_911_027_324_411, + 1_791_522_628_715_580, + 2_052_260_821_186_860, + 2_350_946_848_602_280, + 2_693_103_638_628_474, + 3_085_057_925_791_037, + 3_534_057_237_519_885, + 4_048_403_906_342_940, + 4_637_608_586_213_668, + 5_312_566_111_603_995, + 6_085_756_951_128_531, + 6_971_477_980_728_040, + 7_986_106_843_580_624, + 9_148_404_784_952_770, + 10_479_863_561_632_778, + 12_005_102_840_561_012, + 13_752_325_434_854_380, + 15_753_838_794_879_048, + 18_046_652_397_130_688, + 20_673_162_077_088_732, + 23_681_933_959_870_064, + 27_128_602_484_145_260, + 31_076_899_124_450_156, + 35_599_830_833_736_348, + 40_781_029_996_443_328, + 46_716_300_853_732_512, + 53_515_390_995_440_424, + 61_304_020_674_959_928, + 70_226_207_470_596_936, + 80_446_929_278_126_800, + 92_155_174_875_271_168, + 105_567_438_465_310_176, + 120_931_722_816_550_704, + 138_532_125_018_688_464, + 158_694_089_650_123_072, + 181_790_426_491_212_160, + 208_248_204_055_475_872, + 238_556_646_405_290_848, + 273_276_179_270_092_192, + 313_048_792_736_563_520, + 358_609_912_124_694_080, + 410_801_996_551_064_960, + 470_590_116_626_953_088, + 539_079_799_334_522_496, + 617_537_470_046_187_776, + 707_413_869_675_350_912, + 810_370_879_959_114_368, + 928_312_252_892_475_904, + 1_063_418_812_524_189_696, + 1_218_188_780_021_782_528, + 1_395_483_967_646_286_592, + 1_598_582_695_797_773_824, + 1_831_240_411_607_374_592, + 2_097_759_129_958_809_600, + 2_403_066_980_955_773_440, + 2_752_809_334_727_236_096, + 3_153_453_188_536_351_744, + 3_612_406_746_388_564_480, + 4_138_156_402_255_148_032, + 4_740_423_659_834_265_600, + 5_430_344_890_413_097_984, + 6_220_677_252_688_132_096, + 7_126_034_582_154_840_064, + 8_163_157_611_837_691_904, + 9_351_223_520_943_572_992, + 10_712_200_535_224_332_288, + 12_271_254_135_873_939_456, + 14_057_212_388_066_050_048, + 16_103_098_993_404_108_800, + 18_446_744_073_709_551_615, +]; diff --git a/runtime/polkadot/src/bag_thresholds.rs b/runtime/polkadot/src/bag_thresholds.rs new file mode 100644 index 000000000000..2eb2158d8f13 --- /dev/null +++ b/runtime/polkadot/src/bag_thresholds.rs @@ -0,0 +1,234 @@ +// Copyright 2021 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 . + +//! Autogenerated bag thresholds. +//! +//! Generated on 2021-10-14T08:36:33.156699497+00:00 +//! for the polkadot runtime. + +/// Existential weight for this runtime. +#[cfg(any(test, feature = "std"))] +#[allow(unused)] +pub const EXISTENTIAL_WEIGHT: u64 = 10_000_000_000; + +/// Constant ratio between bags for this runtime. +#[cfg(any(test, feature = "std"))] +#[allow(unused)] +pub const CONSTANT_RATIO: f64 = 1.1131723507077667; + +/// Upper thresholds delimiting the bag list. +pub const THRESHOLDS: [u64; 200] = [ + 10_000_000_000, + 11_131_723_507, + 12_391_526_824, + 13_793_905_044, + 15_354_993_703, + 17_092_754_435, + 19_027_181_634, + 21_180_532_507, + 23_577_583_160, + 26_245_913_670, + 29_216_225_417, + 32_522_694_326, + 36_203_364_094, + 40_300_583_912, + 44_861_495_728, + 49_938_576_656, + 55_590_242_767, + 61_881_521_217, + 68_884_798_439, + 76_680_653_006, + 85_358_782_760, + 95_019_036_859, + 105_772_564_622, + 117_743_094_401, + 131_068_357_174, + 145_901_671_259, + 162_413_706_368, + 180_794_447_305, + 201_255_379_901, + 224_031_924_337, + 249_386_143_848, + 277_609_759_981, + 309_027_509_097, + 344_000_878_735, + 382_932_266_827, + 426_269_611_626, + 474_511_545_609, + 528_213_132_664, + 587_992_254_562, + 654_536_720_209, + 728_612_179_460, + 811_070_932_564, + 902_861_736_593, + 1_005_040_721_687, + 1_118_783_542_717, + 1_245_398_906_179, + 1_386_343_627_960, + 1_543_239_395_225, + 1_717_891_425_287, + 1_912_309_236_147, + 2_128_729_767_682, + 2_369_643_119_512, + 2_637_821_201_686, + 2_936_349_627_828, + 3_268_663_217_709, + 3_638_585_517_729, + 4_050_372_794_022, + 4_508_763_004_364, + 5_019_030_312_352, + 5_587_045_771_074, + 6_219_344_874_498, + 6_923_202_753_807, + 7_706_717_883_882, + 8_578_905_263_043, + 9_549_800_138_161, + 10_630_573_468_586, + 11_833_660_457_397, + 13_172_903_628_838, + 14_663_712_098_160, + 16_323_238_866_411, + 18_170_578_180_087, + 20_226_985_226_447, + 22_516_120_692_255, + 25_064_322_999_817, + 27_900_911_352_605, + 31_058_523_077_268, + 34_573_489_143_434, + 38_486_252_181_966, + 42_841_831_811_331, + 47_690_342_626_046, + 53_087_570_807_094, + 59_095_615_988_698, + 65_783_605_766_662, + 73_228_491_069_308, + 81_515_931_542_404, + 90_741_281_135_191, + 101_010_685_227_495, + 112_442_301_921_293, + 125_167_661_548_718, + 139_333_180_038_781, + 155_101_843_555_358, + 172_655_083_789_626, + 192_194_865_483_744, + 213_946_010_204_502, + 238_158_783_103_893, + 265_111_772_429_462, + 295_115_094_915_607, + 328_513_963_936_552, + 365_692_661_475_578, + 407_078_959_611_349, + 453_149_042_394_237, + 504_432_984_742_966, + 561_520_851_400_862, + 625_069_486_125_324, + 695_810_069_225_823, + 774_556_530_406_243, + 862_214_913_708_369, + 959_793_802_308_039, + 1_068_415_923_109_985, + 1_189_331_064_661_951, + 1_323_930_457_019_515, + 1_473_762_779_014_021, + 1_640_551_977_100_649, + 1_826_217_100_807_404, + 2_032_894_383_008_501, + 2_262_961_819_074_188, + 2_519_066_527_700_738, + 2_804_155_208_229_882, + 3_121_508_044_894_685, + 3_474_776_448_088_622, + 3_868_025_066_902_796, + 4_305_778_556_320_752, + 4_793_073_637_166_665, + 5_335_517_047_800_242, + 5_939_350_054_341_159, + 6_611_520_261_667_250, + 7_359_761_551_432_161, + 8_192_683_066_856_378, + 9_119_868_268_136_230, + 10_151_985_198_186_376, + 11_300_909_227_415_580, + 12_579_859_689_817_292, + 14_003_551_982_487_792, + 15_588_366_878_604_342, + 17_352_539_001_951_086, + 19_316_366_631_550_092, + 21_502_445_250_375_680, + 23_935_927_525_325_748, + 26_644_812_709_737_600, + 29_660_268_798_266_784, + 33_016_991_140_790_860, + 36_753_601_641_491_664, + 40_913_093_136_236_104, + 45_543_324_061_189_736, + 50_697_569_104_240_168, + 56_435_132_174_936_472, + 62_822_028_745_677_552, + 69_931_745_415_056_768, + 77_846_085_432_775_824, + 86_656_109_914_600_688, + 96_463_185_576_826_656, + 107_380_151_045_315_664, + 119_532_615_158_469_088, + 133_060_402_202_199_856, + 148_119_160_705_543_712, + 164_882_154_307_451_552, + 183_542_255_300_186_560, + 204_314_163_786_713_728, + 227_436_877_985_347_776, + 253_176_444_104_585_088, + 281_829_017_427_734_464, + 313_724_269_827_691_328, + 349_229_182_918_168_832, + 388_752_270_484_770_624, + 432_748_278_778_513_664, + 481_723_418_752_617_984, + 536_241_190_443_833_600, + 596_928_866_512_693_376, + 664_484_709_541_257_600, + 739_686_006_129_409_280, + 823_398_010_228_713_984, + 916_583_898_614_395_264, + 1_020_315_853_041_475_584, + 1_135_787_396_594_579_584, + 1_264_327_126_171_442_688, + 1_407_413_999_103_859_968, + 1_566_694_349_801_462_272, + 1_744_000_832_209_069_824, + 1_941_373_506_026_471_680, + 2_161_083_309_305_266_176, + 2_405_658_187_494_662_656, + 2_677_912_179_572_818_944, + 2_980_977_795_924_034_048, + 3_318_342_060_496_414_208, + 3_693_886_631_935_247_360, + 4_111_932_465_319_354_368, + 4_577_289_528_371_127_808, + 5_095_312_144_166_932_480, + 5_671_960_597_112_134_656, + 6_313_869_711_009_142_784, + 7_028_425_188_266_614_784, + 7_823_848_588_596_424_704, + 8_709_291_924_949_524_480, + 9_694_942_965_096_232_960, + 10_792_142_450_433_898_496, + 12_013_514_580_722_579_456, + 13_373_112_266_084_982_784, + 14_886_578_817_516_689_408, + 16_571_327_936_291_497_984, + 18_446_744_073_709_551_615, +]; diff --git a/runtime/westend/src/bag_thresholds.rs b/runtime/westend/src/bag_thresholds.rs new file mode 100644 index 000000000000..d88f469f6b1c --- /dev/null +++ b/runtime/westend/src/bag_thresholds.rs @@ -0,0 +1,234 @@ +// Copyright 2021 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 . + +//! Autogenerated voter bag thresholds. +//! +//! Generated on 2021-07-05T14:35:50.538338181+00:00 +//! for the westend runtime. + +/// Existential weight for this runtime. +#[cfg(any(test, feature = "std"))] +#[allow(unused)] +pub const EXISTENTIAL_WEIGHT: u64 = 10_000_000_000; + +/// Constant ratio between bags for this runtime. +#[cfg(any(test, feature = "std"))] +#[allow(unused)] +pub const CONSTANT_RATIO: f64 = 1.1131723507077667; + +/// Upper thresholds delimiting the bag list. +pub const THRESHOLDS: [u64; 200] = [ + 10_000_000_000, + 11_131_723_507, + 12_391_526_824, + 13_793_905_044, + 15_354_993_703, + 17_092_754_435, + 19_027_181_634, + 21_180_532_507, + 23_577_583_160, + 26_245_913_670, + 29_216_225_417, + 32_522_694_326, + 36_203_364_094, + 40_300_583_912, + 44_861_495_728, + 49_938_576_656, + 55_590_242_767, + 61_881_521_217, + 68_884_798_439, + 76_680_653_006, + 85_358_782_760, + 95_019_036_859, + 105_772_564_622, + 117_743_094_401, + 131_068_357_174, + 145_901_671_259, + 162_413_706_368, + 180_794_447_305, + 201_255_379_901, + 224_031_924_337, + 249_386_143_848, + 277_609_759_981, + 309_027_509_097, + 344_000_878_735, + 382_932_266_827, + 426_269_611_626, + 474_511_545_609, + 528_213_132_664, + 587_992_254_562, + 654_536_720_209, + 728_612_179_460, + 811_070_932_564, + 902_861_736_593, + 1_005_040_721_687, + 1_118_783_542_717, + 1_245_398_906_179, + 1_386_343_627_960, + 1_543_239_395_225, + 1_717_891_425_287, + 1_912_309_236_147, + 2_128_729_767_682, + 2_369_643_119_512, + 2_637_821_201_686, + 2_936_349_627_828, + 3_268_663_217_709, + 3_638_585_517_729, + 4_050_372_794_022, + 4_508_763_004_364, + 5_019_030_312_352, + 5_587_045_771_074, + 6_219_344_874_498, + 6_923_202_753_807, + 7_706_717_883_882, + 8_578_905_263_043, + 9_549_800_138_161, + 10_630_573_468_586, + 11_833_660_457_397, + 13_172_903_628_838, + 14_663_712_098_160, + 16_323_238_866_411, + 18_170_578_180_087, + 20_226_985_226_447, + 22_516_120_692_255, + 25_064_322_999_817, + 27_900_911_352_605, + 31_058_523_077_268, + 34_573_489_143_434, + 38_486_252_181_966, + 42_841_831_811_331, + 47_690_342_626_046, + 53_087_570_807_094, + 59_095_615_988_698, + 65_783_605_766_662, + 73_228_491_069_308, + 81_515_931_542_404, + 90_741_281_135_191, + 101_010_685_227_495, + 112_442_301_921_293, + 125_167_661_548_718, + 139_333_180_038_781, + 155_101_843_555_358, + 172_655_083_789_626, + 192_194_865_483_744, + 213_946_010_204_502, + 238_158_783_103_893, + 265_111_772_429_462, + 295_115_094_915_607, + 328_513_963_936_552, + 365_692_661_475_578, + 407_078_959_611_349, + 453_149_042_394_237, + 504_432_984_742_966, + 561_520_851_400_862, + 625_069_486_125_324, + 695_810_069_225_823, + 774_556_530_406_243, + 862_214_913_708_369, + 959_793_802_308_039, + 1_068_415_923_109_985, + 1_189_331_064_661_951, + 1_323_930_457_019_515, + 1_473_762_779_014_021, + 1_640_551_977_100_649, + 1_826_217_100_807_404, + 2_032_894_383_008_501, + 2_262_961_819_074_188, + 2_519_066_527_700_738, + 2_804_155_208_229_882, + 3_121_508_044_894_685, + 3_474_776_448_088_622, + 3_868_025_066_902_796, + 4_305_778_556_320_752, + 4_793_073_637_166_665, + 5_335_517_047_800_242, + 5_939_350_054_341_159, + 6_611_520_261_667_250, + 7_359_761_551_432_161, + 8_192_683_066_856_378, + 9_119_868_268_136_230, + 10_151_985_198_186_376, + 11_300_909_227_415_580, + 12_579_859_689_817_292, + 14_003_551_982_487_792, + 15_588_366_878_604_342, + 17_352_539_001_951_086, + 19_316_366_631_550_092, + 21_502_445_250_375_680, + 23_935_927_525_325_748, + 26_644_812_709_737_600, + 29_660_268_798_266_784, + 33_016_991_140_790_860, + 36_753_601_641_491_664, + 40_913_093_136_236_104, + 45_543_324_061_189_736, + 50_697_569_104_240_168, + 56_435_132_174_936_472, + 62_822_028_745_677_552, + 69_931_745_415_056_768, + 77_846_085_432_775_824, + 86_656_109_914_600_688, + 96_463_185_576_826_656, + 107_380_151_045_315_664, + 119_532_615_158_469_088, + 133_060_402_202_199_856, + 148_119_160_705_543_712, + 164_882_154_307_451_552, + 183_542_255_300_186_560, + 204_314_163_786_713_728, + 227_436_877_985_347_776, + 253_176_444_104_585_088, + 281_829_017_427_734_464, + 313_724_269_827_691_328, + 349_229_182_918_168_832, + 388_752_270_484_770_624, + 432_748_278_778_513_664, + 481_723_418_752_617_984, + 536_241_190_443_833_600, + 596_928_866_512_693_376, + 664_484_709_541_257_600, + 739_686_006_129_409_280, + 823_398_010_228_713_984, + 916_583_898_614_395_264, + 1_020_315_853_041_475_584, + 1_135_787_396_594_579_584, + 1_264_327_126_171_442_688, + 1_407_413_999_103_859_968, + 1_566_694_349_801_462_272, + 1_744_000_832_209_069_824, + 1_941_373_506_026_471_680, + 2_161_083_309_305_266_176, + 2_405_658_187_494_662_656, + 2_677_912_179_572_818_944, + 2_980_977_795_924_034_048, + 3_318_342_060_496_414_208, + 3_693_886_631_935_247_360, + 4_111_932_465_319_354_368, + 4_577_289_528_371_127_808, + 5_095_312_144_166_932_480, + 5_671_960_597_112_134_656, + 6_313_869_711_009_142_784, + 7_028_425_188_266_614_784, + 7_823_848_588_596_424_704, + 8_709_291_924_949_524_480, + 9_694_942_965_096_232_960, + 10_792_142_450_433_898_496, + 12_013_514_580_722_579_456, + 13_373_112_266_084_982_784, + 14_886_578_817_516_689_408, + 16_571_327_936_291_497_984, + 18_446_744_073_709_551_615, +]; From 6f642b46d7a01c48064c6027f5be10e667049bb2 Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Thu, 14 Oct 2021 02:20:19 -0700 Subject: [PATCH 3/7] Remove trailing semicolon --- runtime/polkadot/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/polkadot/src/lib.rs b/runtime/polkadot/src/lib.rs index 0a6322c573c9..13b7bbc6c72a 100644 --- a/runtime/polkadot/src/lib.rs +++ b/runtime/polkadot/src/lib.rs @@ -509,7 +509,7 @@ impl pallet_staking::Config for Runtime { type ElectionProvider = ElectionProviderMultiPhase; type GenesisElectionProvider = runtime_common::elections::GenesisElectionOf; // Use the nominators map to iter voters, but also keep bags-list up-to-date. - type SortedListProvider = runtime_common::elections::UseNominatorsAndUpdateBagsList;; + type SortedListProvider = runtime_common::elections::UseNominatorsAndUpdateBagsList; type WeightInfo = weights::pallet_staking::WeightInfo; } From 7d6c7b93f271278abec53eca3b77e5a967c40a81 Mon Sep 17 00:00:00 2001 From: kianenigma Date: Thu, 14 Oct 2021 12:34:42 +0200 Subject: [PATCH 4/7] more fixes --- runtime/kusama/src/lib.rs | 3 +- runtime/polkadot/src/lib.rs | 6 +- runtime/polkadot/src/weights/mod.rs | 1 + .../polkadot/src/weights/pallet_bags_list.rs | 65 +++++++++++++++++++ runtime/westend/src/lib.rs | 3 +- utils/remote-ext-tests/bags-list/src/main.rs | 14 +++- .../bags-list/src/voter_bags.rs | 11 +++- 7 files changed, 96 insertions(+), 7 deletions(-) create mode 100644 runtime/polkadot/src/weights/pallet_bags_list.rs diff --git a/runtime/kusama/src/lib.rs b/runtime/kusama/src/lib.rs index a80f93c525de..ab8a552f2c3b 100644 --- a/runtime/kusama/src/lib.rs +++ b/runtime/kusama/src/lib.rs @@ -1081,7 +1081,8 @@ impl InstanceFilter for ProxyType { Call::Registrar(paras_registrar::Call::reserve {..}) | Call::Crowdloan(..) | Call::Slots(..) | - Call::Auctions(..) // Specifically omitting the entire XCM Pallet + Call::Auctions(..) | // Specifically omitting the entire XCM Pallet + Call::BagsList(..) ), ProxyType::Governance => matches!( c, diff --git a/runtime/polkadot/src/lib.rs b/runtime/polkadot/src/lib.rs index 0a6322c573c9..818c052a709f 100644 --- a/runtime/polkadot/src/lib.rs +++ b/runtime/polkadot/src/lib.rs @@ -169,6 +169,7 @@ impl Contains for BaseFilter { Call::Dmp(_) | Call::Ump(_) | Call::Hrmp(_) | + Call::BagsList(_) | Call::Slots(_) => true, // Disable paras registration, crowdloans, and auctions for now. Call::Registrar(_) | Call::Auctions(_) | Call::Crowdloan(_) => false, @@ -509,7 +510,7 @@ impl pallet_staking::Config for Runtime { type ElectionProvider = ElectionProviderMultiPhase; type GenesisElectionProvider = runtime_common::elections::GenesisElectionOf; // Use the nominators map to iter voters, but also keep bags-list up-to-date. - type SortedListProvider = runtime_common::elections::UseNominatorsAndUpdateBagsList;; + type SortedListProvider = runtime_common::elections::UseNominatorsAndUpdateBagsList; type WeightInfo = weights::pallet_staking::WeightInfo; } @@ -1059,7 +1060,8 @@ impl InstanceFilter for ProxyType { Call::Registrar(paras_registrar::Call::reserve {..}) | Call::Crowdloan(..) | Call::Slots(..) | - Call::Auctions(..) // Specifically omitting the entire XCM Pallet + Call::Auctions(..) | // Specifically omitting the entire XCM Pallet + Call::BagsList(..) ), ProxyType::Governance => matches!( c, diff --git a/runtime/polkadot/src/weights/mod.rs b/runtime/polkadot/src/weights/mod.rs index 19842799a533..c913094df553 100644 --- a/runtime/polkadot/src/weights/mod.rs +++ b/runtime/polkadot/src/weights/mod.rs @@ -16,6 +16,7 @@ //! A list of the different weight modules for our runtime. pub mod frame_system; +pub mod pallet_bags_list; pub mod pallet_balances; pub mod pallet_bounties; pub mod pallet_collective_council; diff --git a/runtime/polkadot/src/weights/pallet_bags_list.rs b/runtime/polkadot/src/weights/pallet_bags_list.rs new file mode 100644 index 000000000000..38285f4c2145 --- /dev/null +++ b/runtime/polkadot/src/weights/pallet_bags_list.rs @@ -0,0 +1,65 @@ +// Copyright 2017-2021 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 . +//! Autogenerated weights for `pallet_bags_list` +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2021-09-17, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("kusama-dev"), DB CACHE: 128 + +// Executed Command: +// target/release/polkadot +// benchmark +// --chain=kusama-dev +// --steps=50 +// --repeat=20 +// --pallet=pallet_bags_list +// --extrinsic=* +// --execution=wasm +// --wasm-execution=compiled +// --heap-pages=4096 +// --header=./file_header.txt +// --output=./runtime/kusama/src/weights/ + + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] + +use frame_support::{traits::Get, weights::Weight}; +use sp_std::marker::PhantomData; + +/// Weight functions for `pallet_bags_list`. +pub struct WeightInfo(PhantomData); +impl pallet_bags_list::WeightInfo for WeightInfo { + // Storage: Staking Bonded (r:1 w:0) + // Storage: Staking Ledger (r:1 w:0) + // Storage: BagsList ListNodes (r:4 w:4) + // Storage: BagsList ListBags (r:1 w:1) + fn rebag_non_terminal() -> Weight { + (65_491_000 as Weight) + .saturating_add(T::DbWeight::get().reads(7 as Weight)) + .saturating_add(T::DbWeight::get().writes(5 as Weight)) + } + // Storage: Staking Bonded (r:1 w:0) + // Storage: Staking Ledger (r:1 w:0) + // Storage: BagsList ListNodes (r:3 w:3) + // Storage: BagsList ListBags (r:2 w:2) + fn rebag_terminal() -> Weight { + (64_253_000 as Weight) + .saturating_add(T::DbWeight::get().reads(7 as Weight)) + .saturating_add(T::DbWeight::get().writes(5 as Weight)) + } +} diff --git a/runtime/westend/src/lib.rs b/runtime/westend/src/lib.rs index 963d60b463ff..8c9f1b2976dc 100644 --- a/runtime/westend/src/lib.rs +++ b/runtime/westend/src/lib.rs @@ -751,7 +751,8 @@ impl InstanceFilter for ProxyType { Call::Registrar(paras_registrar::Call::reserve{..}) | Call::Crowdloan(..) | Call::Slots(..) | - Call::Auctions(..) // Specifically omitting the entire XCM Pallet + Call::Auctions(..) | // Specifically omitting the entire XCM Pallet + Call::BagsList(..) ), ProxyType::Staking => { matches!(c, Call::Staking(..) | Call::Session(..) | Call::Utility(..)) diff --git a/utils/remote-ext-tests/bags-list/src/main.rs b/utils/remote-ext-tests/bags-list/src/main.rs index 410cb1e80511..c7ef5cc62791 100644 --- a/utils/remote-ext-tests/bags-list/src/main.rs +++ b/utils/remote-ext-tests/bags-list/src/main.rs @@ -23,6 +23,7 @@ mod voter_bags; #[derive(StructOpt)] enum Runtime { Kusama, + Polkadot, } impl std::str::FromStr for Runtime { @@ -30,6 +31,7 @@ impl std::str::FromStr for Runtime { fn from_str(s: &str) -> Result { match s.to_lowercase().as_str() { "kusama" => Ok(Runtime::Kusama), + "polkadot" => Ok(Runtime::Polkadot), _ => Err("wrong Runtime: can be 'polkadot' or 'kusama'."), } } @@ -37,9 +39,9 @@ impl std::str::FromStr for Runtime { #[derive(StructOpt)] struct Cli { - #[structopt(long, default_value = "wss://rpc.kusama.io")] + #[structopt(long, default_value = "wss://rpc.polkadot.io")] uri: String, - #[structopt(long, short, default_value = "kusama")] + #[structopt(long, short, default_value = "polkadot")] runtime: Runtime, } @@ -55,5 +57,13 @@ async fn main() { ) .await; }, + Runtime::Polkadot => { + use polkadot_runtime::{constants::currency::UNITS, Block, Runtime}; + voter_bags::test_voter_bags_migration::( + UNITS as u64, + options.uri.clone(), + ) + .await; + }, } } diff --git a/utils/remote-ext-tests/bags-list/src/voter_bags.rs b/utils/remote-ext-tests/bags-list/src/voter_bags.rs index 4b7d7d6ec88d..0ed91c14b059 100644 --- a/utils/remote-ext-tests/bags-list/src/voter_bags.rs +++ b/utils/remote-ext-tests/bags-list/src/voter_bags.rs @@ -54,6 +54,15 @@ pub(crate) async fn test_voter_bags_migration< // set the ss58 prefix so addresses printed below are human friendly. sp_core::crypto::set_default_ss58_version(Runtime::SS58Prefix::get().try_into().unwrap()); + // clear anything that may have existed before. + if ::SortedListProvider::count() != 0 { + log::warn!( + target: LOG_TARGET, + "some data already seem to exist in the bags-list pallet.." + ); + } + ::SortedListProvider::clear(None); + // get the nominator & validator count prior to migrating; these should be invariant. let pre_migrate_nominator_count = >::iter().count() as u32; log::info!(target: LOG_TARGET, "Nominator count: {}", pre_migrate_nominator_count); @@ -99,7 +108,7 @@ pub(crate) async fn test_voter_bags_migration< (*vote_weight_thresh).try_into().map_err(|_| "should not fail").unwrap(); if vote_weight_as_balance <= min_nominator_bond { for id in bag.std_iter().map(|node| node.std_id().clone()) { - log::trace!( + log::error!( target: LOG_TARGET, "{} Account found below min bond: {:?}.", pretty_thresh, From 1d27ea48ac96fad7c7efa7d7fcc9b5e5b5df22a8 Mon Sep 17 00:00:00 2001 From: Shawn Tabrizi Date: Mon, 25 Oct 2021 06:07:28 +0200 Subject: [PATCH 5/7] Update runtime/polkadot/src/lib.rs --- runtime/polkadot/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/polkadot/src/lib.rs b/runtime/polkadot/src/lib.rs index 818c052a709f..400a491f51f9 100644 --- a/runtime/polkadot/src/lib.rs +++ b/runtime/polkadot/src/lib.rs @@ -2030,7 +2030,7 @@ sp_api::impl_runtime_apis! { add_benchmark!(params, batches, runtime_parachains::initializer, Initializer); add_benchmark!(params, batches, runtime_parachains::paras, Paras); // Substrate - list_benchmark!(list, extra, pallet_bags_list, BagsList); + add_benchmark!(params, batches, pallet_bags_list, BagsList); add_benchmark!(params, batches, pallet_balances, Balances); add_benchmark!(params, batches, pallet_bounties, Bounties); add_benchmark!(params, batches, pallet_collective, Council); From 09b754b95517d60ecc6602a9df29863dcaf35b98 Mon Sep 17 00:00:00 2001 From: kianenigma Date: Mon, 25 Oct 2021 11:18:19 +0200 Subject: [PATCH 6/7] add features --- runtime/polkadot/Cargo.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/runtime/polkadot/Cargo.toml b/runtime/polkadot/Cargo.toml index f4f4293fb471..b6b78e277441 100644 --- a/runtime/polkadot/Cargo.toml +++ b/runtime/polkadot/Cargo.toml @@ -166,6 +166,7 @@ runtime-benchmarks = [ "frame-system/runtime-benchmarks", "sp-runtime/runtime-benchmarks", "pallet-babe/runtime-benchmarks", + "pallet-bags-list/runtime-benchmarks", "pallet-balances/runtime-benchmarks", "pallet-collective/runtime-benchmarks", "pallet-democracy/runtime-benchmarks", From 12692ca63fec6d536a803a70d07fafd1830f49c3 Mon Sep 17 00:00:00 2001 From: kianenigma Date: Mon, 25 Oct 2021 11:42:05 +0200 Subject: [PATCH 7/7] remove par --- runtime/polkadot/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/polkadot/src/lib.rs b/runtime/polkadot/src/lib.rs index 182972ce6569..d2f10b374b24 100644 --- a/runtime/polkadot/src/lib.rs +++ b/runtime/polkadot/src/lib.rs @@ -1369,7 +1369,7 @@ pub type Executive = frame_executive::Executive< frame_system::ChainContext, Runtime, AllPallets, - (StakingBagsListMigrationV8), + StakingBagsListMigrationV8, >; /// The payload being signed in transactions. pub type SignedPayload = generic::SignedPayload;