diff --git a/lerna.json b/lerna.json index 7e51218b..0205db92 100644 --- a/lerna.json +++ b/lerna.json @@ -4,7 +4,7 @@ ], "npmClient": "yarn", "useWorkspaces": true, - "version": "1.0.17-alpha", + "version": "1.0.18-alpha", "stream": "true", "command": { "version": { diff --git a/package.json b/package.json index 5a9dc416..a1ee000d 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "root", "private": true, - "version": "1.0.17-alpha", + "version": "1.0.18-alpha", "engines": { "node": ">=18.0.0" }, diff --git a/packages/api/package.json b/packages/api/package.json index 0cbb35a2..35cea972 100644 --- a/packages/api/package.json +++ b/packages/api/package.json @@ -1,6 +1,6 @@ { "name": "api", - "version": "1.0.17-alpha", + "version": "1.0.18-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.17-alpha", + "executor": "^1.0.18-alpha", "fastify": "4.14.1", "pino": "8.11.0", "pino-pretty": "10.0.0", "reflect-metadata": "0.1.13", - "types": "^1.0.17-alpha" + "types": "^1.0.18-alpha" }, "devDependencies": { "@types/connect": "3.4.35" diff --git a/packages/cli/package.json b/packages/cli/package.json index ee52b254..d795d221 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,6 +1,6 @@ { "name": "cli", - "version": "1.0.17-alpha", + "version": "1.0.18-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.17-alpha", - "db": "^1.0.17-alpha", - "executor": "^1.0.17-alpha", + "api": "^1.0.18-alpha", + "db": "^1.0.18-alpha", + "executor": "^1.0.18-alpha", "find-up": "5.0.0", "got": "12.5.3", "js-yaml": "4.1.0", - "node": "^1.0.17-alpha", - "types": "^1.0.17-alpha", + "node": "^1.0.18-alpha", + "types": "^1.0.18-alpha", "yargs": "17.6.2" }, "devDependencies": { diff --git a/packages/db/package.json b/packages/db/package.json index c40f0fb5..333b299b 100644 --- a/packages/db/package.json +++ b/packages/db/package.json @@ -1,6 +1,6 @@ { "name": "db", - "version": "1.0.17-alpha", + "version": "1.0.18-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.17-alpha" + "types": "^1.0.18-alpha" }, "devDependencies": { "@types/rocksdb": "3.0.1", diff --git a/packages/executor/package.json b/packages/executor/package.json index 3bde2c51..8df91897 100644 --- a/packages/executor/package.json +++ b/packages/executor/package.json @@ -1,6 +1,6 @@ { "name": "executor", - "version": "1.0.17-alpha", + "version": "1.0.18-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.17-alpha", - "types": "^1.0.17-alpha" + "params": "^1.0.18-alpha", + "types": "^1.0.18-alpha" } } diff --git a/packages/executor/src/entities/MempoolEntry.ts b/packages/executor/src/entities/MempoolEntry.ts index 57b7da77..ed0576ff 100644 --- a/packages/executor/src/entities/MempoolEntry.ts +++ b/packages/executor/src/entities/MempoolEntry.ts @@ -1,5 +1,5 @@ import { BigNumber, BigNumberish, ethers } from "ethers"; -import { hexValue } from "ethers/lib/utils"; +import { getAddress, hexValue } from "ethers/lib/utils"; import * as RpcErrorCodes from "types/lib/api/errors/rpc-error-codes"; import RpcError from "types/lib/api/errors/rpc-error"; import { UserOperationStruct } from "types/lib/executor/contracts/EntryPoint"; @@ -111,6 +111,8 @@ export class MempoolEntry implements IMempoolEntry { validateAndTransformUserOp(): void { try { + this.userOp.sender = getAddress(this.userOp.sender); + this.entryPoint = getAddress(this.entryPoint); this.prefund = BigNumber.from(this.prefund); this.userOp.nonce = BigNumber.from(this.userOp.nonce); this.userOp.callGasLimit = BigNumber.from(this.userOp.callGasLimit); @@ -133,7 +135,7 @@ export class MempoolEntry implements IMempoolEntry { return { chainId: this.chainId, userOp: { - sender: this.userOp.sender, + sender: getAddress(this.userOp.sender), nonce: hexValue(this.userOp.nonce), initCode: this.userOp.initCode, callData: this.userOp.callData, diff --git a/packages/executor/src/executor.ts b/packages/executor/src/executor.ts index a928b8df..3c57716c 100644 --- a/packages/executor/src/executor.ts +++ b/packages/executor/src/executor.ts @@ -105,11 +105,19 @@ export class Executor { this.mempoolService, this.reputationService ); + this.skandha = new Skandha( + this.networkName, + this.chainId, + this.provider, + this.config, + this.logger + ); this.eth = new Eth( this.chainId, this.provider, this.userOpValidationService, this.mempoolService, + this.skandha, this.networkConfig, this.logger, this.nodeApi @@ -121,13 +129,6 @@ export class Executor { this.config, this.logger ); - this.skandha = new Skandha( - this.networkName, - this.chainId, - this.provider, - this.config, - this.logger - ); if (this.config.testingMode || options.bundlingMode == "manual") { this.bundlingService.setBundlingMode("manual"); diff --git a/packages/executor/src/modules/eth.ts b/packages/executor/src/modules/eth.ts index 4808691d..6114d4e3 100644 --- a/packages/executor/src/modules/eth.ts +++ b/packages/executor/src/modules/eth.ts @@ -29,6 +29,7 @@ import { EstimateUserOperationGasArgs, SendUserOperationGasArgs, } from "./interfaces"; +import { Skandha } from "./skandha"; export class Eth { private pvgEstimator: IPVGEstimator | null = null; @@ -38,6 +39,7 @@ export class Eth { private provider: ethers.providers.JsonRpcProvider, private userOpValidationService: UserOpValidationService, private mempoolService: MempoolService, + private skandhaModule: Skandha, private config: NetworkConfig, private logger: Logger, private nodeApi?: INodeAPI @@ -190,21 +192,11 @@ export class Eth { callGasLimit, }; - const gasFee = await getGasFee( - this.chainId, - this.provider, - this.config.etherscanApiKey, - { - entryPoint, - userOp: userOpToEstimate, - } - ); + const gasFee = await this.skandhaModule.getGasPrice(); if (this.pvgEstimator) { - userOpComplemented.maxFeePerGas = - gasFee.maxFeePerGas ?? gasFee.gasPrice ?? 1; - userOpComplemented.maxPriorityFeePerGas = - gasFee.maxPriorityFeePerGas ?? gasFee.gasPrice ?? 1; + userOpComplemented.maxFeePerGas = gasFee.maxFeePerGas; + userOpComplemented.maxPriorityFeePerGas = gasFee.maxPriorityFeePerGas; preVerificationGas = await this.pvgEstimator( entryPoint, userOpComplemented, diff --git a/packages/executor/src/services/BundlingService.ts b/packages/executor/src/services/BundlingService.ts index da4fb5b6..22f5e100 100644 --- a/packages/executor/src/services/BundlingService.ts +++ b/packages/executor/src/services/BundlingService.ts @@ -148,8 +148,7 @@ export class BundlingService { // eslint-disable-next-line @typescript-eslint/no-unused-vars const { gasLimit, ...txWithoutGasLimit } = tx; // some chains, like Bifrost, don't allow setting gasLimit in estimateGas - const estimatedGasLimit = await wallet.estimateGas(txWithoutGasLimit); - tx.gasLimit = estimatedGasLimit; + await wallet.estimateGas(txWithoutGasLimit); } catch (err) { this.logger.error(err); for (const entry of entries) { diff --git a/packages/executor/src/services/MempoolService.ts b/packages/executor/src/services/MempoolService.ts index eb64ff3f..c319cd2d 100644 --- a/packages/executor/src/services/MempoolService.ts +++ b/packages/executor/src/services/MempoolService.ts @@ -3,6 +3,7 @@ import { IDbController } from "types/lib"; import RpcError from "types/lib/api/errors/rpc-error"; import * as RpcErrorCodes from "types/lib/api/errors/rpc-error-codes"; import { UserOperationStruct } from "types/lib/executor/contracts/EntryPoint"; +import { getAddress } from "ethers/lib/utils"; import { getAddr, now } from "../utils"; import { MempoolEntry } from "../entities/MempoolEntry"; import { IMempoolEntry, MempoolEntrySerialized } from "../entities/interfaces"; diff --git a/packages/node/package.json b/packages/node/package.json index b59b28ce..77a9130e 100644 --- a/packages/node/package.json +++ b/packages/node/package.json @@ -1,6 +1,6 @@ { "name": "node", - "version": "1.0.17-alpha", + "version": "1.0.18-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.17-alpha", + "api": "^1.0.18-alpha", "datastore-core": "8.0.1", - "db": "^1.0.17-alpha", + "db": "^1.0.18-alpha", "ethers": "5.7.2", - "executor": "^1.0.17-alpha", + "executor": "^1.0.18-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.17-alpha", + "params": "^1.0.18-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.17-alpha", - "utils": "^1.0.17-alpha", + "types": "^1.0.18-alpha", + "utils": "^1.0.18-alpha", "varint": "6.0.0", "xxhash-wasm": "1.0.2" }, diff --git a/packages/params/package.json b/packages/params/package.json index f08274aa..9cc09f19 100644 --- a/packages/params/package.json +++ b/packages/params/package.json @@ -1,6 +1,6 @@ { "name": "params", - "version": "1.0.17-alpha", + "version": "1.0.18-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.17-alpha", - "utils": "^1.0.17-alpha" + "types": "^1.0.18-alpha", + "utils": "^1.0.18-alpha" }, "scripts": { "clean": "rm -rf lib && rm -f *.tsbuildinfo", diff --git a/packages/params/src/utils/userOp.ts b/packages/params/src/utils/userOp.ts index c161951d..5a676f8a 100644 --- a/packages/params/src/utils/userOp.ts +++ b/packages/params/src/utils/userOp.ts @@ -3,6 +3,7 @@ import { Bytes32, UintBn256 } from "types/lib/primitive/sszTypes"; import { fromHex, toHex } from "utils/lib"; import { BigNumber, BigNumberish } from "ethers"; import { UserOperationStruct } from "types/lib/executor/contracts/EntryPoint"; +import { getAddress } from "ethers/lib/utils"; const bigintToBigNumber = (bn: bigint): BigNumberish => { return BigNumber.from(UintBn256.fromJson(bn) as unknown as string); @@ -23,7 +24,7 @@ export const userOpHashToString = (hash: ts.Bytes32): string => { // eslint-disable-next-line @typescript-eslint/explicit-function-return-type export const deserializeUserOp = (userOp: ts.UserOp) => { const dUserOp = { - sender: toHex(userOp.sender), + sender: getAddress(toHex(userOp.sender)), nonce: bigintToBigNumber(userOp.nonce), initCode: toHex(userOp.initCode), callData: toHex(userOp.callData), @@ -59,7 +60,7 @@ export const deserializeUserOpsWithEP = ( export const serializeUserOp = (userOp: UserOperationStruct): ts.UserOp => { return { - sender: fromHex(userOp.sender), + sender: fromHex(getAddress(userOp.sender)), nonce: bigNumberishToBigint(userOp.nonce), initCode: fromHex(userOp.initCode.toString()), callData: fromHex(userOp.callData.toString()), @@ -80,7 +81,7 @@ export const toUserOpsWithEP = ( blockHash: string ): ts.UserOpsWithEntryPoint => { return { - entry_point_contract: fromHex(entryPoint), + entry_point_contract: fromHex(getAddress(entryPoint)), chain_id: bigNumberishToBigint(chainId), user_operations: userOps.map((userOp) => serializeUserOp(userOp)), verified_at_block_hash: bigNumberishToBigint(blockHash), diff --git a/packages/params/src/whitelisted-entities/paymasters.ts b/packages/params/src/whitelisted-entities/paymasters.ts index c8635c03..b4476fdf 100644 --- a/packages/params/src/whitelisted-entities/paymasters.ts +++ b/packages/params/src/whitelisted-entities/paymasters.ts @@ -135,4 +135,7 @@ export const WhitelistedPaymasters: IWhitelistedEntity = { // USDC/ETH getAddress("0x8b067387ec0B922483Eadb771bc9290194685522"), ], + + // Mantle testnet + 5001: [getAddress("0x6Ea25cbb60360243E871dD935225A293a78704a8")], }; diff --git a/packages/types/package.json b/packages/types/package.json index 9f0604d7..843eef5c 100644 --- a/packages/types/package.json +++ b/packages/types/package.json @@ -1,6 +1,6 @@ { "name": "types", - "version": "1.0.17-alpha", + "version": "1.0.18-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 84542660..0bd4f6c4 100644 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -1,6 +1,6 @@ { "name": "utils", - "version": "1.0.17-alpha", + "version": "1.0.18-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.17-alpha" + "types": "^1.0.18-alpha" } }