Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

Ansonhkg
Copy link
Collaborator

@Ansonhkg Ansonhkg commented Sep 5, 2025

WHAT

Previously, we added support for specifying a private RPC URL in the artillery test, which was great as it resolved the artillery issue. However, the SDK itself should also allow overwriting the RPC URL. This is important for servers running our SDK long term, as they will eventually hit the RPC URL rate limit.

I was thinking we could do something like this initially:

const litClient = await createLitClient({
  networkModule: nagaDev,
  rpcUrl: '<private_rpc_url'
});

but this is not a good solution, because the nagaDev module is a singleton that has already captured the hardcoded RPC when it was instantiated. Overwriting methods on the shared networkModule inside createLitClient is risky because it might have global side effects.

Solution

Add a .withOverrides method on the network module. It’s safer, more testable, and lets you spin up multiple clients with different RPCs without stepping on each other.

eg.

import { nagaDev } from '@lit-protocol/networks';

const customNagaDev = nagaDev.withOverrides({ rpcUrl: '<private_rpc_url' });
const litClient = await createLitClient({ network: customNagaDev });

TEST

LIT_YELLOWSTONE_PRIVATE_RPC_URL=https://rpc-chronicle-yellowstone-testnet-9qgmzfcohk.t.conduit.xyz/xxx bun run test:e2e "rpc override"
image

Docs Update

https://github.com/LIT-Protocol/docs-v2/pull/1/files

…wraps every chain API. It now builds an overridden networkConfig with the resolved RPC URL and a cloned chainConfig whose rpcUrls.default.http and rpcUrls['public'].http use the override. All downstream consumers (state manager, chain APIs, contracts) automatically use the overridden RPC via the standard construction path. No per-method wrapping needed.
const importName = importNameMap[network];
const baseModule: any = (networks as any)[importName];

// apply override
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

looks confusing but purely for observability / checking the logs to see if they are correctly applied.

const networks = await import('@lit-protocol/networks');

// choose module by NETWORK env (same way init.ts does)
const network = process.env.NETWORK || 'naga-dev';
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

There are several places that do this, we will optimise in a follow up PR.

Copy link
Collaborator

@glitch003 glitch003 left a comment

Choose a reason for hiding this comment

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

makes sense to me, looks good

@Ansonhkg Ansonhkg merged commit 1b45ebf into naga_add_hardcoded_keysets-3 Sep 16, 2025
2 of 3 checks passed
@Ansonhkg Ansonhkg deleted the feature/jss-81-naga-bug-overwrite-rpc-url-based-880 branch September 16, 2025 17:12
@Ansonhkg Ansonhkg mentioned this pull request Sep 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants