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

Conversation

MantisClone
Copy link
Member

@MantisClone MantisClone commented Jan 16, 2024

Description of the changes

  • fix: add gasPriceMax and gasPriceMultiplier to the Request Node config

Motivation

(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:

FeeTooLow, EffectivePriorityFeePerGas too low 806006831 < 1000000000, BaseFee: 23667261698

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:

 2,000,000,000 wei (= 2 Gwei)  for the maxPriorityFeePerGas (given to validators)
24,473,268,529 wei (= 24 Gwei) for the maxFeePerGas (total max per gas)

; we are assuming that the baseFeePerGas of the next block (when the transaction will be included) will be 24 - 2 = 22 Gwei.

But, if our estimation is wrong, and the actual baseFeePerGas of the next block is 23.5 Gwei for instance, then the remaining priority fee for validators will be 24 - 23.5 = 0.5 Gwei. Or, in the code of Neithermind (execution client), there is a hardcoded minimum limit of 1 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:

 2,000,000,000 wei (= 2 Gwei)  for the maxPriorityFeePerGas (given to validators)
48,...,...,... wei (= 48 Gwei) for the maxFeePerGas (total max per gas)

; and we would not encounter that issue. We will not pay more gas, as the maxPriorityFee is still defined in the same way, and the baseFeePerGas 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 the maxFeePerGas 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 is 10,000 Gwei per gas or about $0.53345 per transaction on Gnosis

@coveralls
Copy link

Coverage Status

coverage: 87.128%. remained the same
when pulling 9bc0a6d on gas-price-multiplier
into 5c83706 on master.

@MantisClone MantisClone marked this pull request as ready for review January 16, 2024 05:56
@MantisClone MantisClone merged commit 9d8811d into master Jan 16, 2024
27 checks passed
@MantisClone MantisClone deleted the gas-price-multiplier branch January 16, 2024 15:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

None yet

4 participants