From 5c3f4ea19ab6b45344c9e3cfcba99ce7e82f3c12 Mon Sep 17 00:00:00 2001 From: KONFeature Date: Wed, 20 Nov 2024 00:06:14 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20Add=20a=20few=20free=20ups?= =?UTF-8?q?tream=20as=20fallback?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- infra/erpc.ts | 2 + packages/erpc/erpc-config.ts | 84 +++++++++++++++++---- packages/erpc/erpc.yaml | 137 +++++++++++++++++++---------------- 3 files changed, 146 insertions(+), 77 deletions(-) diff --git a/infra/erpc.ts b/infra/erpc.ts index 356edc2..8daf70b 100644 --- a/infra/erpc.ts +++ b/infra/erpc.ts @@ -73,6 +73,8 @@ export const erpcService = new Service("Erpc", { "arn:aws:ssm:eu-west-1:262732185023:parameter/sst/frak-indexer/.fallback/Secret/ALCHEMY_API_KEY/value", PIMLICO_API_KEY: "arn:aws:ssm:eu-west-1:262732185023:parameter/sst/frak-indexer/.fallback/Secret/PIMLICO_API_KEY/value", + DRPC_API_KEY: + "arn:aws:ssm:eu-west-1:262732185023:parameter/sst/frak-indexer/.fallback/Secret/DRPC_API_KEY/value", // Endpoints secrets, PONDER_RPC_SECRET: "arn:aws:ssm:eu-west-1:262732185023:parameter/sst/frak-indexer/.fallback/Secret/PONDER_RPC_SECRET/value", diff --git a/packages/erpc/erpc-config.ts b/packages/erpc/erpc-config.ts index 7150f45..15693b5 100644 --- a/packages/erpc/erpc-config.ts +++ b/packages/erpc/erpc-config.ts @@ -1,5 +1,6 @@ import { type ProjectConfig, + type UpstreamConfig, buildAlchemyUpstream, buildEnvioUpstream, buildEvmNetworks, @@ -16,15 +17,7 @@ import { buildErpcConfig, } from "@konfeature/erpc-config-generator"; import type { EIP1474Methods } from "viem"; -import { - arbitrum, - arbitrumSepolia, - base, - baseSepolia, - optimism, - optimismSepolia, - polygon, -} from "viem/chains"; +import { arbitrum, arbitrumSepolia } from "viem/chains"; /* -------------------------------------------------------------------------- */ /* Config generator for the Frak eRPC config */ @@ -36,7 +29,7 @@ const envioRateLimits = buildRateLimit({ rules: [ { method: "*", - maxCount: 600, + maxCount: 400, period: "1s", }, ], @@ -46,7 +39,7 @@ const alchemyRateLimits = buildRateLimit({ rules: [ { method: "*", - maxCount: 400, + maxCount: 200, period: "1s", }, ], @@ -71,10 +64,40 @@ const pimlicoRateLimits = buildRateLimit({ }, ], }); +const drpcRpcRateLimits = buildRateLimit({ + id: "drpc-rate-limit", + rules: [ + { + method: "*", + maxCount: 200, + period: "1s", + }, + ], +}); +const llamaFreeRpcRateLimits = buildRateLimit({ + id: "llama-free-rpc-rate-limit", + rules: [ + { + method: "*", + maxCount: 50, + period: "1s", + }, + ], +}); +const tenderlyFreeRpcRateLimits = buildRateLimit({ + id: "tenderly-free-rpc-rate-limit", + rules: [ + { + method: "*", + maxCount: 50, + period: "1s", + }, + ], +}); // Each networks we will use const mainnetNetworks = buildEvmNetworks({ - chains: [polygon, arbitrum, optimism, base], + chains: [arbitrum], generic: { // Some failsafe config failsafe: { @@ -96,7 +119,7 @@ const mainnetNetworks = buildEvmNetworks({ }, }); const testnetNetworks = buildEvmNetworks({ - chains: [arbitrumSepolia, optimismSepolia, baseSepolia], + chains: [arbitrumSepolia], generic: { // Some failsafe config failsafe: { @@ -163,12 +186,35 @@ const pimlicoUpstream = buildPimlicoUpstream({ ignoreMethods: ["*"], allowMethods: pimlicoSpecificMethods, }); +const llamaFreeRpcUpstreamArb = buildEvmUpstream({ + id: "llama-arbitrum-free-rpc", + endpoint: "https://arbitrum.llamarpc.com", + rateLimitBudget: llamaFreeRpcRateLimits.id, + ignoreMethods: ["*"], + allowMethods: ["eth_getBlockByNumber"], +}); +const tenderlyFreeRpcUpstreamArbSepolia = buildEvmUpstream({ + id: "tenderly-arbitrum-sepolia-free-rpc", + endpoint: "https://arbitrum-sepolia.gateway.tenderly.co", + rateLimitBudget: tenderlyFreeRpcRateLimits.id, + ignoreMethods: ["*"], + allowMethods: ["eth_getBlockByNumber"], +}); +const drpcUpstream: UpstreamConfig = { + id: "drpc-rpc", + type: "evm+drpc", + vendorName: "drpc", + endpoint: `drpc://${envVariable("DRPC_API_KEY")}`, + rateLimitBudget: drpcRpcRateLimits.id, + ignoreMethods: ["*"], + allowMethods: ["eth_getBlockByNumber", "eth_getLogs"], +}; // Build the ponder indexing project const ponderProject: ProjectConfig = buildProject({ id: "ponder-rpc", networks, - upstreams: [alchemyUpstream, envioUpstream], + upstreams: [alchemyUpstream, llamaFreeRpcUpstreamArb, drpcUpstream], auth: { strategies: [ buildSecretAuthStrategy({ @@ -184,7 +230,12 @@ const ponderProject: ProjectConfig = buildProject({ const ponderDevProject: ProjectConfig = buildProject({ id: "ponder-dev-rpc", networks, - upstreams: [alchemyUpstream, envioUpstream], + upstreams: [ + alchemyUpstream, + tenderlyFreeRpcUpstreamArbSepolia, + drpcUpstream, + envioUpstream, + ], auth: { strategies: [ buildSecretAuthStrategy({ @@ -250,6 +301,9 @@ export default buildErpcConfig({ alchemyRateLimits, pimlicoRateLimits, blockPiRateLimits, + drpcRpcRateLimits, + llamaFreeRpcRateLimits, + tenderlyFreeRpcRateLimits, ], }, }, diff --git a/packages/erpc/erpc.yaml b/packages/erpc/erpc.yaml index 44a1df4..2fa1832 100644 --- a/packages/erpc/erpc.yaml +++ b/packages/erpc/erpc.yaml @@ -23,8 +23,8 @@ database: projects: - rateLimitBudget: "" id: ponder-rpc - networks: &var3 - - failsafe: &var1 + networks: &var1 + - failsafe: timeout: duration: 30s retry: @@ -38,32 +38,11 @@ projects: maxCount: 2 architecture: evm rateLimitBudget: "" - evm: - chainId: 137 - finalityDepth: 1024 - blockTrackerInterval: "" - - failsafe: *var1 - architecture: evm - rateLimitBudget: "" evm: chainId: 42161 finalityDepth: 1024 blockTrackerInterval: "" - - failsafe: *var1 - architecture: evm - rateLimitBudget: "" - evm: - chainId: 10 - finalityDepth: 1024 - blockTrackerInterval: "" - - failsafe: *var1 - architecture: evm - rateLimitBudget: "" - evm: - chainId: 8453 - finalityDepth: 1024 - blockTrackerInterval: "" - - failsafe: &var2 + - failsafe: hedge: delay: 5s maxCount: 2 @@ -73,28 +52,14 @@ projects: blockTrackerInterval: "" architecture: evm rateLimitBudget: "" - - failsafe: *var2 - evm: - chainId: 11155420 - finalityDepth: 2048 - blockTrackerInterval: "" - architecture: evm - rateLimitBudget: "" - - failsafe: *var2 - evm: - chainId: 84532 - finalityDepth: 2048 - blockTrackerInterval: "" - architecture: evm - rateLimitBudget: "" upstreams: - - &var4 + - &var2 id: alchemy endpoint: evm+alchemy://${ALCHEMY_API_KEY} type: evm+alchemy rateLimitBudget: alchemy-rate-limit vendorName: Alchemy - ignoreMethods: &var6 + ignoreMethods: &var4 - eth_estimateUserOperationGas - eth_getUserOperationByHash - eth_getUserOperationReceipt @@ -104,8 +69,53 @@ projects: - pimlico_* allowMethods: [] autoIgnoreUnsupportedMethods: true - - &var5 - id: envio + - id: llama-arbitrum-free-rpc + endpoint: https://arbitrum.llamarpc.com + rateLimitBudget: llama-free-rpc-rate-limit + type: evm + vendorName: Generic Evm + ignoreMethods: + - "*" + allowMethods: + - eth_getBlockByNumber + autoIgnoreUnsupportedMethods: true + - &var3 + id: drpc-rpc + type: evm+drpc + vendorName: drpc + endpoint: drpc://${DRPC_API_KEY} + rateLimitBudget: drpc-rate-limit + ignoreMethods: + - "*" + allowMethods: + - eth_getBlockByNumber + - eth_getLogs + auth: + strategies: + - allowMethods: + - "*" + ignoreMethods: [] + rateLimitBudget: "" + type: secret + secret: + value: ${PONDER_RPC_SECRET} + - rateLimitBudget: "" + id: ponder-dev-rpc + networks: *var1 + upstreams: + - *var2 + - id: tenderly-arbitrum-sepolia-free-rpc + endpoint: https://arbitrum-sepolia.gateway.tenderly.co + rateLimitBudget: tenderly-free-rpc-rate-limit + type: evm + vendorName: Generic Evm + ignoreMethods: + - "*" + allowMethods: + - eth_getBlockByNumber + autoIgnoreUnsupportedMethods: true + - *var3 + - id: envio endpoint: evm+envio://rpc.hypersync.xyz rateLimitBudget: envion-rate-limit type: evm+envio @@ -133,26 +143,11 @@ projects: type: secret secret: value: ${PONDER_RPC_SECRET} - - rateLimitBudget: "" - id: ponder-dev-rpc - networks: *var3 - upstreams: - - *var4 - - *var5 - auth: - strategies: - - allowMethods: - - "*" - ignoreMethods: [] - rateLimitBudget: "" - type: secret - secret: - value: ${PONDER_RPC_SECRET} - rateLimitBudget: "" id: nexus-rpc - networks: *var3 + networks: *var1 upstreams: - - *var4 + - *var2 - id: pimlico endpoint: evm+pimlico://${PIMLICO_API_KEY} rateLimitBudget: pimlico-rate-limit @@ -160,7 +155,7 @@ projects: vendorName: Pimlico ignoreMethods: - "*" - allowMethods: *var6 + allowMethods: *var4 autoIgnoreUnsupportedMethods: true cors: allowedOrigins: @@ -190,13 +185,13 @@ rateLimiters: - id: envion-rate-limit rules: - method: "*" - maxCount: 600 + maxCount: 400 period: 1s waitTime: "" - id: alchemy-rate-limit rules: - method: "*" - maxCount: 400 + maxCount: 200 period: 1s waitTime: "" - id: pimlico-rate-limit @@ -211,3 +206,21 @@ rateLimiters: maxCount: 250 period: 1s waitTime: "" + - id: drpc-rate-limit + rules: + - method: "*" + maxCount: 200 + period: 1s + waitTime: "" + - id: llama-free-rpc-rate-limit + rules: + - method: "*" + maxCount: 50 + period: 1s + waitTime: "" + - id: tenderly-free-rpc-rate-limit + rules: + - method: "*" + maxCount: 50 + period: 1s + waitTime: ""