Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add gasPriceMax and gasPriceMultiplier to the Request Node config #1327

Merged
merged 4 commits into from Jan 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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