Skip to content

Commit

Permalink
feat: proving loop handles repair case
Browse files Browse the repository at this point in the history
  • Loading branch information
AuHau committed Dec 9, 2024
1 parent 26bb7ff commit f568fc0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
5 changes: 5 additions & 0 deletions codex/sales/states/proving.nim
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ logScope:
topics = "marketplace sales proving"

type
SlotFreedError* = object of CatchableError
SlotNotFilledError* = object of CatchableError
SaleProving* = ref object of ErrorHandlingState
loop: Future[void]
Expand Down Expand Up @@ -82,6 +83,10 @@ proc proveLoop(
of SlotState.Cancelled:
debug "Slot reached cancelled state"
# do nothing, let onCancelled callback take care of it
of SlotState.Repair:
warn "Slot was forcible freed"
let message = "Slot was forcible freed and host was removed from its hosting"
raise newException(SlotFreedError, message)

Check warning on line 89 in codex/sales/states/proving.nim

View check run for this annotation

Codecov / codecov/patch

codex/sales/states/proving.nim#L88-L89

Added lines #L88 - L89 were not covered by tests
of SlotState.Failed:
debug "Slot reached failed state"
# do nothing, let onFailed callback take care of it
Expand Down
6 changes: 3 additions & 3 deletions codex/sales/states/unknown.nim
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ method run*(state: SaleUnknown, machine: Machine): Future[?State] {.async.} =
of SlotState.Cancelled:
return some State(SaleCancelled())
of SlotState.Repair:
# TODO: What to do? It could really mean that he was offline for that long that he was kicked out
# from the slot and lost all the collateral. Should we simply "give up" on the slot? Or try
# to "repair" (there is some chance that the dataset is still locally saved) the slot?
# This should never really happen as the Slot is removed from the node's onchain slots tracking
# upon freeing the slot. Hence upon node's restart the slot with the Repair state should not
# be loaded from the onchain.
discard

0 comments on commit f568fc0

Please sign in to comment.