diff --git a/oracle/src/events/processAMBAffirmationRequests/estimateGas.js b/oracle/src/events/processAMBAffirmationRequests/estimateGas.js index 30c0c613..127fdc97 100644 --- a/oracle/src/events/processAMBAffirmationRequests/estimateGas.js +++ b/oracle/src/events/processAMBAffirmationRequests/estimateGas.js @@ -8,10 +8,11 @@ const logger = require('../../services/logger').child({ module: 'processAffirmationRequests:estimateGas' }) -async function estimateGas({ web3, homeBridge, validatorContract, message, address }) { +async function estimateGas({ web3, homeBridge, validatorContract, message, address, gasPrice }) { try { const gasEstimate = await homeBridge.methods.executeAffirmation(message).estimateGas({ - from: address + from: address, + gasPrice }) return gasEstimate diff --git a/oracle/src/events/processAMBAffirmationRequests/index.js b/oracle/src/events/processAMBAffirmationRequests/index.js index 8537ad5d..6c7bad20 100644 --- a/oracle/src/events/processAMBAffirmationRequests/index.js +++ b/oracle/src/events/processAMBAffirmationRequests/index.js @@ -61,7 +61,8 @@ function processAffirmationRequestsBuilder(config) { homeBridge, validatorContract, message, - address: config.validatorAddress + address: config.validatorAddress, + gasPrice }) logger.debug({ gasEstimate }, 'Gas estimated') } catch (e) { diff --git a/oracle/src/events/processAMBCollectedSignatures/estimateGas.js b/oracle/src/events/processAMBCollectedSignatures/estimateGas.js index d54d48c2..5b3c7504 100644 --- a/oracle/src/events/processAMBCollectedSignatures/estimateGas.js +++ b/oracle/src/events/processAMBCollectedSignatures/estimateGas.js @@ -21,13 +21,15 @@ async function estimateGas({ r, s, txHash, - address + address, + gasPrice }) { try { const gasEstimate = await foreignBridge.methods .executeSignatures(message, v, r, s) .estimateGas({ - from: address + from: address, + gasPrice }) return gasEstimate } catch (e) { diff --git a/oracle/src/events/processAMBCollectedSignatures/index.js b/oracle/src/events/processAMBCollectedSignatures/index.js index 477c4c1e..e736c0e5 100644 --- a/oracle/src/events/processAMBCollectedSignatures/index.js +++ b/oracle/src/events/processAMBCollectedSignatures/index.js @@ -90,7 +90,8 @@ function processCollectedSignaturesBuilder(config) { message, numberOfCollectedSignatures: NumberOfCollectedSignatures, txHash, - address: config.validatorAddress + address: config.validatorAddress, + gasPrice }) logger.debug({ gasEstimate }, 'Gas estimated') } catch (e) { diff --git a/oracle/src/utils/utils.js b/oracle/src/utils/utils.js index 78f87475..3cff21ee 100644 --- a/oracle/src/utils/utils.js +++ b/oracle/src/utils/utils.js @@ -1,6 +1,7 @@ const BigNumber = require('bignumber.js') const promiseRetry = require('promise-retry') const Web3 = require('web3') +const Web3Utils = require('web3-utils') const { GAS_PRICE_OPTIONS } = require('./constants') async function syncForEach(array, callback) { @@ -102,7 +103,7 @@ function generateGasPriceOptions({ dataType, gasPrice, gasPriceSpeed }) { if (dataType === GAS_PRICE_OPTIONS.GAS_PRICE) { gasPriceOptions = { type: dataType, - value: gasPrice + value: Web3Utils.hexToNumberString(gasPrice) } } else if (dataType === GAS_PRICE_OPTIONS.SPEED) { gasPriceOptions = { diff --git a/oracle/test/utils.test.js b/oracle/test/utils.test.js index f43b19b6..682d3745 100644 --- a/oracle/test/utils.test.js +++ b/oracle/test/utils.test.js @@ -3,6 +3,7 @@ const chai = require('chai') const chaiAsPromised = require('chai-as-promised') const BigNumber = require('bignumber.js') const proxyquire = require('proxyquire') +const Web3Utils = require('web3-utils') const { addExtraGas, syncForEach, generateGasPriceOptions } = require('../src/utils/utils') const { GAS_PRICE_OPTIONS, ORACLE_GAS_PRICE_SPEEDS } = require('../src/utils/constants') @@ -139,12 +140,14 @@ describe('utils', () => { it('should work for GAS_PRICE option', () => { // given const dataType = GAS_PRICE_OPTIONS.GAS_PRICE - const gasPrice = BigNumber('0000000000000000000000000000000000000000000000000000000165a0bc00') + const gasPrice = Web3Utils.toBN( + '0000000000000000000000000000000000000000000000000000000165a0bc00' + ) const gasPriceSpeed = null const expectedResult = { type: dataType, - value: gasPrice + value: Web3Utils.hexToNumberString(gasPrice) } // when