humanprotocol / human-protocol

Human Protocol python/js/ts Monorepo with example
https://dashboard.humanprotocol.org
MIT License
23 stars 33 forks source link

[Reputation Oracle] Refactor `processPaidWebhooks` method #2638

Closed Dzeranov closed 58 minutes ago

Dzeranov commented 1 month ago

Description Rework webhook processing by introducing new entities for better tracking and error handling. This includes adding a WebhookOutgoingEntity to manage outgoing webhooks, an EscrowCompletionTrackingEntity to track escrow status, and enhancing error handling mechanisms to prevent redundant operations and ensure failed webhooks are properly retried.

Motivation With current implementation in case escrow has been successfully completed but webhook wasn't sent, cron job will be launched again trying to update escrow status to completed and this operation will fail causing webhook to be stuck.

Implementation details:

eugenvoronov commented 3 weeks ago

Description Need to rework processPaidWebhooks cron job. Desired behaviour: In case await escrowClient.complete() is successful we don't need to try complete the escrow again. In case webhookService.sendWebhook() fails, we want to launch a cron job only for resending failed webhook(s).

My suggestion here is to implement some kind of a webhook queue because we are sending webhooks to multiple instances (JL, ExO, RecO) and we want to track which notification failed to be sent.

Motivation With current implementation in case escrow has been successfully completed but webhook wasn't sent, cron job will be launched again trying to update escrow status to completed and this operation will fail causing webhook to be stuck.

Implemented: