diff --git a/polkadot/runtime/polkadot/src/lib.rs b/polkadot/runtime/polkadot/src/lib.rs index 6efc15b092..f32fba2a0d 100644 --- a/polkadot/runtime/polkadot/src/lib.rs +++ b/polkadot/runtime/polkadot/src/lib.rs @@ -1549,6 +1549,39 @@ mod test_fees { test_with_multiplier(Multiplier::saturating_from_rational(1, 1_000_000_000u128)); } + #[test] + fn full_block_council_election_cost() { + // the number of voters needed to consume almost a full block in council election, and how + // much it is going to cost. + use pallet_elections_phragmen::WeightInfo; + + // Loser candidate lose a lot of money; sybil attack by candidates is even more expensive, + // and we don't care about it here. For now, we assume no extra candidates, and only + // superfluous voters. + let candidates = DesiredMembers::get() + DesiredRunnersUp::get(); + let mut voters = 1u32; + let weight_with = |v| { + ::WeightInfo::election_phragmen( + candidates, + v, + v * 16, + ) + }; + + while weight_with(voters) <= BlockWeights::get().max_block { + voters += 1; + } + + let cost = voters as Balance * (VotingBondBase::get() + 16 * VotingBondFactor::get()); + let cost_dollars = cost / DOLLARS; + println!( + "can support {} voters in a single block for council elections; total bond {}", + voters, + cost_dollars, + ); + assert!(cost_dollars > 150_000); // DOLLAR ~ new DOT ~ 10e10 + } + #[test] fn nominator_limit() { use pallet_election_provider_multi_phase::WeightInfo;