fix: add gasPriceMax
and gasPriceMultiplier
to the Request Node config
#1327
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description of the changes
gasPriceMax
andgasPriceMultiplier
to the Request Node configMotivation
(Copied with minor edits from https://github.com/RequestNetwork/marble/pull/141, written by @alexandre-abrioux)
This PR was made possible thanks to #1318, and should fix the following issue that we get from time to time while persisting transactions on-chain:
Origin of the issue
There is also more info on why the
gasPriceMultiplier
was introduced in the protocol #1318 (comment).Practical example
When submitting a transaction with the following EIP-1559 parameters:
; we are assuming that the
baseFeePerGas
of the next block (when the transaction will be included) will be24 - 2 = 22 Gwei
.But, if our estimation is wrong, and the actual
baseFeePerGas
of the next block is23.5 Gwei
for instance, then the remaining priority fee for validators will be24 - 23.5 = 0.5 Gwei
. Or, in the code of Neithermind (execution client), there is a hardcoded minimum limit of1 Gwei
for the priority fee. Quicknode uses that execution client. In this case, the transaction will not be accepted by the client.Solution
Let's always multiply by two the
maxFeePerGas
. In this case, the transaction would be submitted with the following parameters:; and we would not encounter that issue. We will not pay more gas, as the
maxPriorityFee
is still defined in the same way, and thebaseFeePerGas
is defined by the network and cannot be cheated when including a block.To do so, we introduce a new environment variable
GAS_PRICE_MULTIPLIER
.Bonus
To protect ourselves against gas price spikes, we also introduce
GAS_PRICE_MAX
. This will limit themaxFeePerGas
value to a certain amount. In case this ever happens, our transactions might get delayed for a bit until the frenzy of "insert new NFT protocol" slows down and the network goes back to normal. The current default is10,000 Gwei
per gas or about $0.53345 per transaction on Gnosis