Feature request: Smarter gas pricing

When running scheduled autotasks, one is completely at the mercy of current market conditions. If the gas spikes to 6000 for whatever reason, a "safeLow" will exec at this price, and continue to climb if it goes unexecuted.

When running scheduled tasks, normally they need to be run every X days/hours, however, not necessarily right at that moment. IN our case, 9/10 times it is acceptable to delay for hours/days until gas prices go back to normal.

:computer: Environment

Scheduled autotasks on the admin dashboard.


A solution here (from the clients perspective) is to tailor the code in the autotask to be a bit more intelligent. We can set the schedule to run 30 mins, and then have some logic in the code that checks the last time a tx was called, and the current gas prices, and decides whether to call or delay. This could be tricky because we don't have the higher level visibility of pending tx's etc and could be messy.

I propose that Openzeppelin integrate this into the defender. When setting up a schedule, choose the DESIRED time of execution, and a max-gas price, and then at this point in time, the transaction starts to try to execute, and checks every 5/10/30 minutes for favourable gas conditions before eventually executing.

Users could choose the importance of each tx (could be binary initially) to turn this setting off/on.

Hey @alsco77! Thanks for the suggestion, this is something we've been evaluating for some time already, since it's a common request given all the gas price spikes. We'll probably start with something simple (like a "max gas price" policy for a relayer) that allows you to control how much you are willing to pay for a tx, causing the relayer to wait until the spike passes.

Next steps would be being smart enough to detect when we're on a spike, without requiring any hardcoded values, and being able to decide whether to hold off or push to get included!

Sounds good. Looking forward to it @spalladino

No pressure, but I don't suppose you would have an ETA for this first version?

Not yet, but we'll keep you posted!

1 Like