relayer tx job attempts

This commit is contained in:
smart_ex 2022-07-07 18:36:04 +10:00
parent 185b18b33a
commit 591c2d94f3
3 changed files with 5 additions and 2 deletions

View File

@ -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,

View File

@ -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,
},
});

View File

@ -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);
}