Add oracle configuration option for max block range length (#557)

This commit is contained in:
Kirill Fedoseev 2021-04-26 19:47:38 +03:00 committed by GitHub
parent 59e0bf7565
commit 429312500a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 12 additions and 3 deletions

@ -49,6 +49,8 @@ ORACLE_SHUTDOWN_SERVICE_POLLING_INTERVAL | Optional interval in milliseconds use
ORACLE_SIDE_RPC_URL | Optional HTTPS URL(s) for communication with the external shutdown service or side RPC nodes, used for shutdown manager activities. Several URLs can be specified, delimited by spaces. If the connection to one of these nodes is lost the next URL is used for connection. | URL(s)
ORACLE_SHUTDOWN_CONTRACT_ADDRESS | Optional contract address in the side chain accessible through `ORACLE_SIDE_RPC_URL`, where the method passed in `ORACLE_SHUTDOWN_CONTRACT_METHOD` is implemented. | `address`
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`
## Monitor configuration

@ -15,6 +15,7 @@ COMMON_HOME_GAS_PRICE_FALLBACK=1000000000
ORACLE_HOME_GAS_PRICE_UPDATE_INTERVAL=600000
COMMON_HOME_GAS_PRICE_FACTOR=1
ORACLE_HOME_TX_RESEND_INTERVAL=300000
ORACLE_HOME_RPC_BLOCK_POLLING_LIMIT=
COMMON_FOREIGN_GAS_PRICE_SUPPLIER_URL=https://gasprice.poa.network/
COMMON_FOREIGN_GAS_PRICE_SPEED_TYPE=standard
@ -22,6 +23,7 @@ COMMON_FOREIGN_GAS_PRICE_FALLBACK=1000000000
ORACLE_FOREIGN_GAS_PRICE_UPDATE_INTERVAL=600000
COMMON_FOREIGN_GAS_PRICE_FACTOR=1
ORACLE_FOREIGN_TX_RESEND_INTERVAL=1200000
ORACLE_FOREIGN_RPC_BLOCK_POLLING_LIMIT=4000
ORACLE_QUEUE_URL=amqp://rabbit
ORACLE_REDIS_URL=redis://redis

@ -73,6 +73,8 @@ const bridgeConfig = {
shutdownKey: 'oracle-shutdown'
}
const toBNOrNull = x => (x ? toBN(x) : null)
const homeConfig = {
chain: 'home',
eventContractAddress: process.env.COMMON_HOME_BRIDGE_ADDRESS,
@ -81,6 +83,7 @@ const homeConfig = {
bridgeAbi: homeAbi,
pollingInterval: process.env.ORACLE_HOME_RPC_POLLING_INTERVAL,
startBlock: toBN(process.env.ORACLE_HOME_START_BLOCK || 0),
blockPollingLimit: toBNOrNull(process.env.ORACLE_HOME_RPC_BLOCK_POLLING_LIMIT),
web3: web3Home
}
@ -92,6 +95,7 @@ const foreignConfig = {
bridgeAbi: foreignAbi,
pollingInterval: process.env.ORACLE_FOREIGN_RPC_POLLING_INTERVAL,
startBlock: toBN(process.env.ORACLE_FOREIGN_START_BLOCK || 0),
blockPollingLimit: toBNOrNull(process.env.ORACLE_FOREIGN_RPC_BLOCK_POLLING_LIMIT),
web3: web3Foreign
}

@ -178,7 +178,8 @@ async function main({ sendToQueue, sendToWorker }) {
}
const fromBlock = lastProcessedBlock.add(ONE)
const toBlock = lastBlockToProcess
const rangeEndBlock = config.blockPollingLimit ? fromBlock.add(config.blockPollingLimit) : lastBlockToProcess
const toBlock = BN.min(lastBlockToProcess, rangeEndBlock)
const events = await getEvents({
contract: eventContract,
@ -202,8 +203,8 @@ async function main({ sendToQueue, sendToWorker }) {
}
}
logger.debug({ lastProcessedBlock: lastBlockToProcess.toString() }, 'Updating last processed block')
await updateLastProcessedBlock(lastBlockToProcess)
logger.debug({ lastProcessedBlock: toBlock.toString() }, 'Updating last processed block')
await updateLastProcessedBlock(toBlock)
} catch (e) {
logger.error(e)
}