Skip to content

Commit 2e1306a

Browse files
authored
chore: fix custom error handling when simulating invalid proofs (#1217)
* Fix custom error handling when simulating invalid proofs * Update error message
1 parent 45ade0e commit 2e1306a

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

codex/contracts/market.nim

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,12 @@ method submitProof*(
366366
market: OnChainMarket, id: SlotId, proof: Groth16Proof
367367
) {.async: (raises: [CancelledError, MarketError]).} =
368368
convertEthersError("Failed to submit proof"):
369-
discard await market.contract.submitProof(id, proof).confirm(1)
369+
try:
370+
discard await market.contract.submitProof(id, proof).confirm(1)
371+
except Proofs_InvalidProof as parent:
372+
raise newException(
373+
ProofInvalidError, "Failed to submit proof because the proof is invalid", parent
374+
)
370375

371376
method markProofAsMissing*(
372377
market: OnChainMarket, id: SlotId, period: Period

codex/market.nim

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ type
2020
MarketError* = object of CodexError
2121
SlotStateMismatchError* = object of MarketError
2222
SlotReservationNotAllowedError* = object of MarketError
23+
ProofInvalidError* = object of MarketError
2324
Subscription* = ref object of RootObj
2425
OnRequest* =
2526
proc(id: RequestId, ask: StorageAsk, expiry: uint64) {.gcsafe, upraises: [].}

codex/sales/states/provingsimulated.nim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ when codex_enable_proof_failures:
4040
try:
4141
warn "Submitting INVALID proof", period = currentPeriod, slotId = slot.id
4242
await market.submitProof(slot.id, Groth16Proof.default)
43-
except Proofs_InvalidProof as e:
43+
except ProofInvalidError as e:
4444
discard # expected
4545
except CancelledError as error:
4646
raise error

0 commit comments

Comments
 (0)