Skip to content

Commit

Permalink
Merge pull request #63 from etherspot/whitelist-entities
Browse files Browse the repository at this point in the history
feat: whitelist paymasters
  • Loading branch information
0xSulpiride authored Jul 27, 2023
2 parents abf0af7 + 8f94621 commit b6e9c68
Show file tree
Hide file tree
Showing 15 changed files with 163 additions and 20 deletions.
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
],
"npmClient": "yarn",
"useWorkspaces": true,
"version": "0.0.23",
"version": "0.0.24",
"stream": "true",
"command": {
"version": {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "root",
"private": true,
"version": "0.0.23",
"version": "0.0.24",
"engines": {
"node": ">=18.0.0"
},
Expand Down
6 changes: 3 additions & 3 deletions packages/api/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down Expand Up @@ -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"
Expand Down
10 changes: 5 additions & 5 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cli",
"version": "0.0.23",
"version": "0.0.24",
"description": "> TODO: description",
"author": "zincoshine <[email protected]>",
"homepage": "https://https://github.com/etherspot/skandha#readme",
Expand Down Expand Up @@ -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": {
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/cmds/start/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions packages/db/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down Expand Up @@ -37,6 +37,6 @@
"devDependencies": {
"@types/rocksdb": "3.0.1",
"prettier": "^2.8.4",
"types": "^0.0.23"
"types": "^0.0.24"
}
}
6 changes: 3 additions & 3 deletions packages/executor/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down Expand Up @@ -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"
}
}
17 changes: 16 additions & 1 deletion packages/executor/src/services/UserOpValidation.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -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";
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions packages/params/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -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",
Expand Down
11 changes: 11 additions & 0 deletions packages/params/src/types/IWhitelistedEntities.ts
Original file line number Diff line number Diff line change
@@ -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;
};
3 changes: 3 additions & 0 deletions packages/params/src/whitelisted-entities/accounts.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { IWhitelistedEntity } from "../types/IWhitelistedEntities";

export const WhitelistedAccounts: IWhitelistedEntity = {};
3 changes: 3 additions & 0 deletions packages/params/src/whitelisted-entities/factories.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { IWhitelistedEntity } from "../types/IWhitelistedEntities";

export const WhitelistedFactories: IWhitelistedEntity = {};
10 changes: 10 additions & 0 deletions packages/params/src/whitelisted-entities/index.ts
Original file line number Diff line number Diff line change
@@ -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,
};
101 changes: 101 additions & 0 deletions packages/params/src/whitelisted-entities/paymasters.ts
Original file line number Diff line number Diff line change
@@ -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"),
],
};
2 changes: 1 addition & 1 deletion packages/types/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down

0 comments on commit b6e9c68

Please sign in to comment.