mirror of
https://github.com/sigp/lighthouse.git
synced 2026-05-08 17:26:04 +00:00
@@ -25,8 +25,8 @@ use task_executor::ShutdownReason;
|
|||||||
use tokio::sync::mpsc;
|
use tokio::sync::mpsc;
|
||||||
use tokio::time::Sleep;
|
use tokio::time::Sleep;
|
||||||
use types::{
|
use types::{
|
||||||
ChainSpec, EthSpec, ForkContext, ForkName, RelativeEpoch, Slot, SubnetId,
|
ChainSpec, EthSpec, ForkContext, RelativeEpoch, Slot, SubnetId, SyncCommitteeSubscription,
|
||||||
SyncCommitteeSubscription, SyncSubnetId, Unsigned, ValidatorSubscription,
|
SyncSubnetId, Unsigned, ValidatorSubscription,
|
||||||
};
|
};
|
||||||
|
|
||||||
mod tests;
|
mod tests;
|
||||||
@@ -281,32 +281,34 @@ impl<T: BeaconChainTypes> NetworkService<T> {
|
|||||||
pub fn required_gossip_fork_digests(&self) -> Vec<[u8; 4]> {
|
pub fn required_gossip_fork_digests(&self) -> Vec<[u8; 4]> {
|
||||||
let fork_context = &self.fork_context;
|
let fork_context = &self.fork_context;
|
||||||
let spec = &self.beacon_chain.spec;
|
let spec = &self.beacon_chain.spec;
|
||||||
match fork_context.current_fork() {
|
|
||||||
ForkName::Base => {
|
|
||||||
// If we are SUBSCRIBE_DELAY_SLOTS before the fork slot, subscribe only to Base,
|
|
||||||
// else subscribe to Base and Altair.
|
|
||||||
let current_slot = self.beacon_chain.slot().unwrap_or(spec.genesis_slot);
|
let current_slot = self.beacon_chain.slot().unwrap_or(spec.genesis_slot);
|
||||||
match spec.next_fork_epoch::<T::EthSpec>(current_slot) {
|
let current_fork = fork_context.current_fork();
|
||||||
Some((_, fork_epoch)) => {
|
|
||||||
|
let mut result = vec![fork_context
|
||||||
|
.to_context_bytes(current_fork)
|
||||||
|
.unwrap_or_else(|| {
|
||||||
|
panic!(
|
||||||
|
"{} fork bytes should exist as it's initialized in ForkContext",
|
||||||
|
current_fork
|
||||||
|
)
|
||||||
|
})];
|
||||||
|
|
||||||
|
if let Some((next_fork, fork_epoch)) = spec.next_fork_epoch::<T::EthSpec>(current_slot) {
|
||||||
if current_slot.saturating_add(Slot::new(SUBSCRIBE_DELAY_SLOTS))
|
if current_slot.saturating_add(Slot::new(SUBSCRIBE_DELAY_SLOTS))
|
||||||
>= fork_epoch.start_slot(T::EthSpec::slots_per_epoch())
|
>= fork_epoch.start_slot(T::EthSpec::slots_per_epoch())
|
||||||
{
|
{
|
||||||
fork_context.all_fork_digests()
|
let next_fork_context_bytes =
|
||||||
} else {
|
fork_context.to_context_bytes(next_fork).unwrap_or_else(|| {
|
||||||
vec![fork_context.genesis_context_bytes()]
|
panic!(
|
||||||
|
"context bytes should exist as spec.next_fork_epoch({}) returned Some({})",
|
||||||
|
current_slot, next_fork
|
||||||
|
)
|
||||||
|
});
|
||||||
|
result.push(next_fork_context_bytes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
None => vec![fork_context.genesis_context_bytes()],
|
|
||||||
}
|
result
|
||||||
}
|
|
||||||
ForkName::Altair => vec![fork_context
|
|
||||||
.to_context_bytes(ForkName::Altair)
|
|
||||||
.expect("Altair fork bytes should exist as it's initialized in ForkContext")],
|
|
||||||
// TODO: check this.. what even is this?
|
|
||||||
ForkName::Merge => vec![fork_context
|
|
||||||
.to_context_bytes(ForkName::Merge)
|
|
||||||
.expect("Merge fork bytes should exist as it's initialized in ForkContext")],
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user