Skip to content

[BCN] Multi Provider With Alchemy Adapter#4111

Open
leolambo wants to merge 9 commits intobitpay:masterfrom
leolambo:multiProviderAlchemy
Open

[BCN] Multi Provider With Alchemy Adapter#4111
leolambo wants to merge 9 commits intobitpay:masterfrom
leolambo:multiProviderAlchemy

Conversation

@leolambo
Copy link
Contributor

@leolambo leolambo commented Feb 24, 2026

Description

Add multi-provider external chain state adapter with Alchemy integration, enabling failover between multiple indexed API providers for EVM chains.

Follow-up:

Moralis Adapter, API streaming improvements, Integration tests

Changelog

  • Add adapter error taxonomy with health-affecting classification
  • Add provider health tracker using consecutive-failure counter and cooldown
  • Add IIndexedAPIAdapter interface, config types, and AdapterFactory
  • Add AlchemyAdapter with asset transfer stream
  • Add multi-provider chain state provider with round-robin failover and block-time caching
  • Align provider config with Moralis patterns (dynamic URL resolution, isBreakerableaffectsHealth)

Testing Notes

cd packages/bitcore-node && npm run tests

Checklist

  • I have read CONTRIBUTING.md and verified that this PR follows the guidelines and requirements outlined in it.
  • I have added the appropriate package tag(s) (e.g. BWC if modifying the bitcore-wallet-client package, CLI if modifying the bitcore-cli package, etc.)
  • I have verified that this is not an existing PR (open or closed)

Replace the circuit breaker state machine with a simpler
consecutive-failure counter and cooldown approach.
N failures in a row, skip for M seconds, then retry.
- Fix getBlockBeforeTime signature to match
  GetBlockBeforeTimeParams
- Fix AlchemyAssetTransferStream field collision
  with base class
- Fix blockHeight possibly undefined in confirmation
- Remove unused imports and dead code
- Cast test args as any to satisfy type constraints
- Add operational logging to csp.ts (stream lifecycle,
  failover events, block-by-date resolution)
- Rename _enforceFloorSemantics to _verifyBlockBeforeDate
- Rename IProviderConfig to IMultiProviderConfig with
  only health/priority/timeout fields
- Move apiKey to global config.externalProviders.alchemy
  (matches Moralis pattern)
- Resolve Alchemy URLs dynamically per-call via
  ALCHEMY_NETWORK_MAP
- Add chain/network to AdapterBlockByDateParams for
  dynamic URL resolution
- Add blockAtTimeCache (LRU per chain:network) to
  multi-provider CSP
- Rename isBreakerable to affectsHealth across error
  taxonomy
- Update all tests (47 passing)
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