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:
Eitan Seri-Levi
2026-02-01 21:58:42 -08:00
committed by GitHub
parent cd8049a696
commit 3ecf964385
56 changed files with 579 additions and 184 deletions

View File

@@ -54,7 +54,7 @@ pub struct PeerScoreSettings<E: EthSpec> {
impl<E: EthSpec> PeerScoreSettings<E> {
pub fn new(chain_spec: &ChainSpec, mesh_n: usize) -> PeerScoreSettings<E> {
let slot = Duration::from_secs(chain_spec.seconds_per_slot);
let slot = chain_spec.get_slot_duration();
let beacon_attestation_subnet_weight = 1.0 / chain_spec.attestation_subnet_count as f64;
let max_positive_score = (MAX_IN_MESH_SCORE + MAX_FIRST_MESSAGE_DELIVERIES_SCORE)
* (BEACON_BLOCK_WEIGHT

View File

@@ -232,7 +232,7 @@ impl<E: EthSpec> Network<E> {
config.network_load,
ctx.fork_context.clone(),
gossipsub_config_params,
ctx.chain_spec.seconds_per_slot,
ctx.chain_spec.get_slot_duration(),
E::slots_per_epoch(),
config.idontwant_message_size_threshold,
);
@@ -240,13 +240,12 @@ impl<E: EthSpec> Network<E> {
let score_settings = PeerScoreSettings::new(&ctx.chain_spec, gs_config.mesh_n());
let gossip_cache = {
let slot_duration = std::time::Duration::from_secs(ctx.chain_spec.seconds_per_slot);
let half_epoch = std::time::Duration::from_secs(
ctx.chain_spec.seconds_per_slot * E::slots_per_epoch() / 2,
let half_epoch = std::time::Duration::from_millis(
(ctx.chain_spec.get_slot_duration().as_millis() as u64) * E::slots_per_epoch() / 2,
);
GossipCache::builder()
.beacon_block_timeout(slot_duration)
.beacon_block_timeout(ctx.chain_spec.get_slot_duration())
.aggregates_timeout(half_epoch)
.attestation_timeout(half_epoch)
.voluntary_exit_timeout(half_epoch * 2)