docs: add RPC endpoint best practices#873
Conversation
|
why are we not seeing the full CI run on this .. |
| | Package | Best for | Builds on | | ||
| | --------- | ---------- | ----------- | | ||
| | **[Synapse SDK](/developer-guides/synapse/)** | Most applications | Core | | ||
| | **[RPC Endpoints](/developer-guides/rpc-endpoints/)** | Production apps, bulk uploads, dashboards | Viem | |
There was a problem hiding this comment.
it's not a published "package" like the others so doesn't belong here
| | **[RPC Endpoints](/developer-guides/rpc-endpoints/)** | Production apps, bulk uploads, dashboards | Viem | |
| | Uploading to an account with existing data sets | The SDK resolves reusable data sets before creating new ones. | | ||
| | Dashboards and migrations | Repeated listing, filtering, and inspection can multiply reads across many data sets. | | ||
|
|
||
| For these workflows, use an authenticated endpoint, avoid tight polling loops, and cache known data set IDs or piece information when your application can tolerate cached state. |
There was a problem hiding this comment.
do we dare suggest that for heavy, large-scale workloads, that they considering installing Forest, or Lotus nodes to have their own trusted, local, un-capped endpoint?
There was a problem hiding this comment.
I considered it yesterday, but it felt a bit heavy on them, especially for developers who are just getting to know them. However, adding this part here is not a problem; it just gives them another option, which I will add later.
| title: RPC Endpoints | ||
| description: Best practices for using external RPC endpoints and avoiding rate limits. | ||
| sidebar: | ||
| order: 3 |
There was a problem hiding this comment.
I think you should put this in position 5, after the packages themselves
|
Good content, but there's a fundamental limitation that I think we need to figure out a path through before we adopt docs like this. The "recommended" path is only suitable for server-side apps and other situations where you have a local private key you can feed in, it's not helpful for wallet connected clients, like MetaMask, which has its own RPC, which you can't just patch to point to your authenticated RPC endpoint (a dapp developer might be able to document all of the ways users of their dapp could configure their wallets to talk to an authenticated endpoint and how to sign up for an endpoint, but that's pretty tedious and not likely to help cause average users just don't grok this stuff). The batching and multicall advice is still useful. Comes back to #504 and I don't think we really fully resolved that to solve for this problem in the sdk at least. In synapse-core at least you can choose what client you pass in, but the sdk takes one There seem to be two possibilities here we can pursue:
Until we have that, I think this page should be scoped more narrowly:
I'll defer to @hugomrdias for more input, he's thought more about this than me. I think I'd be happy adding option 2 and I don't think it'd be too hard with what we have now. |
PR incoming |
|
Even a split client still doesn't fully solve the fundamental problem because I don't think we can practically advise dapp developers to push their glif RPC token out to their clients. Clients are either going to have to configure their own RPC (which I don't think scales well as advice), dapps may have to proxy RPC and expose that (kind of gross), or we have some kind of graceful rate limit handling that slows down calls when you hit limits (a bit gross and prone to breakage, but we could pull something basic off). OR we could limit scope of this even further and be clear that caring about this is for the cases of high volume usage, particularly where data sets get very large or you have lots of data sets. The common case should be fine, but "if you encounter 429 rate limits then ..." might be the right framing for this doc instead. Then our job becomes focusing on how we can limit the number of RPC calls to get it under threshold as much as possible. |
|
Yes, my starting point is that I am worried that glif will be more likely to have this problem after reducing the RPM. After waiting for more ideas to enter, I will to update this section. |

Summary
Adds a developer guide for using external RPC endpoints with Synapse SDK and avoiding public endpoint rate limits.
The guide covers:
Synapsehttp(url, { batch: true })batch: { multicall: true }Authorization: BearerheadersAlso adds the page to the Developer Guides overview and adjusts sidebar ordering.
Closes #866.
Validation
eth_chainId = 0x4cb2fAuthorization: Bearertoken returnedeth_chainId = 0x4cb2f403pnpm exec markdownlint-cli2 --config .github/.markdownlint-cli2.jsonc docs/src/content/docs/developer-guides/rpc-endpoints.md docs/src/content/docs/developer-guides/index.md200 OK:http://localhost:4321/developer-guides/rpc-endpoints/