mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-09 19:51:47 +00:00
Adds ENR "eth2" field and Fork logic to networking (#953)
* Merge #913 * Correct release tests * Completed release test corrections * Initial work on upgrading discovery * Updates discovery to latest version * Update ENR initialisation logic * Remove debug statements * Shifts timing units to slots * Initial work * Add initial fork versioning and EnrForkId * Correct linking for EnrForkId * Adds eth2 field to local ENR * Initial work to eth2 field integration * Integrate eth2 field into discovery * temp commit * Add a timer to adjust fork versions during a hard fork for the ENR
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
///! Maintains a hard-coded list of known forks and their slots at which they were activated.
|
||||
use types::{Epoch, EthSpec, Slot, FAR_FUTURE_EPOCH};
|
||||
use types::{ChainSpec, Epoch, EthSpec, Slot};
|
||||
|
||||
mod forks;
|
||||
|
||||
@@ -7,7 +7,7 @@ mod forks;
|
||||
/// number.
|
||||
///
|
||||
/// The disabled_forks parameter select which forks are disabled by their name.
|
||||
pub fn current_fork_version(slot: Slot, disabled_forks: Vec<String>) -> [u8; 4] {
|
||||
pub fn current_fork_version(slot: Slot, disabled_forks: &[String]) -> [u8; 4] {
|
||||
let mut version = [0, 0, 0, 0];
|
||||
for (fork_name, fork_slot_no, fork_version) in forks::KNOWN_FORKS.iter() {
|
||||
if *fork_slot_no <= slot.as_u64() {
|
||||
@@ -25,7 +25,7 @@ pub fn current_fork_version(slot: Slot, disabled_forks: Vec<String>) -> [u8; 4]
|
||||
version
|
||||
}
|
||||
|
||||
pub fn next_fork_version(slot: Slot, disabled_forks: Vec<String>) -> [u8; 4] {
|
||||
pub fn next_fork_version(slot: Slot, disabled_forks: &[String]) -> [u8; 4] {
|
||||
let mut version = None;
|
||||
for (fork_name, fork_slot_no, fork_version) in forks::KNOWN_FORKS.iter() {
|
||||
if *fork_slot_no > slot.as_u64() {
|
||||
@@ -48,7 +48,11 @@ pub fn next_fork_version(slot: Slot, disabled_forks: Vec<String>) -> [u8; 4] {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn next_fork_epoch<T: EthSpec>(slot: Slot, disabled_forks: Vec<String>) -> Epoch {
|
||||
pub fn next_fork_epoch<T: EthSpec>(
|
||||
spec: &ChainSpec,
|
||||
slot: Slot,
|
||||
disabled_forks: &[String],
|
||||
) -> Epoch {
|
||||
let mut next_fork_slot = None;
|
||||
for (fork_name, fork_slot_no, _fork_version) in forks::KNOWN_FORKS.iter() {
|
||||
if *fork_slot_no > slot.as_u64() {
|
||||
@@ -66,6 +70,6 @@ pub fn next_fork_epoch<T: EthSpec>(slot: Slot, disabled_forks: Vec<String>) -> E
|
||||
if let Some(fork_slot) = next_fork_slot {
|
||||
fork_slot.epoch(T::slots_per_epoch())
|
||||
} else {
|
||||
FAR_FUTURE_EPOCH
|
||||
Epoch::from(spec.far_future_epoch)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user