2024-01-25 10:04:09 +00:00
|
|
|
# fluffy
|
|
|
|
# Copyright (c) 2022-2024 Status Research & Development GmbH
|
2022-10-28 07:49:18 +00:00
|
|
|
# Licensed and distributed under either of
|
|
|
|
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
|
|
|
|
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
|
|
|
|
# at your option. This file may not be copied, modified, or distributed except according to those terms.
|
|
|
|
|
2023-01-31 12:38:08 +00:00
|
|
|
{.push raises: [].}
|
2022-10-28 07:49:18 +00:00
|
|
|
|
|
|
|
import
|
|
|
|
std/typetraits,
|
2024-02-28 17:31:45 +00:00
|
|
|
chronos,
|
|
|
|
chronicles,
|
2024-05-30 12:54:03 +00:00
|
|
|
stew/base10,
|
|
|
|
results,
|
2022-10-28 07:49:18 +00:00
|
|
|
eth/p2p/discoveryv5/random2,
|
2024-07-04 05:41:32 +00:00
|
|
|
beacon_chain/spec/datatypes/[phase0, altair, bellatrix, capella, deneb, electra],
|
2023-02-26 18:18:03 +00:00
|
|
|
beacon_chain/spec/[forks_light_client, digest],
|
2022-10-28 07:49:18 +00:00
|
|
|
beacon_chain/beacon_clock,
|
2023-09-22 16:42:02 +00:00
|
|
|
beacon_chain/sync/light_client_sync_helpers,
|
2023-10-20 10:06:25 +00:00
|
|
|
"."/[beacon_network, beacon_content, beacon_db]
|
2022-10-28 07:49:18 +00:00
|
|
|
|
2022-12-02 15:09:31 +00:00
|
|
|
from beacon_chain/consensus_object_pools/block_pools_types import VerifierError
|
2022-10-28 07:49:18 +00:00
|
|
|
|
|
|
|
logScope:
|
2023-03-13 20:30:57 +00:00
|
|
|
topics = "beacon_lc_man"
|
2022-10-28 07:49:18 +00:00
|
|
|
|
|
|
|
type
|
|
|
|
Nothing = object
|
2023-09-22 16:42:02 +00:00
|
|
|
ResponseError = object of CatchableError
|
2022-11-18 09:00:06 +00:00
|
|
|
|
2022-10-28 07:49:18 +00:00
|
|
|
NetRes*[T] = Result[T, void]
|
2024-02-28 17:31:45 +00:00
|
|
|
Endpoint[K, V] = (K, V) # https://github.com/nim-lang/Nim/issues/19531
|
|
|
|
Bootstrap = Endpoint[Eth2Digest, ForkedLightClientBootstrap]
|
|
|
|
UpdatesByRange = Endpoint[
|
|
|
|
tuple[startPeriod: SyncCommitteePeriod, count: uint64], ForkedLightClientUpdate
|
|
|
|
]
|
|
|
|
FinalityUpdate = Endpoint[Slot, ForkedLightClientFinalityUpdate]
|
|
|
|
OptimisticUpdate = Endpoint[Slot, ForkedLightClientOptimisticUpdate]
|
2022-10-28 07:49:18 +00:00
|
|
|
|
2024-06-14 12:21:30 +00:00
|
|
|
ValueVerifier[V] = proc(v: V): Future[Result[void, VerifierError]] {.
|
|
|
|
async: (raises: [CancelledError], raw: true)
|
|
|
|
.}
|
2024-02-28 17:31:45 +00:00
|
|
|
BootstrapVerifier* = ValueVerifier[ForkedLightClientBootstrap]
|
|
|
|
UpdateVerifier* = ValueVerifier[ForkedLightClientUpdate]
|
|
|
|
FinalityUpdateVerifier* = ValueVerifier[ForkedLightClientFinalityUpdate]
|
|
|
|
OptimisticUpdateVerifier* = ValueVerifier[ForkedLightClientOptimisticUpdate]
|
2022-10-28 07:49:18 +00:00
|
|
|
|
2024-02-28 17:31:45 +00:00
|
|
|
GetTrustedBlockRootCallback* = proc(): Option[Eth2Digest] {.gcsafe, raises: [].}
|
|
|
|
GetBoolCallback* = proc(): bool {.gcsafe, raises: [].}
|
|
|
|
GetSlotCallback* = proc(): Slot {.gcsafe, raises: [].}
|
2022-10-28 07:49:18 +00:00
|
|
|
|
|
|
|
LightClientManager* = object
|
2023-10-20 10:06:25 +00:00
|
|
|
network: BeaconNetwork
|
2022-10-28 07:49:18 +00:00
|
|
|
rng: ref HmacDrbgContext
|
|
|
|
getTrustedBlockRoot: GetTrustedBlockRootCallback
|
|
|
|
bootstrapVerifier: BootstrapVerifier
|
|
|
|
updateVerifier: UpdateVerifier
|
|
|
|
finalityUpdateVerifier: FinalityUpdateVerifier
|
|
|
|
optimisticUpdateVerifier: OptimisticUpdateVerifier
|
|
|
|
isLightClientStoreInitialized: GetBoolCallback
|
|
|
|
isNextSyncCommitteeKnown: GetBoolCallback
|
2022-11-18 09:00:06 +00:00
|
|
|
getFinalizedSlot: GetSlotCallback
|
|
|
|
getOptimisticSlot: GetSlotCallback
|
2022-10-28 07:49:18 +00:00
|
|
|
getBeaconTime: GetBeaconTimeFn
|
|
|
|
loopFuture: Future[void]
|
|
|
|
|
|
|
|
func init*(
|
|
|
|
T: type LightClientManager,
|
2023-10-20 10:06:25 +00:00
|
|
|
network: BeaconNetwork,
|
2022-10-28 07:49:18 +00:00
|
|
|
rng: ref HmacDrbgContext,
|
|
|
|
getTrustedBlockRoot: GetTrustedBlockRootCallback,
|
|
|
|
bootstrapVerifier: BootstrapVerifier,
|
|
|
|
updateVerifier: UpdateVerifier,
|
|
|
|
finalityUpdateVerifier: FinalityUpdateVerifier,
|
|
|
|
optimisticUpdateVerifier: OptimisticUpdateVerifier,
|
|
|
|
isLightClientStoreInitialized: GetBoolCallback,
|
|
|
|
isNextSyncCommitteeKnown: GetBoolCallback,
|
2022-11-18 09:00:06 +00:00
|
|
|
getFinalizedSlot: GetSlotCallback,
|
|
|
|
getOptimisticSlot: GetSlotCallback,
|
2024-02-28 17:31:45 +00:00
|
|
|
getBeaconTime: GetBeaconTimeFn,
|
2022-10-28 07:49:18 +00:00
|
|
|
): LightClientManager =
|
|
|
|
## Initialize light client manager.
|
|
|
|
LightClientManager(
|
|
|
|
network: network,
|
|
|
|
rng: rng,
|
|
|
|
getTrustedBlockRoot: getTrustedBlockRoot,
|
|
|
|
bootstrapVerifier: bootstrapVerifier,
|
|
|
|
updateVerifier: updateVerifier,
|
|
|
|
finalityUpdateVerifier: finalityUpdateVerifier,
|
|
|
|
optimisticUpdateVerifier: optimisticUpdateVerifier,
|
|
|
|
isLightClientStoreInitialized: isLightClientStoreInitialized,
|
|
|
|
isNextSyncCommitteeKnown: isNextSyncCommitteeKnown,
|
2022-11-18 09:00:06 +00:00
|
|
|
getFinalizedSlot: getFinalizedSlot,
|
|
|
|
getOptimisticSlot: getOptimisticSlot,
|
2024-02-28 17:31:45 +00:00
|
|
|
getBeaconTime: getBeaconTime,
|
2022-10-28 07:49:18 +00:00
|
|
|
)
|
|
|
|
|
2023-02-26 18:18:03 +00:00
|
|
|
proc getFinalizedPeriod(self: LightClientManager): SyncCommitteePeriod =
|
|
|
|
self.getFinalizedSlot().sync_committee_period
|
|
|
|
|
|
|
|
proc getOptimisticPeriod(self: LightClientManager): SyncCommitteePeriod =
|
|
|
|
self.getOptimisticSlot().sync_committee_period
|
|
|
|
|
2023-09-22 16:42:02 +00:00
|
|
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/altair/light-client/p2p-interface.md#getlightclientbootstrap
|
2022-10-28 07:49:18 +00:00
|
|
|
proc doRequest(
|
2024-02-28 17:31:45 +00:00
|
|
|
e: typedesc[Bootstrap], n: BeaconNetwork, blockRoot: Eth2Digest
|
2024-06-14 12:21:30 +00:00
|
|
|
): Future[NetRes[ForkedLightClientBootstrap]] {.
|
|
|
|
async: (raises: [CancelledError], raw: true)
|
|
|
|
.} =
|
2022-10-28 07:49:18 +00:00
|
|
|
n.getLightClientBootstrap(blockRoot)
|
|
|
|
|
2023-09-22 16:42:02 +00:00
|
|
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/altair/light-client/p2p-interface.md#lightclientupdatesbyrange
|
2023-02-26 18:18:03 +00:00
|
|
|
type LightClientUpdatesByRangeResponse = NetRes[ForkedLightClientUpdateList]
|
2022-10-28 07:49:18 +00:00
|
|
|
proc doRequest(
|
|
|
|
e: typedesc[UpdatesByRange],
|
2023-10-20 10:06:25 +00:00
|
|
|
n: BeaconNetwork,
|
2024-02-28 17:31:45 +00:00
|
|
|
key: tuple[startPeriod: SyncCommitteePeriod, count: uint64],
|
2024-06-14 12:21:30 +00:00
|
|
|
): Future[LightClientUpdatesByRangeResponse] {.
|
|
|
|
async: (raises: [ResponseError, CancelledError])
|
|
|
|
.} =
|
2023-09-22 16:42:02 +00:00
|
|
|
let (startPeriod, count) = key
|
|
|
|
doAssert count > 0 and count <= MAX_REQUEST_LIGHT_CLIENT_UPDATES
|
|
|
|
let response = await n.getLightClientUpdatesByRange(startPeriod, count)
|
|
|
|
if response.isOk:
|
2024-02-28 17:31:45 +00:00
|
|
|
let e = distinctBase(response.get).checkLightClientUpdates(startPeriod, count)
|
2023-09-22 16:42:02 +00:00
|
|
|
if e.isErr:
|
|
|
|
raise newException(ResponseError, e.error)
|
|
|
|
return response
|
|
|
|
|
|
|
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/altair/light-client/p2p-interface.md#getlightclientfinalityupdate
|
2022-10-28 07:49:18 +00:00
|
|
|
proc doRequest(
|
2024-02-28 17:31:45 +00:00
|
|
|
e: typedesc[FinalityUpdate], n: BeaconNetwork, finalizedSlot: Slot
|
2024-06-14 12:21:30 +00:00
|
|
|
): Future[NetRes[ForkedLightClientFinalityUpdate]] {.
|
|
|
|
async: (raises: [CancelledError], raw: true)
|
|
|
|
.} =
|
2024-02-28 17:31:45 +00:00
|
|
|
n.getLightClientFinalityUpdate(distinctBase(finalizedSlot))
|
2022-10-28 07:49:18 +00:00
|
|
|
|
2023-09-22 16:42:02 +00:00
|
|
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/altair/light-client/p2p-interface.md#getlightclientoptimisticupdate
|
2022-10-28 07:49:18 +00:00
|
|
|
proc doRequest(
|
2024-02-28 17:31:45 +00:00
|
|
|
e: typedesc[OptimisticUpdate], n: BeaconNetwork, optimisticSlot: Slot
|
2024-06-14 12:21:30 +00:00
|
|
|
): Future[NetRes[ForkedLightClientOptimisticUpdate]] {.
|
|
|
|
async: (raises: [CancelledError], raw: true)
|
|
|
|
.} =
|
2022-11-18 09:00:06 +00:00
|
|
|
n.getLightClientOptimisticUpdate(distinctBase(optimisticSlot))
|
2022-10-28 07:49:18 +00:00
|
|
|
|
|
|
|
template valueVerifier[E](
|
2024-02-28 17:31:45 +00:00
|
|
|
self: LightClientManager, e: typedesc[E]
|
2022-10-28 07:49:18 +00:00
|
|
|
): ValueVerifier[E.V] =
|
2023-02-26 18:18:03 +00:00
|
|
|
when E.V is ForkedLightClientBootstrap:
|
2022-10-28 07:49:18 +00:00
|
|
|
self.bootstrapVerifier
|
2023-02-26 18:18:03 +00:00
|
|
|
elif E.V is ForkedLightClientUpdate:
|
2022-10-28 07:49:18 +00:00
|
|
|
self.updateVerifier
|
2023-02-26 18:18:03 +00:00
|
|
|
elif E.V is ForkedLightClientFinalityUpdate:
|
2022-10-28 07:49:18 +00:00
|
|
|
self.finalityUpdateVerifier
|
2023-02-26 18:18:03 +00:00
|
|
|
elif E.V is ForkedLightClientOptimisticUpdate:
|
2022-10-28 07:49:18 +00:00
|
|
|
self.optimisticUpdateVerifier
|
2024-02-28 17:31:45 +00:00
|
|
|
else:
|
|
|
|
static:
|
|
|
|
doAssert false
|
2022-10-28 07:49:18 +00:00
|
|
|
|
|
|
|
iterator values(v: auto): auto =
|
|
|
|
## Local helper for `workerTask` to share the same implementation for both
|
|
|
|
## scalar and aggregate values, by treating scalars as 1-length aggregates.
|
2023-02-26 18:18:03 +00:00
|
|
|
when v is List:
|
2022-10-28 07:49:18 +00:00
|
|
|
for i in v:
|
|
|
|
yield i
|
|
|
|
else:
|
|
|
|
yield v
|
|
|
|
|
|
|
|
proc workerTask[E](
|
2024-02-28 17:31:45 +00:00
|
|
|
self: LightClientManager, e: typedesc[E], key: E.K
|
2024-06-14 12:21:30 +00:00
|
|
|
): Future[bool] {.async: (raises: [CancelledError]).} =
|
2024-02-28 17:31:45 +00:00
|
|
|
var didProgress = false
|
2022-10-28 07:49:18 +00:00
|
|
|
try:
|
|
|
|
let value =
|
|
|
|
when E.K is Nothing:
|
|
|
|
await E.doRequest(self.network)
|
|
|
|
else:
|
|
|
|
await E.doRequest(self.network, key)
|
|
|
|
if value.isOk:
|
2023-02-26 18:18:03 +00:00
|
|
|
for val in value.get().values:
|
2022-10-28 07:49:18 +00:00
|
|
|
let res = await self.valueVerifier(E)(val)
|
|
|
|
if res.isErr:
|
|
|
|
case res.error
|
2022-12-02 15:09:31 +00:00
|
|
|
of VerifierError.MissingParent:
|
2022-10-28 07:49:18 +00:00
|
|
|
# Stop, requires different request to progress
|
|
|
|
return didProgress
|
2022-12-02 15:09:31 +00:00
|
|
|
of VerifierError.Duplicate:
|
2022-10-28 07:49:18 +00:00
|
|
|
# Ignore, a concurrent request may have already fulfilled this
|
2023-02-26 18:18:03 +00:00
|
|
|
when E.V is ForkedLightClientBootstrap:
|
2022-10-28 07:49:18 +00:00
|
|
|
didProgress = true
|
|
|
|
else:
|
|
|
|
discard
|
2022-12-02 15:09:31 +00:00
|
|
|
of VerifierError.UnviableFork:
|
2023-02-26 18:18:03 +00:00
|
|
|
withForkyObject(val):
|
|
|
|
when lcDataFork > LightClientDataFork.None:
|
|
|
|
notice "Received value from an unviable fork",
|
|
|
|
value = forkyObject, endpoint = E.name
|
|
|
|
else:
|
2024-02-28 17:31:45 +00:00
|
|
|
notice "Received value from an unviable fork", endpoint = E.name
|
2022-10-28 07:49:18 +00:00
|
|
|
return didProgress
|
2022-12-02 15:09:31 +00:00
|
|
|
of VerifierError.Invalid:
|
2023-02-26 18:18:03 +00:00
|
|
|
withForkyObject(val):
|
|
|
|
when lcDataFork > LightClientDataFork.None:
|
2024-02-28 17:31:45 +00:00
|
|
|
warn "Received invalid value",
|
|
|
|
value = forkyObject.shortLog, endpoint = E.name
|
2023-02-26 18:18:03 +00:00
|
|
|
else:
|
|
|
|
warn "Received invalid value", endpoint = E.name
|
2022-10-28 07:49:18 +00:00
|
|
|
return didProgress
|
|
|
|
else:
|
2023-10-18 14:59:44 +00:00
|
|
|
# TODO:
|
|
|
|
# This is data coming from either the network or the database.
|
|
|
|
# Either way it comes in encoded and is passed along till here in its
|
|
|
|
# decoded format. It only gets stored in the database here as it is
|
|
|
|
# required to pass validation first ( didprogress == true). Next it
|
|
|
|
# gets encoded again before dropped in the database. Optimisations
|
|
|
|
# are possible here if the beacon_light_client_manager and the
|
|
|
|
# manager are better interfaced with each other.
|
|
|
|
when E.V is ForkedLightClientBootstrap:
|
|
|
|
withForkyObject(val):
|
|
|
|
when lcDataFork > LightClientDataFork.None:
|
2023-10-20 10:06:25 +00:00
|
|
|
self.network.beaconDb.putBootstrap(key, val)
|
2023-10-18 14:59:44 +00:00
|
|
|
else:
|
2024-02-28 17:31:45 +00:00
|
|
|
notice "Received value from an unviable fork", endpoint = E.name
|
2023-10-18 14:59:44 +00:00
|
|
|
elif E.V is ForkedLightClientUpdate:
|
|
|
|
withForkyObject(val):
|
|
|
|
when lcDataFork > LightClientDataFork.None:
|
|
|
|
let period =
|
|
|
|
forkyObject.attested_header.beacon.slot.sync_committee_period
|
2023-10-20 10:06:25 +00:00
|
|
|
self.network.beaconDb.putUpdateIfBetter(period, val)
|
2023-10-18 14:59:44 +00:00
|
|
|
else:
|
2024-02-28 17:31:45 +00:00
|
|
|
notice "Received value from an unviable fork", endpoint = E.name
|
2023-10-18 14:59:44 +00:00
|
|
|
|
2022-10-28 07:49:18 +00:00
|
|
|
didProgress = true
|
|
|
|
else:
|
2023-09-22 16:42:02 +00:00
|
|
|
debug "Failed to receive value on request", value, endpoint = E.name
|
|
|
|
except ResponseError as exc:
|
|
|
|
warn "Received invalid response", error = exc.msg, endpoint = E.name
|
2022-10-28 07:49:18 +00:00
|
|
|
except CancelledError as exc:
|
|
|
|
raise exc
|
|
|
|
|
|
|
|
return didProgress
|
|
|
|
|
2024-06-14 12:21:30 +00:00
|
|
|
proc query[E](
|
|
|
|
self: LightClientManager, e: typedesc[E], key: E.K
|
|
|
|
): Future[bool] {.async: (raises: [CancelledError], raw: true).} =
|
2023-09-22 16:42:02 +00:00
|
|
|
# Note:
|
|
|
|
# The libp2p version does concurrent requests here. But it seems to be done
|
|
|
|
# for the same key and thus as redundant request to avoid waiting on a not
|
|
|
|
# responding peer.
|
|
|
|
# In Portal this is already build into the lookups and thus not really
|
|
|
|
# needed. On difference important is that the lookup concurrent requests are
|
|
|
|
# already getting canceled when 1 peer returns the content but before the
|
|
|
|
# content gets validated. This is improvement to do for all Portal content
|
|
|
|
# requests however, see: https://github.com/status-im/nimbus-eth1/issues/1769
|
|
|
|
self.workerTask(e, key)
|
2022-10-28 07:49:18 +00:00
|
|
|
|
2023-09-22 16:42:02 +00:00
|
|
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/altair/light-client/light-client.md#light-client-sync-process
|
2024-06-14 12:21:30 +00:00
|
|
|
proc loop(self: LightClientManager) {.async: (raises: [CancelledError]).} =
|
2023-09-22 16:42:02 +00:00
|
|
|
var nextSyncTaskTime = self.getBeaconTime()
|
2022-10-28 07:49:18 +00:00
|
|
|
while true:
|
|
|
|
# Periodically wake and check for changes
|
|
|
|
let wallTime = self.getBeaconTime()
|
2023-09-22 16:42:02 +00:00
|
|
|
if wallTime < nextSyncTaskTime:
|
2022-10-28 07:49:18 +00:00
|
|
|
await sleepAsync(chronos.seconds(2))
|
|
|
|
continue
|
|
|
|
|
|
|
|
# Obtain bootstrap data once a trusted block root is supplied
|
|
|
|
if not self.isLightClientStoreInitialized():
|
|
|
|
let trustedBlockRoot = self.getTrustedBlockRoot()
|
|
|
|
if trustedBlockRoot.isNone:
|
|
|
|
await sleepAsync(chronos.seconds(2))
|
|
|
|
continue
|
|
|
|
|
|
|
|
let didProgress = await self.query(Bootstrap, trustedBlockRoot.get)
|
2023-09-22 16:42:02 +00:00
|
|
|
nextSyncTaskTime =
|
|
|
|
if didProgress:
|
|
|
|
wallTime
|
|
|
|
else:
|
|
|
|
wallTime + self.rng.computeDelayWithJitter(chronos.seconds(0))
|
2022-10-28 07:49:18 +00:00
|
|
|
continue
|
|
|
|
|
|
|
|
# Fetch updates
|
|
|
|
let
|
2023-09-22 16:42:02 +00:00
|
|
|
current = wallTime.slotOrZero().sync_committee_period
|
|
|
|
|
|
|
|
syncTask = nextLightClientSyncTask(
|
|
|
|
current = current,
|
|
|
|
finalized = self.getFinalizedPeriod(),
|
|
|
|
optimistic = self.getOptimisticPeriod(),
|
2024-02-28 17:31:45 +00:00
|
|
|
isNextSyncCommitteeKnown = self.isNextSyncCommitteeKnown(),
|
|
|
|
)
|
2023-09-22 16:42:02 +00:00
|
|
|
|
2022-10-28 07:49:18 +00:00
|
|
|
didProgress =
|
2023-09-22 16:42:02 +00:00
|
|
|
case syncTask.kind
|
|
|
|
of LcSyncKind.UpdatesByRange:
|
2024-02-28 17:31:45 +00:00
|
|
|
await self.query(
|
|
|
|
UpdatesByRange, (startPeriod: syncTask.startPeriod, count: syncTask.count)
|
|
|
|
)
|
2023-09-22 16:42:02 +00:00
|
|
|
of LcSyncKind.FinalityUpdate:
|
2023-10-06 13:46:53 +00:00
|
|
|
let finalizedSlot = start_slot(epoch(wallTime.slotOrZero()) - 2)
|
|
|
|
await self.query(FinalityUpdate, finalizedSlot)
|
2023-09-22 16:42:02 +00:00
|
|
|
of LcSyncKind.OptimisticUpdate:
|
2023-10-06 15:42:34 +00:00
|
|
|
let optimisticSlot = wallTime.slotOrZero()
|
2022-11-18 09:00:06 +00:00
|
|
|
await self.query(OptimisticUpdate, optimisticSlot)
|
2022-10-28 07:49:18 +00:00
|
|
|
|
2024-02-28 17:31:45 +00:00
|
|
|
nextSyncTaskTime =
|
|
|
|
wallTime +
|
|
|
|
self.rng.nextLcSyncTaskDelay(
|
|
|
|
wallTime,
|
|
|
|
finalized = self.getFinalizedPeriod(),
|
|
|
|
optimistic = self.getOptimisticPeriod(),
|
|
|
|
isNextSyncCommitteeKnown = self.isNextSyncCommitteeKnown(),
|
|
|
|
didLatestSyncTaskProgress = didProgress,
|
|
|
|
)
|
2022-10-28 07:49:18 +00:00
|
|
|
|
|
|
|
proc start*(self: var LightClientManager) =
|
|
|
|
## Start light client manager's loop.
|
|
|
|
doAssert self.loopFuture == nil
|
|
|
|
self.loopFuture = self.loop()
|
|
|
|
|
2024-06-14 12:21:30 +00:00
|
|
|
proc stop*(self: var LightClientManager) {.async: (raises: []).} =
|
2022-10-28 07:49:18 +00:00
|
|
|
## Stop light client manager's loop.
|
|
|
|
if self.loopFuture != nil:
|
2024-06-14 12:21:30 +00:00
|
|
|
await noCancel self.loopFuture.cancelAndWait()
|
2022-10-28 07:49:18 +00:00
|
|
|
self.loopFuture = nil
|