-
Notifications
You must be signed in to change notification settings - Fork 68
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
fix: LIT-3607 - Use StaticJsonRpcProvider to improve performance of RPC requests #537
Conversation
new ethers.providers.JsonRpcProvider( | ||
this.config.rpcUrl || LIT_CHAINS['lit'].rpcUrls[0] | ||
new ethers.providers.StaticJsonRpcProvider( | ||
this.config.rpcUrl || RPC_URL_BY_NETWORK[this.config.litNetwork] |
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.
Fixed a bug here; we were always using LIT_CHAINS['lit']
here. It just so happened that due to internal override logic inside of the contracts SDK this actually worked.
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.
Should we do this in the constructor instead? so that this.config.rpcUrl
is always defined,
eg:
if (!this.config.rpcUrl) {
this.config.rpcUrl = RPC_URL_BY_NETWORK[this.config.litNetwork];
}
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.
cc @MaximusHaximus ^^
…requests Reference issue - ethers-io/ethers.js#901 Cuts our RPC request cost approx in half by eliminating a sequential call to get `chainId` from every(!) contract call we make
78e85e4
to
91ed6c1
Compare
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.
Just tested this with the pkp mint demo and not only this saves the time on every contract call, it was also making that request in a loop every a few seconds. There is a massive bandwidth and rpc load save as every client would be making those constantly Huge improvement! 🔥 |
Reference issue - ethers-io/ethers.js#901 Cuts our RPC request time costs approximately in half by eliminating a sequential call to get
chainId
from every(!) contract call we makeDescription
Replaced ethers JSONRPCProvider instances with StaticJSONRPCProvider
This eliminates unnecessary RPC calls to get
chainId
every time we use one of our contract methods.Type of change
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration
Checklist: