API: Randomize output of eth_feeHistory to mimic ETH API #511
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.
In ETH API,
eth_feeHistory
is originally intended to return the history ofgas tip
s in recent blocks, which has to be used as a data source for a customgas tip
estimation. Typically, the resultinggas tip
is expected to be an average or a median of the historic median values.The same approach cannot be used in FTM due to the leaderless and asynchronous nature of the consensus algorithm. Instead,
eth_feeHistory
itself performs the estimation ofgas tip
and calculates a singlegas tip
, wherepercentile
is interpreted as a confidence level (higher -> larger fee). This value is then copied for each requested block, in a case if multiple blocks were requested.We expect that users can reuse the same code for
gas tip
estimation which they use for ETH, because both an average or a median of the copied values will still be equal to the intended value. However, it causes a confusion as it's apparent that the output doesn't match the ETH API description of the method.This PR randomizes the copied
gas tip
by up to 2% upward in order to closer cosmetically mimic the original ETH API variant of the method. Thegas tip
for last requested block is left as-is without randomization.The PR adds note to output of eth_feeHistory which explains the difference in output.
This way, we endeavor to balance fidelity to the original API design with the adaptations necessary for FTM's unique architecture, thereby providing users with a tool that is both familiar and optimized for the new context.