Skip to content

Commit

Permalink
fix(relayer): Handle undefined BOT_IDENFITIER in looping mode (#1823)
Browse files Browse the repository at this point in the history
The relayer handover logic incorrectly assumes that BOT_IDENTIFIER is
not undefined. This was identified by the Lisk team when they updated
their relayer.
  • Loading branch information
pxrl authored Sep 18, 2024
1 parent f295529 commit 9b3f759
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/relayer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<void> {
Expand Down Expand Up @@ -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.
Expand All @@ -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);
Expand Down

0 comments on commit 9b3f759

Please sign in to comment.