-
Notifications
You must be signed in to change notification settings - Fork 2
feat: ws specific rpc urls #574
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
packages/indexer/src/main.ts
Outdated
|
|
||
| if (process.env.ENABLE_WEBSOCKET_INDEXER === "true") { | ||
| const allProviders = parseEnv.parseProvidersUrls(); | ||
| const allProviders = parseEnv.parseProvidersUrls("WS_RPC_PROVIDER_URLS_"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a way to keep using RPC_PROVIDER_URLS_ as a fallback? It would be ideal to not redeclare the RPC URL if the existing one used for polling works as expected for ws as well. Basically use WS_RPC_PROVIDER_URLS_ as a override only if declared and needed 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm is there a way to know whether an RPC URL works for a websocket before seeing if the websocket looses it's connection?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could do something like this:
const rpcProviders = parseEnv.parseProvidersUrls("RPC_PROVIDER_URLS_");
const wsProviders = parseEnv.parseProvidersUrls("WS_RPC_PROVIDER_URLS_");
// Merge providers, allowing WS providers to override RPC providers if defined for a chain
const allProviders = new Map([...rpcProviders, ...wsProviders]);Does this address what you had in mind?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm is there a way to know whether an RPC URL works for a websocket before seeing if the websocket looses it's connection?
I don't think so.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could do something like this:
const rpcProviders = parseEnv.parseProvidersUrls("RPC_PROVIDER_URLS_"); const wsProviders = parseEnv.parseProvidersUrls("WS_RPC_PROVIDER_URLS_"); // Merge providers, allowing WS providers to override RPC providers if defined for a chain const allProviders = new Map([...rpcProviders, ...wsProviders]);Does this address what you had in mind?
Something like this, yes.
const allProviders = new Map([...rpcProviders, ...wsProviders]);
Here order matters, right? Basically wsProviders is overriding rpcProviders because it comes after
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes that was the intention, wsProviders overwrites rpcProviders.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
amateima
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀
We want to be able to control which indexer is using what RPC URLs, this is both because Websockets are not equally well supported by all RPC providers and we want to know the Websocket specific RPC usage, which means we have to separate the keys being used by the Websocket and poll based indexer.
Related to https://github.com/UMAprotocol/zion/pull/1153