Skip to content

Commit c5cec0b

Browse files
authored
Merge pull request #43 from etherspot/arbitrum
Fix issue with the tracer on arbitrum
2 parents 2e20e33 + a800be0 commit c5cec0b

18 files changed

Lines changed: 142 additions & 30 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.8",
7+
"version": "0.0.9",
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.8",
4+
"version": "0.0.9",
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.8",
3+
"version": "0.0.9",
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.8",
38+
"executor": "^0.0.9",
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.8"
43+
"types": "^0.0.9"
4444
},
4545
"devDependencies": {
4646
"@types/connect": "3.4.35"

packages/api/src/server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import fastify, { FastifyInstance } from "fastify";
22
import cors from "@fastify/cors";
33
import RpcError from "types/lib/api/errors/rpc-error";
4-
import { ServerConfig } from "types/src/api/interfaces";
4+
import { ServerConfig } from "types/lib/api/interfaces";
55
import logger from "./logger";
66

77
export class Server {

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.8",
3+
"version": "0.0.9",
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.8",
35-
"db": "^0.0.8",
36-
"executor": "^0.0.8",
34+
"api": "^0.0.9",
35+
"db": "^0.0.9",
36+
"executor": "^0.0.9",
3737
"find-up": "5.0.0",
3838
"got": "12.5.3",
3939
"js-yaml": "4.1.0",
40-
"types": "^0.0.8",
40+
"types": "^0.0.9",
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.8",
3+
"version": "0.0.9",
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.8"
40+
"types": "^0.0.9"
4141
}
4242
}

packages/executor/customTracer.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,9 @@ function tracer() {
5656
switch (opcode) {
5757
case 'SLOAD':
5858
case 'SSTORE':
59-
this.pSloadStore(log);
59+
if (log.getDepth() !== 1) {
60+
this.pSloadStore(log);
61+
}
6062
break;
6163
case 'REVERT':
6264
case 'RETURN':
@@ -73,7 +75,9 @@ function tracer() {
7375
}
7476
break;
7577
case 'KECCAK256':
76-
this.pKeccak(log);
78+
if (log.getDepth() !== 1) {
79+
this.pKeccak(log);
80+
}
7781
break;
7882
case 'NUMBER':
7983
if (log.getDepth() == 1) {

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.8",
3+
"version": "0.0.9",
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.8",
37-
"types": "^0.0.8"
36+
"params": "^0.0.9",
37+
"types": "^0.0.9"
3838
}
3939
}

packages/executor/src/executor.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ export class Executor {
9292
this.reputationService
9393
);
9494
this.eth = new Eth(
95+
this.network,
9596
this.provider,
9697
this.userOpValidationService,
9798
this.mempoolService,

packages/executor/src/modules/eth.ts

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { BigNumber, ethers } from "ethers";
1+
import { BigNumber, BigNumberish, ethers } from "ethers";
22
import { arrayify, hexlify } from "ethers/lib/utils";
33
import RpcError from "types/lib/api/errors/rpc-error";
44
import * as RpcErrorCodes from "types/lib/api/errors/rpc-error-codes";
@@ -13,6 +13,9 @@ import {
1313
UserOperationReceipt,
1414
} from "types/lib/api/interfaces";
1515
import { EntryPoint__factory } from "types/lib/executor/contracts/factories";
16+
import { NetworkName } from "types/lib";
17+
import { estimateArbitrumPVG } from "params/lib/gas-estimation/arbitrum";
18+
import { IPVGEstimator } from "params/lib/types/IPVGEstimator";
1619
import { NetworkConfig } from "../config";
1720
import { deepHexlify, packUserOp } from "../utils";
1821
import { UserOpValidationService, MempoolService } from "../services";
@@ -23,13 +26,22 @@ import {
2326
} from "./interfaces";
2427

2528
export class Eth {
29+
private pvgEstimator: IPVGEstimator | null = null;
30+
2631
constructor(
32+
private networkName: NetworkName,
2733
private provider: ethers.providers.JsonRpcProvider,
2834
private userOpValidationService: UserOpValidationService,
2935
private mempoolService: MempoolService,
3036
private config: NetworkConfig,
3137
private logger: Logger
32-
) {}
38+
) {
39+
if (
40+
["arbitrum", "arbitrumNitro", "arbitrumNova"].includes(this.networkName)
41+
) {
42+
this.pvgEstimator = estimateArbitrumPVG(this.provider);
43+
}
44+
}
3345

3446
/**
3547
*
@@ -86,14 +98,21 @@ export class Eth {
8698
preVerificationGas: 0,
8799
...userOp,
88100
};
89-
const preVerificationGas = this.calcPreVerificationGas(userOp);
101+
let preVerificationGas: BigNumberish = this.calcPreVerificationGas(userOp);
90102
userOpComplemented.preVerificationGas = preVerificationGas;
91103

92104
const { returnInfo } =
93105
await this.userOpValidationService.validateForEstimation(
94106
userOpComplemented,
95107
entryPoint
96108
);
109+
if (this.pvgEstimator) {
110+
preVerificationGas = await this.pvgEstimator(
111+
entryPoint,
112+
userOpComplemented,
113+
preVerificationGas
114+
);
115+
}
97116

98117
// eslint-disable-next-line prefer-const
99118
let { preOpGas, validAfter, validUntil } = returnInfo;
@@ -110,7 +129,7 @@ export class Eth {
110129
err.message.match(/reason="(.*?)"/)?.at(1) ?? "execution reverted";
111130
throw new RpcError(message, RpcErrorCodes.EXECUTION_REVERTED);
112131
});
113-
// const preVerificationGas = this.calcPreVerificationGas(userOp);
132+
114133
const verificationGas = BigNumber.from(preOpGas).toNumber();
115134
validAfter = BigNumber.from(validAfter);
116135
validUntil = BigNumber.from(validUntil);

0 commit comments

Comments
 (0)