mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-03 00:31:50 +00:00
Replace INTERVALS_PER_SLOT with explicit slot component times (#7944)
https://github.com/ethereum/consensus-specs/pull/4476 Co-Authored-By: Barnabas Busa <barnabas.busa@ethereum.org> Co-Authored-By: Eitan Seri- Levi <eserilev@gmail.com> Co-Authored-By: Eitan Seri-Levi <eserilev@ucsc.edu> Co-Authored-By: Michael Sproul <michaelsproul@users.noreply.github.com> Co-Authored-By: Michael Sproul <michael@sigmaprime.io>
This commit is contained in:
@@ -540,6 +540,7 @@ impl<T: BeaconChainTypes> NetworkBeaconProcessor<T> {
|
||||
aggregate,
|
||||
indexed_attestation,
|
||||
&self.chain.slot_clock,
|
||||
&self.chain.spec,
|
||||
);
|
||||
|
||||
metrics::inc_counter(
|
||||
@@ -809,7 +810,7 @@ impl<T: BeaconChainTypes> NetworkBeaconProcessor<T> {
|
||||
Ok(gossip_verified_blob) => {
|
||||
metrics::inc_counter(&metrics::BEACON_PROCESSOR_GOSSIP_BLOB_VERIFIED_TOTAL);
|
||||
|
||||
if delay >= self.chain.slot_clock.unagg_attestation_production_delay() {
|
||||
if delay >= self.chain.spec.get_unaggregated_attestation_due() {
|
||||
metrics::inc_counter(&metrics::BEACON_BLOB_GOSSIP_ARRIVED_LATE_TOTAL);
|
||||
debug!(
|
||||
block_root = ?gossip_verified_blob.block_root(),
|
||||
@@ -1237,7 +1238,7 @@ impl<T: BeaconChainTypes> NetworkBeaconProcessor<T> {
|
||||
|
||||
let verified_block = match verification_result {
|
||||
Ok(verified_block) => {
|
||||
if block_delay >= self.chain.slot_clock.unagg_attestation_production_delay() {
|
||||
if block_delay >= self.chain.spec.get_unaggregated_attestation_due() {
|
||||
metrics::inc_counter(&metrics::BEACON_BLOCK_DELAY_GOSSIP_ARRIVED_LATE_TOTAL);
|
||||
debug!(
|
||||
block_root = ?verified_block.block_root,
|
||||
@@ -1914,6 +1915,7 @@ impl<T: BeaconChainTypes> NetworkBeaconProcessor<T> {
|
||||
seen_timestamp,
|
||||
sync_signature.sync_message(),
|
||||
&self.chain.slot_clock,
|
||||
&self.chain.spec,
|
||||
);
|
||||
|
||||
metrics::inc_counter(&metrics::BEACON_PROCESSOR_SYNC_MESSAGE_VERIFIED_TOTAL);
|
||||
@@ -1976,6 +1978,7 @@ impl<T: BeaconChainTypes> NetworkBeaconProcessor<T> {
|
||||
sync_contribution.aggregate(),
|
||||
sync_contribution.participant_pubkeys(),
|
||||
&self.chain.slot_clock,
|
||||
&self.chain.spec,
|
||||
);
|
||||
metrics::inc_counter(&metrics::BEACON_PROCESSOR_SYNC_CONTRIBUTION_VERIFIED_TOTAL);
|
||||
|
||||
|
||||
@@ -297,7 +297,7 @@ impl<T: BeaconChainTypes> NetworkBeaconProcessor<T> {
|
||||
&& current_slot == slot
|
||||
{
|
||||
// Note: this metric is useful to gauge how long it takes to receive blobs requested
|
||||
// over rpc. Since we always send the request for block components at `slot_clock.single_lookup_delay()`
|
||||
// over rpc. Since we always send the request for block components at `get_unaggregated_attestation_due() / 2`
|
||||
// we can use that as a baseline to measure against.
|
||||
let delay = get_slot_delay_ms(seen_timestamp, slot, &self.chain.slot_clock);
|
||||
|
||||
|
||||
@@ -862,9 +862,11 @@ impl<T: BeaconChainTypes> NetworkService<T> {
|
||||
self.next_digest_update = Box::pin(next_digest_delay(&self.beacon_chain).into());
|
||||
|
||||
// Set the next_unsubscribe delay.
|
||||
let epoch_duration =
|
||||
self.beacon_chain.spec.seconds_per_slot * T::EthSpec::slots_per_epoch();
|
||||
let unsubscribe_delay = Duration::from_secs(UNSUBSCRIBE_DELAY_EPOCHS * epoch_duration);
|
||||
let unsubscribe_delay = Duration::from_secs(
|
||||
UNSUBSCRIBE_DELAY_EPOCHS
|
||||
* self.beacon_chain.spec.get_slot_duration().as_secs()
|
||||
* T::EthSpec::slots_per_epoch(),
|
||||
);
|
||||
|
||||
// Update the `next_topic_subscriptions` timer if the next change in the fork digest is known.
|
||||
self.next_topic_subscriptions =
|
||||
@@ -915,7 +917,7 @@ fn next_topic_subscriptions_delay<T: BeaconChainTypes>(
|
||||
) -> Option<tokio::time::Sleep> {
|
||||
if let Some((_, duration_to_epoch)) = beacon_chain.duration_to_next_digest() {
|
||||
let duration_to_subscription = duration_to_epoch.saturating_sub(Duration::from_secs(
|
||||
beacon_chain.spec.seconds_per_slot * SUBSCRIBE_DELAY_SLOTS,
|
||||
beacon_chain.spec.get_slot_duration().as_secs() * SUBSCRIBE_DELAY_SLOTS,
|
||||
));
|
||||
if !duration_to_subscription.is_zero() {
|
||||
return Some(tokio::time::sleep(duration_to_subscription));
|
||||
|
||||
Reference in New Issue
Block a user