Skip to content

Commit

Permalink
fix(validation): asyncSpawns run
Browse files Browse the repository at this point in the history
- annotates run with raises: []
- asyncSpawns run, to ensure there are no escaping exceptions
  • Loading branch information
emizzle committed Dec 13, 2024
1 parent 19af797 commit 6f8e0d1
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions codex/validation.nim
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ proc markProofsAsMissing(validation: Validation) {.async.} =
let previousPeriod = validation.getCurrentPeriod() - 1
await validation.markProofAsMissing(slotId, previousPeriod)

proc run(validation: Validation) {.async.} =
proc run(validation: Validation) {.async: (raises: []).} =
trace "Validation started"
try:
while true:
Expand All @@ -115,7 +115,7 @@ proc run(validation: Validation) {.async.} =
await validation.markProofsAsMissing()
except CancelledError:
trace "Validation stopped"
discard
discard # do not propagate as run is asyncSpawned
except CatchableError as e:
error "Validation failed", msg = e.msg

Expand All @@ -124,6 +124,7 @@ proc start*(validation: Validation) {.async.} =
validation.proofTimeout = await validation.market.proofTimeout()
await validation.subscribeSlotFilled()
validation.running = validation.run()
asyncSpawn validation.running

proc stop*(validation: Validation) {.async.} =
await validation.running.cancelAndWait()
Expand Down

0 comments on commit 6f8e0d1

Please sign in to comment.