Skip to content

Commit 554fe6f

Browse files
authored
binary search gas limits (#84)
* binary search gas limits * adjust to new test cases * chore(release): v0.0.42
1 parent 71b6bf5 commit 554fe6f

16 files changed

Lines changed: 467 additions & 225 deletions

File tree

lerna.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
],
55
"npmClient": "yarn",
66
"useWorkspaces": true,
7-
"version": "0.0.41",
7+
"version": "0.0.42",
88
"stream": "true",
99
"command": {
1010
"version": {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "root",
33
"private": true,
4-
"version": "0.0.41",
4+
"version": "0.0.42",
55
"engines": {
66
"node": ">=18.0.0"
77
},

packages/api/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "api",
3-
"version": "0.0.41",
3+
"version": "0.0.42",
44
"description": "The API module of Etherspot bundler client",
55
"author": "Etherspot",
66
"homepage": "https://https://github.com/etherspot/skandha#readme",
@@ -35,12 +35,12 @@
3535
"class-transformer": "0.5.1",
3636
"class-validator": "0.14.0",
3737
"ethers": "5.7.2",
38-
"executor": "^0.0.41",
38+
"executor": "^0.0.42",
3939
"fastify": "4.14.1",
4040
"pino": "8.11.0",
4141
"pino-pretty": "10.0.0",
4242
"reflect-metadata": "0.1.13",
43-
"types": "^0.0.41"
43+
"types": "^0.0.42"
4444
},
4545
"devDependencies": {
4646
"@types/connect": "3.4.35"

packages/cli/package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "cli",
3-
"version": "0.0.41",
3+
"version": "0.0.42",
44
"description": "> TODO: description",
55
"author": "zincoshine <psramanuj@gmail.com>",
66
"homepage": "https://https://github.com/etherspot/skandha#readme",
@@ -31,13 +31,13 @@
3131
"url": "https://https://github.com/etherspot/skandha/issues"
3232
},
3333
"dependencies": {
34-
"api": "^0.0.41",
35-
"db": "^0.0.41",
36-
"executor": "^0.0.41",
34+
"api": "^0.0.42",
35+
"db": "^0.0.42",
36+
"executor": "^0.0.42",
3737
"find-up": "5.0.0",
3838
"got": "12.5.3",
3939
"js-yaml": "4.1.0",
40-
"types": "^0.0.41",
40+
"types": "^0.0.42",
4141
"yargs": "17.6.2"
4242
},
4343
"devDependencies": {

packages/db/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "db",
3-
"version": "0.0.41",
3+
"version": "0.0.42",
44
"description": "The DB module of Etherspot bundler client",
55
"author": "Etherspot",
66
"homepage": "https://github.com/etherspot/etherspot-bundler#readme",
@@ -37,6 +37,6 @@
3737
"devDependencies": {
3838
"@types/rocksdb": "3.0.1",
3939
"prettier": "^2.8.4",
40-
"types": "^0.0.41"
40+
"types": "^0.0.42"
4141
}
4242
}

packages/executor/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "executor",
3-
"version": "0.0.41",
3+
"version": "0.0.42",
44
"description": "The Relayer module of Etherspot bundler client",
55
"author": "Etherspot",
66
"homepage": "https://https://github.com/etherspot/skandha#readme",
@@ -33,7 +33,7 @@
3333
"dependencies": {
3434
"async-mutex": "0.4.0",
3535
"ethers": "5.7.2",
36-
"params": "^0.0.41",
37-
"types": "^0.0.41"
36+
"params": "^0.0.42",
37+
"types": "^0.0.42"
3838
}
3939
}

packages/executor/src/modules/eth.ts

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -159,12 +159,23 @@ export class Eth {
159159
});
160160
//>
161161

162-
const userOpToEstimate: UserOperationStruct = {
162+
// Binary search gas limits
163+
let userOpToEstimate: UserOperationStruct = {
163164
...userOpComplemented,
164165
preVerificationGas,
165166
verificationGasLimit,
166167
callGasLimit,
167168
};
169+
170+
// binary search vgl and cgl
171+
try {
172+
userOpToEstimate = await this.userOpValidationService.binarySearchVGL(
173+
userOpToEstimate,
174+
entryPoint
175+
);
176+
// eslint-disable-next-line no-empty
177+
} catch (err) {}
178+
168179
const gasFee = await getGasFee(
169180
this.networkName,
170181
this.provider,
@@ -177,11 +188,11 @@ export class Eth {
177188

178189
return {
179190
preVerificationGas,
180-
verificationGasLimit,
181-
verificationGas: verificationGasLimit,
191+
verificationGasLimit: userOpToEstimate.verificationGasLimit,
192+
verificationGas: userOpToEstimate.verificationGasLimit,
182193
validAfter: BigNumber.from(validAfter),
183194
validUntil: BigNumber.from(validUntil),
184-
callGasLimit,
195+
callGasLimit: userOpToEstimate.callGasLimit,
185196
maxFeePerGas: gasFee.maxFeePerGas,
186197
maxPriorityFeePerGas: gasFee.maxPriorityFeePerGas,
187198
};

packages/executor/src/services/BundlingService.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ export class BundlingService {
5252

5353
async sendNextBundle(): Promise<SendBundleReturn | null> {
5454
return await this.mutex.runExclusive(async () => {
55+
const entries = await this.mempoolService.getSortedOps();
56+
if (!entries.length) {
57+
return null;
58+
}
5559
this.logger.debug("sendNextBundle");
5660
const gasFee = await getGasFee(
5761
this.network,

packages/executor/src/services/UserOpValidation/service.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,4 +111,24 @@ export class UserOpValidationService {
111111

112112
return true;
113113
}
114+
115+
async binarySearchVGL(
116+
userOp: UserOperationStruct,
117+
entryPoint: string
118+
): Promise<UserOperationStruct> {
119+
if (this.config.unsafeMode) {
120+
return this.estimationService.binarySearchVGL(userOp, entryPoint);
121+
}
122+
return this.estimationService.binarySearchVGLSafe(userOp, entryPoint);
123+
}
124+
125+
async binarySearchCGL(
126+
userOp: UserOperationStruct,
127+
entryPoint: string
128+
): Promise<UserOperationStruct> {
129+
if (this.config.unsafeMode) {
130+
return userOp; // CGL search not supported in unsafeMode
131+
}
132+
return this.estimationService.binarySearchCGLSafe(userOp, entryPoint);
133+
}
114134
}

packages/executor/src/services/UserOpValidation/utils.ts

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export function nethermindErrorHandler(
2323
): any {
2424
try {
2525
let { error } = errorResult;
26-
if (error.error) {
26+
if (error && error.error) {
2727
error = error.error;
2828
}
2929
if (error && error.code == -32015 && error.data.startsWith("Reverted ")) {
@@ -311,3 +311,21 @@ export function isSlotAssociatedWith(
311311
}
312312
return false;
313313
}
314+
315+
export function parseValidationResult(
316+
entryPointContract: IEntryPoint,
317+
userOp: UserOperationStruct,
318+
data: string
319+
): UserOpValidationResult {
320+
const { name: errorName, args: errorArgs } =
321+
entryPointContract.interface.parseError(data);
322+
const errFullName = `${errorName}(${errorArgs.toString()})`;
323+
const errResult = parseErrorResult(userOp, {
324+
errorName,
325+
errorArgs,
326+
});
327+
if (!errorName.includes("Result")) {
328+
throw new Error(errFullName);
329+
}
330+
return errResult;
331+
}

0 commit comments

Comments
 (0)