Skip to content

Commit 9dea200

Browse files
authored
Add option to light client to sync finality to engine API (#7735)
Enable the `nimbus_light_client` to sync the finalized block hash to the execution layers via startup flag `--sync-light-client-finality`.
1 parent 4b6ef8d commit 9dea200

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

beacon_chain/conf_light_client.nim

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,11 @@ type LightClientConf* = object
117117
desc: "Recent trusted finalized block root to initialize light client from"
118118
name: "trusted-block-root" .}: Eth2Digest
119119

120+
syncLightClientFinality* {.
121+
desc: "Whether the light client should including finality information when syncing execution layers"
122+
defaultValue: false
123+
name: "sync-light-client-finality" .}: bool
124+
120125
# Execution layer
121126
web3Urls* {.
122127
desc: "One or more execution layer Engine API URLs"

beacon_chain/nimbus_light_client.nim

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,12 +179,25 @@ proc main() {.noinline, raises: [CatchableError].} =
179179
not isSynced(bid.slot, beaconClock.currentSlot):
180180
return
181181

182+
let finalizedBlockHash =
183+
if config.syncLightClientFinality:
184+
let finalizedHeader = lightClient.finalizedHeader
185+
withForkyHeader(finalizedHeader):
186+
when lcDataFork >= LightClientDataFork.Capella:
187+
forkyHeader.execution.block_hash
188+
else:
189+
ZERO_HASH
190+
else:
191+
ZERO_HASH
192+
182193
withConsensusFork(consensusFork):
183194
when lcDataForkAtConsensusFork(consensusFork) == lcDataFork:
195+
debug "Sending forkchoiceUpdated",
196+
finalizedBlockHash = finalizedBlockHash
184197
optimisticFcuFut = elManager.forkchoiceUpdated(
185198
headBlockHash = blockHash,
186-
safeBlockHash = blockHash, # stub value
187-
finalizedBlockHash = ZERO_HASH,
199+
safeBlockHash = finalizedBlockHash, # justified not available
200+
finalizedBlockHash = finalizedBlockHash,
188201
payloadAttributes = Opt.none(consensusFork.PayloadAttributes))
189202
optimisticFcuFut.addCallback do (future: pointer):
190203
optimisticFcuFut = nil

0 commit comments

Comments
 (0)