Skip to content

Commit 031d24f

Browse files
authored
taskpools: bump (#6757)
* taskpools: bump * better raises effects * get rid of custom naming * bump * oops * bump stable
1 parent 7d81ee1 commit 031d24f

File tree

6 files changed

+27
-28
lines changed

6 files changed

+27
-28
lines changed

beacon_chain/gossip_processing/batch_validation.nim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ type
144144

145145
proc new*(
146146
T: type BatchCrypto, rng: ref HmacDrbgContext,
147-
eager: Eager, genesis_validators_root: Eth2Digest, taskpool: TaskPoolPtr):
147+
eager: Eager, genesis_validators_root: Eth2Digest, taskpool: Taskpool):
148148
Result[ref BatchCrypto, string] =
149149
let res = (ref BatchCrypto)(
150150
rng: rng, taskpool: taskpool,

beacon_chain/gossip_processing/eth2_processor.nim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ proc new*(T: type Eth2Processor,
169169
blobQuarantine: ref BlobQuarantine,
170170
rng: ref HmacDrbgContext,
171171
getBeaconTime: GetBeaconTimeFn,
172-
taskpool: TaskPoolPtr
172+
taskpool: Taskpool
173173
): ref Eth2Processor =
174174
(ref Eth2Processor)(
175175
doppelgangerDetectionEnabled: doppelgangerDetectionEnabled,

beacon_chain/nimbus_beacon_node.nim

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -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:

beacon_chain/spec/signatures_batch.nim

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,16 @@ import
2626
export results, rand, altair, phase0, taskpools, signatures
2727

2828
type
29-
TaskPoolPtr* = Taskpool
30-
3129
BatchVerifier* = object
3230
sigVerifCache*: BatchedBLSVerifierCache
3331
## A cache for batch BLS signature verification contexts
3432
rng*: ref HmacDrbgContext
3533
## A reference to the Nimbus application-wide RNG
36-
taskpool*: TaskPoolPtr
34+
taskpool*: Taskpool
3735

3836
proc init*(
3937
T: type BatchVerifier, rng: ref HmacDrbgContext,
40-
taskpool: TaskPoolPtr): BatchVerifier =
38+
taskpool: Taskpool): BatchVerifier =
4139
BatchVerifier(
4240
sigVerifCache: BatchedBLSVerifierCache.init(taskpool),
4341
rng: rng,
@@ -46,7 +44,7 @@ proc init*(
4644

4745
proc new*(
4846
T: type BatchVerifier, rng: ref HmacDrbgContext,
49-
taskpool: TaskPoolPtr): ref BatchVerifier =
47+
taskpool: Taskpool): ref BatchVerifier =
5048
(ref BatchVerifier)(
5149
sigVerifCache: BatchedBLSVerifierCache.init(taskpool),
5250
rng: rng,

tests/consensus_spec/test_fixture_light_client_data_collection.nim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ proc runTest(suiteName, path: string, consensusFork: static ConsensusFork) =
144144
lcDataConfig = LightClientDataConfig(
145145
serve: true, importMode: LightClientDataImportMode.Full))
146146
rng = HmacDrbgContext.new()
147-
taskpool = TaskPool.new()
147+
taskpool = Taskpool.new()
148148
var
149149
verifier = BatchVerifier.init(rng, taskpool)
150150
quarantine = newClone(Quarantine.init())

0 commit comments

Comments
 (0)