Skip to content

Commit

Permalink
fix: add gasPriceMax and gasPriceMultiplier to the Request Node c…
Browse files Browse the repository at this point in the history
…onfig (#1327)
  • Loading branch information
MantisClone committed Jan 16, 2024
1 parent 5c83706 commit 9d8811d
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 3 deletions.
34 changes: 32 additions & 2 deletions packages/request-node/src/config.ts
Expand Up @@ -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: {
Expand Down Expand Up @@ -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
*/
Expand Down Expand Up @@ -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 (${
Expand All @@ -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
Expand Down
11 changes: 10 additions & 1 deletion packages/request-node/src/dataAccess.ts
Expand Up @@ -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,
Expand Down

0 comments on commit 9d8811d

Please sign in to comment.