Skip to content

Commit

Permalink
feat: eip2930 & dont override signature (#99)
Browse files Browse the repository at this point in the history
* feat: eip2930 & dont override signature

* chore(release): 1.0.6-alpha
  • Loading branch information
0xSulpiride authored Oct 9, 2023
1 parent f42ae6e commit 698b505
Show file tree
Hide file tree
Showing 19 changed files with 95 additions and 45 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ Or follow the steps below:
"gasPriceMarkup": 0, # adds % markup on reported gas price via skandha_getGasPrice, 10000 = 100.00%, 500 = 5%
"enforceGasPrice": false, # do not bundle userops with low gas prices
"enforceGasPriceThreshold": 1000, # gas price threshold in bps. If set to 500, userops' gas price is allowed to be 5% lower than the network's gas price
"eip2930": false # enables eip-2930
}
}
}
Expand Down
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": "1.0.5-alpha",
"version": "1.0.6-alpha",
"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": "1.0.5-alpha",
"version": "1.0.6-alpha",
"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": "1.0.5-alpha",
"version": "1.0.6-alpha",
"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": "1.0.5-alpha",
"executor": "1.0.6-alpha",
"fastify": "4.14.1",
"pino": "8.11.0",
"pino-pretty": "10.0.0",
"reflect-metadata": "0.1.13",
"types": "1.0.5-alpha"
"types": "1.0.6-alpha"
},
"devDependencies": {
"@types/connect": "3.4.35"
Expand Down
12 changes: 6 additions & 6 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cli",
"version": "1.0.5-alpha",
"version": "1.0.6-alpha",
"description": "> TODO: description",
"author": "zincoshine <[email protected]>",
"homepage": "https://https://github.com/etherspot/skandha#readme",
Expand Down Expand Up @@ -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.5-alpha",
"db": "1.0.5-alpha",
"executor": "1.0.5-alpha",
"api": "1.0.6-alpha",
"db": "1.0.6-alpha",
"executor": "1.0.6-alpha",
"find-up": "5.0.0",
"got": "12.5.3",
"js-yaml": "4.1.0",
"node": "1.0.5-alpha",
"types": "1.0.5-alpha",
"node": "1.0.6-alpha",
"types": "1.0.6-alpha",
"yargs": "17.6.2"
},
"devDependencies": {
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": "1.0.5-alpha",
"version": "1.0.6-alpha",
"description": "The DB module of Etherspot bundler client",
"author": "Etherspot",
"homepage": "https://github.com/etherspot/etherspot-bundler#readme",
Expand Down Expand Up @@ -33,7 +33,7 @@
"dependencies": {
"@chainsafe/ssz": "0.10.1",
"@farcaster/rocksdb": "5.5.0",
"types": "1.0.5-alpha"
"types": "1.0.6-alpha"
},
"devDependencies": {
"@types/rocksdb": "3.0.1",
Expand Down
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": "1.0.5-alpha",
"version": "1.0.6-alpha",
"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": "1.0.5-alpha",
"types": "1.0.5-alpha"
"params": "1.0.6-alpha",
"types": "1.0.6-alpha"
}
}
8 changes: 8 additions & 0 deletions packages/executor/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,13 @@ export class Config {
bundlerDefaultConfigs.enforceGasPriceThreshold
)
);
conf.eip2930 = Boolean(
fromEnvVar(
network,
"EIP2930",
conf.eip2930 || bundlerDefaultConfigs.eip2930
)
);

return Object.assign({}, bundlerDefaultConfigs, conf);
}
Expand All @@ -227,6 +234,7 @@ const bundlerDefaultConfigs: BundlerConfig = {
gasPriceMarkup: 0,
enforceGasPrice: false,
enforceGasPriceThreshold: 1000,
eip2930: false,
};

