From 913649c0bec24b5c8d833b36810c7a9ecfd2c832 Mon Sep 17 00:00:00 2001 From: Yaco 0x Date: Fri, 25 Oct 2024 18:23:50 +0200 Subject: [PATCH] docs: finalize request docs --- .../automated-dispute/src/services/eboActor.ts | 16 ++++++++++++++++ .../src/services/eboProcessor.ts | 2 +- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/packages/automated-dispute/src/services/eboActor.ts b/packages/automated-dispute/src/services/eboActor.ts index 33c60ca..17dc71c 100644 --- a/packages/automated-dispute/src/services/eboActor.ts +++ b/packages/automated-dispute/src/services/eboActor.ts @@ -333,6 +333,13 @@ export class EboActor { await Promise.all(settledDisputes); } + /** + * Get the first response to be used to finalize a request. + * + * @param request request to search responses for + * @param atTimestamp timestamp to validate Prophet's time windows + * @returns a `Response` if can be used to finalize `request. Otherwise undefined. + */ private getFinalizableResponse(request: Request, atTimestamp: UnixTimestamp) { this.logger.info("Getting finalizable requests..."); @@ -350,6 +357,12 @@ export class EboActor { return this.getAcceptedResponse(atTimestamp); } + /** + * Finalize `request` with `response`. + * + * @param request a `Request` + * @param response a `Response` + */ private async finalizeRequest(request: Request, response: Response) { this.logger.info(`Finalizing request.`); this.logger.debug(stringify({ request: request, response: response })); @@ -358,6 +371,9 @@ export class EboActor { await this.protocolProvider.finalize(request.prophetData, response.prophetData); } catch (err) { if (err instanceof CustomContractError) { + this.logger.warn(`Finalizing request reverted: ${err.name}`); + this.logger.debug(stringify({ request, error: err })); + err.setContext({ request, response, diff --git a/packages/automated-dispute/src/services/eboProcessor.ts b/packages/automated-dispute/src/services/eboProcessor.ts index c18136e..2f435da 100644 --- a/packages/automated-dispute/src/services/eboProcessor.ts +++ b/packages/automated-dispute/src/services/eboProcessor.ts @@ -129,7 +129,7 @@ export class EboProcessor { const lastBlock = await this.getLastFinalizedBlock(); // Events will sync starting from the block after the last checked one, - // making the block interval exclusive on its lower bound: + // making the block interval exclusive of its lower bound: // (last checked block, last block] const events = await this.getEvents(this.lastCheckedBlock + 1n, lastBlock.number);