mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 23:21:02 +00:00
Add Auctions and Crowdloans to Kusama and Westend (#2999)
* add to westend * fixes * fix runtime tests * add to kusama * cargo run --release --features=runtime-benchmarks -- benchmark --chain=westend-dev --steps=50 --repeat=20 --pallet=runtime_common::auctions --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --header=./file_header.txt --output=./runtime/westend/src/weights/runtime_common_auctions.rs * cargo run --release --features=runtime-benchmarks -- benchmark --chain=westend-dev --steps=50 --repeat=20 --pallet=runtime_common::crowdloan --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --header=./file_header.txt --output=./runtime/westend/src/weights/runtime_common_crowdloan.rs * fix auctions benchmarks * add benchmark to kusama * update weights * cargo run --release --features=runtime-benchmarks -- benchmark --chain=kusama-dev --steps=50 --repeat=20 --pallet=runtime_common::crowdloan --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --header=./file_header.txt --output=./runtime/kusama/src/weights/runtime_common_crowdloan.rs * cargo run --release --features=runtime-benchmarks -- benchmark --chain=kusama-dev --steps=50 --repeat=20 --pallet=runtime_common::auctions --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --header=./file_header.txt --output=./runtime/kusama/src/weights/runtime_common_auctions.rs * update to use weights * cargo run --release --features=runtime-benchmarks -- benchmark --chain=westend-dev --steps=50 --repeat=20 --pallet=runtime_common::auctions --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --header=./file_header.txt --output=./runtime/westend/src/weights/runtime_common_auctions.rs * Initiate auctions with 2/3 council * add check and docs * update crowdloan deposits * move tests * move other tests * update ending period * cargo run --release --features=runtime-benchmarks -- benchmark --chain=westend-dev --steps=50 --repeat=20 --pallet=runtime_common::auctions --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --header=./file_header.txt --output=./runtime/westend/src/weights/runtime_common_auctions.rs * fix origin * cargo run --release --features=runtime-benchmarks -- benchmark --chain=kusama-dev --steps=50 --repeat=20 --pallet=runtime_common::auctions --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --header=./file_header.txt --output=./runtime/kusama/src/weights/runtime_common_auctions.rs Co-authored-by: Parity Bot <admin@parity.io> Co-authored-by: Gavin Wood <gavin@parity.io>
This commit is contained in:
@@ -17,6 +17,120 @@
|
||||
//! Tests for the Kusama Runtime Configuration
|
||||
|
||||
use crate::*;
|
||||
use frame_support::weights::WeightToFeePolynomial;
|
||||
use frame_support::storage::StorageValue;
|
||||
use sp_runtime::FixedPointNumber;
|
||||
use frame_support::weights::GetDispatchInfo;
|
||||
use parity_scale_codec::Encode;
|
||||
use pallet_transaction_payment::Multiplier;
|
||||
use separator::Separatable;
|
||||
|
||||
#[test]
|
||||
fn remove_keys_weight_is_sensible() {
|
||||
use runtime_common::crowdloan::WeightInfo;
|
||||
let max_weight = <Runtime as crowdloan::Config>::WeightInfo::refund(RemoveKeysLimit::get());
|
||||
// Max remove keys limit should be no more than half the total block weight.
|
||||
assert!(max_weight * 2 < BlockWeights::get().max_block);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn sample_size_is_sensible() {
|
||||
use runtime_common::auctions::WeightInfo;
|
||||
// Need to clean up all samples at the end of an auction.
|
||||
let samples: BlockNumber = EndingPeriod::get() / SampleLength::get();
|
||||
let max_weight: Weight = RocksDbWeight::get().reads_writes(samples.into(), samples.into());
|
||||
// Max sample cleanup should be no more than half the total block weight.
|
||||
assert!(max_weight * 2 < BlockWeights::get().max_block);
|
||||
assert!(<Runtime as auctions::Config>::WeightInfo::on_initialize() * 2 < BlockWeights::get().max_block);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn payout_weight_portion() {
|
||||
use pallet_staking::WeightInfo;
|
||||
let payout_weight =
|
||||
<Runtime as pallet_staking::Config>::WeightInfo::payout_stakers_alive_staked(
|
||||
MaxNominatorRewardedPerValidator::get(),
|
||||
) as f64;
|
||||
let block_weight = BlockWeights::get().max_block as f64;
|
||||
|
||||
println!(
|
||||
"a full payout takes {:.2} of the block weight [{} / {}]",
|
||||
payout_weight / block_weight,
|
||||
payout_weight,
|
||||
block_weight
|
||||
);
|
||||
assert!(payout_weight * 2f64 < block_weight);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore]
|
||||
fn block_cost() {
|
||||
let max_block_weight = BlockWeights::get().max_block;
|
||||
let raw_fee = WeightToFee::calc(&max_block_weight);
|
||||
|
||||
println!(
|
||||
"Full Block weight == {} // WeightToFee(full_block) == {} plank",
|
||||
max_block_weight,
|
||||
raw_fee.separated_string(),
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore]
|
||||
fn transfer_cost_min_multiplier() {
|
||||
let min_multiplier = runtime_common::MinimumMultiplier::get();
|
||||
let call = <pallet_balances::Call<Runtime>>::transfer_keep_alive(Default::default(), Default::default());
|
||||
let info = call.get_dispatch_info();
|
||||
// convert to outer call.
|
||||
let call = Call::Balances(call);
|
||||
let len = call.using_encoded(|e| e.len()) as u32;
|
||||
|
||||
let mut ext = sp_io::TestExternalities::new_empty();
|
||||
let mut test_with_multiplier = |m| {
|
||||
ext.execute_with(|| {
|
||||
pallet_transaction_payment::NextFeeMultiplier::put(m);
|
||||
let fee = TransactionPayment::compute_fee(len, &info, 0);
|
||||
println!(
|
||||
"weight = {:?} // multiplier = {:?} // full transfer fee = {:?}",
|
||||
info.weight.separated_string(),
|
||||
pallet_transaction_payment::NextFeeMultiplier::get(),
|
||||
fee.separated_string(),
|
||||
);
|
||||
});
|
||||
};
|
||||
|
||||
test_with_multiplier(min_multiplier);
|
||||
test_with_multiplier(Multiplier::saturating_from_rational(1, 1u128));
|
||||
test_with_multiplier(Multiplier::saturating_from_rational(1, 1_000u128));
|
||||
test_with_multiplier(Multiplier::saturating_from_rational(1, 1_000_000u128));
|
||||
test_with_multiplier(Multiplier::saturating_from_rational(1, 1_000_000_000u128));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn nominator_limit() {
|
||||
use pallet_election_provider_multi_phase::WeightInfo;
|
||||
// starting point of the nominators.
|
||||
let all_voters: u32 = 10_000;
|
||||
|
||||
// assuming we want around 5k candidates and 1k active validators.
|
||||
let all_targets: u32 = 5_000;
|
||||
let desired: u32 = 1_000;
|
||||
let weight_with = |active| {
|
||||
<Runtime as pallet_election_provider_multi_phase::Config>::WeightInfo::submit_unsigned(
|
||||
all_voters.max(active),
|
||||
all_targets,
|
||||
active,
|
||||
desired,
|
||||
)
|
||||
};
|
||||
|
||||
let mut active = 1;
|
||||
while weight_with(active) <= OffchainSolutionWeightLimit::get() || active == all_voters {
|
||||
active += 1;
|
||||
}
|
||||
|
||||
println!("can support {} nominators to yield a weight of {}", active, weight_with(active));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn compute_inflation_should_give_sensible_results() {
|
||||
|
||||
Reference in New Issue
Block a user