Issues using a custom EVM RPC provider

Hi,

I’m adding support for EVM chains other than Mainnet and Sepolia to my app. Using Alchemy as a custom provider works great while developing locally. When running on mainnet I run into issues and wonder if someone has ideas for workarounds.

1. Alchemy reqs per second quota exceeded

The Alchemy endpoint only allows 10 calls per second on the free tier. Upgrading to the next tier allows 15 I believe, still not enough as IC sends 20+ requests per EVM call. Upgrading to the enterprise tier is waay to expensive.

2. Consensus not reached after implementing a proxy

I thought I could solve it by setting up a caching cloudflare proxy. This works great! Identical requests are cached and the Alchemy limits are respected.

But… Cloudflare don’t send 100% identical headers on the responses even though the body is the same. So, the EVM_RPC canister don’t believe there is consensus among the responses:

Canister http responses were different across replicas, and no consensus was reached

And since I can’t modify the transform() function of the EVM_RPC canister I can’t instruct it to ignore the headers that differ.

Remains to skip the EVM_RPC canister and call the Alchemy API directly. If possible I want to avoid that as it means reimplementing a lot of what is already in the EVM_RPC canister: request/response serialization/deserialization, error handling, etc.

Ideas anyone?

2 Likes

If you decided to

you can use this tutorial repo to getting started, it handles the request/response and serialization/deserialization using serde.

1 Like

Thanks. Yeah, that would be the last resort. I would like to use the EVM_RPC canister if possible though as a lot of work already have gone into creating that implementation.

2 Likes

Adding to above issues. I thought caching was working. But, since the requests from the IC nodes are coming in from all over they are hitting different Cloudflare datacenters with different caches. So, 90% of requests are not cached.

Plus, since all requests are sent almost at the same time (within a few ms), even the requests sent to the same datacenter are mostly not cached because of … there being nothing to cache yet.

If anyone have managed to use the EVM_RPC canister successfully with other chains than Mainnet and Sepolia I’d like to know how :slight_smile:

So, I managed to sort this out writing a new Cloudflare Worker, this one using Durable Objects to both proxy, cache and deduplicate the requests to the EVM RPC.

For reference, if someone else runs into similar issues:

2 Likes

Maybe @rvanasa can help?