@@ -291,7 +291,7 @@ proc initFullNode(
291291 rng: ref HmacDrbgContext ,
292292 dag: ChainDAGRef ,
293293 clist: ChainListRef ,
294- taskpool: TaskPoolPtr ,
294+ taskpool: Taskpool ,
295295 getBeaconTime: GetBeaconTimeFn ) {.async .} =
296296 template config (): auto = node.config
297297
@@ -417,7 +417,7 @@ proc initFullNode(
417417 blobQuarantine = newClone (BlobQuarantine .init (onBlobSidecarAdded))
418418 dataColumnQuarantine = newClone (DataColumnQuarantine .init ())
419419 supernode = node.config.subscribeAllSubnets
420- localCustodySubnets =
420+ localCustodySubnets =
421421 if supernode:
422422 DATA_COLUMN_SIDECAR_SUBNET_COUNT .uint64
423423 else :
@@ -529,28 +529,28 @@ proc initFullNode(
529529 (proc (): bool = syncManager.inProgress),
530530 quarantine, blobQuarantine, rmanBlockVerifier,
531531 rmanBlockLoader, rmanBlobLoader)
532-
533- # As per EIP 7594, the BN is now categorised into a
532+
533+ # As per EIP 7594, the BN is now categorised into a
534534 # `Fullnode` and a `Supernode`, the fullnodes custodies a
535535 # given set of data columns, and hence ONLY subcribes to those
536536 # data column subnet topics, however, the supernodes subscribe
537537 # to all of the topics. This in turn keeps our `data column quarantine`
538538 # really variable. Whenever the BN is a supernode, column quarantine
539- # essentially means all the NUMBER_OF_COLUMNS, as per mentioned in the
539+ # essentially means all the NUMBER_OF_COLUMNS, as per mentioned in the
540540 # spec. However, in terms of fullnode, quarantine is really dependent
541541 # on the randomly assigned columns, by `get_custody_columns`.
542542
543543 # Hence, in order to keep column quarantine accurate and error proof
544544 # the custody columns are computed once as the BN boots. Then the values
545- # are used globally around the codebase.
545+ # are used globally around the codebase.
546546
547547 # `get_custody_columns` is not a very expensive function, but there
548- # are multiple instances of computing custody columns, especially
548+ # are multiple instances of computing custody columns, especially
549549 # during peer selection, sync with columns, and so on. That is why,
550550 # the rationale of populating it at boot and using it gloabally.
551551
552552 dataColumnQuarantine[].supernode = supernode
553- dataColumnQuarantine[].custody_columns =
553+ dataColumnQuarantine[].custody_columns =
554554 node.network.nodeId.get_custody_columns (max (SAMPLES_PER_SLOT .uint64 ,
555555 localCustodySubnets))
556556 if node.config.lightClientDataServe:
@@ -654,7 +654,6 @@ proc init*(T: type BeaconNode,
654654 metadata: Eth2NetworkMetadata ): Future [BeaconNode ]
655655 {.async .} =
656656 var
657- taskpool: TaskPoolPtr
658657 genesisState: ref ForkedHashedBeaconState = nil
659658
660659 template cfg : auto = metadata.cfg
@@ -690,18 +689,20 @@ proc init*(T: type BeaconNode,
690689 altair_fork_epoch = metadata.cfg.ALTAIR_FORK_EPOCH
691690 quit 1
692691
693- try :
694- if config.numThreads < 0 :
695- fatal " The number of threads --numThreads cannot be negative."
692+ let taskpool =
693+ try :
694+ if config.numThreads < 0 :
695+ fatal " The number of threads --num-threads cannot be negative."
696+ quit 1
697+ elif config.numThreads == 0 :
698+ Taskpool .new (numThreads = min (countProcessors (), 16 ))
699+ else :
700+ Taskpool .new (numThreads = config.numThreads)
701+ except CatchableError as e:
702+ fatal " Cannot start taskpool" , err = e.msg
696703 quit 1
697- elif config.numThreads == 0 :
698- taskpool = TaskPoolPtr .new (numThreads = min (countProcessors (), 16 ))
699- else :
700- taskpool = TaskPoolPtr .new (numThreads = config.numThreads)
701704
702- info " Threadpool started" , numThreads = taskpool.numThreads
703- except Exception :
704- raise newException (Defect , " Failure in taskpool initialization." )
705+ info " Threadpool started" , numThreads = taskpool.numThreads
705706
706707 if metadata.genesis.kind == BakedIn :
707708 if config.genesisState.isSome:
0 commit comments