mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-29 03:17:56 +00:00
Cost analysis of a council election full block (#2782)
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user