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

pm: Update tx cost check for faceValue() #2071

Merged
merged 2 commits into from
Oct 28, 2021

Conversation

yondonfu
Copy link
Member

@yondonfu yondonfu commented Oct 26, 2021

What does this pull request do? Explain your changes. (required)

This PR addresses the problem described in #2049 which can occur when there are really big gas price spikes (think 500+ gwei) on mainnet that last for a relatively short period of time.

The solution in this PR contains an update to the solution presented in #2049. The tx cost check should not be completely removed because then it is possible for an O to do a bunch of transcoding without ever being able to redeem any tickets profitably. Instead, the tx cost check is updated such that O calculates the tx cost based on the current estimated gas price and the average estimated gas price (which could be calculated over a time period such as a few hours, a day, etc.). If there is a gas price spike and the desired ticket face value is less than the tx cost based on the current gas price then O also checks the face value against the tx cost based on the average gas price. If this fallback check passes then O proceeds to generate ticket params. The idea is that typically the current gas price will be less than or equal to the average gas price so the fallback check never runs, but if the current gas price exceeds the average gas price then as long as the average gas price check passes there is still a reasonable chance that the current gas price falls at some point such that the ticket face value can cover the tx cost based on the current gas price.

In this first pass, the average gas price value is hardcoded for now and the intent is to replace the hardcoded value with a dynamic way to determine the average gas price over a period of time later (i.e. using the ETH JSON-RPC feeHistory API or in a GasPriceMonitor implementation).

Specific updates (required)

See commit history.

How did you test each of these updates (required)

Updated unit tests.

Does this pull request close any open issues?

Fixes #2049

Checklist:

@yondonfu yondonfu marked this pull request as ready for review October 26, 2021 16:09
Copy link
Contributor

@darkdarkdragon darkdarkdragon left a comment

Choose a reason for hiding this comment

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

LGTM

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.

Remove tx cost check when calculating ticket face value for O
2 participants