diff --git a/lerna.json b/lerna.json index f9dee9e7..79a03998 100644 --- a/lerna.json +++ b/lerna.json @@ -4,7 +4,7 @@ ], "npmClient": "yarn", "useWorkspaces": true, - "version": "0.0.23", + "version": "0.0.24", "stream": "true", "command": { "version": { diff --git a/package.json b/package.json index f6877166..a4b17ee6 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "root", "private": true, - "version": "0.0.23", + "version": "0.0.24", "engines": { "node": ">=18.0.0" }, diff --git a/packages/api/package.json b/packages/api/package.json index b3a0d552..502a7d4e 100644 --- a/packages/api/package.json +++ b/packages/api/package.json @@ -1,6 +1,6 @@ { "name": "api", - "version": "0.0.23", + "version": "0.0.24", "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.23", + "executor": "^0.0.24", "fastify": "4.14.1", "pino": "8.11.0", "pino-pretty": "10.0.0", "reflect-metadata": "0.1.13", - "types": "^0.0.23" + "types": "^0.0.24" }, "devDependencies": { "@types/connect": "3.4.35" diff --git a/packages/cli/package.json b/packages/cli/package.json index 64f5dd1d..86909043 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,6 +1,6 @@ { "name": "cli", - "version": "0.0.23", + "version": "0.0.24", "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.23", - "db": "^0.0.23", - "executor": "^0.0.23", + "api": "^0.0.24", + "db": "^0.0.24", + "executor": "^0.0.24", "find-up": "5.0.0", "got": "12.5.3", "js-yaml": "4.1.0", - "types": "^0.0.23", + "types": "^0.0.24", "yargs": "17.6.2" }, "devDependencies": { diff --git a/packages/cli/src/cmds/start/handler.ts b/packages/cli/src/cmds/start/handler.ts index 37b79619..10868d05 100644 --- a/packages/cli/src/cmds/start/handler.ts +++ b/packages/cli/src/cmds/start/handler.ts @@ -23,7 +23,7 @@ export async function bundlerHandler( let config: Config; try { - const configPath = path.resolve(dataDir, networksFile); + const configPath = path.resolve(dataDir, "..", networksFile); const configOptions = readFile(configPath) as ConfigOptions; config = new Config({ networks: configOptions.networks, diff --git a/packages/db/package.json b/packages/db/package.json index 1bbd0db7..f7b1e24b 100644 --- a/packages/db/package.json +++ b/packages/db/package.json @@ -1,6 +1,6 @@ { "name": "db", - "version": "0.0.23", + "version": "0.0.24", "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.23" + "types": "^0.0.24" } } diff --git a/packages/executor/package.json b/packages/executor/package.json index fcdae65a..14a5dc82 100644 --- a/packages/executor/package.json +++ b/packages/executor/package.json @@ -1,6 +1,6 @@ { "name": "executor", - "version": "0.0.23", + "version": "0.0.24", "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.23", - "types": "^0.0.23" + "params": "^0.0.24", + "types": "^0.0.24" } } diff --git a/packages/executor/src/services/UserOpValidation.ts b/packages/executor/src/services/UserOpValidation.ts index 63015778..499e66d0 100644 --- a/packages/executor/src/services/UserOpValidation.ts +++ b/packages/executor/src/services/UserOpValidation.ts @@ -1,5 +1,5 @@ import { BigNumberish, BytesLike, ethers, providers } from "ethers"; -import { Interface, hexZeroPad } from "ethers/lib/utils"; +import { Interface, getAddress, hexZeroPad } 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 { EntryPoint__factory } from "types/lib/executor/contracts/factories"; @@ -16,6 +16,7 @@ import { import { BannedContracts } from "params/lib"; import { NetworkName } from "types/lib"; import { AddressZero, BytesZero } from "params/lib"; +import { WhitelistedEntities } from "params/lib/whitelisted-entities"; import { getAddr } from "../utils"; import { Logger, NetworkConfig, TracerCall, TracerResult } from "../interfaces"; import { Config } from "../config"; @@ -191,6 +192,20 @@ export class UserOpValidationService { ) as keyof typeof stakeInfoEntities; // OPCODE RULES const violation = trace.violation || {}; + + // Skip whitelisted entities + const whitelist = WhitelistedEntities[title]; + if ( + whitelist && + whitelist[this.network] && + whitelist[this.network]!.some((addr) => addr === getAddress(address)) + ) { + this.logger.debug( + "Paymaster is in whitelist. Skipping opcode validation..." + ); + continue; + } + for (const [opcode, count] of Object.entries(violation)) { if (opcode === "CREATE2" && Number(count) < 2 && title === "factory") { continue; diff --git a/packages/params/package.json b/packages/params/package.json index 5e03a9d6..5a390d19 100644 --- a/packages/params/package.json +++ b/packages/params/package.json @@ -1,6 +1,6 @@ { "name": "params", - "version": "0.0.23", + "version": "0.0.24", "description": "Various bundler parameters", "author": "Etherspot", "homepage": "https://github.com/etherspot/skandha#readme", @@ -24,7 +24,7 @@ "@arbitrum/sdk": "3.1.4", "@eth-optimism/sdk": "3.0.0", "ethers": "5.7.2", - "types": "^0.0.23" + "types": "^0.0.24" }, "scripts": { "clean": "rm -rf lib && rm -f *.tsbuildinfo", diff --git a/packages/params/src/types/IWhitelistedEntities.ts b/packages/params/src/types/IWhitelistedEntities.ts new file mode 100644 index 00000000..f117f359 --- /dev/null +++ b/packages/params/src/types/IWhitelistedEntities.ts @@ -0,0 +1,11 @@ +import { NetworkName } from "types/lib"; + +export type IEntity = "paymaster" | "account" | "factory"; + +export type IWhitelistedEntity = { + [network in NetworkName]?: string[]; +}; + +export type IWhitelistedEntities = { + [entity in IEntity]: IWhitelistedEntity; +}; diff --git a/packages/params/src/whitelisted-entities/accounts.ts b/packages/params/src/whitelisted-entities/accounts.ts new file mode 100644 index 00000000..80b1b914 --- /dev/null +++ b/packages/params/src/whitelisted-entities/accounts.ts @@ -0,0 +1,3 @@ +import { IWhitelistedEntity } from "../types/IWhitelistedEntities"; + +export const WhitelistedAccounts: IWhitelistedEntity = {}; diff --git a/packages/params/src/whitelisted-entities/factories.ts b/packages/params/src/whitelisted-entities/factories.ts new file mode 100644 index 00000000..72ea2c13 --- /dev/null +++ b/packages/params/src/whitelisted-entities/factories.ts @@ -0,0 +1,3 @@ +import { IWhitelistedEntity } from "../types/IWhitelistedEntities"; + +export const WhitelistedFactories: IWhitelistedEntity = {}; diff --git a/packages/params/src/whitelisted-entities/index.ts b/packages/params/src/whitelisted-entities/index.ts new file mode 100644 index 00000000..3be49971 --- /dev/null +++ b/packages/params/src/whitelisted-entities/index.ts @@ -0,0 +1,10 @@ +import { IWhitelistedEntities } from "../types/IWhitelistedEntities"; +import { WhitelistedAccounts } from "./accounts"; +import { WhitelistedFactories } from "./factories"; +import { WhitelistedPaymasters } from "./paymasters"; + +export const WhitelistedEntities: IWhitelistedEntities = { + factory: WhitelistedFactories, + account: WhitelistedAccounts, + paymaster: WhitelistedPaymasters, +}; diff --git a/packages/params/src/whitelisted-entities/paymasters.ts b/packages/params/src/whitelisted-entities/paymasters.ts new file mode 100644 index 00000000..cd2d8cd4 --- /dev/null +++ b/packages/params/src/whitelisted-entities/paymasters.ts @@ -0,0 +1,101 @@ +import { getAddress } from "ethers/lib/utils"; +import { IWhitelistedEntity } from "../types/IWhitelistedEntities"; + +export const WhitelistedPaymasters: IWhitelistedEntity = { + mainnet: [ + // Stackup + // https://docs.stackup.sh/docs/entity-addresses + getAddress("0xE93ECa6595fe94091DC1af46aaC2A8b5D7990770"), + ], + matic: [ + // Pimlico + // https://docs.pimlico.io/reference/erc20-paymaster/contracts + getAddress("0xa683b47e447De6c8A007d9e294e87B6Db333Eb18"), + + // Stackup + // https://docs.stackup.sh/docs/entity-addresses + getAddress("0x474Ea64BEdDE53aaD1084210BD60eeF2989bF80f"), + getAddress("0xE93ECa6595fe94091DC1af46aaC2A8b5D7990770"), + getAddress("0x3870419Ba2BBf0127060bCB37f69A1b1C090992B"), + ], + arbitrum: [ + // Pimlico + // https://docs.pimlico.io/reference/erc20-paymaster/contracts + getAddress("0x49EE41bC335Fb36be46A17307dcFe536A3494644"), + + // Stackup + // https://docs.stackup.sh/docs/entity-addresses + getAddress("0xE93ECa6595fe94091DC1af46aaC2A8b5D7990770"), + ], + bsc: [ + // Stackup + // https://docs.stackup.sh/docs/entity-addresses + getAddress("0xE93ECa6595fe94091DC1af46aaC2A8b5D7990770"), + ], + optimism: [ + // Stackup + // https://docs.stackup.sh/docs/entity-addresses + getAddress("0xE93ECa6595fe94091DC1af46aaC2A8b5D7990770"), + ], + xdai: [ + // Stackup + // https://docs.stackup.sh/docs/entity-addresses + getAddress("0xE93ECa6595fe94091DC1af46aaC2A8b5D7990770"), + ], + + /* ====== TESTNETS ====== */ + goerli: [ + // Pimlico + // https://docs.pimlico.io/reference/erc20-paymaster/contracts + getAddress("0xEc43912D8C772A0Eba5a27ea5804Ba14ab502009"), + + // Stackup + // https://docs.stackup.sh/docs/entity-addresses + getAddress("0xE93ECa6595fe94091DC1af46aaC2A8b5D7990770"), + getAddress("0x3870419Ba2BBf0127060bCB37f69A1b1C090992B"), + ], + mumbai: [ + // Pimlico + // https://docs.pimlico.io/reference/erc20-paymaster/contracts + getAddress("0x32aCDFeA07a614E52403d2c1feB747aa8079A353"), + + // Stackup + // https://docs.stackup.sh/docs/entity-addresses + getAddress("0xE93ECa6595fe94091DC1af46aaC2A8b5D7990770"), + getAddress("0x3870419Ba2BBf0127060bCB37f69A1b1C090992B"), + ], + baseGoerli: [ + // Pimlico + // https://docs.pimlico.io/reference/erc20-paymaster/contracts + getAddress("0x13f490FafBb206440F25760A10C21A6220017fFa"), + + // Stackup + // https://docs.stackup.sh/docs/entity-addresses + getAddress("0xE93ECa6595fe94091DC1af46aaC2A8b5D7990770"), + getAddress("0x3870419Ba2BBf0127060bCB37f69A1b1C090992B"), + ], + bscTest: [ + // Stackup + // https://docs.stackup.sh/docs/entity-addresses + getAddress("0xE93ECa6595fe94091DC1af46aaC2A8b5D7990770"), + getAddress("0x3870419Ba2BBf0127060bCB37f69A1b1C090992B"), + ], + optimismGoerli: [ + // Stackup + // https://docs.stackup.sh/docs/entity-addresses + getAddress("0xE93ECa6595fe94091DC1af46aaC2A8b5D7990770"), + getAddress("0x3870419Ba2BBf0127060bCB37f69A1b1C090992B"), + ], + sepolia: [ + // Stackup + // https://docs.stackup.sh/docs/entity-addresses + getAddress("0xE93ECa6595fe94091DC1af46aaC2A8b5D7990770"), + getAddress("0x3870419Ba2BBf0127060bCB37f69A1b1C090992B"), + ], + arbitrumNitro: [ + // Stackup + // https://docs.stackup.sh/docs/entity-addresses + getAddress("0xE93ECa6595fe94091DC1af46aaC2A8b5D7990770"), + getAddress("0x3870419Ba2BBf0127060bCB37f69A1b1C090992B"), + ], +}; diff --git a/packages/types/package.json b/packages/types/package.json index 0044a265..de8b9c53 100644 --- a/packages/types/package.json +++ b/packages/types/package.json @@ -1,6 +1,6 @@ { "name": "types", - "version": "0.0.23", + "version": "0.0.24", "description": "The types of Etherspot bundler client", "author": "Etherspot", "homepage": "https://https://github.com/etherspot/skandha#readme",