From 591c2d94f37bfc914ee085f5fdff21e3b71b8e20 Mon Sep 17 00:00:00 2001 From: smart_ex Date: Thu, 7 Jul 2022 18:36:04 +1000 Subject: [PATCH] relayer tx job attempts --- src/config.ts | 1 + src/queue/index.ts | 3 ++- src/queue/relayer.processor.ts | 3 ++- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/config.ts b/src/config.ts index 974ed21..e7f99a8 100644 --- a/src/config.ts +++ b/src/config.ts @@ -27,6 +27,7 @@ export const rewardAccount = process.env.REWARD_ACCOUNT; export const governanceAddress = '0x5efda50f22d34F262c29268506C5Fa42cB56A1Ce'; export const tornadoGoerliProxy = '0x454d870a72e29d5E5697f635128D18077BD04C60'; export const ovmGasPriceOracleContract = '0x420000000000000000000000000000000000000F'; +export const txJobAttempts = 3; export const gasLimits = { [RelayerJobType.TORNADO_WITHDRAW]: 390000, [RelayerJobType.WITHDRAW_WITH_EXTRA]: 700000, diff --git a/src/queue/index.ts b/src/queue/index.ts index 1243d16..57b5202 100644 --- a/src/queue/index.ts +++ b/src/queue/index.ts @@ -8,6 +8,7 @@ import { RedisStore } from '../modules/redis'; import { ConfigService } from '../services/config.service'; import { relayerProcessor } from './relayer.processor'; import { healthProcessor } from './health.processor'; +import { txJobAttempts } from '../config'; type PriceJobData = Token[]; type PriceJobReturn = number; @@ -92,7 +93,7 @@ export class RelayerQueueHelper { connection: this.store.client, defaultJobOptions: { stackTraceLimit: 100, - attempts: 3, + attempts: txJobAttempts, backoff: 1000, }, }); diff --git a/src/queue/relayer.processor.ts b/src/queue/relayer.processor.ts index c8ef1e5..e44aac5 100644 --- a/src/queue/relayer.processor.ts +++ b/src/queue/relayer.processor.ts @@ -3,6 +3,7 @@ import { getTxService } from '../services'; import { JobStatus } from '../types'; import { UnrecoverableError } from 'bullmq'; import { ExecutionError } from '../services/tx.service'; +import { txJobAttempts } from '../config'; class RevertError extends UnrecoverableError { code: string; @@ -26,7 +27,7 @@ export const relayerProcessor: RelayerProcessor = async (job) => { const txData = await txService.prepareTxData(withdrawalData); return await txService.sendTx(txData); } catch (e) { - if (e instanceof ExecutionError && e.code === 'REVERTED') { + if ((e instanceof ExecutionError && e.code === 'REVERTED') || job.attemptsMade === txJobAttempts) { await job.update({ ...job.data, status: JobStatus.FAILED }); throw new RevertError(e.message, e.code); }