From 1aa21becc9115e77efdefe7d25e2d26e5b791fb7 Mon Sep 17 00:00:00 2001 From: marie-fourier Date: Wed, 1 Nov 2023 16:27:28 +0500 Subject: [PATCH 1/2] feat: batch rpc & increase min CGL --- packages/api/src/app.ts | 44 ++++++++++++++++----------------- packages/executor/src/config.ts | 10 +++++++- 2 files changed, 31 insertions(+), 23 deletions(-) diff --git a/packages/api/src/app.ts b/packages/api/src/app.ts index 3357f050..fa4ec6dd 100644 --- a/packages/api/src/app.ts +++ b/packages/api/src/app.ts @@ -84,16 +84,11 @@ export class ApiApp { const redirectApi = new RedirectAPI(executor.networkName, this.config); const skandhaApi = new SkandhaAPI(executor.eth, executor.skandha); - return async (req, res): Promise => { - let result: any = undefined; - const { method, params, jsonrpc, id } = req.body as any; - + const handleRpc = async (ip: string, request: any): Promise => { + let result: any; + const { method, params, jsonrpc, id } = request; // ADMIN METHODS - if ( - this.testingMode || - req.ip === "localhost" || - req.ip === "127.0.0.1" - ) { + if (this.testingMode || ip === "localhost" || ip === "127.0.0.1") { switch (method) { case BundlerRPCMethods.debug_bundler_setBundlingMode: result = await debugApi.setBundlingMode(params[0]); @@ -136,12 +131,12 @@ export class ApiApp { if (this.redirectRpc && method in RedirectedRPCMethods) { const body = await redirectApi.redirect(method, params); if (body.error) { - return res.status(HttpStatus.OK).send({ ...body, id }); + return { ...body, id }; } - return res.status(HttpStatus.OK).send({ jsonrpc, id, ...body }); + return { jsonrpc, id, ...body }; } - if (result === undefined) { + if (!result) { switch (method) { case BundlerRPCMethods.eth_supportedEntryPoints: result = await ethApi.getSupportedEntryPoints(); @@ -197,11 +192,7 @@ export class ApiApp { case CustomRPCMethods.skandha_config: result = await skandhaApi.getConfig(); // skip hexlify for this particular rpc - return res.status(HttpStatus.OK).send({ - jsonrpc, - id, - result, - }); + return { jsonrpc, id, result }; default: throw new RpcError( `Method ${method} is not supported`, @@ -211,11 +202,20 @@ export class ApiApp { } result = deepHexlify(result); - return res.status(HttpStatus.OK).send({ - jsonrpc, - id, - result, - }); + return { jsonrpc, id, result }; + }; + + return async (req, res): Promise => { + let response: any = null; + if (Array.isArray(req.body)) { + response = []; + for (const request of req.body) { + response.push(await handleRpc(req.ip, request)); + } + } else { + response = await handleRpc(req.ip, req.body); + } + return res.status(HttpStatus.OK).send(response); }; } } diff --git a/packages/executor/src/config.ts b/packages/executor/src/config.ts index 05302976..cbf05c93 100644 --- a/packages/executor/src/config.ts +++ b/packages/executor/src/config.ts @@ -221,6 +221,14 @@ export class Config { conf.useropsTTL || bundlerDefaultConfigs.useropsTTL ) ); + conf.estimationStaticBuffer = Number( + fromEnvVar( + network, + "ESTIMATION_STATIC_BUFFER", + conf.estimationStaticBuffer || + bundlerDefaultConfigs.estimationStaticBuffer + ) + ); return Object.assign({}, bundlerDefaultConfigs, conf); } @@ -232,7 +240,7 @@ const bundlerDefaultConfigs: BundlerConfig = { banSlack: 10, minSignerBalance: utils.parseEther("0.1"), multicall: "0xcA11bde05977b3631167028862bE2a173976CA11", // default multicall address - estimationStaticBuffer: 21000, + estimationStaticBuffer: 35000, validationGasLimit: 10e6, receiptLookupRange: 1024, etherscanApiKey: "", From 8fc4f286b7e72c8ab1be83fe58a81e702d427053 Mon Sep 17 00:00:00 2001 From: marie-fourier Date: Wed, 1 Nov 2023 16:28:18 +0500 Subject: [PATCH 2/2] chore(release): 1.0.17-alpha --- lerna.json | 2 +- package.json | 2 +- packages/api/package.json | 6 +++--- packages/cli/package.json | 12 ++++++------ packages/db/package.json | 4 ++-- packages/executor/package.json | 6 +++--- packages/node/package.json | 14 +++++++------- packages/params/package.json | 6 +++--- packages/types/package.json | 2 +- packages/utils/package.json | 4 ++-- 10 files changed, 29 insertions(+), 29 deletions(-) diff --git a/lerna.json b/lerna.json index 0d9f2a5e..7e51218b 100644 --- a/lerna.json +++ b/lerna.json @@ -4,7 +4,7 @@ ], "npmClient": "yarn", "useWorkspaces": true, - "version": "1.0.16-alpha", + "version": "1.0.17-alpha", "stream": "true", "command": { "version": { diff --git a/package.json b/package.json index 60f9c418..5a9dc416 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "root", "private": true, - "version": "1.0.16-alpha", + "version": "1.0.17-alpha", "engines": { "node": ">=18.0.0" }, diff --git a/packages/api/package.json b/packages/api/package.json index 581005b8..0cbb35a2 100644 --- a/packages/api/package.json +++ b/packages/api/package.json @@ -1,6 +1,6 @@ { "name": "api", - "version": "1.0.16-alpha", + "version": "1.0.17-alpha", "description": "The API module of Etherspot bundler client", "author": "Etherspot", "homepage": "https://https://github.com/etherspot/skandha#readme", @@ -35,12 +35,12 @@ "class-transformer": "0.5.1", "class-validator": "0.14.0", "ethers": "5.7.2", - "executor": "^1.0.16-alpha", + "executor": "^1.0.17-alpha", "fastify": "4.14.1", "pino": "8.11.0", "pino-pretty": "10.0.0", "reflect-metadata": "0.1.13", - "types": "^1.0.16-alpha" + "types": "^1.0.17-alpha" }, "devDependencies": { "@types/connect": "3.4.35" diff --git a/packages/cli/package.json b/packages/cli/package.json index 06f88757..ee52b254 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,6 +1,6 @@ { "name": "cli", - "version": "1.0.16-alpha", + "version": "1.0.17-alpha", "description": "> TODO: description", "author": "zincoshine ", "homepage": "https://https://github.com/etherspot/skandha#readme", @@ -38,14 +38,14 @@ "@libp2p/peer-id-factory": "2.0.1", "@libp2p/prometheus-metrics": "1.1.3", "@multiformats/multiaddr": "12.1.3", - "api": "^1.0.16-alpha", - "db": "^1.0.16-alpha", - "executor": "^1.0.16-alpha", + "api": "^1.0.17-alpha", + "db": "^1.0.17-alpha", + "executor": "^1.0.17-alpha", "find-up": "5.0.0", "got": "12.5.3", "js-yaml": "4.1.0", - "node": "^1.0.16-alpha", - "types": "^1.0.16-alpha", + "node": "^1.0.17-alpha", + "types": "^1.0.17-alpha", "yargs": "17.6.2" }, "devDependencies": { diff --git a/packages/db/package.json b/packages/db/package.json index df4a0d6c..c40f0fb5 100644 --- a/packages/db/package.json +++ b/packages/db/package.json @@ -1,6 +1,6 @@ { "name": "db", - "version": "1.0.16-alpha", + "version": "1.0.17-alpha", "description": "The DB module of Etherspot bundler client", "author": "Etherspot", "homepage": "https://github.com/etherspot/etherspot-bundler#readme", @@ -33,7 +33,7 @@ "dependencies": { "@chainsafe/ssz": "0.10.1", "@farcaster/rocksdb": "5.5.0", - "types": "^1.0.16-alpha" + "types": "^1.0.17-alpha" }, "devDependencies": { "@types/rocksdb": "3.0.1", diff --git a/packages/executor/package.json b/packages/executor/package.json index a3d1a108..3bde2c51 100644 --- a/packages/executor/package.json +++ b/packages/executor/package.json @@ -1,6 +1,6 @@ { "name": "executor", - "version": "1.0.16-alpha", + "version": "1.0.17-alpha", "description": "The Relayer module of Etherspot bundler client", "author": "Etherspot", "homepage": "https://https://github.com/etherspot/skandha#readme", @@ -33,7 +33,7 @@ "dependencies": { "async-mutex": "0.4.0", "ethers": "5.7.2", - "params": "^1.0.16-alpha", - "types": "^1.0.16-alpha" + "params": "^1.0.17-alpha", + "types": "^1.0.17-alpha" } } diff --git a/packages/node/package.json b/packages/node/package.json index 48fcbaf9..b59b28ce 100644 --- a/packages/node/package.json +++ b/packages/node/package.json @@ -1,6 +1,6 @@ { "name": "node", - "version": "1.0.16-alpha", + "version": "1.0.17-alpha", "description": "The bundler node module of Etherspot bundler client", "author": "Etherspot", "homepage": "https://https://github.com/etherspot/skandha#readme", @@ -56,24 +56,24 @@ "@libp2p/tcp": "6.1.0", "@multiformats/multiaddr": "11.4.0", "abstract-leveldown": "7.2.0", - "api": "^1.0.16-alpha", + "api": "^1.0.17-alpha", "datastore-core": "8.0.1", - "db": "^1.0.16-alpha", + "db": "^1.0.17-alpha", "ethers": "5.7.2", - "executor": "^1.0.16-alpha", + "executor": "^1.0.17-alpha", "it-filter": "1.0.2", "it-map": "1.0.5", "it-sort": "1.0.0", "it-take": "1.0.1", "libp2p": "0.42.2", - "params": "^1.0.16-alpha", + "params": "^1.0.17-alpha", "prettier": "2.8.4", "snappy": "7.2.2", "snappyjs": "0.7.0", "stream-to-it": "0.2.4", "strict-event-emitter-types": "2.0.0", - "types": "^1.0.16-alpha", - "utils": "^1.0.16-alpha", + "types": "^1.0.17-alpha", + "utils": "^1.0.17-alpha", "varint": "6.0.0", "xxhash-wasm": "1.0.2" }, diff --git a/packages/params/package.json b/packages/params/package.json index 8a47ec9f..f08274aa 100644 --- a/packages/params/package.json +++ b/packages/params/package.json @@ -1,6 +1,6 @@ { "name": "params", - "version": "1.0.16-alpha", + "version": "1.0.17-alpha", "description": "Various bundler parameters", "author": "Etherspot", "homepage": "https://github.com/etherspot/skandha#readme", @@ -26,8 +26,8 @@ "@eth-optimism/sdk": "3.0.0", "@mantleio/sdk": "0.2.1", "ethers": "5.7.2", - "types": "^1.0.16-alpha", - "utils": "^1.0.16-alpha" + "types": "^1.0.17-alpha", + "utils": "^1.0.17-alpha" }, "scripts": { "clean": "rm -rf lib && rm -f *.tsbuildinfo", diff --git a/packages/types/package.json b/packages/types/package.json index 2c0147ab..9f0604d7 100644 --- a/packages/types/package.json +++ b/packages/types/package.json @@ -1,6 +1,6 @@ { "name": "types", - "version": "1.0.16-alpha", + "version": "1.0.17-alpha", "description": "The types of Etherspot bundler client", "author": "Etherspot", "homepage": "https://https://github.com/etherspot/skandha#readme", diff --git a/packages/utils/package.json b/packages/utils/package.json index 548bbbb5..84542660 100644 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -1,6 +1,6 @@ { "name": "utils", - "version": "1.0.16-alpha", + "version": "1.0.17-alpha", "description": "utils of Etherspot bundler client", "author": "Etherspot", "homepage": "https://https://github.com/etherspot/skandha#readme", @@ -37,6 +37,6 @@ "case": "^1.6.3", "pino": "8.11.0", "pino-pretty": "10.0.0", - "types": "^1.0.16-alpha" + "types": "^1.0.17-alpha" } }