const NETWORKS_ENV = (): string[] | undefined => {
Expand Down
17 changes: 17 additions & 0 deletions packages/executor/src/executor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { BigNumber, providers } from "ethers";
import { IDbController } from "types/lib";
import { NetworkName } from "types/lib";
import { INodeAPI } from "types/lib/node";
import { chainsWithoutEIP1559 } from "params/lib";
import { Web3, Debug, Eth, Skandha } from "./modules";
import {
MempoolService,
Expand Down Expand Up @@ -145,5 +146,21 @@ export class Executor {
if (this.networkConfig.enforceGasPrice) {
this.logger.info(`${this.networkName}: [x] ENFORCING GAS PRICES`);
}

// can't use eip2930 in unsafeMode and on chains that dont support 1559
if (
(this.config.unsafeMode ||
chainsWithoutEIP1559.some((chainId) => chainId === this.chainId)) &&
this.networkConfig.eip2930
) {
this.logger.error(
"Can not use EIP-2930 in unsafe mode or on chains that dont supports EIP-1559"
);
throw new Error("disable EIP2930");
}

if (this.networkConfig.eip2930) {
this.logger.info(`${this.networkName}: [x] EIP2930 ENABLED`);
}
}
}
4 changes: 4 additions & 0 deletions packages/executor/src/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,10 @@ export interface NetworkConfig {
// if set to 500, then the userop's gas price is allowed to be
// 5% lower than the networks gas prices
enforceGasPriceThreshold: number;
// enables eip-2930
// pls check if the node supports eip-2930 before enabling this flag
// can not be used in unsafeMode and on chains that dont support 1559
eip2930: boolean;
}

export type BundlerConfig = Omit<
Expand Down
24 changes: 9 additions & 15 deletions packages/executor/src/modules/eth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,14 @@ import {
import { IEntryPoint__factory } from "types/lib/executor/contracts/factories";
import { INodeAPI } from "types/lib/node";
import { IPVGEstimator } from "params/lib/types/IPVGEstimator";
import { estimateOptimismPVG, estimateArbitrumPVG } from "params/lib";
import {
estimateOptimismPVG,
estimateArbitrumPVG,
ECDSA_DUMMY_SIGNATURE,
} from "params/lib";
import { getGasFee } from "params/lib";
import { NetworkConfig } from "../interfaces";
import { deepHexlify, getUserOpHash, packUserOp } from "../utils";
import { deepHexlify, packUserOp } from "../utils";
import { UserOpValidationService, MempoolService } from "../services";
import { Logger, Log } from "../interfaces";
import {
Expand Down Expand Up @@ -137,10 +141,9 @@ export class Eth {
maxPriorityFeePerGas: 1,
};

userOpComplemented.signature = await this.getDummySignature({
userOp: userOpComplemented,
entryPoint: args.entryPoint,
});
if (userOpComplemented.signature.length <= 2) {
userOpComplemented.signature = ECDSA_DUMMY_SIGNATURE;
}

const returnInfo = await this.userOpValidationService.validateForEstimation(
userOpComplemented,
Expand Down Expand Up @@ -391,15 +394,6 @@ export class Eth {
});
}

async getDummySignature(args: SendUserOperationGasArgs): Promise<string> {
const randomWallet = ethers.Wallet.createRandom();
const chainId = await this.getChainId();
const dummySignature = randomWallet.signMessage(
getUserOpHash(args.userOp, args.entryPoint, chainId)
);
return dummySignature;
}

/**
* eth_chainId
* @returns EIP-155 Chain ID.
Expand Down
1 change: 1 addition & 0 deletions packages/executor/src/modules/skandha.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ export class Skandha {
enforceGasPriceThreshold: BigNumber.from(
this.networkConfig.enforceGasPriceThreshold
).toNumber(),
eip2930: this.networkConfig.eip2930,
};
}

Expand Down
23 changes: 22 additions & 1 deletion packages/executor/src/services/BundlingService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { GasPriceMarkupOne, chainsWithoutEIP1559 } from "params/lib";
import { IEntryPoint } from "types/lib/executor/contracts";
import { getGasFee } from "params/lib";
import { IGetGasFeeResult } from "params/lib/gas-price-oracles/oracles";
import { AccessList } from "ethers/lib/utils";
import { getAddr } from "../utils";
import { MempoolEntry } from "../entities/MempoolEntry";
import { ReputationStatus } from "../entities/interfaces";
Expand Down Expand Up @@ -108,11 +109,30 @@ export class BundlingService {
maxPriorityFeePerGas: gasFee.maxPriorityFeePerGas,
maxFeePerGas: gasFee.maxFeePerGas,
};
if (this.networkConfig.eip2930) {
const { storageMap } = bundle;
const addresses = Object.keys(storageMap);
if (addresses.length) {
const accessList: AccessList = [];
for (const address of addresses) {
const storageKeys = storageMap[address];
if (typeof storageKeys == "object") {
accessList.push({
address,
storageKeys: Object.keys(storageKeys),
});
}
}
transaction.accessList = accessList;
}
}

if (chainsWithoutEIP1559.some((chainId) => chainId === this.chainId)) {
transaction.gasPrice = gasFee.gasPrice;
delete transaction.maxPriorityFeePerGas;
delete transaction.maxFeePerGas;
delete transaction.type;
delete transaction.accessList;
}

const gasLimit = await this.estimateBundleGas(entries);
Expand Down Expand Up @@ -376,7 +396,8 @@ export class BundlingService {

senders.add(entry.userOp.sender);
if (
this.networkConfig.conditionalTransactions &&
(this.networkConfig.conditionalTransactions ||
this.networkConfig.eip2930) &&
validationResult.storageMap
) {
if (BigNumber.from(entry.userOp.nonce).gt(0)) {
Expand Down
14 changes: 7 additions & 7 deletions packages/node/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "node",
"version": "1.0.5-alpha",
"version": "1.0.6-alpha",
"description": "The bundler node module of Etherspot bundler client",
"author": "Etherspot",
"homepage": "https://https://github.com/etherspot/skandha#readme",
Expand Down Expand Up @@ -56,24 +56,24 @@
"@libp2p/tcp": "6.1.0",
"@multiformats/multiaddr": "11.4.0",
"abstract-leveldown": "7.2.0",
"api": "1.0.5-alpha",
"api": "1.0.6-alpha",
"datastore-core": "8.0.1",
"db": "1.0.5-alpha",
"db": "1.0.6-alpha",
"ethers": "5.7.2",
"executor": "1.0.5-alpha",
"executor": "1.0.6-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.5-alpha",
"params": "1.0.6-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.5-alpha",
"utils": "1.0.5-alpha",
"types": "1.0.6-alpha",
"utils": "1.0.6-alpha",
"varint": "6.0.0",
"xxhash-wasm": "1.0.2"
},
Expand Down
6 changes: 3 additions & 3 deletions packages/params/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "params",
"version": "1.0.5-alpha",
"version": "1.0.6-alpha",
"description": "Various bundler parameters",
"author": "Etherspot",
"homepage": "https://github.com/etherspot/skandha#readme",
Expand All @@ -26,8 +26,8 @@
"@eth-optimism/sdk": "3.0.0",
"@mantleio/sdk": "0.2.1",
"ethers": "5.7.2",
"types": "1.0.5-alpha",
"utils": "1.0.5-alpha"
"types": "1.0.6-alpha",
"utils": "1.0.6-alpha"
},
"scripts": {
"clean": "rm -rf lib && rm -f *.tsbuildinfo",
Expand Down
3 changes: 3 additions & 0 deletions packages/params/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@ export const AddressZero = constants.AddressZero;
export const BytesZero = "0x";

export const GasPriceMarkupOne = BigNumber.from(10000); // 100.00%

export const ECDSA_DUMMY_SIGNATURE =
"0xfffffffffffffffffffffffffffffff0000000000000000000000000000000007aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1c";
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": "1.0.5-alpha",
"version": "1.0.6-alpha",
"description": "The types of Etherspot bundler client",
"author": "Etherspot",
"homepage": "https://https://github.com/etherspot/skandha#readme",
Expand Down
1 change: 1 addition & 0 deletions packages/types/src/api/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ export type GetConfigResponse = {
gasPriceMarkup: number;
enforceGasPrice: boolean;
enforceGasPriceThreshold: number;
eip2930: boolean;
};

export type SupportedEntryPoints = string[];
Expand Down
4 changes: 2 additions & 2 deletions packages/utils/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "utils",
"version": "1.0.5-alpha",
"version": "1.0.6-alpha",
"description": "utils of Etherspot bundler client",
"author": "Etherspot",
"homepage": "https://https://github.com/etherspot/skandha#readme",
Expand Down Expand Up @@ -37,6 +37,6 @@
"case": "^1.6.3",
"pino": "8.11.0",
"pino-pretty": "10.0.0",
"types": "1.0.5-alpha"
"types": "1.0.6-alpha"
}
}

0 comments on commit 698b505

Please sign in to comment.