This repository has been archived by the owner on Oct 19, 2024. It is now read-only.
fix: backwards compatibility for eth_feeHistory #395
Merged
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.
Motivation
Geth v1.10.6 expects
blockCount
parameter in the RPC call toeth_feeHistory
to be an unsigned integer, whereas since v1.10.7 it allows both unsigned integer as well as hex encoded uint. Hardhat allows only hex encoded uint.The response format has also changed in Geth v1.10.7, whereby the field
oldestBlock
is now a hex-encoded uint.Solution
Deserialisation of the
FeeHistory
struct is made backwards-compatible with Geth v1.10.6 as well, and in case the call to Hardhat (or any other client only supporting hex-encoded form forblockCount
) fails, we fallback to the unsigned integer serialiastion while making the RPC call.Note: This is for convenience for more users since a few networks (at this point in time Infura) are running Geth v1.10.6, while others may have upgraded. We don't want the
eth_feeHistory
to fail, since the EIP-1559 fee estimator makes use of this RPC method.