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
Companion for Decouple Staking and Election - Part 3: Signed Phase #2793
Merged
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
36502dc
Companion for Decouple Staking and Election - Part 3: Signed Phase
coriolinus 1e509e9
Merge remote-tracking branch 'origin/master' into prgn-companion-for-…
coriolinus 9638fcf
Merge remote-tracking branch 'origin/master' into prgn-companion-for-…
coriolinus 0fc8c64
remove some config types
coriolinus a7ded3d
Merge remote-tracking branch 'origin/master' into prgn-companion-for-…
coriolinus 5a972b2
Merge remote-tracking branch 'origin/master' into prgn-companion-for-…
coriolinus 3c51221
allow up to 5 signed submissions on polkadot and kusama
coriolinus 9538b7e
signed phase is equal induration to unsigned phase
coriolinus 3da0659
use chain defaults for base and per-byte deposits; >= 16 SignedMaxSub…
coriolinus 0f380ae
use a small but non-trivial solution reward
coriolinus fd9e8c6
reduce signed deposit per byte fee
coriolinus a0372e3
reduce signed reward, adjust polkadot expected soln size
coriolinus e1f3a06
copy submit benchmark from substrate
coriolinus b19f7e1
demo calculating an appropriate fee for the signed reward
coriolinus ff228bc
SignedRewardBase is 1.5x the fee to submit a signed solution
coriolinus f97eca3
Merge remote-tracking branch 'origin/master' into prgn-companion-for-…
coriolinus f5b6dd5
all chains use deposit byte of base per 50k
coriolinus 99a16f3
Merge remote-tracking branch 'origin/master' into prgn-companion-for-…
7084efc
update Substrate
8cf97b6
cargo update -p pallet-election-provider-multi-phase
coriolinus File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,7 +34,8 @@ use primitives::v1::{ | |
use runtime_common::{ | ||
claims, paras_registrar, xcm_sender, slots, auctions, crowdloan, | ||
SlowAdjustingFeeUpdate, CurrencyToVote, impls::DealWithFees, | ||
BlockHashCount, RocksDbWeight, BlockWeights, BlockLength, OffchainSolutionWeightLimit, OffchainSolutionLengthLimit, | ||
BlockHashCount, RocksDbWeight, BlockWeights, BlockLength, | ||
OffchainSolutionWeightLimit, OffchainSolutionLengthLimit, elections::fee_for_submit_call, | ||
ToAuthor, | ||
}; | ||
|
||
|
@@ -348,11 +349,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 = 16; | ||
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; | ||
pub SolutionImprovementThreshold: Perbill = Perbill::from_rational(5u32, 10_000); | ||
|
@@ -375,6 +389,14 @@ impl pallet_election_provider_multi_phase::Config for Runtime { | |
type Event = Event; | ||
type Currency = Balances; | ||
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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same, could use more thought. My initial values here are all placeholders. |
||
type RewardHandler = (); // nothing to do upon rewards | ||
type SignedPhase = SignedPhase; | ||
type SolutionImprovementThreshold = SolutionImprovementThreshold; | ||
type MinerMaxIterations = MinerMaxIterations; | ||
|
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this might lead to negative turnout to run the bot, since your discounting the length fee (which in this case is probably more dominant than the weight fee)(I also forgot about length fee earlier).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
might still help, but not a blocker since this is too conservattive and thus safe.