ConsensusSpec parameterizes every consensus constant that differs between presets except the slot duration. Three sites assume 12 seconds (master @ 43a8c9f):
|
pub fn expected_current_slot(now: SystemTime, genesis_time: u64) -> u64 { |
|
let now = now.duration_since(UNIX_EPOCH).unwrap_or_default().as_secs(); |
|
|
|
let since_genesis = now - genesis_time; |
|
|
|
since_genesis / 12 |
|
} |
— expected_current_slot computes since_genesis / 12
|
fn slot_timestamp(&self, slot: u64) -> u64 { |
|
slot * 12 + self.config.chain.genesis_time |
|
} |
— Inner::slot_timestamp computes slot * 12; used by is_valid_checkpoint and the head-age log line
|
let mut interval = interval_at(start, std::time::Duration::from_secs(12)); |
— the advance loop ticks every Duration::from_secs(12), and
|
let time_to_next_slot = next_slot_timestamp - now; |
phases each tick 4 s (one third of a 12 s slot) into the slot
A ConsensusSpec for a chain with a different slot time therefore gets wrong wall-clock slots. On a 5-second chain (Gnosis), expected_current_slot is 2.4x too low, so verify_generic_update rejects every fresh update with InvalidTimestamp; and slot_timestamp ages checkpoints 2.4x too fast, so a checkpoint that is 6 days old fails the max_checkpoint_age check as 14.4 days old. The minimal preset the test vectors under testdata/ are built from also declares SECONDS_PER_SLOT: 6, which MinimalConsensusSpec cannot express.
Proposed fix: a ConsensusSpec::seconds_per_slot() default method returning 12, used at those three sites, with MinimalConsensusSpec overriding to 6. Mainnet is unaffected. PR: #809.
ConsensusSpecparameterizes every consensus constant that differs between presets except the slot duration. Three sites assume 12 seconds (master @ 43a8c9f):helios/ethereum/consensus-core/src/consensus_core.rs
Lines 389 to 395 in 43a8c9f
expected_current_slotcomputessince_genesis / 12helios/ethereum/src/consensus.rs
Lines 660 to 662 in 43a8c9f
Inner::slot_timestampcomputesslot * 12; used byis_valid_checkpointand the head-age log linehelios/ethereum/src/consensus.rs
Line 178 in 43a8c9f
Duration::from_secs(12), andhelios/ethereum/src/consensus.rs
Line 531 in 43a8c9f
A
ConsensusSpecfor a chain with a different slot time therefore gets wrong wall-clock slots. On a 5-second chain (Gnosis),expected_current_slotis 2.4x too low, soverify_generic_updaterejects every fresh update withInvalidTimestamp; andslot_timestampages checkpoints 2.4x too fast, so a checkpoint that is 6 days old fails themax_checkpoint_agecheck as 14.4 days old. Theminimalpreset the test vectors undertestdata/are built from also declaresSECONDS_PER_SLOT: 6, whichMinimalConsensusSpeccannot express.Proposed fix: a
ConsensusSpec::seconds_per_slot()default method returning 12, used at those three sites, withMinimalConsensusSpecoverriding to 6. Mainnet is unaffected. PR: #809.