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

@@ -443,7 +443,7 @@ pub fn gossipsub_config(
network_load: u8,
fork_context: Arc<ForkContext>,
gossipsub_config_params: GossipsubConfigParams,
seconds_per_slot: u64,
slot_duration: Duration,
slots_per_epoch: u64,
idontwant_message_size_threshold: usize,
) -> gossipsub::Config {
@@ -487,7 +487,7 @@ pub fn gossipsub_config(
// To accommodate the increase, we should increase the duplicate cache time to filter older seen messages.
// 2 epochs is quite sane for pre-deneb network parameters as well.
// Hence we keep the same parameters for pre-deneb networks as well to avoid switching at the fork.
let duplicate_cache_time = Duration::from_secs(slots_per_epoch * seconds_per_slot * 2);
let duplicate_cache_time = Duration::from_secs(slots_per_epoch * slot_duration.as_secs() * 2);
gossipsub::ConfigBuilder::default()
.max_transmit_size(gossipsub_config_params.gossipsub_max_transmit_size)

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)