Unverified Commit 5dac5323 authored by Zeke Mostov's avatar Zeke Mostov Committed by GitHub
Browse files

Reduce staking miner reward (companion `substrate/pull/9395`) (#3465)



* Reduce staking miner reward

* Add EOF

* Fix stuff

* remove import

* Add tyoe

* remove redundant stuff

* update Substrate
Co-authored-by: default avatarkianenigma <kian@parity.io>
Co-authored-by: parity-processbot <>
parent 71b2a4e3
Pipeline #148936 passed with stages
in 41 minutes and 27 seconds
This diff is collapsed.
......@@ -20,12 +20,7 @@ use frame_support::{
parameter_types,
weights::{DispatchClass, Weight},
};
use sp_runtime::{
traits::{Zero, Dispatchable},
FixedU128, FixedPointNumber, Perbill,
};
use pallet_transaction_payment::OnChargeTransaction;
use frame_support::weights::{DispatchInfo, Pays};
use sp_runtime::Perbill;
use super::{BlockExecutionWeight, BlockLength, BlockWeights};
parameter_types! {
......@@ -48,25 +43,6 @@ parameter_types! {
.get(DispatchClass::Normal);
}
pub fn fee_for_submit_call<T>(
multiplier: FixedU128,
weight: Weight,
length: u32,
) -> primitives::v1::Balance
where
T: pallet_transaction_payment::Config,
<T as pallet_transaction_payment::Config>::OnChargeTransaction:
OnChargeTransaction<T, Balance = primitives::v1::Balance>,
<T as frame_system::Config>::Call: Dispatchable<Info = DispatchInfo>,
{
let info = DispatchInfo { weight, class: DispatchClass::Normal, pays_fee: Pays::Yes };
multiplier.saturating_mul_int(pallet_transaction_payment::Pallet::<T>::compute_fee(
length,
&info,
Zero::zero(),
))
}
/// The numbers configured here should always be more than the the maximum limits of staking pallet
/// to ensure election snapshot will not run out of memory.
pub struct BenchmarkConfig;
......
......@@ -35,7 +35,7 @@ use runtime_common::{
claims, paras_registrar, xcm_sender, slots, auctions, crowdloan,
SlowAdjustingFeeUpdate, CurrencyToVote, impls::DealWithFees,
BlockHashCount, RocksDbWeight, BlockWeights, BlockLength,
OffchainSolutionWeightLimit, OffchainSolutionLengthLimit, elections::fee_for_submit_call,
OffchainSolutionWeightLimit, OffchainSolutionLengthLimit,
ToAuthor,
};
......@@ -66,7 +66,7 @@ use xcm_executor::XcmExecutor;
use sp_arithmetic::Perquintill;
use sp_runtime::{
create_runtime_str, generic, impl_opaque_keys, ApplyExtrinsicResult, KeyTypeId, Percent,
Permill, Perbill, FixedPointNumber,
Permill, Perbill,
transaction_validity::{TransactionValidity, TransactionSource, TransactionPriority},
traits::{
BlakeTwo256, Block as BlockT, OpaqueKeys, ConvertInto, AccountIdLookup,
......@@ -347,7 +347,6 @@ impl pallet_session::historical::Config for Runtime {
type FullIdentificationOf = pallet_staking::ExposureOf<Runtime>;
}
use pallet_election_provider_multi_phase::WeightInfo;
parameter_types! {
// phase durations. 1/4 of the last session for each.
pub const SignedPhase: u32 = EPOCH_DURATION_IN_SLOTS / 4;
......@@ -360,15 +359,8 @@ parameter_types! {
// 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>(
// give 20% threshold.
sp_runtime::FixedU128::saturating_from_rational(12, 10),
// maximum weight possible.
weights::pallet_election_provider_multi_phase::WeightInfo::<Runtime>::submit(SignedMaxSubmissions::get()),
// assume a solution of 100kb length.
100 * 1024
);
// Each good submission will get 1/10 KSM as reward
pub SignedRewardBase: Balance = UNITS / 10;
// fallback: emergency phase.
pub const Fallback: pallet_election_provider_multi_phase::FallbackStrategy =
pallet_election_provider_multi_phase::FallbackStrategy::Nothing;
......@@ -391,6 +383,7 @@ sp_npos_elections::generate_solution_type!(
impl pallet_election_provider_multi_phase::Config for Runtime {
type Event = Event;
type Currency = Balances;
type EstimateCallFee = TransactionPayment;
type UnsignedPhase = UnsignedPhase;
type SignedMaxSubmissions = SignedMaxSubmissions;
type SignedRewardBase = SignedRewardBase;
......
......@@ -26,7 +26,6 @@ use runtime_common::{
impls::DealWithFees,
BlockHashCount, RocksDbWeight, BlockWeights, BlockLength,
OffchainSolutionWeightLimit, OffchainSolutionLengthLimit,
elections::fee_for_submit_call,
ParachainSessionKeyPlaceholder, AssignmentSessionKeyPlaceholder,
};
......@@ -41,7 +40,7 @@ use primitives::v1::{
ValidatorIndex, InboundDownwardMessage, InboundHrmpMessage, SessionInfo,
};
use sp_runtime::{
create_runtime_str, generic, impl_opaque_keys, ApplyExtrinsicResult, FixedPointNumber,
create_runtime_str, generic, impl_opaque_keys, ApplyExtrinsicResult,
KeyTypeId, Percent, Permill, Perbill, curve::PiecewiseLinear,
transaction_validity::{TransactionValidity, TransactionSource, TransactionPriority},
traits::{
......@@ -327,7 +326,6 @@ impl pallet_session::historical::Config for Runtime {
type FullIdentificationOf = pallet_staking::ExposureOf<Runtime>;
}
use pallet_election_provider_multi_phase::WeightInfo;
parameter_types! {
// phase durations. 1/4 of the last session for each.
pub const SignedPhase: u32 = EPOCH_DURATION_IN_SLOTS / 4;
......@@ -340,15 +338,8 @@ parameter_types! {
// 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>(
// give 20% threshold.
sp_runtime::FixedU128::saturating_from_rational(12, 10),
// maximum weight possible.
weights::pallet_election_provider_multi_phase::WeightInfo::<Runtime>::submit(SignedMaxSubmissions::get()),
// assume a solution of 200kb length.
200 * 1024
);
// Each good submission will get 1 DOT as reward
pub SignedRewardBase: Balance = 1 * UNITS;
// fallback: emergency phase.
pub const Fallback: pallet_election_provider_multi_phase::FallbackStrategy =
pallet_election_provider_multi_phase::FallbackStrategy::Nothing;
......@@ -371,6 +362,7 @@ sp_npos_elections::generate_solution_type!(
impl pallet_election_provider_multi_phase::Config for Runtime {
type Event = Event;
type Currency = Balances;
type EstimateCallFee = TransactionPayment;
type SignedPhase = SignedPhase;
type UnsignedPhase = UnsignedPhase;
type SignedMaxSubmissions = SignedMaxSubmissions;
......
......@@ -36,7 +36,6 @@ use runtime_common::{
impls::ToAuthor,
BlockHashCount, BlockWeights, BlockLength, RocksDbWeight,
OffchainSolutionWeightLimit, OffchainSolutionLengthLimit,
elections::fee_for_submit_call,
};
use runtime_parachains::origin as parachains_origin;
......@@ -65,7 +64,7 @@ use xcm_builder::{
};
use sp_runtime::{
create_runtime_str, generic, impl_opaque_keys, FixedPointNumber,
create_runtime_str, generic, impl_opaque_keys,
ApplyExtrinsicResult, KeyTypeId, Perbill, curve::PiecewiseLinear,
transaction_validity::{TransactionValidity, TransactionSource, TransactionPriority},
traits::{
......@@ -332,7 +331,6 @@ impl pallet_session::historical::Config for Runtime {
type FullIdentificationOf = pallet_staking::ExposureOf<Runtime>;
}
use pallet_election_provider_multi_phase::WeightInfo;
parameter_types! {
// phase durations. 1/4 of the last session for each.
pub const SignedPhase: u32 = EPOCH_DURATION_IN_SLOTS / 4;
......@@ -345,15 +343,8 @@ parameter_types! {
// 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>(
// give 20% threshold.
sp_runtime::FixedU128::saturating_from_rational(12, 10),
// maximum weight possible.
weights::pallet_election_provider_multi_phase::WeightInfo::<Runtime>::submit(SignedMaxSubmissions::get()),
// assume a solution of 100kb length.
100 * 1024
);
// Each good submission will get 1 WND as reward
pub SignedRewardBase: Balance = 1 * UNITS;
// fallback: emergency phase.
pub const Fallback: pallet_election_provider_multi_phase::FallbackStrategy =
pallet_election_provider_multi_phase::FallbackStrategy::Nothing;
......@@ -377,6 +368,7 @@ sp_npos_elections::generate_solution_type!(
impl pallet_election_provider_multi_phase::Config for Runtime {
type Event = Event;
type Currency = Balances;
type EstimateCallFee = TransactionPayment;
type SignedPhase = SignedPhase;
type UnsignedPhase = UnsignedPhase;
type SignedMaxSubmissions = SignedMaxSubmissions;
......
......@@ -36,3 +36,4 @@ fn sample_size_is_sensible() {
assert!(max_weight * 2 < BlockWeights::get().max_block);
assert!(<Runtime as auctions::Config>::WeightInfo::on_initialize() * 2 < BlockWeights::get().max_block);
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment