From 7379fe41901c0f599e46ef5bc231ac04419a0f79 Mon Sep 17 00:00:00 2001 From: Kirill Fedoseev Date: Mon, 20 Sep 2021 12:07:49 +0300 Subject: [PATCH] Allow to override JSON RPC error codes (#603) --- CONFIGURATION.md | 1 + oracle/src/services/HttpListProvider.js | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CONFIGURATION.md b/CONFIGURATION.md index ed1c6e283..35708b897 100644 --- a/CONFIGURATION.md +++ b/CONFIGURATION.md @@ -52,6 +52,7 @@ ORACLE_SHUTDOWN_CONTRACT_ADDRESS | Optional contract address in the side chain a ORACLE_SHUTDOWN_CONTRACT_METHOD | Method signature to be used in the side chain to identify the current shutdown status. Method should return boolean. Default value is `isShutdown()`. | `function signature` ORACLE_FOREIGN_RPC_BLOCK_POLLING_LIMIT | Max length for the block range used in `eth_getLogs` requests for polling contract events for the Foreign chain. Infinite, if not provided. | `integer` ORACLE_HOME_RPC_BLOCK_POLLING_LIMIT | Max length for the block range used in `eth_getLogs` requests for polling contract events for the Home chain. Infinite, if not provided. | `integer` +ORACLE_JSONRPC_ERROR_CODES | Override default JSON rpc error codes that can trigger RPC fallback to the next URL from the list (or a retry in case of a single RPC URL). Default is `-32603,-32002,-32005`. Should be a comma-separated list of negative integers. | `string` ## Monitor configuration diff --git a/oracle/src/services/HttpListProvider.js b/oracle/src/services/HttpListProvider.js index 781e597ac..efd5d9728 100644 --- a/oracle/src/services/HttpListProvider.js +++ b/oracle/src/services/HttpListProvider.js @@ -4,8 +4,12 @@ const { FALLBACK_RPC_URL_SWITCH_TIMEOUT } = require('../utils/constants') const { onInjected } = require('./injectedLogger') +const { ORACLE_JSONRPC_ERROR_CODES } = process.env + // From EIP-1474 and Infura documentation -const JSONRPC_ERROR_CODES = [-32603, -32002, -32005] +const JSONRPC_ERROR_CODES = ORACLE_JSONRPC_ERROR_CODES + ? ORACLE_JSONRPC_ERROR_CODES.split(',').map(s => parseInt(s, 10)) + : [-32603, -32002, -32005] const defaultOptions = { name: 'main',