Skip to content

Support Multiple Electrs Backends with Failover#3270

Open
adamkrellenstein wants to merge 2 commits intodevelopfrom
adam/electrses
Open

Support Multiple Electrs Backends with Failover#3270
adamkrellenstein wants to merge 2 commits intodevelopfrom
adam/electrses

Conversation

@adamkrellenstein
Copy link
Copy Markdown
Member

@adamkrellenstein adamkrellenstein commented Jan 30, 2026

Summary

The service previously relied on a single Blockstream API endpoint for UTXO lookups and pubkey searches, which is unreliable. This changes config.ELECTRS_URL (single string) to config.ELECTRS_URLS (list) with automatic failover on connection, timeout, or HTTP errors.

  • --electrs-url can now be specified multiple times for failover
  • Mainnet defaults to both blockstream.info/api and mempool.space/api
  • Prints a startup warning when using default URLs (not recommended for production)
  • Fixes a pre-existing if/if bug in initialise.py for testnet/testnet4 network selection

Checklist

  • Double-check the spelling and grammar of all strings, code comments, etc.
  • Double-check that all code is deterministic that needs to be
  • Add tests to cover any new or revised logic
  • Ensure that the test suite passes
  • Update the project release notes (release-notes-v11.0.5.md)
  • Update the project documentation, as appropriate, with a corresponding Pull Request in the Documentation repository

Replace single config.ELECTRS_URL with config.ELECTRS_URLS list.
On request failure (connection, timeout, or HTTP error), the next
backend is tried automatically. Default mainnet to both
blockstream.info and mempool.space. --electrs-url can now be
specified multiple times. Print a startup warning when using
default URLs.
@codecov
Copy link
Copy Markdown

codecov Bot commented Jan 30, 2026

Codecov Report

❌ Patch coverage is 32.43243% with 25 lines in your changes missing coverage. Please review.
✅ Project coverage is 57.85%. Comparing base (bfef947) to head (93b187e).

Files with missing lines Patch % Lines
...party-core/counterpartycore/lib/backend/electrs.py 0.00% 13 Missing ⚠️
...rparty-core/counterpartycore/lib/cli/initialise.py 35.71% 9 Missing ⚠️
...arty-core/counterpartycore/lib/backend/__init__.py 0.00% 2 Missing ⚠️
...ounterparty-core/counterpartycore/lib/cli/setup.py 50.00% 1 Missing ⚠️

❗ There is a different number of reports uploaded between BASE (bfef947) and HEAD (93b187e). Click for more details.

HEAD has 8 uploads less than BASE
Flag BASE (bfef947) HEAD (93b187e)
15 7
Additional details and impacted files
@@             Coverage Diff              @@
##           develop    #3270       +/-   ##
============================================
- Coverage    88.13%   57.85%   -30.28%     
============================================
  Files          108      106        -2     
  Lines        14584    14550       -34     
============================================
- Hits         12853     8418     -4435     
- Misses        1731     6132     +4401     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Cover welcome_message warning, initialise_config URL handling,
add_config_arguments append action, and argparse edge cases.
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.

1 participant