Skip to content

Commit

Permalink
🐛 Reput envio
Browse files Browse the repository at this point in the history
  • Loading branch information
KONFeature committed Oct 18, 2024
1 parent 4f778ed commit f6a7ca5
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 18 deletions.
32 changes: 21 additions & 11 deletions packages/erpc/erpc-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,22 @@ import {
/* -------------------------------------------------------------------------- */

// Build every rate limits
const envioRateLimits = buildRateLimit({
id: "envion-rate-limit",
rules: [
{
method: "*",
maxCount: 600,
period: "1s",
},
],
});
const alchemyRateLimits = buildRateLimit({
id: "alchemy-rate-limit",
rules: [
{
method: "*",
maxCount: 400,
maxCount: 250,
period: "1s",
},
],
Expand All @@ -46,7 +56,7 @@ const blockPiRateLimits = buildRateLimit({
rules: [
{
method: "*",
maxCount: 400,
maxCount: 250,
period: "1s",
},
],
Expand All @@ -56,7 +66,7 @@ const pimlicoRateLimits = buildRateLimit({
rules: [
{
method: "*",
maxCount: 500,
maxCount: 400,
period: "1s",
},
],
Expand Down Expand Up @@ -111,6 +121,7 @@ const pimlicoSpecificMethods: RpcMethodWithRegex<EIP1474Methods>[] = [

// Build each upstream we will use
const envioUpstream = buildEnvioUpstream({
rateLimitBudget: envioRateLimits.id,
ignoreMethods: ["*"],
// todo: simple port of the vendors/evio.go stuff hereh
// since ts sdk doesn't support null value if ts definition doesn't give optional stuff
Expand All @@ -125,10 +136,6 @@ const envioUpstream = buildEnvioUpstream({
"eth_getTransactionReceipt",
"eth_getBlockReceipts",
"eth_getLogs",
"eth_getFilterLogs",
"eth_getFilterChanges",
"eth_uninstallFilter",
"eth_newFilter",
],
});
const alchemyUpstream = buildAlchemyUpstream({
Expand All @@ -139,14 +146,12 @@ const alchemyUpstream = buildAlchemyUpstream({
const blockpiArbSepoliaUpstream = buildEvmUpstream({
id: "blockpi-arbSepolia",
endpoint: `https://arbitrum-sepolia.blockpi.network/v1/rpc/${envVariable("BLOCKPI_API_KEY_ARB_SEPOLIA")}`,
allowMethods: ["*"],
rateLimitBudget: blockPiRateLimits.id,
ignoreMethods: pimlicoSpecificMethods,
});
const blockpiArbUpstream = buildEvmUpstream({
id: "blockpi-arb",
endpoint: `https://arbitrum.blockpi.network/v1/rpc/${envVariable("BLOCKPI_API_KEY_ARB")}`,
allowMethods: ["*"],
rateLimitBudget: blockPiRateLimits.id,
ignoreMethods: pimlicoSpecificMethods,
});
Expand All @@ -161,7 +166,7 @@ const pimlicoUpstream = buildPimlicoUpstream({
const ponderProject: ProjectConfig = buildProject({
id: "ponder-rpc",
networks,
upstreams: [alchemyUpstream, blockpiArbUpstream],
upstreams: [envioUpstream, alchemyUpstream, blockpiArbUpstream],
auth: {
strategies: [
buildSecretAuthStrategy({
Expand Down Expand Up @@ -234,7 +239,12 @@ export default buildErpcConfig({
},
projects: [ponderProject, nexusProject],
rateLimiters: {
budgets: [alchemyRateLimits, pimlicoRateLimits, blockPiRateLimits],
budgets: [
envioRateLimits,
alchemyRateLimits,
pimlicoRateLimits,
blockPiRateLimits,
],
},
},
});
37 changes: 30 additions & 7 deletions packages/erpc/erpc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,25 @@ projects:
architecture: evm
rateLimitBudget: ""
upstreams:
- id: envio
endpoint: evm+envio://rpc.hypersync.xyz
rateLimitBudget: envion-rate-limit
type: evm+envio
vendorName: Envio
ignoreMethods:
- "*"
allowMethods:
- eth_chainId
- eth_blockNumber
- eth_getBlockByNumber
- eth_getBlockByHash
- eth_getTransactionByHash
- eth_getTransactionByBlockHashAndIndex
- eth_getTransactionByBlockNumberAndIndex
- eth_getTransactionReceipt
- eth_getBlockReceipts
- eth_getLogs
autoIgnoreUnsupportedMethods: true
- &var5
id: alchemy
endpoint: evm+alchemy://${ALCHEMY_API_KEY}
Expand All @@ -111,8 +130,7 @@ projects:
type: evm
vendorName: Generic Evm
ignoreMethods: *var3
allowMethods:
- "*"
allowMethods: []
autoIgnoreUnsupportedMethods: true
auth:
strategies:
Expand Down Expand Up @@ -143,8 +161,7 @@ projects:
type: evm
vendorName: Generic Evm
ignoreMethods: *var3
allowMethods:
- "*"
allowMethods: []
autoIgnoreUnsupportedMethods: true
- *var6
cors:
Expand Down Expand Up @@ -177,21 +194,27 @@ projects:
value: ${NEXUS_RPC_SECRET}
rateLimiters:
budgets:
- id: envion-rate-limit
rules:
- method: "*"
maxCount: 600
period: 1s
waitTime: ""
- id: alchemy-rate-limit
rules:
- method: "*"
maxCount: 400
maxCount: 250
period: 1s
waitTime: ""
- id: pimlico-rate-limit
rules:
- method: "*"
maxCount: 500
maxCount: 400
period: 1s
waitTime: ""
- id: block-pi-rate-limit
rules:
- method: "*"
maxCount: 400
maxCount: 250
period: 1s
waitTime: ""

0 comments on commit f6a7ca5

Please sign in to comment.