From 07e9101984caa559b64b1fcdce5e5bfe00386c2b Mon Sep 17 00:00:00 2001 From: Peter Goodspeed-Niklaus Date: Wed, 23 Jun 2021 17:18:01 +0200 Subject: [PATCH] Revert "demo calculating an appropriate fee for the signed reward" This reverts commit b19f7e1dcaae9a042615c2698d569b9809571704. --- Cargo.lock | 1 - runtime/common/Cargo.toml | 3 +- runtime/common/src/elections.rs | 61 --------------------------------- runtime/common/src/lib.rs | 24 +++++++++++-- runtime/westend/src/lib.rs | 7 +--- 5 files changed, 23 insertions(+), 73 deletions(-) delete mode 100644 runtime/common/src/elections.rs diff --git a/Cargo.lock b/Cargo.lock index b8a112d952e5..eeaac3b736a4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6599,7 +6599,6 @@ dependencies = [ "pallet-babe", "pallet-balances", "pallet-beefy", - "pallet-election-provider-multi-phase", "pallet-mmr", "pallet-offences", "pallet-session", diff --git a/runtime/common/Cargo.toml b/runtime/common/Cargo.toml index c892871a798d..27a8b93f4898 100644 --- a/runtime/common/Cargo.toml +++ b/runtime/common/Cargo.toml @@ -35,7 +35,7 @@ pallet-vesting = { git = "https://github.com/paritytech/substrate", branch = "ma pallet-offences = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } pallet-transaction-payment = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } pallet-treasury = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } -pallet-election-provider-multi-phase = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } + pallet-beefy = { git = "https://github.com/paritytech/grandpa-bridge-gadget", branch = "master", default-features = false } pallet-mmr = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } @@ -91,7 +91,6 @@ std = [ "pallet-vesting/std", "pallet-transaction-payment/std", "pallet-treasury/std", - "pallet-election-provider-multi-phase/std", "slot-range-helper/std", "sp-runtime/std", "sp-session/std", diff --git a/runtime/common/src/elections.rs b/runtime/common/src/elections.rs deleted file mode 100644 index 35f73fc65d98..000000000000 --- a/runtime/common/src/elections.rs +++ /dev/null @@ -1,61 +0,0 @@ -// 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 . - -//! 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 `ratio` 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_weight(ratio: 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()); - ratio * WeightToFee::calc(&expected_weight) -} diff --git a/runtime/common/src/lib.rs b/runtime/common/src/lib.rs index e96034c2ccda..406b3fc17c56 100644 --- a/runtime/common/src/lib.rs +++ b/runtime/common/src/lib.rs @@ -1,4 +1,4 @@ -// Copyright 2019-2021 Parity Technologies (UK) Ltd. +// Copyright 2019-2020 Parity Technologies (UK) Ltd. // This file is part of Polkadot. // Polkadot is free software: you can redistribute it and/or modify @@ -30,7 +30,6 @@ pub mod paras_registrar; pub mod slot_range; pub mod traits; pub mod xcm_sender; -pub mod elections; #[cfg(test)] mod mock; @@ -55,7 +54,6 @@ pub use pallet_staking::StakerStatus; pub use sp_runtime::BuildStorage; pub use pallet_timestamp::Call as TimestampCall; pub use pallet_balances::Call as BalancesCall; -pub use elections::{OffchainSolutionLengthLimit, OffchainSolutionWeightLimit}; /// Implementations of some helper traits passed into runtime modules as associated types. pub use impls::ToAuthor; @@ -110,6 +108,26 @@ parameter_types! { .build_or_panic(); } +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); +} + /// Parameterized slow adjusting fee updated based on /// https://w3f-research.readthedocs.io/en/latest/polkadot/Token%20Economics.html#-2.-slow-adjusting-mechanism pub type SlowAdjustingFeeUpdate = TargetedFeeAdjustment< diff --git a/runtime/westend/src/lib.rs b/runtime/westend/src/lib.rs index 367313df9d04..100df4b3d417 100644 --- a/runtime/westend/src/lib.rs +++ b/runtime/westend/src/lib.rs @@ -36,7 +36,6 @@ use runtime_common::{ impls::ToAuthor, BlockHashCount, BlockWeights, BlockLength, RocksDbWeight, OffchainSolutionWeightLimit, OffchainSolutionLengthLimit, - elections::fee_for_weight, }; use runtime_parachains::origin as parachains_origin; @@ -344,11 +343,7 @@ parameter_types! { // A typical solution occupies 20kb. This formula is currently adjusted such that a typical // solution will spend approximately equal amounts on the base and per-byte deposits. pub const SignedDepositByte: Balance = deposit(1, 0) / (20 * 1024 * 1024); - pub const SignedRewardBase: Balance = fee_for_weight::< - Runtime, - crate::constants::fee::WeightToFee, - crate::weights::pallet_election_provider_multi_phase::WeightInfo, - >(Perbill::from_perthousand(3500)); + pub const SignedRewardBase: Balance = 1 * CENTS; // fallback: emergency phase. pub const Fallback: pallet_election_provider_multi_phase::FallbackStrategy =