[BCN] Multi Provider With Alchemy Adapter#4111
Merged
kajoseph merged 13 commits intobitpay:masterfrom Mar 16, 2026
Merged
Conversation
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)
kajoseph
reviewed
Mar 5, 2026
Collaborator
kajoseph
left a comment
There was a problem hiding this comment.
Lots of lint errors, particularly with imports. Make sure you have the eslint extension installed and you may need to clear all your node_modules:
npx lerna exec rm -rf node_modules
Still functionally testing, but so far this is looking good!
packages/bitcore-node/src/providers/chain-state/external/adapters/alchemy.ts
Outdated
Show resolved
Hide resolved
kajoseph
reviewed
Mar 10, 2026
kajoseph
reviewed
Mar 11, 2026
packages/bitcore-node/src/providers/chain-state/external/adapters/alchemy.ts
Show resolved
Hide resolved
packages/bitcore-node/src/providers/chain-state/external/adapters/alchemy.ts
Show resolved
Hide resolved
Separate per-network routing order from provider credentials. The externalProviders key at the config root now holds only API keys, while indexedProviderRouting defines the priority-ordered adapter list per network.
BigInt values from external providers can exceed Number.MAX_SAFE_INTEGER, losing precision when cast to number. Accept string alongside number in gasLimit, gasPrice, nonce, value, and transactionIndex to preserve full precision.
Replace static ALCHEMY_NETWORK_MAP with convention-based URL derivation so new chains need no code change. Return RPC quantity fields as BigInt strings to avoid IEEE 754 precision loss. Update test assertions accordingly.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
IIndexedAPIAdapterinterface, config types, andAdapterFactoryAlchemyAdapterwith asset transfer streamisBreakerable→affectsHealth)Testing Notes
Checklist
BWCif modifying the bitcore-wallet-client package,CLIif modifying the bitcore-cli package, etc.)