mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-23 22:31:06 +00:00
Staking Miner (#3141)
Co-authored-by: Peter Goodspeed-Niklaus <coriolinus@users.noreply.github.com> Co-authored-by: Peter Goodspeed-Niklaus <peter.r.goodspeedniklaus@gmail.com>
This commit is contained in:
@@ -18,10 +18,14 @@
|
||||
|
||||
use frame_support::{
|
||||
parameter_types,
|
||||
traits::Get,
|
||||
weights::{DispatchClass, Weight, WeightToFeePolynomial},
|
||||
weights::{DispatchClass, Weight},
|
||||
};
|
||||
use sp_runtime::Perbill;
|
||||
use sp_runtime::{
|
||||
traits::{Zero, Dispatchable},
|
||||
FixedU128, FixedPointNumber, Perbill,
|
||||
};
|
||||
use pallet_transaction_payment::OnChargeTransaction;
|
||||
use frame_support::weights::{DispatchInfo, Pays};
|
||||
use super::{BlockExecutionWeight, BlockLength, BlockWeights};
|
||||
|
||||
parameter_types! {
|
||||
@@ -44,18 +48,21 @@ parameter_types! {
|
||||
.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
|
||||
pub fn fee_for_submit_call<T>(
|
||||
multiplier: FixedU128,
|
||||
weight: Weight,
|
||||
length: u32,
|
||||
) -> primitives::v1::Balance
|
||||
where
|
||||
T: pallet_election_provider_multi_phase::Config,
|
||||
WeightToFee: WeightToFeePolynomial,
|
||||
WeightInfo: pallet_election_provider_multi_phase::WeightInfo,
|
||||
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 expected_weight = WeightInfo::submit(T::SignedMaxSubmissions::get());
|
||||
multiplier * WeightToFee::calc(&expected_weight)
|
||||
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(),
|
||||
))
|
||||
}
|
||||
|
||||
@@ -65,8 +65,8 @@ use xcm_builder::{
|
||||
use xcm_executor::XcmExecutor;
|
||||
use sp_arithmetic::Perquintill;
|
||||
use sp_runtime::{
|
||||
create_runtime_str, generic, impl_opaque_keys,
|
||||
ApplyExtrinsicResult, KeyTypeId, Percent, Permill, Perbill,
|
||||
create_runtime_str, generic, impl_opaque_keys, ApplyExtrinsicResult, KeyTypeId, Percent,
|
||||
Permill, Perbill, FixedPointNumber,
|
||||
transaction_validity::{TransactionValidity, TransactionSource, TransactionPriority},
|
||||
traits::{
|
||||
BlakeTwo256, Block as BlockT, OpaqueKeys, ConvertInto, AccountIdLookup,
|
||||
@@ -101,6 +101,7 @@ 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 pallet_election_provider_multi_phase::Call as EPMCall;
|
||||
|
||||
/// Constant values used within the runtime.
|
||||
pub mod constants;
|
||||
@@ -348,6 +349,7 @@ 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,11 +362,14 @@ 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,
|
||||
crate::constants::fee::WeightToFee,
|
||||
crate::weights::pallet_election_provider_multi_phase::WeightInfo<Runtime>,
|
||||
>(Perbill::from_perthousand(1500));
|
||||
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
|
||||
);
|
||||
|
||||
// fallback: emergency phase.
|
||||
pub const Fallback: pallet_election_provider_multi_phase::FallbackStrategy =
|
||||
|
||||
@@ -41,7 +41,7 @@ use primitives::v1::{
|
||||
ValidatorIndex, InboundDownwardMessage, InboundHrmpMessage, SessionInfo,
|
||||
};
|
||||
use sp_runtime::{
|
||||
create_runtime_str, generic, impl_opaque_keys, ApplyExtrinsicResult,
|
||||
create_runtime_str, generic, impl_opaque_keys, ApplyExtrinsicResult, FixedPointNumber,
|
||||
KeyTypeId, Percent, Permill, Perbill, curve::PiecewiseLinear,
|
||||
transaction_validity::{TransactionValidity, TransactionSource, TransactionPriority},
|
||||
traits::{
|
||||
@@ -77,6 +77,7 @@ 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 pallet_election_provider_multi_phase::Call as EPMCall;
|
||||
|
||||
/// Constant values used within the runtime.
|
||||
pub mod constants;
|
||||
@@ -328,6 +329,7 @@ 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,11 +342,14 @@ 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,
|
||||
crate::constants::fee::WeightToFee,
|
||||
crate::weights::pallet_election_provider_multi_phase::WeightInfo<Runtime>,
|
||||
>(Perbill::from_perthousand(1500));
|
||||
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
|
||||
);
|
||||
|
||||
// fallback: emergency phase.
|
||||
pub const Fallback: pallet_election_provider_multi_phase::FallbackStrategy =
|
||||
|
||||
@@ -65,7 +65,7 @@ use xcm_builder::{
|
||||
};
|
||||
|
||||
use sp_runtime::{
|
||||
create_runtime_str, generic, impl_opaque_keys,
|
||||
create_runtime_str, generic, impl_opaque_keys, FixedPointNumber,
|
||||
ApplyExtrinsicResult, KeyTypeId, Perbill, curve::PiecewiseLinear,
|
||||
transaction_validity::{TransactionValidity, TransactionSource, TransactionPriority},
|
||||
traits::{
|
||||
@@ -100,6 +100,7 @@ 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 pallet_election_provider_multi_phase::Call as EPMCall;
|
||||
|
||||
/// Constant values used within the runtime.
|
||||
pub mod constants;
|
||||
@@ -333,6 +334,7 @@ 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,11 +347,14 @@ 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,
|
||||
crate::constants::fee::WeightToFee,
|
||||
crate::weights::pallet_election_provider_multi_phase::WeightInfo<Runtime>,
|
||||
>(Perbill::from_perthousand(1500));
|
||||
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
|
||||
);
|
||||
|
||||
// fallback: emergency phase.
|
||||
pub const Fallback: pallet_election_provider_multi_phase::FallbackStrategy =
|
||||
|
||||
Reference in New Issue
Block a user