-
Notifications
You must be signed in to change notification settings - Fork 72
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
Sanitized provider recommended gas price #1772
Conversation
@bdrhn9 before I continue and also adapt the test, can you confirm this is going in the right direction |
Nit again: alternative naming for baseFeePerGas could be baseFee. This leads to shorten all variables include baseFeePerGas like: baseFeePerGasMultiplier => baseFeeMultiplier However this suggestion more than nit :-D so feel free to ignore. |
Well maybe not even so much of a nit. I've only now seen that we are using everywhere else |
Final review @bdrhn9 😄 ? |
Pending manual testing. |
export const fetchBaseFeePerGas = async ( | ||
provider: Provider, | ||
startTime: number | ||
): Promise<ethers.providers.Block['baseFeePerGas']> => { | ||
const goLatestBlock = await go(() => provider.getBlock('latest'), { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function throws error when block header couldn't be fetched. In this case, gasOracle tries to the following strategy if it is defined. In case it's defined, it'll be probably providerRecommendedGasPrice
strategy and again we make another RPC request to get providerRecommendedGasPrice
. Or the other case where there is no next strategy defined, gasOracle will use constant gas price which is not safe for all chain. So instead of throwing error when block header couldn't be fetched, returning already fetched and calculated providerRecommendedGasPrice is more efficient and safe way to go.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or better and more elegant solution is first making RPC call for block header (throws error if fail) and then making RPC call for providerRecommendedGasPrice
. So in this case, if block header can't be fetched, gasOracle tries the next strategy which will be probably providerRecommendedGasPrice
.
Because new implementation and testing is necessary, it's better to continue on new PR #1828. |
Closes #1711