fix light client topic subscriptions (#6351)

Using `let contextFork = consensusFork` no longer seems to work to avoid
capturing the `var` loop variable; it ends up being `Electra` for all
handlers. Use `closureScope` as a more sustainable fix.
This commit is contained in:
Etan Kissling 2024-06-14 02:45:40 +02:00 committed by GitHub
parent 81e6fe5045
commit b6d6247fa1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 18 additions and 17 deletions

View File

@ -342,25 +342,26 @@ proc installMessageValidators*(
for consensusFork in ConsensusFork: for consensusFork in ConsensusFork:
withLcDataFork(lcDataForkAtConsensusFork(consensusFork)): withLcDataFork(lcDataForkAtConsensusFork(consensusFork)):
when lcDataFork > LightClientDataFork.None: when lcDataFork > LightClientDataFork.None:
let closureScope:
contextFork = consensusFork # Avoid capturing `Deneb` (Nim 1.6) let
digest = forkDigests[].atConsensusFork(contextFork) contextFork = consensusFork
digest = forkDigests[].atConsensusFork(contextFork)
# light_client_optimistic_update # light_client_optimistic_update
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.5/specs/altair/light-client/p2p-interface.md#light_client_finality_update # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.5/specs/altair/light-client/p2p-interface.md#light_client_finality_update
lightClient.network.addValidator( lightClient.network.addValidator(
getLightClientFinalityUpdateTopic(digest), proc ( getLightClientFinalityUpdateTopic(digest), proc (
msg: lcDataFork.LightClientFinalityUpdate msg: lcDataFork.LightClientFinalityUpdate
): ValidationResult = ): ValidationResult =
validate(msg, contextFork, processLightClientFinalityUpdate)) validate(msg, contextFork, processLightClientFinalityUpdate))
# light_client_optimistic_update # light_client_optimistic_update
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.5/specs/altair/light-client/p2p-interface.md#light_client_optimistic_update # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.5/specs/altair/light-client/p2p-interface.md#light_client_optimistic_update
lightClient.network.addValidator( lightClient.network.addValidator(
getLightClientOptimisticUpdateTopic(digest), proc ( getLightClientOptimisticUpdateTopic(digest), proc (
msg: lcDataFork.LightClientOptimisticUpdate msg: lcDataFork.LightClientOptimisticUpdate
): ValidationResult = ): ValidationResult =
validate(msg, contextFork, processLightClientOptimisticUpdate)) validate(msg, contextFork, processLightClientOptimisticUpdate))
proc updateGossipStatus*( proc updateGossipStatus*(
lightClient: LightClient, slot: Slot, dagIsBehind = default(Option[bool])) = lightClient: LightClient, slot: Slot, dagIsBehind = default(Option[bool])) =