Skip to content

Commit

Permalink
feat: batch rpc & increase min CGL
Browse files Browse the repository at this point in the history
  • Loading branch information
0xSulpiride committed Nov 1, 2023
1 parent 292c609 commit 1aa21be
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 23 deletions.
44 changes: 22 additions & 22 deletions packages/api/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<void> => {
let result: any = undefined;
const { method, params, jsonrpc, id } = req.body as any;

const handleRpc = async (ip: string, request: any): Promise<any> => {
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]);
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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`,
Expand All @@ -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<void> => {
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);
};
}
}
10 changes: 9 additions & 1 deletion packages/executor/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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: "",
Expand Down

0 comments on commit 1aa21be

Please sign in to comment.