mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 17:01:09 +00:00
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:
@@ -63,7 +63,8 @@ use srml_aura::{
|
||||
};
|
||||
use substrate_telemetry::{telemetry, CONSENSUS_TRACE, CONSENSUS_DEBUG, CONSENSUS_WARN, CONSENSUS_INFO};
|
||||
|
||||
use slots::{CheckedHeader, SlotData, SlotWorker, SlotInfo, SlotCompatible, slot_now, check_equivocation};
|
||||
use slots::{CheckedHeader, SlotData, SlotWorker, SlotInfo, SlotCompatible};
|
||||
use slots::{SignedDuration, check_equivocation};
|
||||
|
||||
pub use aura_primitives::*;
|
||||
pub use consensus_common::SyncOracle;
|
||||
@@ -283,8 +284,8 @@ impl<H, B, C, E, I, P, Error, SO> SlotWorker<B> for AuraWorker<C, E, I, P, SO> w
|
||||
Box::new(proposal_work.map(move |b| {
|
||||
// minor hack since we don't have access to the timestamp
|
||||
// that is actually set by the proposer.
|
||||
let slot_after_building = slot_now(slot_duration);
|
||||
if slot_after_building != Some(slot_num) {
|
||||
let slot_after_building = SignedDuration::default().slot_now(slot_duration);
|
||||
if slot_after_building != slot_num {
|
||||
info!(
|
||||
"Discarding proposal for slot {}; block production took too long",
|
||||
slot_num
|
||||
|
||||
Reference in New Issue
Block a user