Fix proving with latest ethers bump (tested on master)

This commit is contained in:
Eric 2023-09-28 16:58:13 +10:00
parent 9e421e4a81
commit 6ba03b7a14
No known key found for this signature in database
2 changed files with 16 additions and 12 deletions

View File

@ -1,6 +1,7 @@
import std/options
import pkg/chronicles
import ../../clock
import ../../utils/exceptions
import ../statemachine
import ../salesagent
import ../salescontext
@ -29,8 +30,10 @@ method prove*(
let proof = await onProve(slot)
debug "Submitting proof", currentPeriod = currentPeriod, slotId = $slot.id
await market.submitProof(slot.id, proof)
except CancelledError:
discard
except CatchableError as e:
error "Submitting proof failed", msg = e.msg
error "Submitting proof failed", msg = e.msgDetail
proc proveLoop(
state: SaleProving,
@ -84,7 +87,7 @@ method onCancelled*(state: SaleProving, request: StorageRequest): ?State =
try:
waitFor state.loop.cancelAndWait()
except CatchableError as e:
error "Error during cancelation of prooving loop", msg = e.msg
error "Error during cancellation of proving loop", msg = e.msg
state.loop = nil
@ -96,7 +99,7 @@ method onFailed*(state: SaleProving, request: StorageRequest): ?State =
try:
waitFor state.loop.cancelAndWait()
except CatchableError as e:
error "Error during cancelation of prooving loop", msg = e.msg
error "Error during cancellation of proving loop", msg = e.msg
state.loop = nil
@ -136,12 +139,12 @@ method run*(state: SaleProving, machine: Machine): Future[?State] {.async.} =
debug "Stopping proving.", requestId = $data.requestId, slotIndex
if not state.loop.isNil:
if not state.loop.finished:
try:
await state.loop.cancelAndWait()
except CatchableError as e:
error "Error during cancelation of prooving loop", msg = e.msg
if not state.loop.finished:
try:
await state.loop.cancelAndWait()
except CatchableError as e:
error "Error during cancellation of proving loop", msg = e.msg
state.loop = nil
state.loop = nil
return some State(SalePayout())

View File

@ -8,6 +8,7 @@ when codex_enable_proof_failures:
import ../../contracts/requests
import ../../market
import ../../utils/exceptions
import ../salescontext
import ./proving
@ -20,7 +21,7 @@ when codex_enable_proof_failures:
proofCount: int
proc onSubmitProofError(error: ref CatchableError, period: UInt256, slotId: SlotId) =
error "Submitting invalid proof failed", period = period, slotId = $slotId, msg = error.msg
error "Submitting invalid proof failed", period = period, slotId = $slotId, msg = error.msgDetail
method prove*(state: SaleProvingSimulated, slot: Slot, onProve: OnProve, market: Market, currentPeriod: Period) {.async.} =
trace "Processing proving in simulated mode"
@ -32,8 +33,8 @@ when codex_enable_proof_failures:
try:
warn "Submitting INVALID proof", period = currentPeriod, slotId = slot.id
await market.submitProof(slot.id, newSeq[byte](0))
except ProviderError as e:
if not e.revertReason.contains("Invalid proof"):
except SignerError as e:
if not e.msgDetail.contains("Invalid proof"):
onSubmitProofError(e, currentPeriod, slot.id)
except CatchableError as e:
onSubmitProofError(e, currentPeriod, slot.id)