Skip to content

Commit

Permalink
⚡️ Remove slow rpc
Browse files Browse the repository at this point in the history
  • Loading branch information
KONFeature committed Jan 7, 2025
1 parent 37a4865 commit d02b4f5
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 57 deletions.
10 changes: 5 additions & 5 deletions packages/erpc/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
FROM oven/bun:latest AS bundler

# Clean up and create directory with proper permissions
RUN rm -rf /temp/dev || true && mkdir -p /temp/dev
RUN rm -rf /tmp/dev || true && mkdir -p /tmp/dev

# Bundle everything in a single erpc.js file
COPY . /temp/dev
RUN cd /temp/dev && bun install --production
RUN cd /temp/dev && bun build --outfile ./erpc.js --minify --target node --external "@erpc-cloud/*" src/index.ts
COPY . /tmp/dev
RUN cd /tmp/dev && bun install --production
RUN cd /tmp/dev && bun build --outfile ./erpc.js --minify --target node --external "@erpc-cloud/*" src/index.ts

# Final image
#FROM erpc-dev AS final
Expand All @@ -17,7 +17,7 @@ FROM ghcr.io/erpc/erpc@sha256:896792cfeb49093d1d922649962a587d00a963adb7de0cff67
RUN apt-get update && apt-get install -y curl

# Copy the bundled config
COPY --from=bundler ./temp/dev/erpc.js /root/erpc.js
COPY --from=bundler ./tmp/dev/erpc.js /root/erpc.js

# Run the server
CMD ["./erpc-server"]
30 changes: 3 additions & 27 deletions packages/erpc/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,14 @@ import {
blockPiRateRules,
drpcRateRules,
envioRateRules,
llamaFreeRateRules,
pimlicoRateRules,
tenderlyFreeRateRules,
} from "./rateLimits";
import { cacheConfig } from "./storage";
import {
alchemyUpstream,
drpcUpstream,
envioUpstream,
llamaFreeUpstreamArb,
pimlicoUpstream,
tenderlyFreeUpstreamArbSepolia,
} from "./upstreams";

/**
Expand All @@ -41,8 +37,6 @@ export default initErpcConfig({
pimlico: pimlicoRateRules,
blockPi: blockPiRateRules,
drpc: drpcRateRules,
llamaFree: llamaFreeRateRules,
tenderlyFree: tenderlyFreeRateRules,
})
// Add networks to the config
.decorate("networks", {
Expand All @@ -55,20 +49,12 @@ export default initErpcConfig({
alchemy: alchemyUpstream,
pimlico: pimlicoUpstream,
drpc: drpcUpstream,
llamaFree: llamaFreeUpstreamArb,
tenderlyFreeArbSepolia: tenderlyFreeUpstreamArbSepolia,
})
// Add our ponder prod project
.addProject(({ store: { upstreams, networks } }) => ({
id: "ponder-rpc",
networks: [networks.arbitrum, networks.arbitrumSepolia],
upstreams: [
upstreams.alchemy,
upstreams.envio,
upstreams.drpc,
upstreams.llamaFree,
upstreams.tenderlyFreeArbSepolia,
],
upstreams: [upstreams.alchemy, upstreams.envio, upstreams.drpc],
auth: {
strategies: [
{
Expand All @@ -84,12 +70,7 @@ export default initErpcConfig({
.addProject(({ store: { upstreams, networks } }) => ({
id: "ponder-dev-rpc",
networks: [networks.arbitrumSepolia],
upstreams: [
upstreams.alchemy,
upstreams.envio,
upstreams.drpc,
upstreams.tenderlyFreeArbSepolia,
],
upstreams: [upstreams.alchemy, upstreams.envio, upstreams.drpc],
auth: {
strategies: [
{
Expand All @@ -105,12 +86,7 @@ export default initErpcConfig({
.addProject(({ store: { upstreams, networks } }) => ({
id: "nexus-rpc",
networks: [networks.arbitrum, networks.arbitrumSepolia],
upstreams: [
upstreams.alchemy,
upstreams.drpc,
upstreams.pimlico,
upstreams.llamaFree,
],
upstreams: [upstreams.alchemy, upstreams.drpc, upstreams.pimlico],
auth: {
strategies: [
{
Expand Down
3 changes: 0 additions & 3 deletions packages/erpc/src/rateLimits.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,3 @@ export const pimlicoRateRules: RuleExport = [genericRateLimitsRules(400)];
export const blockPiRateRules: RuleExport = [genericRateLimitsRules(100)];

export const drpcRateRules: RuleExport = [genericRateLimitsRules(100)];

export const llamaFreeRateRules: RuleExport = [genericRateLimitsRules(30)];
export const tenderlyFreeRateRules: RuleExport = [genericRateLimitsRules(10)];
22 changes: 0 additions & 22 deletions packages/erpc/src/upstreams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,25 +87,3 @@ export const drpcUpstream = {
ignoreMethods: ["*"],
allowMethods: drpcMethods,
} as const satisfies UpstreamConfig;

export const llamaFreeUpstreamArb = {
endpoint: "https://arbitrum.llamarpc.com",
type: "evm",
vendorName: "LlamaFree",
// Budget for rate limiting
rateLimitBudget: "llamaFree",
// Only allow chainId and getBlockBy
ignoreMethods: ["*"],
allowMethods: freeRpcMethods,
} as const satisfies UpstreamConfig;

export const tenderlyFreeUpstreamArbSepolia = {
endpoint: "https://arbitrum-sepolia.gateway.tenderly.co",
type: "evm",
vendorName: "TenderlyFree",
// Budget for rate limiting
rateLimitBudget: "tenderlyFree",
// Only allow chainId and getBlockBy
ignoreMethods: ["*"],
allowMethods: freeRpcMethods,
} as const satisfies UpstreamConfig;

0 comments on commit d02b4f5

Please sign in to comment.