mirror of
https://github.com/sigp/lighthouse.git
synced 2026-04-19 13:58:28 +00:00
* Incomplete scraps
* Add progress on new fork choice impl
* Further progress
* First complete compiling version
* Remove chain reference
* Add new lmd_ghost crate
* Start integrating into beacon chain
* Update `milagro_bls` to new release (#1183)
* Update milagro_bls to new release
Signed-off-by: Kirk Baird <baird.k@outlook.com>
* Tidy up fake cryptos
Signed-off-by: Kirk Baird <baird.k@outlook.com>
* move SecretHash to bls and put plaintext back
Signed-off-by: Kirk Baird <baird.k@outlook.com>
* Update state processing for v0.12
* Fix EF test runners for v0.12
* Fix some tests
* Fix broken attestation verification test
* More test fixes
* Rough beacon chain impl working
* Remove fork_choice_2
* Remove checkpoint manager
* Half finished ssz impl
* Add missed file
* Add persistence
* Tidy, fix some compile errors
* Remove RwLock from ProtoArrayForkChoice
* Fix store-based compile errors
* Add comments, tidy
* Move function out of ForkChoice struct
* Start testing
* More testing
* Fix compile error
* Tidy beacon_chain::fork_choice
* Queue attestations from the current slot
* Allow fork choice to handle prior-to-genesis start
* Improve error granularity
* Test attestation dequeuing
* Process attestations during block
* Store target root in fork choice
* Move fork choice verification into new crate
* Update tests
* Consensus updates for v0.12 (#1228)
* Update state processing for v0.12
* Fix EF test runners for v0.12
* Fix some tests
* Fix broken attestation verification test
* More test fixes
* Fix typo found in review
* Add `Block` struct to ProtoArray
* Start fixing get_ancestor
* Add rough progress on testing
* Get fork choice tests working
* Progress with testing
* Fix partialeq impl
* Move slot clock from fc_store
* Improve testing
* Add testing for best justified
* Add clone back to SystemTimeSlotClock
* Add balances test
* Start adding balances cache again
* Wire-in balances cache
* Improve tests
* Remove commented-out tests
* Remove beacon_chain::ForkChoice
* Rename crates
* Update wider codebase to new fork_choice layout
* Move advance_slot in test harness
* Tidy ForkChoice::update_time
* Fix verification tests
* Fix compile error with iter::once
* Fix fork choice tests
* Ensure block attestations are processed
* Fix failing beacon_chain tests
* Add first invalid block check
* Add finalized block check
* Progress with testing, new store builder
* Add fixes to get_ancestor
* Fix old genesis justification test
* Fix remaining fork choice tests
* Change root iteration method
* Move on_verified_block
* Remove unused method
* Start adding attestation verification tests
* Add invalid ffg target test
* Add target epoch test
* Add queued attestation test
* Remove old fork choice verification tests
* Tidy, add test
* Move fork choice lock drop
* Rename BeaconForkChoiceStore
* Add comments, tidy BeaconForkChoiceStore
* Update metrics, rename fork_choice_store.rs
* Remove genesis_block_root from ForkChoice
* Tidy
* Update fork_choice comments
* Tidy, add comments
* Tidy, simplify ForkChoice, fix compile issue
* Tidy, removed dead file
* Increase http request timeout
* Fix failing rest_api test
* Set HTTP timeout back to 5s
* Apply fix to get_ancestor
* Address Michael's comments
* Fix typo
* Revert "Fix broken attestation verification test"
This reverts commit 722cdc903b.
Co-authored-by: Kirk Baird <baird.k@outlook.com>
Co-authored-by: Michael Sproul <michael@sigmaprime.io>
66 lines
2.4 KiB
Rust
66 lines
2.4 KiB
Rust
#[macro_use]
|
|
extern crate lazy_static;
|
|
|
|
mod manual_slot_clock;
|
|
mod metrics;
|
|
mod system_time_slot_clock;
|
|
|
|
use std::time::Duration;
|
|
|
|
pub use crate::manual_slot_clock::ManualSlotClock;
|
|
pub use crate::manual_slot_clock::ManualSlotClock as TestingSlotClock;
|
|
pub use crate::system_time_slot_clock::SystemTimeSlotClock;
|
|
pub use metrics::scrape_for_metrics;
|
|
pub use types::Slot;
|
|
|
|
/// A clock that reports the current slot.
|
|
///
|
|
/// The clock is not required to be monotonically increasing and may go backwards.
|
|
pub trait SlotClock: Send + Sync + Sized {
|
|
/// Creates a new slot clock where the first slot is `genesis_slot`, genesis occurred
|
|
/// `genesis_duration` after the `UNIX_EPOCH` and each slot is `slot_duration` apart.
|
|
fn new(genesis_slot: Slot, genesis_duration: Duration, slot_duration: Duration) -> Self;
|
|
|
|
/// Returns the slot at this present time.
|
|
fn now(&self) -> Option<Slot>;
|
|
|
|
/// Indicates if the current time is prior to genesis time.
|
|
///
|
|
/// Returns `None` if the system clock cannot be read.
|
|
fn is_prior_to_genesis(&self) -> Option<bool>;
|
|
|
|
/// Returns the present time as a duration since the UNIX epoch.
|
|
///
|
|
/// Returns `None` if the present time is before the UNIX epoch (unlikely).
|
|
fn now_duration(&self) -> Option<Duration>;
|
|
|
|
/// Returns the slot of the given duration since the UNIX epoch.
|
|
fn slot_of(&self, now: Duration) -> Option<Slot>;
|
|
|
|
/// Returns the duration between slots
|
|
fn slot_duration(&self) -> Duration;
|
|
|
|
/// Returns the duration from now until `slot`.
|
|
fn duration_to_slot(&self, slot: Slot) -> Option<Duration>;
|
|
|
|
/// Returns the duration until the next slot.
|
|
fn duration_to_next_slot(&self) -> Option<Duration>;
|
|
|
|
/// Returns the duration until the first slot of the next epoch.
|
|
fn duration_to_next_epoch(&self, slots_per_epoch: u64) -> Option<Duration>;
|
|
|
|
/// Returns the first slot to be returned at the genesis time.
|
|
fn genesis_slot(&self) -> Slot;
|
|
|
|
/// Returns the slot if the internal clock were advanced by `duration`.
|
|
fn now_with_future_tolerance(&self, tolerance: Duration) -> Option<Slot> {
|
|
self.slot_of(self.now_duration()?.checked_add(tolerance)?)
|
|
}
|
|
|
|
/// Returns the slot if the internal clock were reversed by `duration`.
|
|
fn now_with_past_tolerance(&self, tolerance: Duration) -> Option<Slot> {
|
|
self.slot_of(self.now_duration()?.checked_sub(tolerance)?)
|
|
.or_else(|| Some(self.genesis_slot()))
|
|
}
|
|
}
|