mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 05:51:02 +00:00
Companion for Decouple Staking and Election - Part 3: Signed Phase (#2793)
* Companion for Decouple Staking and Election - Part 3: Signed Phase https://github.com/paritytech/substrate/pull/7910 * remove some config types * allow up to 5 signed submissions on polkadot and kusama * signed phase is equal induration to unsigned phase * use chain defaults for base and per-byte deposits; >= 16 SignedMaxSubmissions * use a small but non-trivial solution reward * reduce signed deposit per byte fee * reduce signed reward, adjust polkadot expected soln size * copy submit benchmark from substrate * demo calculating an appropriate fee for the signed reward Unfortunately, this doesn't work: it needs to be a constant function, and AFAIK there's no way to make a trait method constant. * SignedRewardBase is 1.5x the fee to submit a signed solution * all chains use deposit byte of base per 50k * update Substrate * cargo update -p pallet-election-provider-multi-phase Co-authored-by: parity-processbot <>
This commit is contained in:
committed by
GitHub
parent
e8d7e9f0dc
commit
95736d1bf1
@@ -36,6 +36,7 @@ use runtime_common::{
|
||||
impls::ToAuthor,
|
||||
BlockHashCount, BlockWeights, BlockLength, RocksDbWeight,
|
||||
OffchainSolutionWeightLimit, OffchainSolutionLengthLimit,
|
||||
elections::fee_for_submit_call,
|
||||
};
|
||||
|
||||
use runtime_parachains::origin as parachains_origin;
|
||||
@@ -333,11 +334,24 @@ impl pallet_session::historical::Config for Runtime {
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
// no signed phase for now, just unsigned.
|
||||
pub const SignedPhase: u32 = 0;
|
||||
// phase durations. 1/4 of the last session for each.
|
||||
pub const SignedPhase: u32 = EPOCH_DURATION_IN_SLOTS / 4;
|
||||
pub const UnsignedPhase: u32 = EPOCH_DURATION_IN_SLOTS / 4;
|
||||
|
||||
// fallback: run election on-chain.
|
||||
// signed config
|
||||
pub const SignedMaxSubmissions: u32 = 128;
|
||||
pub const SignedDepositBase: Balance = deposit(1, 0);
|
||||
// A typical solution occupies within an order of magnitude of 50kb.
|
||||
// This formula is currently adjusted such that a typical solution will spend an amount equal
|
||||
// to the base deposit for every 50 kb.
|
||||
pub const SignedDepositByte: Balance = deposit(1, 0) / (50 * 1024);
|
||||
pub SignedRewardBase: Balance = fee_for_submit_call::<
|
||||
Runtime,
|
||||
crate::constants::fee::WeightToFee,
|
||||
crate::weights::pallet_election_provider_multi_phase::WeightInfo<Runtime>,
|
||||
>(Perbill::from_perthousand(1500));
|
||||
|
||||
// fallback: emergency phase.
|
||||
pub const Fallback: pallet_election_provider_multi_phase::FallbackStrategy =
|
||||
pallet_election_provider_multi_phase::FallbackStrategy::Nothing;
|
||||
|
||||
@@ -362,6 +376,14 @@ impl pallet_election_provider_multi_phase::Config for Runtime {
|
||||
type Currency = Balances;
|
||||
type SignedPhase = SignedPhase;
|
||||
type UnsignedPhase = UnsignedPhase;
|
||||
type SignedMaxSubmissions = SignedMaxSubmissions;
|
||||
type SignedRewardBase = SignedRewardBase;
|
||||
type SignedDepositBase = SignedDepositBase;
|
||||
type SignedDepositByte = SignedDepositByte;
|
||||
type SignedDepositWeight = ();
|
||||
type SignedMaxWeight = Self::MinerMaxWeight;
|
||||
type SlashHandler = (); // burn slashes
|
||||
type RewardHandler = (); // nothing to do upon rewards
|
||||
type SolutionImprovementThreshold = SolutionImprovementThreshold;
|
||||
type MinerMaxIterations = MinerMaxIterations;
|
||||
type MinerMaxWeight = OffchainSolutionWeightLimit; // For now use the one from staking.
|
||||
|
||||
@@ -92,4 +92,21 @@ impl<T: frame_system::Config> pallet_election_provider_multi_phase::WeightInfo f
|
||||
.saturating_add((3_731_000 as Weight).saturating_mul(d as Weight))
|
||||
.saturating_add(T::DbWeight::get().reads(4 as Weight))
|
||||
}
|
||||
fn finalize_signed_phase_accept_solution() -> Weight {
|
||||
(47_783_000 as Weight)
|
||||
.saturating_add(T::DbWeight::get().reads(1 as Weight))
|
||||
.saturating_add(T::DbWeight::get().writes(2 as Weight))
|
||||
}
|
||||
fn finalize_signed_phase_reject_solution() -> Weight {
|
||||
(21_277_000 as Weight)
|
||||
.saturating_add(T::DbWeight::get().reads(1 as Weight))
|
||||
.saturating_add(T::DbWeight::get().writes(1 as Weight))
|
||||
}
|
||||
fn submit(c: u32) -> Weight {
|
||||
(78_972_000 as Weight)
|
||||
// Standard Error: 16_000
|
||||
.saturating_add((308_000 as Weight).saturating_mul(c as Weight))
|
||||
.saturating_add(T::DbWeight::get().reads(4 as Weight))
|
||||
.saturating_add(T::DbWeight::get().writes(3 as Weight))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user