From 692d9782260e21e5d38a07503156055e08b73ce7 Mon Sep 17 00:00:00 2001 From: Utkir S Date: Tue, 12 Dec 2023 17:47:44 +0500 Subject: [PATCH] feat: create configurable pvg markup (#136) --- README.md | 48 ++++++++++++++++-------- lerna.json | 2 +- package.json | 2 +- packages/api/package.json | 8 ++-- packages/cli/package.json | 14 +++---- packages/db/package.json | 4 +- packages/executor/package.json | 8 ++-- packages/executor/src/config.ts | 9 +++++ packages/executor/src/interfaces.ts | 4 ++ packages/executor/src/modules/eth.ts | 2 +- packages/executor/src/modules/skandha.ts | 1 + packages/monitoring/package.json | 4 +- packages/node/package.json | 16 ++++---- packages/params/package.json | 6 +-- packages/types/package.json | 2 +- packages/types/src/api/interfaces.ts | 1 + packages/utils/package.json | 4 +- 17 files changed, 84 insertions(+), 51 deletions(-) diff --git a/README.md b/README.md index 9893f3b7..f03a1330 100644 --- a/README.md +++ b/README.md @@ -65,7 +65,23 @@ Or follow the steps below: ## 🔑 Relayer Configuration -#### config.json +#### Simplest config.json +```yaml +{ + "networks": { + "mumbai": { + "entryPoints": [ + "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789" + ], + "relayer": "0x{RELAYER-PRIVATE-KEY}", + "beneficiary": "0x{BENEFICIARY-ADDRESS}", + "rpcEndpoint": "https://polygon-mumbai.blockpi.network/v1/rpc/public" + } + } +} +``` + +#### config.json with a default value of each config parameter ```yaml { @@ -84,26 +100,27 @@ Or follow the steps below: "minUnstakeDelay": 0, # optional, min unstake delay of an entity "minSignerBalance": 1, # optional, default is 0.1 ETH. If the relayer's balance drops lower than this, it will be selected as a fee collector "multicall": "0xcA11bde05977b3631167028862bE2a173976CA11", # optional, multicall3 contract (see https://github.com/mds1/multicall#multicall3-contract-addresses) - "estimationStaticBuffer": 21000, # adds certain amount of gas to callGasLimit on estimation - "validationGasLimit": 10e6, # gas limit during simulateHandleOps and simulateValidation calls - "receiptLookupRange": 1024, # limits the block range of getUserOperationByHash and getUserOperationReceipt - "etherscanApiKey": "", # etherscan api is used to fetch gas prices - "conditionalTransactions": false, # enable conditional transactions - "rpcEndpointSubmit": "", # rpc endpoint that is used only during submission of a bundle - "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 - "useropsTTL": 300, # Userops time to live (in seconds) - "whitelistedEntities": { # Entities that bypass stake and opcode validation (array of addresses) + "estimationStaticBuffer": 21000, # optional,adds certain amount of gas to callGasLimit on estimation + "validationGasLimit": 10e6, # optional,gas limit during simulateHandleOps and simulateValidation calls + "receiptLookupRange": 1024, # optional,limits the block range of getUserOperationByHash and getUserOperationReceipt + "etherscanApiKey": "", # optional,etherscan api is used to fetch gas prices + "conditionalTransactions": false, # optional,enable conditional transactions + "rpcEndpointSubmit": "", # optional,rpc endpoint that is used only during submission of a bundle + "gasPriceMarkup": 0, # optional,adds % markup on reported gas price via skandha_getGasPrice, 10000 = 100.00%, 500 = 5% + "enforceGasPrice": false, # optional,do not bundle userops with low gas prices + "enforceGasPriceThreshold": 1000, # optional,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, # optional, enables eip-2930 + "useropsTTL": 300, # optional, Userops time to live (in seconds) + "whitelistedEntities": { # optional, Entities that bypass stake and opcode validation (array of addresses) "factory": [], "paymaster": [], "account": [] }, - "bundleGasLimitMarkup": 25000, # adds some amount of additional gas to a bundle tx + "bundleGasLimitMarkup": 25000, # optional, adds some amount of additional gas to a bundle tx "relayingMode": "classic"; # optional, allows to switch to Flashbots Builder api if set to "flashbots", see packages/executor/src/interfaces.ts for more "bundleInterval": 10000, # bundle creation interval - "bundleSize": 4 # max size of a bundle, 4 userops by default + "bundleSize": 4, # optional, max size of a bundle, 4 userops by default + "pvgMarkup": 0 # optional, adds some gas on top of estimated PVG } } } @@ -123,6 +140,7 @@ Licensed under the [MIT License](https://github.com/etherspot/skandha/blob/maste - Sepolia | QmdDwVFoEEcgv5qnaTB8ncnXGMnqrhnA5nYpRr4ouWe4AT | https://ipfs.io/ipfs/QmdDwVFoEEcgv5qnaTB8ncnXGMnqrhnA5nYpRr4ouWe4AT?filename=sepolia_canonical_mempool.yaml - Mumbai | QmQfRyE9iVTBqZ17hPSP4tuMzaez83Y5wD874ymyRtj9VE | https://ipfs.io/ipfs/QmQfRyE9iVTBqZ17hPSP4tuMzaez83Y5wD874ymyRtj9VE?filename=mumbai_canonical_mempool.yaml +- Goerli | QmTmj4cizhWpEFCCqk5dP67yws7R2PPgCtb2bd2RgVPCbF | https://ipfs.io/ipfs/QmTmj4cizhWpEFCCqk5dP67yws7R2PPgCtb2bd2RgVPCbF?filename=goerli_canonical_mempool.yaml ## 🔢 Statistics ![Alt](https://repobeats.axiom.co/api/embed/4d7ec3ece88b2461c5b1757574321f4f6540cdd5.svg "Skandha analytics image") diff --git a/lerna.json b/lerna.json index ace792aa..f98d5a56 100644 --- a/lerna.json +++ b/lerna.json @@ -4,7 +4,7 @@ ], "npmClient": "yarn", "useWorkspaces": true, - "version": "1.0.27-alpha", + "version": "1.0.28-alpha", "stream": "true", "command": { "version": { diff --git a/package.json b/package.json index 0e07ddba..70a74a89 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "root", "private": true, - "version": "1.0.27-alpha", + "version": "1.0.28-alpha", "engines": { "node": ">=18.0.0" }, diff --git a/packages/api/package.json b/packages/api/package.json index 73dd5d15..10c068fb 100644 --- a/packages/api/package.json +++ b/packages/api/package.json @@ -1,6 +1,6 @@ { "name": "api", - "version": "1.0.27-alpha", + "version": "1.0.28-alpha", "description": "The API module of Etherspot bundler client", "author": "Etherspot", "homepage": "https://https://github.com/etherspot/skandha#readme", @@ -35,13 +35,13 @@ "class-transformer": "0.5.1", "class-validator": "0.14.0", "ethers": "5.7.2", - "executor": "^1.0.27-alpha", + "executor": "^1.0.28-alpha", "fastify": "4.14.1", - "monitoring": "^1.0.27-alpha", + "monitoring": "^1.0.28-alpha", "pino": "8.11.0", "pino-pretty": "10.0.0", "reflect-metadata": "0.1.13", - "types": "^1.0.27-alpha" + "types": "^1.0.28-alpha" }, "devDependencies": { "@types/connect": "3.4.35" diff --git a/packages/cli/package.json b/packages/cli/package.json index de68c0b4..4ab87b38 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,6 +1,6 @@ { "name": "cli", - "version": "1.0.27-alpha", + "version": "1.0.28-alpha", "description": "> TODO: description", "author": "zincoshine ", "homepage": "https://https://github.com/etherspot/skandha#readme", @@ -38,15 +38,15 @@ "@libp2p/peer-id-factory": "2.0.1", "@libp2p/prometheus-metrics": "1.1.3", "@multiformats/multiaddr": "12.1.3", - "api": "^1.0.27-alpha", - "db": "^1.0.27-alpha", - "executor": "^1.0.27-alpha", + "api": "^1.0.28-alpha", + "db": "^1.0.28-alpha", + "executor": "^1.0.28-alpha", "find-up": "5.0.0", "got": "12.5.3", "js-yaml": "4.1.0", - "monitoring": "^1.0.27-alpha", - "node": "^1.0.27-alpha", - "types": "^1.0.27-alpha", + "monitoring": "^1.0.28-alpha", + "node": "^1.0.28-alpha", + "types": "^1.0.28-alpha", "yargs": "17.6.2" }, "devDependencies": { diff --git a/packages/db/package.json b/packages/db/package.json index 2c2e97f7..22fe5bc5 100644 --- a/packages/db/package.json +++ b/packages/db/package.json @@ -1,6 +1,6 @@ { "name": "db", - "version": "1.0.27-alpha", + "version": "1.0.28-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.27-alpha" + "types": "^1.0.28-alpha" }, "devDependencies": { "@types/rocksdb": "3.0.1", diff --git a/packages/executor/package.json b/packages/executor/package.json index 91020017..2c95e811 100644 --- a/packages/executor/package.json +++ b/packages/executor/package.json @@ -1,6 +1,6 @@ { "name": "executor", - "version": "1.0.27-alpha", + "version": "1.0.28-alpha", "description": "The Relayer module of Etherspot bundler client", "author": "Etherspot", "homepage": "https://https://github.com/etherspot/skandha#readme", @@ -34,8 +34,8 @@ "@flashbots/ethers-provider-bundle": "0.6.2", "async-mutex": "0.4.0", "ethers": "5.7.2", - "monitoring": "^1.0.27-alpha", - "params": "^1.0.27-alpha", - "types": "^1.0.27-alpha" + "monitoring": "^1.0.28-alpha", + "params": "^1.0.28-alpha", + "types": "^1.0.28-alpha" } } diff --git a/packages/executor/src/config.ts b/packages/executor/src/config.ts index cc780e01..97203309 100644 --- a/packages/executor/src/config.ts +++ b/packages/executor/src/config.ts @@ -282,6 +282,14 @@ export class Config { ) ); + conf.pvgMarkup = Number( + fromEnvVar( + network, + "PVG_MARKUP", + conf.pvgMarkup || bundlerDefaultConfigs.pvgMarkup + ) + ); + // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions if (!conf.whitelistedEntities) { conf.whitelistedEntities = bundlerDefaultConfigs.whitelistedEntities; @@ -337,6 +345,7 @@ const bundlerDefaultConfigs: BundlerConfig = { bundleInterval: 10000, // 10 seconds bundleSize: 4, // max size of bundle (in terms of user ops) relayingMode: "classic", + pvgMarkup: 0, }; const NETWORKS_ENV = (): string[] | undefined => { diff --git a/packages/executor/src/interfaces.ts b/packages/executor/src/interfaces.ts index b62040fb..356e5749 100644 --- a/packages/executor/src/interfaces.ts +++ b/packages/executor/src/interfaces.ts @@ -141,6 +141,10 @@ export interface NetworkConfig { // max bundle size in terms of user ops // default is 4 bundleSize: number; + // adds markup on PVG + // 1000 = adds 1000 gas on top of estimated PVG + // default = 0 + pvgMarkup: number; } export type BundlerConfig = Omit< diff --git a/packages/executor/src/modules/eth.ts b/packages/executor/src/modules/eth.ts index 2b5a1d36..dae4be2e 100644 --- a/packages/executor/src/modules/eth.ts +++ b/packages/executor/src/modules/eth.ts @@ -459,7 +459,7 @@ export class Eth { ov.perUserOp + ov.perUserOpWord * lengthInWord ); - return ret; + return Math.max(ret + this.config.pvgMarkup, 0); } private async getUserOperationEvent( diff --git a/packages/executor/src/modules/skandha.ts b/packages/executor/src/modules/skandha.ts index 86ffe809..c9efbbfb 100644 --- a/packages/executor/src/modules/skandha.ts +++ b/packages/executor/src/modules/skandha.ts @@ -119,6 +119,7 @@ export class Skandha { bundleInterval: this.networkConfig.bundleInterval, bundleSize: this.networkConfig.bundleSize, minUnstakeDelay: this.networkConfig.minUnstakeDelay, + pvgMarkup: this.networkConfig.pvgMarkup, }; } diff --git a/packages/monitoring/package.json b/packages/monitoring/package.json index 13511e3a..2461e36f 100644 --- a/packages/monitoring/package.json +++ b/packages/monitoring/package.json @@ -1,6 +1,6 @@ { "name": "monitoring", - "version": "1.0.27-alpha", + "version": "1.0.28-alpha", "description": "The Monitoring module of Etherspot bundler client", "author": "Etherspot", "homepage": "https://github.com/etherspot/etherspot-bundler#readme", @@ -32,6 +32,6 @@ }, "dependencies": { "prom-client": "^14.2.0", - "types": "^1.0.27-alpha" + "types": "^1.0.28-alpha" } } diff --git a/packages/node/package.json b/packages/node/package.json index 6b1d9695..e3b1bbd6 100644 --- a/packages/node/package.json +++ b/packages/node/package.json @@ -1,6 +1,6 @@ { "name": "node", - "version": "1.0.27-alpha", + "version": "1.0.28-alpha", "description": "The bundler node module of Etherspot bundler client", "author": "Etherspot", "homepage": "https://https://github.com/etherspot/skandha#readme", @@ -56,25 +56,25 @@ "@libp2p/tcp": "6.1.0", "@multiformats/multiaddr": "11.4.0", "abstract-leveldown": "7.2.0", - "api": "^1.0.27-alpha", + "api": "^1.0.28-alpha", "datastore-core": "8.0.1", - "db": "^1.0.27-alpha", + "db": "^1.0.28-alpha", "ethers": "5.7.2", - "executor": "^1.0.27-alpha", + "executor": "^1.0.28-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", - "monitoring": "^1.0.27-alpha", - "params": "^1.0.27-alpha", + "monitoring": "^1.0.28-alpha", + "params": "^1.0.28-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.27-alpha", - "utils": "^1.0.27-alpha", + "types": "^1.0.28-alpha", + "utils": "^1.0.28-alpha", "varint": "6.0.0", "xxhash-wasm": "1.0.2" }, diff --git a/packages/params/package.json b/packages/params/package.json index 45639a9a..011bddad 100644 --- a/packages/params/package.json +++ b/packages/params/package.json @@ -1,6 +1,6 @@ { "name": "params", - "version": "1.0.27-alpha", + "version": "1.0.28-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.27-alpha", - "utils": "^1.0.27-alpha" + "types": "^1.0.28-alpha", + "utils": "^1.0.28-alpha" }, "scripts": { "clean": "rm -rf lib && rm -f *.tsbuildinfo", diff --git a/packages/types/package.json b/packages/types/package.json index 89c9428d..25b73b63 100644 --- a/packages/types/package.json +++ b/packages/types/package.json @@ -1,6 +1,6 @@ { "name": "types", - "version": "1.0.27-alpha", + "version": "1.0.28-alpha", "description": "The types of Etherspot bundler client", "author": "Etherspot", "homepage": "https://https://github.com/etherspot/skandha#readme", diff --git a/packages/types/src/api/interfaces.ts b/packages/types/src/api/interfaces.ts index 0c6a6abe..5dd35f3f 100644 --- a/packages/types/src/api/interfaces.ts +++ b/packages/types/src/api/interfaces.ts @@ -76,6 +76,7 @@ export type GetConfigResponse = { bundleInterval: number; bundleSize: number; minUnstakeDelay: number; + pvgMarkup: number; }; export type SupportedEntryPoints = string[]; diff --git a/packages/utils/package.json b/packages/utils/package.json index 4dbda0b8..47dca4fc 100644 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -1,6 +1,6 @@ { "name": "utils", - "version": "1.0.27-alpha", + "version": "1.0.28-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.27-alpha" + "types": "^1.0.28-alpha" } }