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:
André Silva
2021-03-12 11:50:07 +00:00
committed by GitHub
parent a4e8875897
commit 5182209788
12 changed files with 403 additions and 142 deletions
+2 -8
View File
@@ -260,7 +260,7 @@ impl Config for Test {
pub fn go_to_block(n: u64, s: u64) {
use frame_support::traits::OnFinalize;
System::on_finalize(System::block_number());
Babe::on_finalize(System::block_number());
Session::on_finalize(System::block_number());
Staking::on_finalize(System::block_number());
@@ -274,14 +274,8 @@ pub fn go_to_block(n: u64, s: u64) {
let pre_digest = make_secondary_plain_pre_digest(0, s.into());
System::initialize(&n, &parent_hash, &pre_digest, InitKind::Full);
System::set_block_number(n);
Timestamp::set_timestamp(n);
if s > 1 {
CurrentSlot::put(Slot::from(s));
}
System::on_initialize(n);
Babe::on_initialize(n);
Session::on_initialize(n);
Staking::on_initialize(n);
}