diff --git a/lerna.json b/lerna.json index d544facd..c877993a 100644 --- a/lerna.json +++ b/lerna.json @@ -4,7 +4,7 @@ ], "npmClient": "yarn", "useWorkspaces": true, - "version": "1.0.13-alpha", + "version": "1.0.14-alpha", "stream": "true", "command": { "version": { diff --git a/package.json b/package.json index f7b83e7c..ea37b7f9 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "root", "private": true, - "version": "1.0.13-alpha", + "version": "1.0.14-alpha", "engines": { "node": ">=18.0.0" }, diff --git a/packages/api/package.json b/packages/api/package.json index 9016b704..bcc7e722 100644 --- a/packages/api/package.json +++ b/packages/api/package.json @@ -1,6 +1,6 @@ { "name": "api", - "version": "1.0.13-alpha", + "version": "1.0.14-alpha", "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": "^1.0.13-alpha", + "executor": "^1.0.14-alpha", "fastify": "4.14.1", "pino": "8.11.0", "pino-pretty": "10.0.0", "reflect-metadata": "0.1.13", - "types": "^1.0.13-alpha" + "types": "^1.0.14-alpha" }, "devDependencies": { "@types/connect": "3.4.35" diff --git a/packages/api/src/modules/redirect.ts b/packages/api/src/modules/redirect.ts index 6cf33c8d..4231d536 100644 --- a/packages/api/src/modules/redirect.ts +++ b/packages/api/src/modules/redirect.ts @@ -32,6 +32,16 @@ export class RedirectAPI { } /** */ + /** BIFROST ERROR PARSIGN */ + if ( + body.error.data && + body.error.code == -32603 && + body.error.data + ) { + body.error.code = 3; + body.error.message = "execution reverted"; + } + return body; // eslint-disable-next-line no-empty } catch (err) {} diff --git a/packages/cli/package.json b/packages/cli/package.json index 6f415c59..e3458fdf 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,6 +1,6 @@ { "name": "cli", - "version": "1.0.13-alpha", + "version": "1.0.14-alpha", "description": "> TODO: description", "author": "zincoshine ", "homepage": "https://https://github.com/etherspot/skandha#readme", @@ -38,14 +38,14 @@ "@libp2p/peer-id-factory": "2.0.1", "@libp2p/prometheus-metrics": "1.1.3", "@multiformats/multiaddr": "12.1.3", - "api": "^1.0.13-alpha", - "db": "^1.0.13-alpha", - "executor": "^1.0.13-alpha", + "api": "^1.0.14-alpha", + "db": "^1.0.14-alpha", + "executor": "^1.0.14-alpha", "find-up": "5.0.0", "got": "12.5.3", "js-yaml": "4.1.0", - "node": "^1.0.13-alpha", - "types": "^1.0.13-alpha", + "node": "^1.0.14-alpha", + "types": "^1.0.14-alpha", "yargs": "17.6.2" }, "devDependencies": { diff --git a/packages/db/package.json b/packages/db/package.json index 76299b46..221b00b6 100644 --- a/packages/db/package.json +++ b/packages/db/package.json @@ -1,6 +1,6 @@ { "name": "db", - "version": "1.0.13-alpha", + "version": "1.0.14-alpha", "description": "The DB module of Etherspot bundler client", "author": "Etherspot", "homepage": "https://github.com/etherspot/etherspot-bundler#readme", @@ -33,7 +33,7 @@ "dependencies": { "@chainsafe/ssz": "0.10.1", "@farcaster/rocksdb": "5.5.0", - "types": "^1.0.13-alpha" + "types": "^1.0.14-alpha" }, "devDependencies": { "@types/rocksdb": "3.0.1", diff --git a/packages/executor/package.json b/packages/executor/package.json index 74885475..f42c4da3 100644 --- a/packages/executor/package.json +++ b/packages/executor/package.json @@ -1,6 +1,6 @@ { "name": "executor", - "version": "1.0.13-alpha", + "version": "1.0.14-alpha", "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": "^1.0.13-alpha", - "types": "^1.0.13-alpha" + "params": "^1.0.14-alpha", + "types": "^1.0.14-alpha" } } diff --git a/packages/executor/src/modules/eth.ts b/packages/executor/src/modules/eth.ts index 98210ec7..966896af 100644 --- a/packages/executor/src/modules/eth.ts +++ b/packages/executor/src/modules/eth.ts @@ -151,14 +151,6 @@ export class Eth { let preVerificationGas: BigNumberish = this.calcPreVerificationGas(userOp); userOpComplemented.preVerificationGas = preVerificationGas; - if (this.pvgEstimator) { - preVerificationGas = await this.pvgEstimator( - entryPoint, - userOpComplemented, - preVerificationGas - ); - } - let callGasLimit: BigNumber = BigNumber.from(0); // calculate callGasLimit based on paid fee @@ -202,6 +194,18 @@ export class Eth { } ); + if (this.pvgEstimator) { + userOpComplemented.maxFeePerGas = + gasFee.maxFeePerGas ?? gasFee.gasPrice ?? 1; + userOpComplemented.maxPriorityFeePerGas = + gasFee.maxPriorityFeePerGas ?? gasFee.gasPrice ?? 1; + preVerificationGas = await this.pvgEstimator( + entryPoint, + userOpComplemented, + preVerificationGas + ); + } + return { preVerificationGas, verificationGasLimit: userOpToEstimate.verificationGasLimit, diff --git a/packages/executor/src/services/UserOpValidation/utils.ts b/packages/executor/src/services/UserOpValidation/utils.ts index 7448cb2e..e7262996 100644 --- a/packages/executor/src/services/UserOpValidation/utils.ts +++ b/packages/executor/src/services/UserOpValidation/utils.ts @@ -17,7 +17,7 @@ import { BundlerCollectorReturn, CallEntry } from "types/lib/executor"; import { UserOpValidationResult, StakeInfo } from "../../interfaces"; import { getAddr } from "../../utils"; -export function nethermindErrorHandler( +export function nonGethErrorHandler( epContract: IEntryPoint, errorResult: any ): any { @@ -27,12 +27,21 @@ export function nethermindErrorHandler( error = error.error; } if (error && error.code == -32015 && error.data.startsWith("Reverted ")) { + /** NETHERMIND */ const parsed = epContract.interface.parseError(error.data.slice(9)); errorResult = { ...parsed, errorName: parsed.name, errorArgs: parsed.args, }; + } else if (error && error.code == -32603 && error.data) { + /** BIFROST */ + const parsed = epContract.interface.parseError(error.data); + errorResult = { + ...parsed, + errorName: parsed.name, + errorArgs: parsed.args, + }; } } catch (err) { /* empty */ diff --git a/packages/executor/src/services/UserOpValidation/validators/estimation.ts b/packages/executor/src/services/UserOpValidation/validators/estimation.ts index 3b4ceb61..16bf1679 100644 --- a/packages/executor/src/services/UserOpValidation/validators/estimation.ts +++ b/packages/executor/src/services/UserOpValidation/validators/estimation.ts @@ -5,7 +5,7 @@ import { UserOperationStruct } from "types/lib/executor/contracts/EntryPoint"; import { BundlerCollectorReturn, ExitInfo } from "types/lib/executor"; import * as RpcErrorCodes from "types/lib/api/errors/rpc-error-codes"; import { BigNumber, providers } from "ethers"; -import { nethermindErrorHandler } from "../utils"; +import { nonGethErrorHandler } from "../utils"; import { ExecutionResult, Logger } from "../../../interfaces"; import { GethTracer } from "../GethTracer"; @@ -49,7 +49,7 @@ export class EstimationService { const errorResult = await entryPointContract.callStatic .simulateHandleOp(userOp, AddressZero, BytesZero) - .catch((e: any) => nethermindErrorHandler(entryPointContract, e)); + .catch((e: any) => nonGethErrorHandler(entryPointContract, e)); if (errorResult.errorName === "FailedOp") { throw new RpcError( diff --git a/packages/executor/src/services/UserOpValidation/validators/unsafe.ts b/packages/executor/src/services/UserOpValidation/validators/unsafe.ts index 64df3447..5d9aa934 100644 --- a/packages/executor/src/services/UserOpValidation/validators/unsafe.ts +++ b/packages/executor/src/services/UserOpValidation/validators/unsafe.ts @@ -6,7 +6,7 @@ import { NetworkConfig, UserOpValidationResult, } from "../../../interfaces"; -import { nethermindErrorHandler, parseErrorResult } from "../utils"; +import { nonGethErrorHandler, parseErrorResult } from "../utils"; export class UnsafeValidationService { constructor( @@ -28,7 +28,7 @@ export class UnsafeValidationService { .simulateValidation(userOp, { gasLimit: validationGasLimit, }) - .catch((e: any) => nethermindErrorHandler(entryPointContract, e)); + .catch((e: any) => nonGethErrorHandler(entryPointContract, e)); return parseErrorResult(userOp, errorResult); } } diff --git a/packages/node/package.json b/packages/node/package.json index 7b727ab7..da96b857 100644 --- a/packages/node/package.json +++ b/packages/node/package.json @@ -1,6 +1,6 @@ { "name": "node", - "version": "1.0.13-alpha", + "version": "1.0.14-alpha", "description": "The bundler node module of Etherspot bundler client", "author": "Etherspot", "homepage": "https://https://github.com/etherspot/skandha#readme", @@ -56,24 +56,24 @@ "@libp2p/tcp": "6.1.0", "@multiformats/multiaddr": "11.4.0", "abstract-leveldown": "7.2.0", - "api": "^1.0.13-alpha", + "api": "^1.0.14-alpha", "datastore-core": "8.0.1", - "db": "^1.0.13-alpha", + "db": "^1.0.14-alpha", "ethers": "5.7.2", - "executor": "^1.0.13-alpha", + "executor": "^1.0.14-alpha", "it-filter": "1.0.2", "it-map": "1.0.5", "it-sort": "1.0.0", "it-take": "1.0.1", "libp2p": "0.42.2", - "params": "^1.0.13-alpha", + "params": "^1.0.14-alpha", "prettier": "2.8.4", "snappy": "7.2.2", "snappyjs": "0.7.0", "stream-to-it": "0.2.4", "strict-event-emitter-types": "2.0.0", - "types": "^1.0.13-alpha", - "utils": "^1.0.13-alpha", + "types": "^1.0.14-alpha", + "utils": "^1.0.14-alpha", "varint": "6.0.0", "xxhash-wasm": "1.0.2" }, diff --git a/packages/params/package.json b/packages/params/package.json index 3098309b..f4a639b0 100644 --- a/packages/params/package.json +++ b/packages/params/package.json @@ -1,6 +1,6 @@ { "name": "params", - "version": "1.0.13-alpha", + "version": "1.0.14-alpha", "description": "Various bundler parameters", "author": "Etherspot", "homepage": "https://github.com/etherspot/skandha#readme", @@ -26,8 +26,8 @@ "@eth-optimism/sdk": "3.0.0", "@mantleio/sdk": "0.2.1", "ethers": "5.7.2", - "types": "^1.0.13-alpha", - "utils": "^1.0.13-alpha" + "types": "^1.0.14-alpha", + "utils": "^1.0.14-alpha" }, "scripts": { "clean": "rm -rf lib && rm -f *.tsbuildinfo", diff --git a/packages/params/src/gas-estimation/optimism.ts b/packages/params/src/gas-estimation/optimism.ts index fb165da6..2f894b95 100644 --- a/packages/params/src/gas-estimation/optimism.ts +++ b/packages/params/src/gas-estimation/optimism.ts @@ -1,7 +1,7 @@ import { UserOperationStruct } from "types/lib/executor/contracts/EntryPoint"; import { BigNumber, BigNumberish, ethers } from "ethers"; import { IEntryPoint__factory } from "types/lib/executor/contracts"; -import { estimateL1Gas } from "@eth-optimism/sdk"; +import { estimateL1GasCost } from "@eth-optimism/sdk"; import { IPVGEstimator, IPVGEstimatorWrapper } from "../types/IPVGEstimator"; export const estimateOptimismPVG: IPVGEstimatorWrapper = ( @@ -20,11 +20,20 @@ export const estimateOptimismPVG: IPVGEstimatorWrapper = ( ]); try { - const l1GasEstimated = await estimateL1Gas(provider, { + const latestBlock = await provider.getBlock("latest"); + if (latestBlock.baseFeePerGas == null) { + throw new Error("no base fee"); + } + const l1GasCost = await estimateL1GasCost(provider, { to: entryPointAddr, data: handleOpsData, }); - return l1GasEstimated.add(initial); + const l2MaxFee = BigNumber.from(userOp.maxFeePerGas); + const l2PriorityFee = latestBlock.baseFeePerGas.add( + userOp.maxPriorityFeePerGas + ); + const l2Price = l2MaxFee.lt(l2PriorityFee) ? l2MaxFee : l2PriorityFee; + return l1GasCost.div(l2Price).add(initial); } catch (err) { // eslint-disable-next-line no-console console.error("Error while estimating optimism PVG", err); diff --git a/packages/types/package.json b/packages/types/package.json index 39e577d5..249895e5 100644 --- a/packages/types/package.json +++ b/packages/types/package.json @@ -1,6 +1,6 @@ { "name": "types", - "version": "1.0.13-alpha", + "version": "1.0.14-alpha", "description": "The types of Etherspot bundler client", "author": "Etherspot", "homepage": "https://https://github.com/etherspot/skandha#readme", diff --git a/packages/utils/package.json b/packages/utils/package.json index 6b704f1c..455f4e8f 100644 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -1,6 +1,6 @@ { "name": "utils", - "version": "1.0.13-alpha", + "version": "1.0.14-alpha", "description": "utils of Etherspot bundler client", "author": "Etherspot", "homepage": "https://https://github.com/etherspot/skandha#readme", @@ -37,6 +37,6 @@ "case": "^1.6.3", "pino": "8.11.0", "pino-pretty": "10.0.0", - "types": "^1.0.13-alpha" + "types": "^1.0.14-alpha" } }