Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(relayer): Handle undefined BOT_IDENFITIER in looping mode #1823

Merged
merged 2 commits into from
Sep 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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