Skip to content
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
merged 2 commits into from
Aug 19, 2021

Conversation

roynalnaruto
Copy link
Collaborator

Motivation

Geth v1.10.6 expects blockCount parameter in the RPC call to eth_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 for blockCount ) 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.

@roynalnaruto roynalnaruto requested a review from gakonst August 19, 2021 14:52
@roynalnaruto roynalnaruto changed the title fix: backwards compatibility for eth_feeHistor fix: backwards compatibility for eth_feeHistory Aug 19, 2021
Copy link
Owner

@gakonst gakonst left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - one small nit if you want to make it slightly easier to use

ethers-providers/src/lib.rs Outdated Show resolved Hide resolved
@gakonst gakonst merged commit ab0e3ca into gakonst:master Aug 19, 2021
meetmangukiya pushed a commit to meetmangukiya/ethers-rs that referenced this pull request Mar 21, 2022
@roynalnaruto roynalnaruto deleted the fix/fee-history-params branch April 16, 2022 15:24
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants