-
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
base: master
Are you sure you want to change the base?
Conversation
without revealing the fee algo
@@ -1,332 +1,6 @@ | |||
pub mod service { |
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.
Moved to a separate file.
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.
nothing changed
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. 🚀
let missing_fees = self.download_missing_fees(&fees, height_range).await?; | ||
|
||
self.update_cache(&mut cache_guard, missing_fees.clone()); | ||
drop(cache_guard); |
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.
Just caught my eye. Is there a specific reason to drop it manually ?
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.
Just to drop it ASAP, this is the earliest it can die without needing to wait until the end.
We don't need to hold it during the sorting or validating below.
…-block-committer into feat/price_optimizing_algo
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: