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

API: Randomize output of eth_feeHistory to mimic ETH API #511

Merged

Conversation

uprendis
Copy link
Contributor

In ETH API, eth_feeHistory is originally intended to return the history of gas tips in recent blocks, which has to be used as a data source for a custom gas tip estimation. Typically, the resulting gas 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 of gas tip and calculates a single gas tip, where percentile 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. The gas 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.

@uprendis uprendis merged commit 438f216 into Fantom-foundation:develop Sep 14, 2023
1 check failed
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.

1 participant