From 9d8811d5c4e69225333fbea4b5177444320ef722 Mon Sep 17 00:00:00 2001 From: MantisClone Date: Tue, 16 Jan 2024 10:14:46 -0500 Subject: [PATCH] fix: add `gasPriceMax` and `gasPriceMultiplier` to the Request Node config (#1327) --- packages/request-node/src/config.ts | 34 +++++++++++++++++++++++-- packages/request-node/src/dataAccess.ts | 11 +++++++- 2 files changed, 42 insertions(+), 3 deletions(-) diff --git a/packages/request-node/src/config.ts b/packages/request-node/src/config.ts index be73050469..b4d36d2be4 100644 --- a/packages/request-node/src/config.ts +++ b/packages/request-node/src/config.ts @@ -20,7 +20,10 @@ const defaultValues = { ethereum: { networkId: 0, web3ProviderUrl: 'http://localhost:8545', - gasPriceMin: '1000000000', // one gwei + gasPriceMin: '1000000000', // 1 gwei per gas + gasPriceMax: '10000000000000', // 10,000 gwei per gas + // multiply by 2 the estimated max fee per gas to accomadate for volatility + gasPriceMultiplier: 200, blockConfirmations: 2, }, ipfs: { @@ -100,6 +103,21 @@ export function getGasPriceMin(): BigNumber | undefined { return gasPriceMin ? BigNumber.from(gasPriceMin) : undefined; } +export function getGasPriceMax(): BigNumber | undefined { + const gasPriceMax = getOption( + 'gasPriceMax', + 'GAS_PRICE_MAX', + defaultValues.storage.ethereum.gasPriceMax, + ); + return gasPriceMax ? BigNumber.from(gasPriceMax) : undefined; +} + +export const getGasPriceMultiplier = makeOption( + 'gasPriceMultiplier', + 'GAS_PRICE_MULTIPLIER', + defaultValues.storage.ethereum.gasPriceMultiplier, +); + /** * Get the number of block confirmations to wait before considering a transaction successful */ @@ -186,7 +204,7 @@ export function getHelpMessage(): string { })\t\t\t\tCustom headers to send with the API responses THE GRAPH OPTIONS - graphNodeUrl (${defaultValues.storage.thegraph.nodeUrl})\t\t\t\t + graphNodeUrl (${defaultValues.storage.thegraph.nodeUrl})\t\t\t\tURL of the Graph node ETHEREUM OPTIONS networkId (${ @@ -195,6 +213,18 @@ export function getHelpMessage(): string { providerUrl (${ defaultValues.storage.ethereum.web3ProviderUrl })\tUrl of the web3 provider for Ethereum + gasPriceMin (${ + defaultValues.storage.ethereum.gasPriceMin + })\t\t\t\tMinimum value for maxPriorityFeePerGas and maxFeePerGas + gasPriceMax (${ + defaultValues.storage.ethereum.gasPriceMax + })\t\t\t\tMaximum value for maxFeePerGas + gasPriceMultiplier (${ + defaultValues.storage.ethereum.gasPriceMultiplier + })\t\t\t\tMultiplier for the computed maxFeePerGas + blockConfirmations (${ + defaultValues.storage.ethereum.blockConfirmations + })\t\t\t\tNumber of block confirmations to wait before considering a transaction successful IPFS OPTIONS ipfsUrl (${defaultValues.storage.ipfs.url})\t\t\tURL of the IPFS gateway diff --git a/packages/request-node/src/dataAccess.ts b/packages/request-node/src/dataAccess.ts index 91fe399fb5..9f51609b41 100644 --- a/packages/request-node/src/dataAccess.ts +++ b/packages/request-node/src/dataAccess.ts @@ -21,8 +21,17 @@ export function getDataAccess( const signer = new NonceManager(wallet); const gasPriceMin = config.getGasPriceMin(); + const gasPriceMax = config.getGasPriceMax(); + const gasPriceMultiplier = config.getGasPriceMultiplier(); const blockConfirmations = config.getBlockConfirmations(); - const txSubmitter = new EthereumTransactionSubmitter({ network, logger, gasPriceMin, signer }); + const txSubmitter = new EthereumTransactionSubmitter({ + network, + logger, + gasPriceMin, + gasPriceMax, + gasPriceMultiplier, + signer, + }); const pendingStore = new PendingStore(); const storage = new EthereumStorage({ ipfsStorage,