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

perf: remove getBlock request in feeHistory #414

Merged
merged 5 commits into from
Mar 29, 2024

Conversation

mattsse
Copy link
Member

@mattsse mattsse commented Mar 27, 2024

the basefee of the "Latest" block is the second last entry in the vec, if the feeHistory response is correct then we don't need to fetch the block.

this keeps the block request as fallback but perhaps we should just error here?

see MM for ref:

https://github.com/MetaMask/core/blob/main/packages/gas-fee-controller/src/fetchGasEstimatesViaEthFeeHistory/calculateGasFeeEstimatesForPriorityLevels.ts#L62

@mattsse
Copy link
Member Author

mattsse commented Mar 27, 2024

the failing test looks more like an anvil issue

 FeeHistory {
    base_fee_per_gas: [
        0x0_U256,
        0x0_U256,
    ],
    gas_used_ratio: [
        0.0,
    ],

hmm looks like returning 0s pre 1559 is expected, so perhaps we should use this as the check?
if base fee is 0 then 1559 is not supported.

although this request would most likely fail because eth_feeHistory does not exist for networks without 1559

so we need to check against the error I suppose

@mattsse
Copy link
Member Author

mattsse commented Mar 27, 2024

Update:

basefee entries are 0 pre EIP-1559 for eth_feeHistory

https://github.com/ethereum/go-ethereum/blob/767b00b0b514771a663f3362dd0310fc28d40c25/eth/gasprice/feehistory.go#L83-L83

so this checks for is_zero to fallback to getBlock to confirm, although we could just return an error here because 0 is unreachable anyway

crates/rpc-types/src/eth/fee.rs Outdated Show resolved Hide resolved
crates/rpc-types/src/eth/fee.rs Outdated Show resolved Hide resolved
mattsse and others added 2 commits March 29, 2024 12:43
@prestwich prestwich merged commit 1fc24a7 into main Mar 29, 2024
17 checks passed
@prestwich prestwich deleted the matt/rm-redundant-block-request branch March 29, 2024 19:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants