From 2f30a427487a40900f9aeae919deeb9da9ebf9e0 Mon Sep 17 00:00:00 2001 From: Gerardo Nardelli Date: Fri, 7 Jun 2019 16:06:58 -0300 Subject: [PATCH] Add new nonce error message detection on oracle sender --- oracle/src/sender.js | 8 +++----- oracle/src/utils/utils.js | 11 ++++++++++- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/oracle/src/sender.js b/oracle/src/sender.js index 97d8361c..6bd8faa4 100644 --- a/oracle/src/sender.js +++ b/oracle/src/sender.js @@ -13,7 +13,8 @@ const { privateKeyToAddress, syncForEach, waitForFunds, - watchdog + watchdog, + nonceError } = require('./utils/utils') const { EXIT_CODES, EXTRA_GAS_PERCENTAGE } = require('./utils/constants') @@ -152,10 +153,7 @@ async function main({ msg, ackMsg, nackMsg, sendToQueue, channel }) { logger.error( `Insufficient funds: ${currentBalance}. Stop processing messages until the balance is at least ${minimumBalance}.` ) - } else if ( - e.message.includes('Transaction nonce is too low') || - e.message.includes('transaction with same nonce in the queue') - ) { + } else if (nonceError(e)) { nonce = await readNonce(true) } } diff --git a/oracle/src/utils/utils.js b/oracle/src/utils/utils.js index 7bf20851..8d59bdb1 100644 --- a/oracle/src/utils/utils.js +++ b/oracle/src/utils/utils.js @@ -96,6 +96,14 @@ function privateKeyToAddress(privateKey) { : null } +function nonceError(e) { + return ( + e.message.includes('Transaction nonce is too low') || + e.message.includes('nonce too low') || + e.message.includes('transaction with same nonce in the queue') + ) +} + module.exports = { syncForEach, checkHTTPS, @@ -103,5 +111,6 @@ module.exports = { addExtraGas, setIntervalAndRun, watchdog, - privateKeyToAddress + privateKeyToAddress, + nonceError }