Skip to content

Commit

Permalink
test binary searched cgl with eth_call (#235)
Browse files Browse the repository at this point in the history
0xSulpiride authored Aug 13, 2024
1 parent 2f968ea commit c412e9e
Showing 13 changed files with 61 additions and 45 deletions.
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@
"packages/*"
],
"npmClient": "yarn",
"version": "2.0.15",
"version": "2.0.16",
"stream": "true",
"command": {
"version": {
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": "2.0.15",
"version": "2.0.16",
"engines": {
"node": ">=18.0.0"
},
10 changes: 5 additions & 5 deletions packages/api/package.json
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@
"publishConfig": {
"access": "public"
},
"version": "2.0.15",
"version": "2.0.16",
"description": "The API module of Etherspot bundler client",
"author": "Etherspot",
"homepage": "https://https://github.com/etherspot/skandha#readme",
@@ -34,10 +34,10 @@
"dependencies": {
"@fastify/cors": "9.0.1",
"@fastify/websocket": "10.0.1",
"@skandha/executor": "^2.0.15",
"@skandha/monitoring": "^2.0.15",
"@skandha/types": "^2.0.15",
"@skandha/utils": "^2.0.15",
"@skandha/executor": "^2.0.16",
"@skandha/monitoring": "^2.0.16",
"@skandha/types": "^2.0.16",
"@skandha/utils": "^2.0.16",
"class-transformer": "0.5.1",
"class-validator": "0.14.1",
"ethers": "5.7.2",
14 changes: 7 additions & 7 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@
"publishConfig": {
"access": "public"
},
"version": "2.0.15",
"version": "2.0.16",
"description": "> TODO: description",
"author": "zincoshine <[email protected]>",
"homepage": "https://https://github.com/etherspot/skandha#readme",
@@ -40,12 +40,12 @@
"@libp2p/peer-id-factory": "2.0.1",
"@libp2p/prometheus-metrics": "1.1.3",
"@multiformats/multiaddr": "12.1.3",
"@skandha/api": "^2.0.15",
"@skandha/db": "^2.0.15",
"@skandha/executor": "^2.0.15",
"@skandha/monitoring": "^2.0.15",
"@skandha/node": "^2.0.15",
"@skandha/types": "^2.0.15",
"@skandha/api": "^2.0.16",
"@skandha/db": "^2.0.16",
"@skandha/executor": "^2.0.16",
"@skandha/monitoring": "^2.0.16",
"@skandha/node": "^2.0.16",
"@skandha/types": "^2.0.16",
"find-up": "5.0.0",
"got": "12.5.3",
"js-yaml": "4.1.0",
4 changes: 2 additions & 2 deletions packages/db/package.json
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@
"publishConfig": {
"access": "public"
},
"version": "2.0.15",
"version": "2.0.16",
"description": "The DB module of Etherspot bundler client",
"author": "Etherspot",
"homepage": "https://github.com/etherspot/etherspot-bundler#readme",
@@ -34,7 +34,7 @@
"dependencies": {
"@chainsafe/ssz": "0.10.1",
"@farcaster/rocksdb": "5.5.0",
"@skandha/types": "^2.0.15"
"@skandha/types": "^2.0.16"
},
"devDependencies": {
"@types/rocksdb": "3.0.1",
10 changes: 5 additions & 5 deletions packages/executor/package.json
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@
"publishConfig": {
"access": "public"
},
"version": "2.0.15",
"version": "2.0.16",
"description": "The Relayer module of Etherspot bundler client",
"author": "Etherspot",
"homepage": "https://https://github.com/etherspot/skandha#readme",
@@ -35,10 +35,10 @@
},
"dependencies": {
"@flashbots/ethers-provider-bundle": "0.6.2",
"@skandha/monitoring": "^2.0.15",
"@skandha/params": "^2.0.15",
"@skandha/types": "^2.0.15",
"@skandha/utils": "^2.0.15",
"@skandha/monitoring": "^2.0.16",
"@skandha/params": "^2.0.16",
"@skandha/types": "^2.0.16",
"@skandha/utils": "^2.0.16",
"async-mutex": "0.4.0",
"ethers": "5.7.2",
"strict-event-emitter-types": "2.0.0",
23 changes: 15 additions & 8 deletions packages/executor/src/modules/eth.ts
Original file line number Diff line number Diff line change
@@ -28,6 +28,7 @@ import {
import { GetNodeAPI, NetworkConfig } from "../interfaces";
import { EntryPointVersion } from "../services/EntryPointService/interfaces";
import { getUserOpGasLimit } from "../services/BundlingService/utils";
import { maxBn, minBn } from "../utils/bignumber";
import {
EstimateUserOperationGasArgs,
SendUserOperationGasArgs,
@@ -209,12 +210,8 @@ export class Eth {
.div(10000) // % markup
.add(cglMarkup || 0);

if (binarySearchCGL.lt(cglMarkup)) {
binarySearchCGL = BigNumber.from(cglMarkup);
}

//< checking for execution revert
await this.provider
const ethEstimateGas = await this.provider
.estimateGas({
from: entryPoint,
to: userOp.sender,
@@ -227,15 +224,25 @@ export class Eth {
});
//>

let callGasLimit = binarySearchCGL;
if (callGasLimit.gt(paidFeeCGL)) {
callGasLimit = paidFeeCGL;
let callGasLimit = minBn(binarySearchCGL, paidFeeCGL);
if (userOp.factoryData !== undefined && userOp.factoryData.length > 2) {
await this.provider
.estimateGas({
from: entryPoint,
to: userOp.sender,
data: userOp.callData,
gasLimit: callGasLimit,
})
.catch((_) => {
callGasLimit = maxBn(binarySearchCGL, paidFeeCGL);
});
}
this.logger.debug(
{
callGasLimit,
paidFeeCGL,
binarySearchCGL,
ethEstimateGas,
},
"estimated CGL"
);
9 changes: 9 additions & 0 deletions packages/executor/src/utils/bignumber.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { BigNumber } from "ethers";

export function minBn(lhs: BigNumber, rhs: BigNumber): BigNumber {
return lhs.gt(rhs) ? rhs : lhs;
}

export function maxBn(lhs: BigNumber, rhs: BigNumber): BigNumber {
return lhs.lt(rhs) ? rhs : lhs;
}
4 changes: 2 additions & 2 deletions packages/monitoring/package.json
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@
"publishConfig": {
"access": "public"
},
"version": "2.0.15",
"version": "2.0.16",
"description": "The Monitoring module of Etherspot bundler client",
"author": "Etherspot",
"homepage": "https://github.com/etherspot/etherspot-bundler#readme",
@@ -32,7 +32,7 @@
"check-readme": "typescript-docs-verifier"
},
"dependencies": {
"@skandha/types": "^2.0.15",
"@skandha/types": "^2.0.16",
"prom-client": "15.1.0"
}
}
16 changes: 8 additions & 8 deletions packages/node/package.json
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@
"publishConfig": {
"access": "public"
},
"version": "2.0.15",
"version": "2.0.16",
"description": "The bundler node module of Etherspot bundler client",
"author": "Etherspot",
"homepage": "https://https://github.com/etherspot/skandha#readme",
@@ -56,13 +56,13 @@
"@libp2p/prometheus-metrics": "1.1.3",
"@libp2p/tcp": "6.1.0",
"@multiformats/multiaddr": "11.4.0",
"@skandha/api": "^2.0.15",
"@skandha/db": "^2.0.15",
"@skandha/executor": "^2.0.15",
"@skandha/monitoring": "^2.0.15",
"@skandha/params": "^2.0.15",
"@skandha/types": "^2.0.15",
"@skandha/utils": "^2.0.15",
"@skandha/api": "^2.0.16",
"@skandha/db": "^2.0.16",
"@skandha/executor": "^2.0.16",
"@skandha/monitoring": "^2.0.16",
"@skandha/params": "^2.0.16",
"@skandha/types": "^2.0.16",
"@skandha/utils": "^2.0.16",
"abstract-leveldown": "7.2.0",
"datastore-core": "8.0.1",
"ethers": "5.7.2",
6 changes: 3 additions & 3 deletions packages/params/package.json
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@
"publishConfig": {
"access": "public"
},
"version": "2.0.15",
"version": "2.0.16",
"description": "Various bundler parameters",
"author": "Etherspot",
"homepage": "https://github.com/etherspot/skandha#readme",
@@ -28,8 +28,8 @@
"@arbitrum/sdk": "3.1.4",
"@chainsafe/ssz": "0.16.0",
"@mantleio/sdk": "0.2.1",
"@skandha/types": "^2.0.15",
"@skandha/utils": "^2.0.15",
"@skandha/types": "^2.0.16",
"@skandha/utils": "^2.0.16",
"ethers": "5.7.2"
},
"scripts": {
2 changes: 1 addition & 1 deletion packages/types/package.json
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@
"publishConfig": {
"access": "public"
},
"version": "2.0.15",
"version": "2.0.16",
"description": "The types of Etherspot bundler client",
"author": "Etherspot",
"homepage": "https://https://github.com/etherspot/skandha#readme",
4 changes: 2 additions & 2 deletions packages/utils/package.json
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@
"publishConfig": {
"access": "public"
},
"version": "2.0.15",
"version": "2.0.16",
"description": "utils of Etherspot bundler client",
"author": "Etherspot",
"homepage": "https://https://github.com/etherspot/skandha#readme",
@@ -33,7 +33,7 @@
},
"dependencies": {
"@chainsafe/as-sha256": "0.3.1",
"@skandha/types": "^2.0.15",
"@skandha/types": "^2.0.16",
"any-signal": "3.0.1",
"bigint-buffer": "1.1.5",
"case": "^1.6.3",

0 comments on commit c412e9e

Please sign in to comment.