From a770fadd013c11c174eb9c37ddeccc2ceb5411d4 Mon Sep 17 00:00:00 2001 From: tersec Date: Wed, 7 Sep 2022 08:02:07 +0000 Subject: [PATCH] exchangeTransitionConfiguration fix (#4077) --- beacon_chain/nimbus_beacon_node.nim | 32 ++++++++++------------------- 1 file changed, 11 insertions(+), 21 deletions(-) diff --git a/beacon_chain/nimbus_beacon_node.nim b/beacon_chain/nimbus_beacon_node.nim index 4a4552990..0c99def07 100644 --- a/beacon_chain/nimbus_beacon_node.nim +++ b/beacon_chain/nimbus_beacon_node.nim @@ -709,21 +709,6 @@ proc init*(T: type BeaconNode, else: nil - maxSecondsInMomentType = Moment.high.epochSeconds - # 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 = - max(Moment.init(bellatrixEpochTime, Second), - Moment.now) - let payloadBuilderRestClient = if config.payloadBuilderEnable: RestClientRef.new( @@ -756,7 +741,7 @@ proc init*(T: type BeaconNode, beaconClock: beaconClock, validatorMonitor: validatorMonitor, stateTtlCache: stateTtlCache, - nextExchangeTransitionConfTime: nextExchangeTransitionConfTime, + nextExchangeTransitionConfTime: Moment.now, dynamicFeeRecipientsStore: newClone(DynamicFeeRecipientsStore.init())) node.initLightClient( @@ -1373,11 +1358,16 @@ proc onSecond(node: BeaconNode, time: Moment) = # Nim GC metrics (for the main thread) updateThreadMetrics() - ## This procedure will be called once per minute. - # https://github.com/ethereum/execution-apis/blob/v1.0.0-beta.1/src/engine/specification.md#engine_exchangetransitionconfigurationv1 - if time > node.nextExchangeTransitionConfTime and not node.eth1Monitor.isNil: - node.nextExchangeTransitionConfTime = time + chronos.minutes(1) - traceAsyncErrors node.eth1Monitor.exchangeTransitionConfiguration() + if time >= node.nextExchangeTransitionConfTime and not node.eth1Monitor.isNil: + # The EL client SHOULD log a warning when not receiving an exchange message + # at least once every 120 seconds. If we only attempt to exchange every 60 + # seconds, the warning would be triggered if a single message is missed. + # To accommodate for that, exchange slightly more frequently. + # https://github.com/ethereum/execution-apis/blob/v1.0.0-beta.1/src/engine/specification.md#engine_exchangetransitionconfigurationv1 + node.nextExchangeTransitionConfTime = time + chronos.seconds(45) + + if node.currentSlot.epoch >= node.dag.cfg.BELLATRIX_FORK_EPOCH: + traceAsyncErrors node.eth1Monitor.exchangeTransitionConfiguration() if node.config.stopAtSyncedEpoch != 0 and node.dag.head.slot.epoch >= node.config.stopAtSyncedEpoch: