chore: improve log information (#656)

* Add proof downtime to validator logs

* Add previous state to state machine transition log
This commit is contained in:
Eric 2023-12-19 15:29:18 +11:00 committed by GitHub
parent 39554c8ea9
commit 2c621e0421
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 29 additions and 2 deletions

View File

@ -50,6 +50,13 @@ method proofTimeout*(market: OnChainMarket): Future[UInt256] {.async.} =
let config = await market.contract.config() let config = await market.contract.config()
return config.proofs.timeout return config.proofs.timeout
method proofDowntime*(market: OnChainMarket): Future[uint8] {.async.} =
let config = await market.contract.config()
return config.proofs.downtime
method getPointer*(market: OnChainMarket, slotId: SlotId): Future[uint8] {.async.} =
return await market.contract.getPointer(slotId)
method myRequests*(market: OnChainMarket): Future[seq[RequestId]] {.async.} = method myRequests*(market: OnChainMarket): Future[seq[RequestId]] {.async.} =
return await market.contract.myRequests return await market.contract.myRequests

View File

@ -39,6 +39,17 @@ method periodicity*(market: Market): Future[Periodicity] {.base, async.} =
method proofTimeout*(market: Market): Future[UInt256] {.base, async.} = method proofTimeout*(market: Market): Future[UInt256] {.base, async.} =
raiseAssert("not implemented") raiseAssert("not implemented")
method proofDowntime*(market: Market): Future[uint8] {.base, async.} =
raiseAssert("not implemented")
method getPointer*(market: Market, slotId: SlotId): Future[uint8] {.base, async.} =
raiseAssert("not implemented")
proc inDowntime*(market: Market, slotId: SlotId): Future[bool] {.async.} =
let downtime = await market.proofDowntime
let pntr = await market.getPointer(slotId)
return pntr < downtime
method requestStorage*(market: Market, method requestStorage*(market: Market,
request: StorageRequest) {.base, async.} = request: StorageRequest) {.base, async.} =
raiseAssert("not implemented") raiseAssert("not implemented")

View File

@ -73,8 +73,9 @@ proc scheduler(machine: Machine) {.async.} =
if next =? event(machine.state): if next =? event(machine.state):
if not running.isNil and not running.finished: if not running.isNil and not running.finished:
await running.cancelAndWait() await running.cancelAndWait()
let fromState = if machine.state.isNil: "<none>" else: $machine.state
machine.state = next machine.state = next
debug "enter state", state = machine.state debug "enter state", state = machine.state, fromState
running = machine.run(machine.state) running = machine.run(machine.state)
running running
.track(machine) .track(machine)

View File

@ -72,7 +72,9 @@ proc markProofAsMissing(validation: Validation,
if await validation.market.canProofBeMarkedAsMissing(slotId, period): if await validation.market.canProofBeMarkedAsMissing(slotId, period):
trace "Marking proof as missing", slotId = $slotId, periodProofMissed = period trace "Marking proof as missing", slotId = $slotId, periodProofMissed = period
await validation.market.markProofAsMissing(slotId, period) await validation.market.markProofAsMissing(slotId, period)
else: trace "Proof not missing", checkedPeriod = period else:
let inDowntime {.used.} = await validation.market.inDowntime(slotId)
trace "Proof not missing", checkedPeriod = period, inDowntime
except CancelledError: except CancelledError:
raise raise
except CatchableError as e: except CatchableError as e:

View File

@ -111,6 +111,12 @@ method periodicity*(mock: MockMarket): Future[Periodicity] {.async.} =
method proofTimeout*(market: MockMarket): Future[UInt256] {.async.} = method proofTimeout*(market: MockMarket): Future[UInt256] {.async.} =
return market.config.proofs.timeout return market.config.proofs.timeout
method proofDowntime*(market: MockMarket): Future[uint8] {.async.} =
return market.config.proofs.downtime
method getPointer*(market: MockMarket, slotId: SlotId): Future[uint8] {.async.} =
return 0 # TODO
method requestStorage*(market: MockMarket, request: StorageRequest) {.async.} = method requestStorage*(market: MockMarket, request: StorageRequest) {.async.} =
market.requested.add(request) market.requested.add(request)
var subscriptions = market.subscriptions.onRequest var subscriptions = market.subscriptions.onRequest