mirror of
https://github.com/status-im/nimbus-eth2.git
synced 2025-01-10 22:36:01 +00:00
Avoid overflow in the initial 'nextExchangeTransitionConfTime' calculation (#3809)
This commit is contained in:
parent
725b120bc3
commit
fa7d7fcc42
@ -712,11 +712,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(
|
||||||
|
2
vendor/nim-chronos
vendored
2
vendor/nim-chronos
vendored
@ -1 +1 @@
|
|||||||
Subproject commit 2a5095505f771610f9559d2e774b2a9561f01101
|
Subproject commit a5bc5ca996ab72c1c5dda7d5b922b536f39f603e
|
Loading…
x
Reference in New Issue
Block a user