Conversation
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
|
/run-security-scan |
alexcos20
left a comment
There was a problem hiding this comment.
AI automated code review (Gemini 3).
Overall risk: low
Summary:
This PR introduces an excellent performance improvement by removing blocking network calls (rpcProvider.getNetwork()) during provider initialization and utilizing the staticNetwork: true configuration in ethers v6. It also adds flexible timeouts for primary and fallback RPCs. The code is well-structured, but there is a minor risk of state mutation and potential runtime errors when interacting with networkConfig in the registry.
Comments:
• [WARNING][bug] Mutating networkConfig directly can cause side effects if supportedNetworks is a shared global object/cache. Additionally, if chainId does not exist in supportedNetworks (unlikely but possible), networkConfig will be undefined, causing a TypeError when accessing .chainId. It is safer to use the spread operator to create a new object.
- if (!networkConfig.chainId) networkConfig.chainId = chainId
- // Create Blockchain instance with new constructor
- const blockchain = new Blockchain(this.keyManager, networkConfig)
+ // Create Blockchain instance with new constructor
+ const blockchain = new Blockchain(this.keyManager, { ...networkConfig, chainId })• [INFO][performance] Excellent optimization! Removing the synchronous await rpcProvider.getNetwork() call inside the loop and using staticNetwork: true will significantly speed up provider initialization and prevent potential node stalls from unresponsive RPCs. LGTM!
PR Description
Summary
This PR improves RPC provider initialization and fallback behavior by refactoring
Blockchainconstruction to use full network configuration objects and by making provider timeouts configurable per network.What Changed
1) Blockchain network typing extended
src/@types/blockchain.ts:primaryRpcTimeoutandfallbackRpcTimeouttoSupportedNetwork.2) BlockchainRegistry now passes full network config
src/components/BlockchainRegistry/index.ts:new Blockchain(this.keyManager, rpc, chainId, fallbackRPCs)with:new Blockchain(this.keyManager, networkConfig)3) Blockchain constructor and provider initialization refactor
src/utils/blockchain.ts:SupportedNetworkinstead of separate RPC params.knownRPCsfromnetwork.rpc+network.fallbackRPCsprimaryRpcTimeout(default3000ms)fallbackRpcTimeout(default1500ms)getProvider(force)behavior improved:force=true.staticNetwork: trueto avoid repeated network detection overhead.getNetwork()validation loop and now builds fallback config directly from declared network RPCs.Why