pm: Update tx cost check for faceValue() #2071
Merged
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.
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:
make
runs successfully./test.sh
pass