From 9b3f759b306254ee566047a6cffc3cf33f00ea24 Mon Sep 17 00:00:00 2001 From: Paul <108695806+pxrl@users.noreply.github.com> Date: Wed, 18 Sep 2024 14:50:26 +0200 Subject: [PATCH] fix(relayer): Handle undefined BOT_IDENFITIER in looping mode (#1823) The relayer handover logic incorrectly assumes that BOT_IDENTIFIER is not undefined. This was identified by the Lisk team when they updated their relayer. --- src/relayer/index.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/relayer/index.ts b/src/relayer/index.ts index 2d6f3095f..da8413ee6 100644 --- a/src/relayer/index.ts +++ b/src/relayer/index.ts @@ -16,7 +16,7 @@ config(); let logger: winston.Logger; const ACTIVE_RELAYER_EXPIRY = 600; // 10 minutes. -const { RUN_IDENTIFIER: runIdentifier, BOT_IDENTIFIER: botIdentifier } = process.env; +const { RUN_IDENTIFIER: runIdentifier, BOT_IDENTIFIER: botIdentifier = "across-relayer" } = process.env; const randomNumber = () => Math.floor(Math.random() * 1_000_000); export async function runRelayer(_logger: winston.Logger, baseSigner: Signer): Promise { @@ -59,7 +59,7 @@ export async function runRelayer(_logger: winston.Logger, baseSigner: Signer): P const tLoopStart = performance.now(); const ready = await relayer.update(); - const activeRelayer = await redis.get(botIdentifier); + const activeRelayer = redis ? await redis.get(botIdentifier) : undefined; // If there is another active relayer, allow up to 10 update cycles for this instance to be ready, // then proceed unconditionally to protect against any RPC outages blocking the relayer. @@ -73,7 +73,7 @@ export async function runRelayer(_logger: winston.Logger, baseSigner: Signer): P // Signal to any existing relayer that a handover is underway, or alternatively // check for handover initiated by another (newer) relayer instance. - if (loop && botIdentifier && runIdentifier) { + if (loop && runIdentifier && redis) { if (activeRelayer !== runIdentifier) { if (!activeRelayerUpdated) { await redis.set(botIdentifier, runIdentifier, ACTIVE_RELAYER_EXPIRY);