Skip to content

Commit

Permalink
Allow to override JSON RPC error codes (#603)
Browse files Browse the repository at this point in the history
  • Loading branch information
k1rill-fedoseev authored Sep 20, 2021
1 parent e59766c commit 7379fe4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions CONFIGURATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion oracle/src/services/HttpListProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down

0 comments on commit 7379fe4

Please sign in to comment.