Skip to content

Commit

Permalink
⚡️ Add a few free upstream as fallback
Browse files Browse the repository at this point in the history
  • Loading branch information
KONFeature committed Nov 19, 2024
1 parent 01515c7 commit 5c3f4ea
Show file tree
Hide file tree
Showing 3 changed files with 146 additions and 77 deletions.
2 changes: 2 additions & 0 deletions infra/erpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
84 changes: 69 additions & 15 deletions packages/erpc/erpc-config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {
type ProjectConfig,
type UpstreamConfig,
buildAlchemyUpstream,
buildEnvioUpstream,
buildEvmNetworks,
Expand All @@ -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 */
Expand All @@ -36,7 +29,7 @@ const envioRateLimits = buildRateLimit({
rules: [
{
method: "*",
maxCount: 600,
maxCount: 400,
period: "1s",
},
],
Expand All @@ -46,7 +39,7 @@ const alchemyRateLimits = buildRateLimit({
rules: [
{
method: "*",
maxCount: 400,
maxCount: 200,
period: "1s",
},
],
Expand All @@ -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: {
Expand All @@ -96,7 +119,7 @@ const mainnetNetworks = buildEvmNetworks({
},
});
const testnetNetworks = buildEvmNetworks({
chains: [arbitrumSepolia, optimismSepolia, baseSepolia],
chains: [arbitrumSepolia],
generic: {
// Some failsafe config
failsafe: {
Expand Down Expand Up @@ -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({
Expand All @@ -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({
Expand Down Expand Up @@ -250,6 +301,9 @@ export default buildErpcConfig({
alchemyRateLimits,
pimlicoRateLimits,
blockPiRateLimits,
drpcRpcRateLimits,
llamaFreeRpcRateLimits,
tenderlyFreeRpcRateLimits,
],
},
},
Expand Down
137 changes: 75 additions & 62 deletions packages/erpc/erpc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ database:
projects:
- rateLimitBudget: ""
id: ponder-rpc
networks: &var3
- failsafe: &var1
networks: &var1
- failsafe:
timeout:
duration: 30s
retry:
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -133,34 +143,19 @@ 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
type: evm+pimlico
vendorName: Pimlico
ignoreMethods:
- "*"
allowMethods: *var6
allowMethods: *var4
autoIgnoreUnsupportedMethods: true
cors:
allowedOrigins:
Expand Down Expand Up @@ -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
Expand All @@ -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: ""

0 comments on commit 5c3f4ea

Please sign in to comment.