Skip to content

fix(#1285): use all RPCs defined in fallbackRPCs#1311

Open
ndrpp wants to merge 3 commits intomainfrom
fix/1285-improve-fallback-rpc-handling
Open

fix(#1285): use all RPCs defined in fallbackRPCs#1311
ndrpp wants to merge 3 commits intomainfrom
fix/1285-improve-fallback-rpc-handling

Conversation

@ndrpp
Copy link
Copy Markdown
Member

@ndrpp ndrpp commented Apr 1, 2026

Fixes #1285 .

Changes proposed in this PR:

  • make sure FallbackProvider uses all available RPCs, including those defined in fallbackRPCs
  • use priority, quorum and stallTimeout properties to call RPCs sequentially in case of failures

@ndrpp ndrpp linked an issue Apr 1, 2026 that may be closed by this pull request
@ndrpp ndrpp marked this pull request as ready for review April 1, 2026 08:32
@ndrpp ndrpp requested a review from dnsi0 April 1, 2026 11:35
@dnsi0
Copy link
Copy Markdown
Contributor

dnsi0 commented Apr 1, 2026

/run-security-scan

@ndrpp
Copy link
Copy Markdown
Member Author

ndrpp commented Apr 1, 2026

/run-security-scan

1 similar comment
@alexcos20
Copy link
Copy Markdown
Member

/run-security-scan

this.provider =
configs.length > 0
? new FallbackProvider(configs, undefined, { quorum: 1 })
: new FallbackProvider([])
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what happens if configs is empty?
We have an empty provider ?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will not happen in practice, because there are checks for existing rpcs when the Blockchain class is initialized. This line is just a fix for a test that explicitly tries to create the chain with unreachable RPCs and expects a failure.

"version": "3.972.13",
"resolved": "https://registry.npmjs.org/@aws-sdk/xml-builder/-/xml-builder-3.972.13.tgz",
"integrity": "sha512-I/+BMxM4WE/6xL0tyV7tAUDOAXmyw/va1oGr/eSly43HmLUcD1G+v96vEKAA8VoLcZ03ZQo/PWzjmN9zQErqPQ==",
"version": "3.972.16",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are this necessary in this PR?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, not necessary. I did an npm audit fix here, I can remove it if you think it's not necessary.

@alexcos20
Copy link
Copy Markdown
Member

/run-security-scan

Copy link
Copy Markdown
Member

@alexcos20 alexcos20 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AI automated code review (Gemini 3).

Overall risk: medium

Summary:
This pull request includes dependency updates, a crucial bug fix candidate in the C2D component, a test timeout increase, and significant refactoring of the blockchain provider handling to improve RPC fallback logic. The changes to the Blockchain class are a positive step towards more robust and efficient RPC management, but a critical bug with await removal needs to be addressed.

Comments:
• [ERROR][bug] The getKeyManager().getEthAddress() method is an async function and returns a Promise<string>. Removing the await keyword here will assign a Promise object to nodeAddress instead of the resolved string value. This will likely cause runtime errors when nodeAddress is later used as a string (e.g., in getLocks). Please revert this change and keep await.
• [INFO][other] Adding a check for balocks being empty or undefined is a good defensive programming practice. This helps prevent potential runtime errors if getLocks() returns unexpected data.
• [INFO][performance] The test timeout for should wait for jobWithOutputURL status 70 and download output from URL has been increased from 130s to 180s. While this might be necessary to prevent test flakiness, it's worth investigating if the underlying operation (waitForAllJobsToFinish) is consistently taking longer. Long test execution times can sometimes indicate performance bottlenecks or reliance on external services that are slow. Please ensure this timeout increase is truly necessary and not masking a deeper performance issue.
• [INFO][other] The getProvider method has been significantly refactored to use ethers.FallbackProvider with explicit priority and stallTimeout settings, as well as quorum: 1. This is a positive change for improving the robustness and efficiency of RPC handling.

Specifically:

  • Setting quorum: 1 is excellent, as it allows the provider to accept the first successful response, speeding up interactions.
  • Assigning higher stallTimeout (3000ms) to the primary RPC and lower (1500ms) to fallbacks allows the primary to have a fair chance to respond before falling back, which is a sensible strategy if the primary is expected to be the most reliable but can sometimes have higher latency.
  • The removal of static signers and providers maps, along with the config parameter, points to a cleaner, more instance-centric design for the Blockchain class, reducing global state dependencies.
    • [INFO][style] The removal of JsonRpcApiProvider and OceanNodeConfig along with the config parameter from the Blockchain class reflects a streamlined approach. The JsonRpcProvider is now directly used, which is fine, and configuration seems to be passed more explicitly via the constructor or getKeyManager.
    • [INFO][other] Multiple dependency updates have been applied. Most are minor patch or minor version bumps (e.g., brace-expansion, fast-xml-parser, handlebars, path-expression-matcher, strnum, node-forge). While node-forge is a cryptography library, the update from 1.3.3 to 1.4.0 is a minor version bump, which typically indicates backward-compatible feature additions or bug fixes, rather than breaking changes or critical security patches requiring immediate deep investigation. Overall, these updates seem routine for dependency maintenance.

@ndrpp
Copy link
Copy Markdown
Member Author

ndrpp commented Apr 1, 2026

AI automated code review (Gemini 3).

Comments: • [ERROR][bug] The getKeyManager().getEthAddress() method is an async function and returns a Promise<string>. Removing the await keyword here will assign a Promise object to nodeAddress instead of the resolved string value. This will likely cause runtime errors when nodeAddress is later used as a string (e.g., in getLocks). Please revert this change and keep await.

The function is synchronous 😄

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.

Config & test fallback rpcs on aethir node

3 participants