Relative slots (#2820)

* Initial work on relative slots for BABE

* More work

* Update core/consensus/babe/src/lib.rs

`Aura` → `Babe`

Co-Authored-By: Pierre Krieger <pierre.krieger1708@gmail.com>

* More work on relative slots

* Add missing field in test-runtime

* Bump `impl_version` and `authoring_version`

* Fix compile errors and warnings

* Upgrade dependencies

* Update dependencies more

* Revert some updates to dependencies

Somehow, those broke the build

* Fix compilation errors

* `Duration` → `u128` in calculations

* `slot_duration` is in milleseconds, not seconds

* Median algorithm: ignore blocks with slot_num < sl

* Fix silly compile error

* Store a duration, rather than an instant

It is more useful

* Fix compilation errors

* `INVERSE_NANO` → `NANOS_PER_SEC`

Also: `1000_000_000` → `1_000_000_000`

Suggested-by: Niklas Adolfsson <niklasadolfsson1@gmail.com>

* Un-bump `authoring_version`

* Disable median algorithm when `median_required_blocks` is 0

Otherwise it would panic.

* Apply suggestions from code review

Co-Authored-By: Bastian Köcher <bkchr@users.noreply.github.com>

* Simplify panic

* Fix build error

* Create `SignedDuration` struct

for signed `Duration` values.

Suggested-by: Bastian Köcher

* Refactor median algorithm into separate function

* Add issues for FIXMEs and respond to code review

* Fix minor warnings
This commit is contained in:
DemiMarie-parity
2019-06-22 12:21:29 -04:00
committed by GitHub
parent 437a6bc6b1
commit 48aa32bece
8 changed files with 167 additions and 35 deletions
+2
View File
@@ -470,6 +470,7 @@ cfg_if! {
slot_duration: 1,
expected_block_time: 1,
threshold: std::u64::MAX,
median_required_blocks: 100,
}
}
fn authorities() -> Vec<BabeId> { system::authorities() }
@@ -611,6 +612,7 @@ cfg_if! {
impl consensus_babe::BabeApi<Block> for Runtime {
fn startup_data() -> consensus_babe::BabeConfiguration {
consensus_babe::BabeConfiguration {
median_required_blocks: 0,
slot_duration: 1,
expected_block_time: 1,
threshold: core::u64::MAX,