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?

Hi! Apologies for the delayed response.

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:

The EVM RPC canister discards all HTTP headers in the transform function (relevant source code). Are you sure that this is caused by the headers rather than the JSON body or status code? If you send me the URL in a direct message, I could help investigate (although will be very busy for the next few weeks).

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

For anyone reading this who wants to contribute a bugfix or improvement, feel free to open a PR at the EVM RPC GitHub repository so we can potentially merge your changes into the official canister.

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:

We are planning to release first-class support for L2 chains later this week! If you end up trying it, definitely let us know if you encounter any issues so we can improve the experience for everyone.

2 Likes

Thanks for the reply! The caching Cloudflare deduplication proxy (!) I came up with did work well as a workaround but is not the ideal solution for the longterm. :joy:

Looking forward to this and will definitely try it out ASAP for C–ATTS! Optimism, Base and Arbitrum are my top wishes.

2 Likes

For anyone reading this who might be unaware, we released support for Arbitrum, Base, and Optimism L2 chains as part of the EVM RPC canister back in May. Cheers!

1 Like