Companion for substrate/pull/8113 (Unleash multi phase) (#2432)

* Almost make it work.

* Make the runtimes build

* Some fixes

* Make the whole thing compile

* Apply suggestions from code review

* Fix review comments

* remove unused.

* nit

* Fix

* "Update Substrate"

* bump tx-version

Co-authored-by: parity-processbot <>
This commit is contained in:
Kian Paimani
2021-03-20 13:13:14 +01:00
committed by GitHub
parent df3fef3fd9
commit 6435296cc5
9 changed files with 195 additions and 282 deletions
+12 -24
View File
@@ -106,7 +106,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
apis: RUNTIME_API_VERSIONS,
#[cfg(feature = "disable-runtime-api")]
apis: version::create_apis_vec![[]],
transaction_version: 4,
transaction_version: 5,
};
/// The BABE epoch configuration at genesis.
@@ -312,18 +312,15 @@ impl pallet_session::historical::Config for Runtime {
parameter_types! {
// no signed phase for now, just unsigned.
pub const SignedPhase: u32 = 0;
// NOTE: length of unsigned phase is, for now, different than `ElectionLookahead` to make sure
// that we won't run OCW threads at the same time with staking.
pub const UnsignedPhase: u32 = ElectionLookahead::get() / 2;
pub const UnsignedPhase: u32 = EPOCH_DURATION_IN_BLOCKS / 4;
// fallback: no need to do on-chain phragmen while we re on a dry-run.
// fallback: run election on-chain.
pub const Fallback: pallet_election_provider_multi_phase::FallbackStrategy =
pallet_election_provider_multi_phase::FallbackStrategy::Nothing;
pallet_election_provider_multi_phase::FallbackStrategy::OnChain;
pub SolutionImprovementThreshold: Perbill = Perbill::from_rational(1u32, 10_000);
pub SolutionImprovementThreshold: Perbill = Perbill::from_rational(5u32, 10_000);
// miner configs
pub const MultiPhaseUnsignedPriority: TransactionPriority = StakingUnsignedPriority::get() - 1u64;
pub const MinerMaxIterations: u32 = 10;
}
@@ -332,10 +329,10 @@ impl pallet_election_provider_multi_phase::Config for Runtime {
type Currency = Balances;
type SignedPhase = SignedPhase;
type UnsignedPhase = UnsignedPhase;
type SolutionImprovementThreshold = MinSolutionScoreBump;
type SolutionImprovementThreshold = SolutionImprovementThreshold;
type MinerMaxIterations = MinerMaxIterations;
type MinerMaxWeight = OffchainSolutionWeightLimit; // For now use the one from staking.
type MinerTxPriority = MultiPhaseUnsignedPriority;
type MinerTxPriority = NposSolutionPriority;
type DataProvider = Staking;
type OnChainAccuracy = Perbill;
type CompactSolution = pallet_staking::CompactAssignments;
@@ -364,10 +361,6 @@ parameter_types! {
pub const SlashDeferDuration: pallet_staking::EraIndex = 27;
pub const RewardCurve: &'static PiecewiseLinear<'static> = &REWARD_CURVE;
pub const MaxNominatorRewardedPerValidator: u32 = 64;
// quarter of the last session will be for election.
pub const ElectionLookahead: BlockNumber = EPOCH_DURATION_IN_BLOCKS / 4;
pub const MaxIterations: u32 = 10;
pub MinSolutionScoreBump: Perbill = Perbill::from_rational(5u32, 10_000);
}
impl pallet_staking::Config for Runtime {
@@ -387,12 +380,6 @@ impl pallet_staking::Config for Runtime {
type EraPayout = pallet_staking::ConvertCurve<RewardCurve>;
type MaxNominatorRewardedPerValidator = MaxNominatorRewardedPerValidator;
type NextNewSession = Session;
type ElectionLookahead = ElectionLookahead;
type Call = Call;
type UnsignedPriority = StakingUnsignedPriority;
type MaxIterations = MaxIterations;
type MinSolutionScoreBump = MinSolutionScoreBump;
type OffchainSolutionWeightLimit = OffchainSolutionWeightLimit;
type ElectionProvider = ElectionProviderMultiPhase;
type WeightInfo = weights::pallet_staking::WeightInfo<Runtime>;
}
@@ -427,7 +414,7 @@ parameter_types! {
}
parameter_types! {
pub const StakingUnsignedPriority: TransactionPriority = TransactionPriority::max_value() / 2;
pub const NposSolutionPriority: TransactionPriority = TransactionPriority::max_value() / 2;
pub const ImOnlineUnsignedPriority: TransactionPriority = TransactionPriority::max_value();
}
@@ -437,7 +424,7 @@ impl pallet_im_online::Config for Runtime {
type ValidatorSet = Historical;
type NextSessionRotation = Babe;
type ReportUnresponsiveness = Offences;
type UnsignedPriority = StakingUnsignedPriority;
type UnsignedPriority = ImOnlineUnsignedPriority;
type WeightInfo = weights::pallet_im_online::WeightInfo<Runtime>;
}
@@ -837,7 +824,7 @@ construct_runtime! {
// Consensus support.
Authorship: pallet_authorship::{Pallet, Call, Storage} = 5,
Staking: pallet_staking::{Pallet, Call, Storage, Config<T>, Event<T>, ValidateUnsigned} = 6,
Staking: pallet_staking::{Pallet, Call, Storage, Config<T>, Event<T>} = 6,
Offences: pallet_offences::{Pallet, Call, Storage, Event} = 7,
Historical: session_historical::{Pallet} = 27,
Session: pallet_session::{Pallet, Call, Storage, Event, Config<T>} = 8,
@@ -940,7 +927,7 @@ pub type Executive = frame_executive::Executive<
frame_system::ChainContext<Runtime>,
Runtime,
AllPallets,
BabeEpochConfigMigrations,
BabeEpochConfigMigrations
>;
/// The payload being signed in transactions.
pub type SignedPayload = generic::SignedPayload<Call, SignedExtra>;
@@ -1193,6 +1180,7 @@ sp_api::impl_runtime_apis! {
#[cfg(feature = "try-runtime")]
impl frame_try_runtime::TryRuntime<Block> for Runtime {
fn on_runtime_upgrade() -> Result<(Weight, Weight), sp_runtime::RuntimeString> {
log::info!("try-runtime::on_runtime_upgrade westend.");
let weight = Executive::try_runtime_upgrade()?;
Ok((weight, BlockWeights::get().max_block))
}