This repository has been archived by the owner on Nov 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Companion for Decouple Staking and Election - Part 3: Signed Phase (#…
…2793) * Companion for Decouple Staking and Election - Part 3: Signed Phase paritytech/substrate#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 <>
- Loading branch information
1 parent
2b855f3
commit d5fb327
Showing
10 changed files
with
349 additions
and
187 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
// Copyright 2021 Parity Technologies (UK) Ltd. | ||
// This file is part of Polkadot. | ||
|
||
// Polkadot is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
|
||
// Polkadot is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
|
||
// You should have received a copy of the GNU General Public License | ||
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
//! Code for elections. | ||
use frame_support::{ | ||
parameter_types, | ||
traits::Get, | ||
weights::{DispatchClass, Weight, WeightToFeePolynomial}, | ||
}; | ||
use sp_runtime::Perbill; | ||
use super::{BlockExecutionWeight, BlockLength, BlockWeights}; | ||
|
||
parameter_types! { | ||
/// A limit for off-chain phragmen unsigned solution submission. | ||
/// | ||
/// We want to keep it as high as possible, but can't risk having it reject, | ||
/// so we always subtract the base block execution weight. | ||
pub OffchainSolutionWeightLimit: Weight = BlockWeights::get() | ||
.get(DispatchClass::Normal) | ||
.max_extrinsic | ||
.expect("Normal extrinsics have weight limit configured by default; qed") | ||
.saturating_sub(BlockExecutionWeight::get()); | ||
|
||
/// A limit for off-chain phragmen unsigned solution length. | ||
/// | ||
/// We allow up to 90% of the block's size to be consumed by the solution. | ||
pub OffchainSolutionLengthLimit: u32 = Perbill::from_rational(90_u32, 100) * | ||
*BlockLength::get() | ||
.max | ||
.get(DispatchClass::Normal); | ||
} | ||
|
||
/// Compute the expected fee for submitting an election solution. | ||
/// | ||
/// This is `multiplier` multiplied by the fee for the expected submission weight according to the | ||
/// weight info. | ||
/// | ||
/// Assumes that the signed submission queue is full. | ||
pub fn fee_for_submit_call<T, WeightToFee, WeightInfo>(multiplier: Perbill) -> WeightToFee::Balance | ||
where | ||
T: pallet_election_provider_multi_phase::Config, | ||
WeightToFee: WeightToFeePolynomial, | ||
WeightInfo: pallet_election_provider_multi_phase::WeightInfo, | ||
{ | ||
let expected_weight = WeightInfo::submit(T::SignedMaxSubmissions::get()); | ||
multiplier * WeightToFee::calc(&expected_weight) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters