chainlink icon indicating copy to clipboard operation
chainlink copied to clipboard

FeeHistory estimator

Open dimriou opened this issue 1 year ago • 1 comments

Fixes: https://smartcontract-it.atlassian.net/browse/BCI-3747

Introduces a new gas estimator that consolidates the functionalities of Suggested Price and Block History estimators. For legacy transactions it utilized eth_gasPrice and for dynamic transactions eth_feeHistory.

dimriou avatar Jul 11 '24 20:07 dimriou

The new changes look good to me. I do notice there might be some potential bottleneck, every time we refresh the RefreshDynamicPrice the fee_history will be invoked over the past f.config.BlockHistorySize number of blocks. If the f.config.BlockHistorySize is large for some chains, we will have very slow performance and it's wasteful as we could save the results for most of the previous blocks.

So implement some sort of cache in the future might be helpful, so we only fetch the latest blocks that are not in the cache, and cleanup the cache entries that earlier than the current - f.config.BlockHistorySize

@huangzhen1997 Let me explain why this is not a very realistic scenario: eth_feeHistory RPC call is very fast regardless of how large the history size is, considering the size is within reasonable limits. BlockHistorySize is not expected to be considerably large anyway, because we need the most up-to-date values from the network. Since we're already going to make an RPC call we're going to pay the RTT time, so requesting all values adds negligible delay vs having a complex caching logic in the code.

dimriou avatar Sep 02 '24 11:09 dimriou