Skip to content

Commit

Permalink
exchangeTransitionConfiguration fix (#4077)
Browse files Browse the repository at this point in the history
  • Loading branch information
tersec authored Sep 7, 2022
1 parent ca20c49 commit a770fad
Showing 1 changed file with 11 additions and 21 deletions.
32 changes: 11 additions & 21 deletions beacon_chain/nimbus_beacon_node.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit a770fad

Please sign in to comment.