Skip to content

feat: gas budget tracker with configurable hour/day limits (closes #5)#14

Merged
abhicris merged 1 commit intomainfrom
feat/gas-budget-tracker
Apr 13, 2026
Merged

feat: gas budget tracker with configurable hour/day limits (closes #5)#14
abhicris merged 1 commit intomainfrom
feat/gas-budget-tracker

Conversation

@abhicris
Copy link
Copy Markdown
Contributor

Closes #5. Adds per-wallet gas budget accounting.

  • switchboard/gas_budget.pyGasBudgetTracker, GasLimits, BudgetStatus, BudgetExhausted.
  • Rolling windows (not calendar buckets) — a burst at 23:59 cannot reset one minute later.
  • Thread-safe; pluggable clock for deterministic tests.
  • Pauses the wallet when a limit is crossed; operator calls resume() once the window clears.
  • Zero new runtime deps.

Test plan

  • 14 pytest cases in tests/test_gas_budget.py.
  • PYTHONPATH=. pytest tests/test_gas_budget.py -q → 14 passed.

Pre-existing failures in tests/test_nonce_manager.py are unrelated.

Closes #5. Tracks cumulative gas spent per wallet over rolling
hour + day windows, auto-pauses the wallet when a limit is
crossed, and exposes status/reset/resume controls.

- switchboard/gas_budget.py — tracker, limits, BudgetExhausted
- tests/test_gas_budget.py — 14 pytest cases incl. thread-safety
  and window-roll assertions using an injectable clock

No new runtime deps. Rolling windows (not calendar buckets) so a
burst at 23:59 cannot reset one minute later.
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.

Add gas budget tracker with configurable limits

1 participant