Skip to content

Conversation

@MoonBoi9001
Copy link
Member

@MoonBoi9001 MoonBoi9001 commented Jan 6, 2026

Summary

Stale RPC providers can return low gas estimates when simulating transactions against outdated blockchain state. This caused out-of-gas reverts during oracle startup, as seen in transactions:

Both failed transactions had gas limit of 268,150 while the successful transaction used 630,655.

Changes

  • Increase gas buffer from 25% to 100% (2x multiplier)
  • Add 750k gas floor as safety net for low estimates
  • Cap gas at estimate + 750k to keep limits reasonable
  • Update tests to cover floor, buffer, and ceiling cases

Gas Estimation Logic

gas_with_buffer = estimated_gas * 2.0
ceiling = estimated_gas + 750_000
gas_limit = max(750_000, min(gas_with_buffer, ceiling))
Estimate 2x Buffer Floor Ceiling Result
100k 200k 750k 850k 750k (floor)
500k 1M 750k 1.25M 1M (buffer)
1M 2M 750k 1.75M 1.75M (ceiling)

🤖 Generated with Claude Code

Stale RPC providers can return low gas estimates when simulating against
outdated state, causing transactions to revert from gas exhaustion.

Changes:
- Increase gas buffer from 25% to 100% (2x multiplier)
- Add 750k gas floor as safety net for low estimates
- Cap gas at estimate + 750k to prevent excessive overpayment
- Update tests to cover floor, buffer, and ceiling cases

The bounds ensure transactions have enough gas even when RPC estimates
are based on stale blockchain state.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@MoonBoi9001 MoonBoi9001 requested a review from RembrandtK January 6, 2026 23:50
@RembrandtK
Copy link

How are much do we anticipate spending on gas (in USD)?

I wonder if an alternative to react to insufficient gas error by resubmitting with increased limit (fixed factor increase each time) might both be more reliable (within in a wider limit we can keep increasing until successful without needing to be as generous in general) and more efficient (less excess gas paid)?

Not sure if practical (a complication you want for the code) or significant in terms of savings.

@MoonBoi9001
Copy link
Member Author

MoonBoi9001 commented Jan 7, 2026

A nominal amount, probably less than $10-20 per year in gas. But we can also prevent the number of times the oracle rotates RPC provider, reduce the number of failed transactions, and additionally make the probability of the circuit breaker going open circuit much lower.

You are correct that resubmitting with increased limit on error would be a viable way to react before rotation, and we could potentially consider that as an additional PR in the future, if we start to see rotations occuring because of gas estimation not being high enough. I dont think we will after this PR though, if it happens it would be because we have so many indexers that are elgible to submit in a batch (250 indexers currently per batch) that the gas cost is still higher than our (generous) bounds allowed here.

There should not really be any additional costs by increasing the gas limit from whatever was previously estimated e.g. 630k, to a new floor value of 750k, as each transaction will only consume as much gas as it needs, the rest being unspent. But there is a non zero cost of a failed transaction as it has to be resubmitted.

@MoonBoi9001 MoonBoi9001 merged commit 966dd53 into main Jan 8, 2026
12 checks passed
@MoonBoi9001 MoonBoi9001 deleted the fix/gas-estimation-bounds branch January 8, 2026 16:54
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.

3 participants