Skip to content
This repository was archived by the owner on Mar 13, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
companion for #substrate-8242
  • Loading branch information
aurexav committed Mar 25, 2021
commit 43bac7fb2ae10f0060f339cf92ac9d07698ed393
3 changes: 1 addition & 2 deletions bin/node/runtime/pangolin/src/im_online.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@ use sp_runtime::transaction_validity::TransactionPriority;
use crate::*;

frame_support::parameter_types! {
pub const SessionDuration: BlockNumber = BLOCKS_PER_SESSION as _;
pub const ImOnlineUnsignedPriority: TransactionPriority = TransactionPriority::max_value();
}
impl Config for Runtime {
type AuthorityId = AuthorityId;
type Event = Event;
type NextSessionRotation = Babe;
type ValidatorSet = Historical;
type SessionDuration = SessionDuration;
type ReportUnresponsiveness = Offences;
type UnsignedPriority = ImOnlineUnsignedPriority;
type WeightInfo = SubstrateWeight<Runtime>;
Expand Down
8 changes: 6 additions & 2 deletions frame/staking/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1057,7 +1057,10 @@ decl_module! {
// either current session final based on the plan, or we're forcing.
(Self::is_current_session_final() || Self::will_era_be_forced())
{
if let Some(next_session_change) = T::NextNewSession::estimate_next_new_session(now) {
let (maybe_next_session_change, estimate_next_new_session_weight) =
T::NextNewSession::estimate_next_new_session(now);

if let Some(next_session_change) = maybe_next_session_change {
if let Some(remaining) = next_session_change.checked_sub(&now) {
if remaining <= T::ElectionLookahead::get() && !remaining.is_zero() {
// create snapshot.
Expand All @@ -1079,7 +1082,7 @@ decl_module! {
} else {
log!(warn, "Estimating next session change failed.");
}
add_weight(0, 0, T::NextNewSession::weight(now))
add_weight(0, 0, estimate_next_new_session_weight)
}

// For `era_election_status`, `is_current_session_final`, `will_era_be_forced`
Expand Down Expand Up @@ -3679,6 +3682,7 @@ impl<T: Config> sp_election_providers::ElectionDataProvider<T::AccountId, T::Blo
let session_length = T::NextNewSession::average_session_length();

let until_this_session_end = T::NextNewSession::estimate_next_new_session(now)
.0
.unwrap_or_default()
.saturating_sub(now);

Expand Down