mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-17 17:11:02 +00:00
im-online: use EstimateNextSessionRotation to get better estimates of session progress (#8242)
* frame-support: add method to estimate current session progress * im-online: use EstimateNextSessionRotation trait to delay heartbeats * node: fix im-online pallet instantiation * frame-support: fix docs * frame: fix tests * pallet-session: last block of periodic session means 100% session progress * pallet-session: add test for periodic session progress * pallet-babe: fix epoch progress and add test * frame-support: return weight with session estimates * pallet-im-online: add test for session progress logic
This commit is contained in:
@@ -1365,7 +1365,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.
|
||||
@@ -1387,7 +1390,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`
|
||||
add_weight(3, 0, 0);
|
||||
@@ -3365,6 +3368,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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user