Skip to content

Commit 2e5559f

Browse files
authored
Merge pull request #45 from etherspot/optimism-gas-limit
add additional pvg for optimism
2 parents c5cec0b + c1fda8e commit 2e5559f

13 files changed

Lines changed: 524 additions & 36 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.9",
7+
"version": "0.0.10",
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.9",
4+
"version": "0.0.10",
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.9",
3+
"version": "0.0.10",
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.9",
38+
"executor": "^0.0.10",
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.9"
43+
"types": "^0.0.10"
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.9",
3+
"version": "0.0.10",
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.9",
35-
"db": "^0.0.9",
36-
"executor": "^0.0.9",
34+
"api": "^0.0.10",
35+
"db": "^0.0.10",
36+
"executor": "^0.0.10",
3737
"find-up": "5.0.0",
3838
"got": "12.5.3",
3939
"js-yaml": "4.1.0",
40-
"types": "^0.0.9",
40+
"types": "^0.0.10",
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.9",
3+
"version": "0.0.10",
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.9"
40+
"types": "^0.0.10"
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.9",
3+
"version": "0.0.10",
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.9",
37-
"types": "^0.0.9"
36+
"params": "^0.0.10",
37+
"types": "^0.0.10"
3838
}
3939
}

packages/executor/src/modules/eth.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ import {
1414
} from "types/lib/api/interfaces";
1515
import { EntryPoint__factory } from "types/lib/executor/contracts/factories";
1616
import { NetworkName } from "types/lib";
17-
import { estimateArbitrumPVG } from "params/lib/gas-estimation/arbitrum";
1817
import { IPVGEstimator } from "params/lib/types/IPVGEstimator";
18+
import { estimateOptimismPVG, estimateArbitrumPVG } from "params/lib";
1919
import { NetworkConfig } from "../config";
2020
import { deepHexlify, packUserOp } from "../utils";
2121
import { UserOpValidationService, MempoolService } from "../services";
@@ -41,6 +41,10 @@ export class Eth {
4141
) {
4242
this.pvgEstimator = estimateArbitrumPVG(this.provider);
4343
}
44+
45+
if (["optimism", "optimismGoerli"].includes(this.networkName)) {
46+
this.pvgEstimator = estimateOptimismPVG(this.provider);
47+
}
4448
}
4549

4650
/**

packages/params/package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "params",
3-
"version": "0.0.9",
3+
"version": "0.0.10",
44
"description": "Various bundler parameters",
55
"author": "Etherspot",
66
"homepage": "https://github.com/etherspot/skandha#readme",
@@ -21,9 +21,10 @@
2121
"url": "https://github.com/etherspot/skandha/issues"
2222
},
2323
"dependencies": {
24-
"types": "^0.0.9",
24+
"@arbitrum/sdk": "3.1.4",
25+
"@eth-optimism/sdk": "3.0.0",
2526
"ethers": "5.7.2",
26-
"@arbitrum/sdk": "3.1.4"
27+
"types": "^0.0.10"
2728
},
2829
"scripts": {
2930
"clean": "rm -rf lib && rm -f *.tsbuildinfo",
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export * from "./arbitrum";
2+
export * from "./optimism";
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import { UserOperationStruct } from "types/lib/executor/contracts/EntryPoint";
2+
import { BigNumber, BigNumberish, ethers } from "ethers";
3+
import { EntryPoint__factory } from "types/lib/executor/contracts";
4+
import { estimateL1Gas } from "@eth-optimism/sdk";
5+
import { IPVGEstimator, IPVGEstimatorWrapper } from "../types/IPVGEstimator";
6+
7+
export const estimateOptimismPVG: IPVGEstimatorWrapper = (
8+
provider
9+
): IPVGEstimator => {
10+
const dummyWallet = ethers.Wallet.createRandom();
11+
return async (
12+
entryPointAddr: string,
13+
userOp: UserOperationStruct,
14+
initial: BigNumberish
15+
): Promise<BigNumber> => {
16+
const entryPoint = EntryPoint__factory.connect(entryPointAddr, provider);
17+
const handleOpsData = entryPoint.interface.encodeFunctionData("handleOps", [
18+
[userOp],
19+
dummyWallet.address,
20+
]);
21+
22+
try {
23+
const l1GasEstimated = await estimateL1Gas(provider, {
24+
to: entryPointAddr,
25+
data: handleOpsData,
26+
});
27+
return l1GasEstimated.add(initial);
28+
} catch (err) {
29+
// eslint-disable-next-line no-console
30+
console.error("Error while estimating optimism PVG", err);
31+
return BigNumber.from(initial);
32+
}
33+
};
34+
};

0 commit comments

Comments
 (0)