Skip to content

fix: raise ProviderUnreachableError from get_balance so outages don't read as zero balance#136

Open
edwin-rivera-dev wants to merge 1 commit into
entrius:testfrom
edwin-rivera-dev:fix/balance-check-distinguishes-unreachable-from-zero
Open

fix: raise ProviderUnreachableError from get_balance so outages don't read as zero balance#136
edwin-rivera-dev wants to merge 1 commit into
entrius:testfrom
edwin-rivera-dev:fix/balance-check-distinguishes-unreachable-from-zero

Conversation

@edwin-rivera-dev
Copy link
Copy Markdown

@edwin-rivera-dev edwin-rivera-dev commented Apr 20, 2026

Summary

BitcoinProvider.blockstream_get_balance and SubtensorProvider.get_balance returned 0 on any backend failure. The validator axon at handle_swap_reserve checks balance < from_amount — so during a Blockstream or subtensor RPC outage, every legitimate user is rejected with "Insufficient source balance" regardless of their actual funds.

Change

  • chain_providers/base.py — abstract get_balance docstring: documents the ProviderUnreachableError contract.
  • chain_providers/bitcoin.pyblockstream_get_balance raises ProviderUnreachableError on ConnectionError/Timeout/HTTPError, matching blockstream_verify_transaction.
  • chain_providers/subtensor.pyget_balance raises ProviderUnreachableError on any subtensor failure (non-existent addresses return zero cleanly from RPC, so exceptions mean backend unreachable).
  • validator/axon_handlers.pyhandle_swap_reserve catches ProviderUnreachableError, logs a warning, and skips the balance gate.

Closes #147

@anderdc anderdc added the bug Something isn't working label Apr 21, 2026
@edwin-rivera-dev
Copy link
Copy Markdown
Author

🐛 Fixed
Hi @anderdc , How are you? Could you review this PR please?
Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Validator rejects reservations as "Insufficient source balance" when Blockstream/subtensor is unreachable

2 participants