Avoid overflow in the initial 'nextExchangeTransitionConfTime' calculation (#3809)
This commit is contained in:
parent
ff12c7f9ce
commit
2c3e47d7e6
|
@ -724,11 +724,19 @@ proc init*(T: type BeaconNode,
|
||||||
else:
|
else:
|
||||||
nil
|
nil
|
||||||
|
|
||||||
bellatrixEpochTime =
|
maxSecondsInMomentType = Moment.high.epochSeconds
|
||||||
genesisTime + cfg.BELLATRIX_FORK_EPOCH * SLOTS_PER_EPOCH * SECONDS_PER_SLOT
|
# If the Bellatrix epoch is above this value, the calculation
|
||||||
|
# below will overflow. This happens in practice for networks
|
||||||
|
# where the `BELLATRIX_FORK_EPOCH` is not yet specified.
|
||||||
|
maxSupportedBellatrixEpoch = (maxSecondsInMomentType.uint64 - genesisTime) div
|
||||||
|
(SLOTS_PER_EPOCH * SECONDS_PER_SLOT)
|
||||||
|
bellatrixEpochTime = if cfg.BELLATRIX_FORK_EPOCH < maxSupportedBellatrixEpoch:
|
||||||
|
int64(genesisTime + cfg.BELLATRIX_FORK_EPOCH * SLOTS_PER_EPOCH * SECONDS_PER_SLOT)
|
||||||
|
else:
|
||||||
|
maxSecondsInMomentType
|
||||||
|
|
||||||
nextExchangeTransitionConfTime =
|
nextExchangeTransitionConfTime =
|
||||||
max(Moment.init(int64 bellatrixEpochTime, Second),
|
max(Moment.init(bellatrixEpochTime, Second),
|
||||||
Moment.now)
|
Moment.now)
|
||||||
|
|
||||||
let node = BeaconNode(
|
let node = BeaconNode(
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit c6ce4d4fb26a785aabff84793fcd2b86a0ff93af
|
Subproject commit 84e32a3b695b2e54ff7733ca660bd95332b21d38
|
Loading…
Reference in New Issue