diff --git a/beacon_chain/gossip_processing/batch_validation.nim b/beacon_chain/gossip_processing/batch_validation.nim index 55648c8d4..1fa749754 100644 --- a/beacon_chain/gossip_processing/batch_validation.nim +++ b/beacon_chain/gossip_processing/batch_validation.nim @@ -228,6 +228,13 @@ proc batchVerifyTask(task: ptr BatchTask) {.nimcall.} = discard task[].signal.fireSync() +proc spawnBatchVerifyTask(tp: Taskpool, task: ptr BatchTask) = + # Inlining this `proc` leads to compilation problems on Nim 2.0 + # - Error: cannot generate destructor for generic type: Isolated + # Workaround: Ensure that `tp.spawn` is not used within an `{.async.}` proc + # Possibly related to: https://github.com/nim-lang/Nim/issues/22305 + tp.spawn batchVerifyTask(task) + proc batchVerifyAsync*( verifier: ref BatchVerifier, signal: ThreadSignalPtr, batch: ref Batch): Future[bool] {.async.} = @@ -245,7 +252,7 @@ proc batchVerifyAsync*( let taskPtr = addr task doAssert verifier[].taskpool.numThreads > 1, "Must have at least one separate thread or signal will never be fired" - verifier[].taskpool.spawn batchVerifyTask(taskPtr) + verifier[].taskpool.spawnBatchVerifyTask(taskPtr) await signal.wait() task.ok.load()