-
Notifications
You must be signed in to change notification settings - Fork 24
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
feat: avoiding posting during price surges #179
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
without revealing the fee algo
hal3e
previously approved these changes
Jan 9, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome work. 🚀
…-block-committer into feat/price_optimizing_algo
MujkicA
reviewed
Jan 13, 2025
MujkicA
reviewed
Jan 13, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work. Left some questions regarding tests.
Also, I've skipped reviewing the simulator to catch up with the reviews.
MujkicA
approved these changes
Jan 14, 2025
hal3e
approved these changes
Jan 14, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Closes: #158
Added a simple algorithm to help prevent posting when eth transaction fees are high.
You can visualize how it works by using the simulator:
The simulator lets you see how much a transaction with
N_BLOBS
would have cost at different times in the past. The blob transaction fee is calculated like this:You’ll see three fee values: the current fee, the short-term fee, and the long-term fee.
Right now, “short-term” is set to the last 5 minutes, and “long-term” covers the past 3 hours, but you can adjust these settings.
We decide it’s a good time to send a transaction when the
short_term_fee
drops belowlong_term_fee * max_fee_multiplier
. In the simulator, this is shown with green shaded areas.The
max_fee_multiplier
starts atstart_max_fee_multiplier
(eg.0.8
) and can go up toend_max_fee_multiplier
(e.g.1.7
). As we fall behind on posting L2 blocks, the multiplier linearly increases towards the maximum (when we've reachedmax_l2_blocks_behind
).If the multiplier hits the max value, the algorithm turns off, and we’ll accept any fee.
On the flip side, if the fee goes below
always_acceptable_fee
, we’ll disable the algorithm because it’s better to stay up-to-date than to save just a tiny bit of eth.All of the above-mentioned values can be tweaked in the simulator:
This feature has been running on the testnet and is showing promising results, as you can see from the grafana graphs below:
At around 6:10 the prices start to rise, we wait them out and continue posting after they settle back down.
This PR also keeps track of how many L2 blocks we’re behind. This helps both for monitoring and for the algorithm itself. It’s calculated by: