Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

binary search gas limits #84

Merged
merged 5 commits into from
Sep 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
],
"npmClient": "yarn",
"useWorkspaces": true,
"version": "0.0.41",
"version": "0.0.42",
"stream": "true",
"command": {
"version": {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "root",
"private": true,
"version": "0.0.41",
"version": "0.0.42",
"engines": {
"node": ">=18.0.0"
},
Expand Down
6 changes: 3 additions & 3 deletions packages/api/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "api",
"version": "0.0.41",
"version": "0.0.42",
"description": "The API module of Etherspot bundler client",
"author": "Etherspot",
"homepage": "https://https://github.com/etherspot/skandha#readme",
Expand Down Expand Up @@ -35,12 +35,12 @@
"class-transformer": "0.5.1",
"class-validator": "0.14.0",
"ethers": "5.7.2",
"executor": "^0.0.41",
"executor": "^0.0.42",
"fastify": "4.14.1",
"pino": "8.11.0",
"pino-pretty": "10.0.0",
"reflect-metadata": "0.1.13",
"types": "^0.0.41"
"types": "^0.0.42"
},
"devDependencies": {
"@types/connect": "3.4.35"
Expand Down
10 changes: 5 additions & 5 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cli",
"version": "0.0.41",
"version": "0.0.42",
"description": "> TODO: description",
"author": "zincoshine <[email protected]>",
"homepage": "https://https://github.com/etherspot/skandha#readme",
Expand Down Expand Up @@ -31,13 +31,13 @@
"url": "https://https://github.com/etherspot/skandha/issues"
},
"dependencies": {
"api": "^0.0.41",
"db": "^0.0.41",
"executor": "^0.0.41",
"api": "^0.0.42",
"db": "^0.0.42",
"executor": "^0.0.42",
"find-up": "5.0.0",
"got": "12.5.3",
"js-yaml": "4.1.0",
"types": "^0.0.41",
"types": "^0.0.42",
"yargs": "17.6.2"
},
"devDependencies": {
Expand Down
4 changes: 2 additions & 2 deletions packages/db/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "db",
"version": "0.0.41",
"version": "0.0.42",
"description": "The DB module of Etherspot bundler client",
"author": "Etherspot",
"homepage": "https://github.com/etherspot/etherspot-bundler#readme",
Expand Down Expand Up @@ -37,6 +37,6 @@
"devDependencies": {
"@types/rocksdb": "3.0.1",
"prettier": "^2.8.4",
"types": "^0.0.41"
"types": "^0.0.42"
}
}
6 changes: 3 additions & 3 deletions packages/executor/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "executor",
"version": "0.0.41",
"version": "0.0.42",
"description": "The Relayer module of Etherspot bundler client",
"author": "Etherspot",
"homepage": "https://https://github.com/etherspot/skandha#readme",
Expand Down Expand Up @@ -33,7 +33,7 @@
"dependencies": {
"async-mutex": "0.4.0",
"ethers": "5.7.2",
"params": "^0.0.41",
"types": "^0.0.41"
"params": "^0.0.42",
"types": "^0.0.42"
}
}
19 changes: 15 additions & 4 deletions packages/executor/src/modules/eth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,12 +159,23 @@ export class Eth {
});
//>

const userOpToEstimate: UserOperationStruct = {
// Binary search gas limits
let userOpToEstimate: UserOperationStruct = {
...userOpComplemented,
preVerificationGas,
verificationGasLimit,
callGasLimit,
};

// binary search vgl and cgl
try {
userOpToEstimate = await this.userOpValidationService.binarySearchVGL(
userOpToEstimate,
entryPoint
);
// eslint-disable-next-line no-empty
} catch (err) {}

const gasFee = await getGasFee(
this.networkName,
this.provider,
Expand All @@ -177,11 +188,11 @@ export class Eth {

return {
preVerificationGas,
verificationGasLimit,
verificationGas: verificationGasLimit,
verificationGasLimit: userOpToEstimate.verificationGasLimit,
verificationGas: userOpToEstimate.verificationGasLimit,
validAfter: BigNumber.from(validAfter),
validUntil: BigNumber.from(validUntil),
callGasLimit,
callGasLimit: userOpToEstimate.callGasLimit,
maxFeePerGas: gasFee.maxFeePerGas,
maxPriorityFeePerGas: gasFee.maxPriorityFeePerGas,
};
Expand Down
4 changes: 4 additions & 0 deletions packages/executor/src/services/BundlingService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ export class BundlingService {

async sendNextBundle(): Promise<SendBundleReturn | null> {
return await this.mutex.runExclusive(async () => {
const entries = await this.mempoolService.getSortedOps();
if (!entries.length) {
return null;
}
this.logger.debug("sendNextBundle");
const gasFee = await getGasFee(
this.network,
Expand Down
20 changes: 20 additions & 0 deletions packages/executor/src/services/UserOpValidation/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,24 @@ export class UserOpValidationService {

return true;
}

async binarySearchVGL(
userOp: UserOperationStruct,
entryPoint: string
): Promise<UserOperationStruct> {
if (this.config.unsafeMode) {
return this.estimationService.binarySearchVGL(userOp, entryPoint);
}
return this.estimationService.binarySearchVGLSafe(userOp, entryPoint);
}

async binarySearchCGL(
userOp: UserOperationStruct,
entryPoint: string
): Promise<UserOperationStruct> {
if (this.config.unsafeMode) {
return userOp; // CGL search not supported in unsafeMode
}
return this.estimationService.binarySearchCGLSafe(userOp, entryPoint);
}
}
20 changes: 19 additions & 1 deletion packages/executor/src/services/UserOpValidation/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export function nethermindErrorHandler(
): any {
try {
let { error } = errorResult;
if (error.error) {
if (error && error.error) {
error = error.error;
}
if (error && error.code == -32015 && error.data.startsWith("Reverted ")) {
Expand Down Expand Up @@ -311,3 +311,21 @@ export function isSlotAssociatedWith(
}
return false;
}

export function parseValidationResult(
entryPointContract: IEntryPoint,
userOp: UserOperationStruct,
data: string
): UserOpValidationResult {
const { name: errorName, args: errorArgs } =
entryPointContract.interface.parseError(data);
const errFullName = `${errorName}(${errorArgs.toString()})`;
const errResult = parseErrorResult(userOp, {
errorName,
errorArgs,
});
if (!errorName.includes("Result")) {
throw new Error(errFullName);
}
return errResult;
}
Loading