diff --git a/lerna.json b/lerna.json index 301b0adc..424bbd6e 100644 --- a/lerna.json +++ b/lerna.json @@ -4,7 +4,7 @@ ], "npmClient": "yarn", "useWorkspaces": true, - "version": "0.0.7", + "version": "0.0.8", "stream": "true", "command": { "version": { diff --git a/package.json b/package.json index 16f0b425..545062fe 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "root", "private": true, - "version": "0.0.7", + "version": "0.0.8", "engines": { "node": ">=12.9.0" }, diff --git a/packages/api/package.json b/packages/api/package.json index f4fd4723..7c44ceef 100644 --- a/packages/api/package.json +++ b/packages/api/package.json @@ -1,6 +1,6 @@ { "name": "api", - "version": "0.0.7", + "version": "0.0.8", "description": "The API module of Etherspot bundler client", "author": "Etherspot", "homepage": "https://https://github.com/etherspot/skandha#readme", @@ -35,12 +35,12 @@ "class-transformer": "0.5.1", "class-validator": "0.14.0", "ethers": "5.7.2", - "executor": "^0.0.7", + "executor": "^0.0.8", "fastify": "4.14.1", "pino": "8.11.0", "pino-pretty": "10.0.0", "reflect-metadata": "0.1.13", - "types": "^0.0.7" + "types": "^0.0.8" }, "devDependencies": { "@types/connect": "3.4.35" diff --git a/packages/cli/package.json b/packages/cli/package.json index c9589fe6..cfcf839f 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,6 +1,6 @@ { "name": "cli", - "version": "0.0.7", + "version": "0.0.8", "description": "> TODO: description", "author": "zincoshine ", "homepage": "https://https://github.com/etherspot/skandha#readme", @@ -31,13 +31,13 @@ "url": "https://https://github.com/etherspot/skandha/issues" }, "dependencies": { - "api": "^0.0.7", - "db": "^0.0.7", - "executor": "^0.0.7", + "api": "^0.0.8", + "db": "^0.0.8", + "executor": "^0.0.8", "find-up": "5.0.0", "got": "12.5.3", "js-yaml": "4.1.0", - "types": "^0.0.7", + "types": "^0.0.8", "yargs": "17.6.2" }, "devDependencies": { diff --git a/packages/db/package.json b/packages/db/package.json index 63b1b45a..0856ab2b 100644 --- a/packages/db/package.json +++ b/packages/db/package.json @@ -1,6 +1,6 @@ { "name": "db", - "version": "0.0.7", + "version": "0.0.8", "description": "The DB module of Etherspot bundler client", "author": "Etherspot", "homepage": "https://github.com/etherspot/etherspot-bundler#readme", @@ -37,6 +37,6 @@ "devDependencies": { "@types/rocksdb": "3.0.1", "prettier": "^2.8.4", - "types": "^0.0.7" + "types": "^0.0.8" } } diff --git a/packages/executor/package.json b/packages/executor/package.json index d5bf0ccf..96d6b4db 100644 --- a/packages/executor/package.json +++ b/packages/executor/package.json @@ -1,6 +1,6 @@ { "name": "executor", - "version": "0.0.7", + "version": "0.0.8", "description": "The Relayer module of Etherspot bundler client", "author": "Etherspot", "homepage": "https://https://github.com/etherspot/skandha#readme", @@ -33,7 +33,7 @@ "dependencies": { "async-mutex": "0.4.0", "ethers": "5.7.2", - "params": "^0.0.7", - "types": "^0.0.7" + "params": "^0.0.8", + "types": "^0.0.8" } } diff --git a/packages/executor/src/executor.ts b/packages/executor/src/executor.ts index 090b79ec..554216d4 100644 --- a/packages/executor/src/executor.ts +++ b/packages/executor/src/executor.ts @@ -67,7 +67,8 @@ export class Executor { this.provider, this.reputationService, this.network, - this.config + this.config, + this.logger ); this.mempoolService = new MempoolService( this.db, diff --git a/packages/executor/src/modules/eth.ts b/packages/executor/src/modules/eth.ts index 25fc3cfe..a7e9d59b 100644 --- a/packages/executor/src/modules/eth.ts +++ b/packages/executor/src/modules/eth.ts @@ -80,10 +80,10 @@ export class Eth { } const userOpComplemented: UserOperationStruct = { paymasterAndData: userOp.paymasterAndData ?? "0x", + verificationGasLimit: 10e6, maxFeePerGas: 0, maxPriorityFeePerGas: 0, preVerificationGas: 0, - verificationGasLimit: 10e6, ...userOp, }; const preVerificationGas = this.calcPreVerificationGas(userOp); diff --git a/packages/executor/src/services/BundlingService.ts b/packages/executor/src/services/BundlingService.ts index dd9c8d09..0a6000bd 100644 --- a/packages/executor/src/services/BundlingService.ts +++ b/packages/executor/src/services/BundlingService.ts @@ -1,11 +1,12 @@ /* eslint-disable @typescript-eslint/no-non-null-assertion */ -import { BigNumber, ethers, providers } from "ethers"; +import { BigNumber, BigNumberish, ethers, providers } from "ethers"; import { NetworkName } from "types/lib"; import { EntryPoint__factory } from "types/lib/executor/contracts/factories"; import { EntryPoint } from "types/lib/executor/contracts/EntryPoint"; import { Mutex } from "async-mutex"; import { SendBundleReturn } from "types/lib/executor"; import { IMulticall3__factory } from "types/lib/executor/contracts/factories/IMulticall3__factory"; +import { chainsWithoutEIP1559 } from "params/lib"; import { getAddr } from "../utils"; import { MempoolEntry } from "../entities/MempoolEntry"; import { ReputationStatus } from "../entities/interfaces"; @@ -71,27 +72,27 @@ export class BundlingService { "handleOps", [bundle.map((entry) => entry.userOp), beneficiary] ); - this.logger.debug( - JSON.stringify( - { - to: entryPoint, - data: txRequest, - type: 2, - maxPriorityFeePerGas: gasFee.maxPriorityFeePerGas ?? 0, - maxFeePerGas: gasFee.maxFeePerGas ?? 0, - }, - undefined, - 2 - ) - ); - const gasLimit = await this.estimateBundleGas(bundle); - const tx = await wallet.sendTransaction({ + const transaction = { to: entryPoint, data: txRequest, type: 2, - maxPriorityFeePerGas: gasFee.maxPriorityFeePerGas ?? 0, - maxFeePerGas: gasFee.maxFeePerGas ?? 0, + maxPriorityFeePerGas: gasFee.maxPriorityFeePerGas, + maxFeePerGas: gasFee.maxFeePerGas, + gasPrice: undefined as BigNumberish | undefined, + }; + if (chainsWithoutEIP1559.some((network) => network === this.network)) { + transaction.type = 1; + transaction.gasPrice = gasFee.gasPrice; + delete transaction.maxPriorityFeePerGas; + delete transaction.maxFeePerGas; + } + + this.logger.debug(JSON.stringify(transaction, undefined, 2)); + + const gasLimit = await this.estimateBundleGas(bundle); + const tx = await wallet.sendTransaction({ + ...transaction, gasLimit, }); diff --git a/packages/executor/src/services/UserOpValidation.ts b/packages/executor/src/services/UserOpValidation.ts index 76395755..f108b508 100644 --- a/packages/executor/src/services/UserOpValidation.ts +++ b/packages/executor/src/services/UserOpValidation.ts @@ -16,7 +16,7 @@ import { import { BannedContracts } from "params/lib"; import { NetworkName } from "types/lib"; import { getAddr } from "../utils"; -import { TracerCall, TracerResult } from "../interfaces"; +import { Logger, TracerCall, TracerResult } from "../interfaces"; import { Config } from "../config"; import { ReputationService } from "./ReputationService"; import { GethTracer } from "./GethTracer"; @@ -56,7 +56,8 @@ export class UserOpValidationService { private provider: providers.Provider, private reputationService: ReputationService, private network: NetworkName, - private config: Config + private config: Config, + private logger: Logger ) { this.gethTracer = new GethTracer( this.provider as providers.JsonRpcProvider @@ -76,12 +77,27 @@ export class UserOpValidationService { .catch((e: any) => this.nethermindErrorHandler(entryPointContract, e)); if (errorResult.errorName === "FailedOp") { + this.logger.debug({ + to: entryPoint, + data: entryPointContract.interface.encodeFunctionData( + "simulateValidation", + [userOp] + ), + }); throw new RpcError( errorResult.errorArgs.at(-1), RpcErrorCodes.VALIDATION_FAILED ); } + if (errorResult.errorName !== "ValidationResult") { + this.logger.debug({ + to: entryPoint, + data: entryPointContract.interface.encodeFunctionData( + "simulateValidation", + [userOp] + ), + }); throw errorResult; } diff --git a/packages/executor/src/utils/getGasFee.ts b/packages/executor/src/utils/getGasFee.ts index bf319a89..47d4f636 100644 --- a/packages/executor/src/utils/getGasFee.ts +++ b/packages/executor/src/utils/getGasFee.ts @@ -4,6 +4,7 @@ import { NetworkName } from "types/lib"; export type IGetGasFeeResult = { maxPriorityFeePerGas: BigNumberish | undefined; maxFeePerGas: BigNumberish | undefined; + gasPrice: BigNumberish | undefined; }; export const getGasFee = async ( @@ -23,14 +24,17 @@ export const getGasFee = async ( return { maxPriorityFeePerGas: feeData.maxPriorityFeePerGas ?? 0, maxFeePerGas: feeData.maxFeePerGas ?? 0, + gasPrice: feeData.gasPrice ?? 0, }; } catch (err) { // eslint-disable-next-line no-console console.error(`Couldn't fetch fee data: ${err}`); } + return { maxPriorityFeePerGas: undefined, maxFeePerGas: undefined, + gasPrice: undefined, }; }; @@ -44,5 +48,6 @@ export const getMaticGasFee = async (): Promise => { return { maxPriorityFeePerGas: parseGwei(data.fast.maxPriorityFee), maxFeePerGas: parseGwei(data.fast.maxFee), + gasPrice: parseGwei(data.fast.maxFee), }; }; diff --git a/packages/params/package.json b/packages/params/package.json index 0257c725..d9dbd1db 100644 --- a/packages/params/package.json +++ b/packages/params/package.json @@ -1,6 +1,6 @@ { "name": "params", - "version": "0.0.7", + "version": "0.0.8", "description": "Various bundler parameters", "author": "Etherspot", "homepage": "https://github.com/etherspot/skandha#readme", @@ -21,7 +21,7 @@ "url": "https://github.com/etherspot/skandha/issues" }, "dependencies": { - "types": "^0.0.7" + "types": "^0.0.8" }, "scripts": { "clean": "rm -rf lib && rm -f *.tsbuildinfo", diff --git a/packages/params/src/eip1559.ts b/packages/params/src/eip1559.ts new file mode 100644 index 00000000..7f11d603 --- /dev/null +++ b/packages/params/src/eip1559.ts @@ -0,0 +1,8 @@ +import { NetworkName } from "types/lib"; + +export const chainsWithoutEIP1559: NetworkName[] = [ + "fuse", + "fuseSparknet", + "bsc", + "bscTest", +]; diff --git a/packages/params/src/index.ts b/packages/params/src/index.ts index 3cd8baa9..0be7855b 100644 --- a/packages/params/src/index.ts +++ b/packages/params/src/index.ts @@ -1 +1,2 @@ export * from "./bannedContracts"; +export * from "./eip1559"; diff --git a/packages/types/package.json b/packages/types/package.json index 5e448efb..da7d9889 100644 --- a/packages/types/package.json +++ b/packages/types/package.json @@ -1,6 +1,6 @@ { "name": "types", - "version": "0.0.7", + "version": "0.0.8", "description": "The types of Etherspot bundler client", "author": "Etherspot", "homepage": "https://https://github.com/etherspot/skandha#readme",