EYBlockchain / nightfall_3

a mono-repo containing an optimistic version of nightfall
Creative Commons Zero v1.0 Universal
260 stars 57 forks source link

Publish block data to external services via webhooks #1444

Closed AdarshRon closed 10 months ago

AdarshRon commented 10 months ago

What does this implement/fix? Explain your changes.

This PR adds a DataPublisher utility class to the nightfall client, that is used to publish L2 block data to external services via webhook. This is enabled via the environment variable CALL_WEBHOOK_ON_CONFIRMATION. The url of the webhook is configurable via the environment variable WEBHOOK_PATH.

The DataPublisher supports multiple destinations(webhook for now, could be different transport mechanisms in future like grpc or socket), including multiple webhook destinations for fallback/backup.

The PayloadSigner class abstracts away the optional signing of the payload using HMAC. The signing key(secret) is configurable via the environment variable WEBHOOK_SIGNING_KEY.

The RetryHandler class abstracts away the retry mechanism with exponential backoff strategy that is configurable via environment variables CALL_WEBHOOK_MAX_RETRIES and CALL_WEBHOOK_INITIAL_BACKOFF.

Does this close any currently open issues?

No

What commands can I run to test the change?