Skip to content

Commit 489021a

Browse files
committed
Default slot duration ms to seconds_per_slot if its missing
1 parent 61bfe48 commit 489021a

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

consensus/types/src/core/chain_spec.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1822,8 +1822,9 @@ pub struct Config {
18221822

18231823
#[serde(with = "serde_utils::quoted_u64")]
18241824
seconds_per_slot: u64,
1825-
#[serde(with = "serde_utils::quoted_u64")]
1826-
slot_duration_ms: u64,
1825+
#[serde(default)]
1826+
#[serde(skip_serializing_if = "Option::is_none")]
1827+
slot_duration_ms: Option<MaybeQuoted<u64>>,
18271828
#[serde(with = "serde_utils::quoted_u64")]
18281829
seconds_per_eth1_block: u64,
18291830
#[serde(with = "serde_utils::quoted_u64")]
@@ -2289,7 +2290,9 @@ impl Config {
22892290
.map(|epoch| MaybeQuoted { value: epoch }),
22902291

22912292
seconds_per_slot: spec.seconds_per_slot,
2292-
slot_duration_ms: spec.slot_duration_ms,
2293+
slot_duration_ms: Some(MaybeQuoted {
2294+
value: spec.slot_duration_ms,
2295+
}),
22932296
seconds_per_eth1_block: spec.seconds_per_eth1_block,
22942297
min_validator_withdrawability_delay: spec.min_validator_withdrawability_delay,
22952298
shard_committee_period: spec.shard_committee_period,
@@ -2455,7 +2458,9 @@ impl Config {
24552458
gloas_fork_version,
24562459
gloas_fork_epoch: gloas_fork_epoch.map(|q| q.value),
24572460
seconds_per_slot,
2458-
slot_duration_ms,
2461+
slot_duration_ms: slot_duration_ms
2462+
.map(|q| q.value)
2463+
.unwrap_or_else(|| seconds_per_slot.saturating_mul(1000)),
24592464
seconds_per_eth1_block,
24602465
min_validator_withdrawability_delay,
24612466
shard_committee_period,

0 commit comments

Comments
 (0)