Unverified Commit 028d4b65 authored by Kian Paimani's avatar Kian Paimani Committed by GitHub
Browse files

Cost analysis of a council election full block (#2782)

parent f00588a4
Pipeline #133962 failed with stages
in 19 minutes and 35 seconds
......@@ -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| {
<Runtime as pallet_elections_phragmen::Config>::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;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment