diff --git a/lerna.json b/lerna.json index 381033e9..7d0c4b18 100644 --- a/lerna.json +++ b/lerna.json @@ -4,7 +4,7 @@ ], "npmClient": "yarn", "useWorkspaces": true, - "version": "1.0.38-alpha", + "version": "1.0.39-alpha", "stream": "true", "command": { "version": { diff --git a/package.json b/package.json index 1c22092d..fa88b233 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "root", "private": true, - "version": "1.0.38-alpha", + "version": "1.0.39-alpha", "engines": { "node": ">=18.0.0" }, diff --git a/packages/api/package.json b/packages/api/package.json index ac619492..4f9d34e6 100644 --- a/packages/api/package.json +++ b/packages/api/package.json @@ -1,6 +1,6 @@ { "name": "api", - "version": "1.0.38-alpha", + "version": "1.0.39-alpha", "description": "The API module of Etherspot bundler client", "author": "Etherspot", "homepage": "https://https://github.com/etherspot/skandha#readme", @@ -35,13 +35,13 @@ "class-transformer": "0.5.1", "class-validator": "0.14.0", "ethers": "5.7.2", - "executor": "^1.0.38-alpha", + "executor": "^1.0.39-alpha", "fastify": "4.14.1", - "monitoring": "^1.0.38-alpha", + "monitoring": "^1.0.39-alpha", "pino": "8.11.0", "pino-pretty": "10.0.0", "reflect-metadata": "0.1.13", - "types": "^1.0.38-alpha" + "types": "^1.0.39-alpha" }, "devDependencies": { "@types/connect": "3.4.35" diff --git a/packages/cli/package.json b/packages/cli/package.json index e22018b1..a2fbadc2 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,6 +1,6 @@ { "name": "cli", - "version": "1.0.38-alpha", + "version": "1.0.39-alpha", "description": "> TODO: description", "author": "zincoshine ", "homepage": "https://https://github.com/etherspot/skandha#readme", @@ -38,15 +38,15 @@ "@libp2p/peer-id-factory": "2.0.1", "@libp2p/prometheus-metrics": "1.1.3", "@multiformats/multiaddr": "12.1.3", - "api": "^1.0.38-alpha", - "db": "^1.0.38-alpha", - "executor": "^1.0.38-alpha", + "api": "^1.0.39-alpha", + "db": "^1.0.39-alpha", + "executor": "^1.0.39-alpha", "find-up": "5.0.0", "got": "12.5.3", "js-yaml": "4.1.0", - "monitoring": "^1.0.38-alpha", - "node": "^1.0.38-alpha", - "types": "^1.0.38-alpha", + "monitoring": "^1.0.39-alpha", + "node": "^1.0.39-alpha", + "types": "^1.0.39-alpha", "yargs": "17.6.2" }, "devDependencies": { diff --git a/packages/db/package.json b/packages/db/package.json index 02d2a5b9..9e48f07e 100644 --- a/packages/db/package.json +++ b/packages/db/package.json @@ -1,6 +1,6 @@ { "name": "db", - "version": "1.0.38-alpha", + "version": "1.0.39-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.38-alpha" + "types": "^1.0.39-alpha" }, "devDependencies": { "@types/rocksdb": "3.0.1", diff --git a/packages/executor/package.json b/packages/executor/package.json index 93251c46..1045c107 100644 --- a/packages/executor/package.json +++ b/packages/executor/package.json @@ -1,6 +1,6 @@ { "name": "executor", - "version": "1.0.38-alpha", + "version": "1.0.39-alpha", "description": "The Relayer module of Etherspot bundler client", "author": "Etherspot", "homepage": "https://https://github.com/etherspot/skandha#readme", @@ -34,8 +34,8 @@ "@flashbots/ethers-provider-bundle": "0.6.2", "async-mutex": "0.4.0", "ethers": "5.7.2", - "monitoring": "^1.0.38-alpha", - "params": "^1.0.38-alpha", - "types": "^1.0.38-alpha" + "monitoring": "^1.0.39-alpha", + "params": "^1.0.39-alpha", + "types": "^1.0.39-alpha" } } diff --git a/packages/executor/src/config.ts b/packages/executor/src/config.ts index 2d395347..99f3c390 100644 --- a/packages/executor/src/config.ts +++ b/packages/executor/src/config.ts @@ -341,6 +341,22 @@ export class Config { ) ); + conf.bundleGasLimit = Number( + fromEnvVar( + network, + "BUNDLE_GAS_LIMIT", + conf.bundleGasLimit || bundlerDefaultConfigs.bundleGasLimit + ) + ); + + conf.userOpGasLimit = Number( + fromEnvVar( + network, + "USEROP_GAS_LIMIT", + conf.userOpGasLimit || bundlerDefaultConfigs.userOpGasLimit + ) + ); + // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions if (!conf.whitelistedEntities) { conf.whitelistedEntities = bundlerDefaultConfigs.whitelistedEntities; @@ -400,6 +416,8 @@ const bundlerDefaultConfigs: BundlerConfig = { pvgMarkup: 0, gasFeeInSimulation: false, skipBundleValidation: false, + userOpGasLimit: 25000000, + bundleGasLimit: 25000000, }; const NETWORKS_ENV = (): string[] | undefined => { diff --git a/packages/executor/src/interfaces.ts b/packages/executor/src/interfaces.ts index 9c99ef69..d16f925d 100644 --- a/packages/executor/src/interfaces.ts +++ b/packages/executor/src/interfaces.ts @@ -150,6 +150,8 @@ export interface NetworkConfig { gasFeeInSimulation: boolean; // skips bundle validation skipBundleValidation: boolean; + userOpGasLimit: number; // 25kk by default + bundleGasLimit: number; // 25kk by default } export type BundlerConfig = Omit< diff --git a/packages/executor/src/modules/eth.ts b/packages/executor/src/modules/eth.ts index a1f14954..d06fc7f8 100644 --- a/packages/executor/src/modules/eth.ts +++ b/packages/executor/src/modules/eth.ts @@ -26,6 +26,7 @@ import { PerChainMetrics } from "monitoring/lib"; import { deepHexlify, packUserOp } from "../utils"; import { UserOpValidationService, MempoolService } from "../services"; import { Log, NetworkConfig } from "../interfaces"; +import { getUserOpGasLimit } from "../services/BundlingService/utils"; import { EstimateUserOperationGasArgs, SendUserOperationGasArgs, @@ -76,6 +77,12 @@ export class Eth { await this.mempoolService.validateUserOpReplaceability(userOp, entryPoint); this.logger.debug("Validating user op before sending to mempool..."); + if (getUserOpGasLimit(userOp).gt(this.config.userOpGasLimit)) { + throw new RpcError( + "UserOp's gas limit is too high", + RpcErrorCodes.INVALID_USEROP + ); + } await this.userOpValidationService.validateGasFee(userOp); const validationResult = await this.userOpValidationService.simulateValidation(userOp, entryPoint); diff --git a/packages/executor/src/services/BundlingService/service.ts b/packages/executor/src/services/BundlingService/service.ts index 287515a4..d5f8b72c 100644 --- a/packages/executor/src/services/BundlingService/service.ts +++ b/packages/executor/src/services/BundlingService/service.ts @@ -25,6 +25,7 @@ import { getAddr, wait } from "../../utils"; import { MempoolEntry } from "../../entities/MempoolEntry"; import { IRelayingMode } from "./interfaces"; import { ClassicRelayer, FlashbotsRelayer } from "./relayers"; +import { getUserOpGasLimit } from "./utils"; export class BundlingService { private mutex: Mutex; @@ -34,7 +35,7 @@ export class BundlingService { private maxBundleSize: number; private networkConfig: NetworkConfig; private relayer: IRelayingMode; - private maxSubmitAttempts = 10; + private maxSubmitAttempts = 5; constructor( private chainId: number, @@ -114,6 +115,7 @@ export class BundlingService { maxPriorityFeePerGas: BigNumber.from(0), }; + let gasLimit = BigNumber.from(0); const paymasterDeposit: { [key: string]: BigNumber } = {}; const stakedEntityCount: { [key: string]: number } = {}; const senders = new Set(); @@ -122,6 +124,10 @@ export class BundlingService { }); for (const entry of entries) { + if (getUserOpGasLimit(entry.userOp, gasLimit).gt(this.networkConfig.bundleGasLimit)) { + this.logger.debug(`${entry.userOpHash} reached bundle gas limit`); + continue; + } // validate gas prices if enabled if (this.networkConfig.enforceGasPrice) { let { maxPriorityFeePerGas, maxFeePerGas } = gasFee; @@ -379,7 +385,7 @@ export class BundlingService { bundle.entries, MempoolEntryStatus.Pending ); - // await this.mempoolService.attemptToBundle(bundle.entries); + await this.mempoolService.attemptToBundle(bundle.entries); void this.relayer.sendBundle(bundle).catch((err) => { this.logger.error(err); }); diff --git a/packages/executor/src/services/BundlingService/utils/estimateBundleGasLimit.ts b/packages/executor/src/services/BundlingService/utils/estimateBundleGasLimit.ts index 1f74c99f..14b87a7a 100644 --- a/packages/executor/src/services/BundlingService/utils/estimateBundleGasLimit.ts +++ b/packages/executor/src/services/BundlingService/utils/estimateBundleGasLimit.ts @@ -1,4 +1,5 @@ import { BigNumber } from "ethers"; +import { UserOperationStruct } from "types/lib/executor/contracts/EntryPoint"; import { MempoolEntry } from "../../../entities/MempoolEntry"; export function estimateBundleGasLimit( @@ -7,13 +8,7 @@ export function estimateBundleGasLimit( ): BigNumber { let gasLimit = BigNumber.from(markup); for (const { userOp } of bundle) { - gasLimit = BigNumber.from(userOp.verificationGasLimit) - .mul(3) - .add(userOp.preVerificationGas) - .add(userOp.callGasLimit) - .mul(11) - .div(10) - .add(gasLimit); + gasLimit = getUserOpGasLimit(userOp, gasLimit); } if (gasLimit.lt(1e5)) { // gasLimit should at least be 1e5 to pass test in test-executor @@ -21,3 +16,16 @@ export function estimateBundleGasLimit( } return gasLimit; } + +export function getUserOpGasLimit( + userOp: UserOperationStruct, + markup: BigNumber = BigNumber.from(0) +): BigNumber { + return BigNumber.from(userOp.verificationGasLimit) + .mul(3) + .add(userOp.preVerificationGas) + .add(userOp.callGasLimit) + .mul(11) + .div(10) + .add(markup); +} diff --git a/packages/monitoring/package.json b/packages/monitoring/package.json index 69b832a6..959e0ad7 100644 --- a/packages/monitoring/package.json +++ b/packages/monitoring/package.json @@ -1,6 +1,6 @@ { "name": "monitoring", - "version": "1.0.38-alpha", + "version": "1.0.39-alpha", "description": "The Monitoring module of Etherspot bundler client", "author": "Etherspot", "homepage": "https://github.com/etherspot/etherspot-bundler#readme", @@ -32,6 +32,6 @@ }, "dependencies": { "prom-client": "15.1.0", - "types": "^1.0.38-alpha" + "types": "^1.0.39-alpha" } } diff --git a/packages/node/package.json b/packages/node/package.json index 74f60a73..579b2f45 100644 --- a/packages/node/package.json +++ b/packages/node/package.json @@ -1,6 +1,6 @@ { "name": "node", - "version": "1.0.38-alpha", + "version": "1.0.39-alpha", "description": "The bundler node module of Etherspot bundler client", "author": "Etherspot", "homepage": "https://https://github.com/etherspot/skandha#readme", @@ -56,25 +56,25 @@ "@libp2p/tcp": "6.1.0", "@multiformats/multiaddr": "11.4.0", "abstract-leveldown": "7.2.0", - "api": "^1.0.38-alpha", + "api": "^1.0.39-alpha", "datastore-core": "8.0.1", - "db": "^1.0.38-alpha", + "db": "^1.0.39-alpha", "ethers": "5.7.2", - "executor": "^1.0.38-alpha", + "executor": "^1.0.39-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", - "monitoring": "^1.0.38-alpha", - "params": "^1.0.38-alpha", + "monitoring": "^1.0.39-alpha", + "params": "^1.0.39-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.38-alpha", - "utils": "^1.0.38-alpha", + "types": "^1.0.39-alpha", + "utils": "^1.0.39-alpha", "varint": "6.0.0", "xxhash-wasm": "1.0.2" }, diff --git a/packages/params/package.json b/packages/params/package.json index 83767e63..a5219bf1 100644 --- a/packages/params/package.json +++ b/packages/params/package.json @@ -1,6 +1,6 @@ { "name": "params", - "version": "1.0.38-alpha", + "version": "1.0.39-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.38-alpha", - "utils": "^1.0.38-alpha" + "types": "^1.0.39-alpha", + "utils": "^1.0.39-alpha" }, "scripts": { "clean": "rm -rf lib && rm -f *.tsbuildinfo", diff --git a/packages/types/package.json b/packages/types/package.json index e682fc5f..cecad1b3 100644 --- a/packages/types/package.json +++ b/packages/types/package.json @@ -1,6 +1,6 @@ { "name": "types", - "version": "1.0.38-alpha", + "version": "1.0.39-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 25bd434c..1b3958ee 100644 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -1,6 +1,6 @@ { "name": "utils", - "version": "1.0.38-alpha", + "version": "1.0.39-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.38-alpha" + "types": "^1.0.39-alpha" } }