From c579956659ea82d2cb97881019b7c13b9f9f76a5 Mon Sep 17 00:00:00 2001 From: marie-fourier Date: Fri, 15 Dec 2023 16:29:50 +0500 Subject: [PATCH 1/6] feat: multiple relayers --- README.md | 2 +- packages/executor/src/config.ts | 31 ++++++++++------ packages/executor/src/interfaces.ts | 5 +-- packages/executor/src/modules/skandha.ts | 10 ++++-- .../services/BundlingService/interfaces.ts | 2 +- .../services/BundlingService/relayers/base.ts | 31 +++++++++++++--- .../BundlingService/relayers/classic.ts | 4 ++- .../BundlingService/relayers/flashbots.ts | 3 +- .../src/services/BundlingService/service.ts | 36 +++++-------------- .../executor/src/services/MempoolService.ts | 5 +-- packages/types/src/api/interfaces.ts | 2 +- 11 files changed, 79 insertions(+), 52 deletions(-) diff --git a/README.md b/README.md index f03a1330..83be41e1 100644 --- a/README.md +++ b/README.md @@ -91,7 +91,7 @@ Or follow the steps below: "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789" ], "relayer": "0xprivateKey", # relayer private key, can access from here or via environment variables (SKANDHA_MUMBAI_RELAYER | SKANDHA_DEV_RELAYER | etc.) - "beneficiary": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266", # fee collector, avaiable via env var (SKANDHA_MUMBAI_BENEFICIARY | etc) + "beneficiary": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266", # optional, fee collector, avaiable via env var (SKANDHA_MUMBAI_BENEFICIARY | etc) - if not set, relayer will be used "rpcEndpoint": "http://localhost:8545", # rpc provider, also available via env variable (SKANDHA_MUMBAI_RPC | etc) "minInclusionDenominator": 10, # optional, see EIP-4337 "throttlingSlack": 10, # optional, see EIP-4337 diff --git a/packages/executor/src/config.ts b/packages/executor/src/config.ts index 97203309..fb7e568f 100644 --- a/packages/executor/src/config.ts +++ b/packages/executor/src/config.ts @@ -39,26 +39,28 @@ export class Config { return endpoint ? new providers.JsonRpcProvider(endpoint) : null; } - getRelayer(network: string): Wallet | providers.JsonRpcSigner | null { + getRelayers(network: string): Wallet[] | providers.JsonRpcSigner[] | null { const config = this.getNetworkConfig(network); if (!config) return null; - // fetch from env variables first - const privKey = config.relayer; const provider = this.getNetworkProvider(network); if (!provider) { throw new Error("no provider"); } if (this.testingMode) { - return provider.getSigner(); + return [provider.getSigner()]; } - if (privKey.startsWith("0x")) { - return new Wallet(privKey, provider); + const wallets = []; + for (const privKey of config.relayers) { + if (privKey.startsWith("0x")) { + wallets.push(new Wallet(privKey, provider)); + } else { + wallets.push(Wallet.fromMnemonic(privKey).connect(provider)); + } } - - return Wallet.fromMnemonic(privKey).connect(provider); + return wallets; } getBeneficiary(network: string): string | null { @@ -158,11 +160,19 @@ export class Config { conf.entryPoints, true ) as string[]; - conf.relayer = fromEnvVar(network, "RELAYER", conf.relayer) as string; + + conf.relayer = fromEnvVar(network, "RELAYER", conf.relayer) as string; // deprecated + conf.relayers = fromEnvVar( + network, + "RELAYERS", + conf.relayers ?? [conf.relayer], // fallback to `relayer` if `relayers` not found + true + ) as string[]; + conf.beneficiary = fromEnvVar( network, "BENEFICIARY", - conf.beneficiary + conf.beneficiary || bundlerDefaultConfigs.beneficiary ) as string; conf.rpcEndpoint = fromEnvVar(network, "RPC", conf.rpcEndpoint) as string; @@ -322,6 +332,7 @@ export class Config { } const bundlerDefaultConfigs: BundlerConfig = { + beneficiary: "", minInclusionDenominator: 10, throttlingSlack: 10, banSlack: 50, diff --git a/packages/executor/src/interfaces.ts b/packages/executor/src/interfaces.ts index 356e5749..7febdb79 100644 --- a/packages/executor/src/interfaces.ts +++ b/packages/executor/src/interfaces.ts @@ -75,7 +75,8 @@ export type BundlingMode = "auto" | "manual"; export type Executors = Map; export interface NetworkConfig { entryPoints: string[]; - relayer: string; + relayer: string; // deprecated, but kept for backwards compatibility + relayers: string[]; beneficiary: string; name?: NetworkName; rpcEndpoint: string; @@ -149,7 +150,7 @@ export interface NetworkConfig { export type BundlerConfig = Omit< NetworkConfig, - "entryPoints" | "rpcEndpoint" | "relayer" | "beneficiary" + "entryPoints" | "rpcEndpoint" | "relayer" | "relayers" >; export type Networks = { diff --git a/packages/executor/src/modules/skandha.ts b/packages/executor/src/modules/skandha.ts index c9efbbfb..51c0f43f 100644 --- a/packages/executor/src/modules/skandha.ts +++ b/packages/executor/src/modules/skandha.ts @@ -69,7 +69,13 @@ export class Skandha { } async getConfig(): Promise { - const wallet = this.config.getRelayer(this.networkName); + const wallets = this.config.getRelayers(this.networkName); + const walletAddresses = []; + if (wallets) { + for (const wallet of wallets) { + walletAddresses.push(await wallet.getAddress()); + } + } const hasEtherscanApiKey = Boolean(this.networkConfig.etherscanApiKey); const hasExecutionRpc = Boolean(this.networkConfig.rpcEndpointSubmit); return { @@ -80,7 +86,7 @@ export class Skandha { }, entryPoints: this.networkConfig.entryPoints, beneficiary: this.networkConfig.beneficiary, - relayer: wallet ? await wallet.getAddress() : "", + relayers: walletAddresses, minInclusionDenominator: BigNumber.from( this.networkConfig.minInclusionDenominator ).toNumber(), diff --git a/packages/executor/src/services/BundlingService/interfaces.ts b/packages/executor/src/services/BundlingService/interfaces.ts index cfc61463..4af02892 100644 --- a/packages/executor/src/services/BundlingService/interfaces.ts +++ b/packages/executor/src/services/BundlingService/interfaces.ts @@ -5,5 +5,5 @@ export type Relayer = Wallet | providers.JsonRpcSigner; export interface IRelayingMode { isLocked(): boolean; - sendBundle(bundle: Bundle, beneficiary: string): Promise; + sendBundle(bundle: Bundle): Promise; } diff --git a/packages/executor/src/services/BundlingService/relayers/base.ts b/packages/executor/src/services/BundlingService/relayers/base.ts index a641c26f..50b0aaaf 100644 --- a/packages/executor/src/services/BundlingService/relayers/base.ts +++ b/packages/executor/src/services/BundlingService/relayers/base.ts @@ -27,9 +27,9 @@ export abstract class BaseRelayer implements IRelayingMode { protected reputationService: ReputationService, protected metrics: PerChainMetrics | null ) { - const relayer = this.config.getRelayer(this.network); - if (!relayer) throw new Error("Relayer is not set"); - this.relayers = [relayer]; + const relayers = this.config.getRelayers(this.network); + if (!relayers) throw new Error("Relayers are not set"); + this.relayers = [...relayers]; this.mutexes = this.relayers.map(() => new Mutex()); } @@ -37,7 +37,7 @@ export abstract class BaseRelayer implements IRelayingMode { return this.mutexes.every((mutex) => mutex.isLocked()); } - sendBundle(_bundle: Bundle, _beneficiary: string): Promise { + sendBundle(_bundle: Bundle): Promise { throw new Error("Method not implemented."); } @@ -120,4 +120,27 @@ export abstract class BaseRelayer implements IRelayingMode { }); } } + + /** + * determine who should receive the proceedings of the request. + * if signer's balance is too low, send it to signer. otherwise, send to configured beneficiary. + */ + protected async selectBeneficiary(relayer: Relayer): Promise { + const config = this.config.getNetworkConfig(this.network); + let beneficiary = this.config.getBeneficiary(this.network); + if (!beneficiary || !utils.isAddress(beneficiary)) { + return relayer.getAddress(); + } + + const signerAddress = await relayer.getAddress(); + const currentBalance = await this.provider.getBalance(signerAddress); + + if (currentBalance.lte(config!.minSignerBalance) || !beneficiary) { + beneficiary = signerAddress; + this.logger.info( + `low balance on ${signerAddress}. using it as beneficiary` + ); + } + return beneficiary; + } } diff --git a/packages/executor/src/services/BundlingService/relayers/classic.ts b/packages/executor/src/services/BundlingService/relayers/classic.ts index d41fae52..9d21836e 100644 --- a/packages/executor/src/services/BundlingService/relayers/classic.ts +++ b/packages/executor/src/services/BundlingService/relayers/classic.ts @@ -12,6 +12,7 @@ import { MempoolService } from "../../MempoolService"; import { estimateBundleGasLimit } from "../utils"; import { ReputationService } from "../../ReputationService"; import { BaseRelayer } from "./base"; +import { wait } from "../../../utils"; export class ClassicRelayer extends BaseRelayer { constructor( @@ -38,7 +39,7 @@ export class ClassicRelayer extends BaseRelayer { ); } - async sendBundle(bundle: Bundle, beneficiary: string): Promise { + async sendBundle(bundle: Bundle): Promise { const availableIndex = this.getAvailableRelayerIndex(); if (availableIndex == null) return; const relayer = this.relayers[availableIndex]; @@ -48,6 +49,7 @@ export class ClassicRelayer extends BaseRelayer { if (!bundle.entries.length) return; await mutex.runExclusive(async (): Promise => { + const beneficiary = await this.selectBeneficiary(relayer); const entryPoint = entries[0]!.entryPoint; const entryPointContract = IEntryPoint__factory.connect( entryPoint, diff --git a/packages/executor/src/services/BundlingService/relayers/flashbots.ts b/packages/executor/src/services/BundlingService/relayers/flashbots.ts index 367f6de8..7f7816dd 100644 --- a/packages/executor/src/services/BundlingService/relayers/flashbots.ts +++ b/packages/executor/src/services/BundlingService/relayers/flashbots.ts @@ -43,7 +43,7 @@ export class FlashbotsRelayer extends BaseRelayer { ); } - async sendBundle(bundle: Bundle, beneficiary: string): Promise { + async sendBundle(bundle: Bundle): Promise { const availableIndex = this.getAvailableRelayerIndex(); if (availableIndex == null) return; @@ -54,6 +54,7 @@ export class FlashbotsRelayer extends BaseRelayer { if (!bundle.entries.length) return; await mutex.runExclusive(async (): Promise => { + const beneficiary = await this.selectBeneficiary(relayer); const entryPoint = entries[0]!.entryPoint; const entryPointContract = IEntryPoint__factory.connect( entryPoint, diff --git a/packages/executor/src/services/BundlingService/service.ts b/packages/executor/src/services/BundlingService/service.ts index 532e384b..73fed2d9 100644 --- a/packages/executor/src/services/BundlingService/service.ts +++ b/packages/executor/src/services/BundlingService/service.ts @@ -319,29 +319,11 @@ export class BundlingService { }, this.autoBundlingInterval); } - /** - * determine who should receive the proceedings of the request. - * if signer's balance is too low, send it to signer. otherwise, send to configured beneficiary. - */ - private async selectBeneficiary(): Promise { - const config = this.config.getNetworkConfig(this.network); - let beneficiary = this.config.getBeneficiary(this.network); - const signer = this.config.getRelayer(this.network); - const signerAddress = await signer!.getAddress(); - const currentBalance = await this.provider.getBalance(signerAddress); - - if (currentBalance.lte(config!.minSignerBalance) || !beneficiary) { - beneficiary = signerAddress; - this.logger.info( - `low balance on ${signerAddress}. using it as beneficiary` - ); - } - return beneficiary; - } - async sendNextBundle(): Promise { await this.mutex.runExclusive(async () => { - let entries = await this.mempoolService.getNewEntriesSorted(); + let entries = await this.mempoolService.getNewEntriesSorted( + this.maxBundleSize + ); if (!entries.length) return; if (this.relayer.isLocked()) { this.logger.debug("Have userops, but all relayers are busy."); @@ -357,7 +339,9 @@ export class BundlingService { `Found ${invalidEntries.length} problematic user ops, deleting...` ); await this.mempoolService.removeAll(invalidEntries); - entries = await this.mempoolService.getNewEntriesSorted(); + entries = await this.mempoolService.getNewEntriesSorted( + this.maxBundleSize + ); } if (!entries.length) return; const gasFee = await getGasFee( @@ -380,11 +364,9 @@ export class BundlingService { MempoolEntryStatus.Pending ); await this.mempoolService.attemptToBundle(bundle.entries); - void this.relayer - .sendBundle(bundle, await this.selectBeneficiary()) - .catch((err) => { - this.logger.error(err); - }); + void this.relayer.sendBundle(bundle).catch((err) => { + this.logger.error(err); + }); this.logger.debug("Sent new bundle to Skandha relayer..."); // during testing against spec-tests we need to wait the block to be submitted diff --git a/packages/executor/src/services/MempoolService.ts b/packages/executor/src/services/MempoolService.ts index 3582cf4e..8055a7f6 100644 --- a/packages/executor/src/services/MempoolService.ts +++ b/packages/executor/src/services/MempoolService.ts @@ -148,11 +148,12 @@ export class MempoolService { return this.findByKey(key); } - async getNewEntriesSorted(): Promise { + async getNewEntriesSorted(size: number): Promise { const allEntries = await this.fetchAll(); return allEntries .filter((entry) => entry.status === MempoolEntryStatus.New) - .sort(MempoolEntry.compareByCost); + .sort(MempoolEntry.compareByCost) + .slice(0, size); } async clearState(): Promise { diff --git a/packages/types/src/api/interfaces.ts b/packages/types/src/api/interfaces.ts index 5dd35f3f..42bd8aa5 100644 --- a/packages/types/src/api/interfaces.ts +++ b/packages/types/src/api/interfaces.ts @@ -53,7 +53,7 @@ export type GetConfigResponse = { }; entryPoints: string[]; beneficiary: string; - relayer: string; + relayers: string[]; minInclusionDenominator: number; throttlingSlack: number; banSlack: number; From 6b6a8e97174f22061875a12f4b7d6fd8e146ffae Mon Sep 17 00:00:00 2001 From: marie-fourier Date: Fri, 15 Dec 2023 16:30:22 +0500 Subject: [PATCH 2/6] chore(release): 1.0.30-alpha --- 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/monitoring/package.json | 4 ++-- packages/node/package.json | 16 ++++++++-------- packages/params/package.json | 6 +++--- packages/types/package.json | 2 +- packages/utils/package.json | 4 ++-- 11 files changed, 35 insertions(+), 35 deletions(-) diff --git a/lerna.json b/lerna.json index 4be2144f..deacd8fb 100644 --- a/lerna.json +++ b/lerna.json @@ -4,7 +4,7 @@ ], "npmClient": "yarn", "useWorkspaces": true, - "version": "1.0.29-alpha", + "version": "1.0.30-alpha", "stream": "true", "command": { "version": { diff --git a/package.json b/package.json index d3394820..4e1fa161 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "root", "private": true, - "version": "1.0.29-alpha", + "version": "1.0.30-alpha", "engines": { "node": ">=18.0.0" }, diff --git a/packages/api/package.json b/packages/api/package.json index b8ee5ac6..531a4eda 100644 --- a/packages/api/package.json +++ b/packages/api/package.json @@ -1,6 +1,6 @@ { "name": "api", - "version": "1.0.29-alpha", + "version": "1.0.30-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.29-alpha", + "executor": "^1.0.30-alpha", "fastify": "4.14.1", - "monitoring": "^1.0.29-alpha", + "monitoring": "^1.0.30-alpha", "pino": "8.11.0", "pino-pretty": "10.0.0", "reflect-metadata": "0.1.13", - "types": "^1.0.29-alpha" + "types": "^1.0.30-alpha" }, "devDependencies": { "@types/connect": "3.4.35" diff --git a/packages/cli/package.json b/packages/cli/package.json index 470d7393..b0d871de 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,6 +1,6 @@ { "name": "cli", - "version": "1.0.29-alpha", + "version": "1.0.30-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.29-alpha", - "db": "^1.0.29-alpha", - "executor": "^1.0.29-alpha", + "api": "^1.0.30-alpha", + "db": "^1.0.30-alpha", + "executor": "^1.0.30-alpha", "find-up": "5.0.0", "got": "12.5.3", "js-yaml": "4.1.0", - "monitoring": "^1.0.29-alpha", - "node": "^1.0.29-alpha", - "types": "^1.0.29-alpha", + "monitoring": "^1.0.30-alpha", + "node": "^1.0.30-alpha", + "types": "^1.0.30-alpha", "yargs": "17.6.2" }, "devDependencies": { diff --git a/packages/db/package.json b/packages/db/package.json index 31c57b68..9474c5bc 100644 --- a/packages/db/package.json +++ b/packages/db/package.json @@ -1,6 +1,6 @@ { "name": "db", - "version": "1.0.29-alpha", + "version": "1.0.30-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.29-alpha" + "types": "^1.0.30-alpha" }, "devDependencies": { "@types/rocksdb": "3.0.1", diff --git a/packages/executor/package.json b/packages/executor/package.json index e60d0fe2..7e71bba4 100644 --- a/packages/executor/package.json +++ b/packages/executor/package.json @@ -1,6 +1,6 @@ { "name": "executor", - "version": "1.0.29-alpha", + "version": "1.0.30-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.29-alpha", - "params": "^1.0.29-alpha", - "types": "^1.0.29-alpha" + "monitoring": "^1.0.30-alpha", + "params": "^1.0.30-alpha", + "types": "^1.0.30-alpha" } } diff --git a/packages/monitoring/package.json b/packages/monitoring/package.json index 458c853e..85ff7a0a 100644 --- a/packages/monitoring/package.json +++ b/packages/monitoring/package.json @@ -1,6 +1,6 @@ { "name": "monitoring", - "version": "1.0.29-alpha", + "version": "1.0.30-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.29-alpha" + "types": "^1.0.30-alpha" } } diff --git a/packages/node/package.json b/packages/node/package.json index 4ef3b434..2973cb58 100644 --- a/packages/node/package.json +++ b/packages/node/package.json @@ -1,6 +1,6 @@ { "name": "node", - "version": "1.0.29-alpha", + "version": "1.0.30-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.29-alpha", + "api": "^1.0.30-alpha", "datastore-core": "8.0.1", - "db": "^1.0.29-alpha", + "db": "^1.0.30-alpha", "ethers": "5.7.2", - "executor": "^1.0.29-alpha", + "executor": "^1.0.30-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.29-alpha", - "params": "^1.0.29-alpha", + "monitoring": "^1.0.30-alpha", + "params": "^1.0.30-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.29-alpha", - "utils": "^1.0.29-alpha", + "types": "^1.0.30-alpha", + "utils": "^1.0.30-alpha", "varint": "6.0.0", "xxhash-wasm": "1.0.2" }, diff --git a/packages/params/package.json b/packages/params/package.json index b7199b25..2640cbdc 100644 --- a/packages/params/package.json +++ b/packages/params/package.json @@ -1,6 +1,6 @@ { "name": "params", - "version": "1.0.29-alpha", + "version": "1.0.30-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.29-alpha", - "utils": "^1.0.29-alpha" + "types": "^1.0.30-alpha", + "utils": "^1.0.30-alpha" }, "scripts": { "clean": "rm -rf lib && rm -f *.tsbuildinfo", diff --git a/packages/types/package.json b/packages/types/package.json index c2202d7b..a25a31b3 100644 --- a/packages/types/package.json +++ b/packages/types/package.json @@ -1,6 +1,6 @@ { "name": "types", - "version": "1.0.29-alpha", + "version": "1.0.30-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 46bf201e..fa48be2f 100644 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -1,6 +1,6 @@ { "name": "utils", - "version": "1.0.29-alpha", + "version": "1.0.30-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.29-alpha" + "types": "^1.0.30-alpha" } } From a004da7b6026928d94ec520708fcbdcef3201e87 Mon Sep 17 00:00:00 2001 From: marie-fourier Date: Fri, 15 Dec 2023 16:35:35 +0500 Subject: [PATCH 3/6] update readme --- README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 83be41e1..78cdb1d5 100644 --- a/README.md +++ b/README.md @@ -90,7 +90,10 @@ Or follow the steps below: "entryPoints": [ # supported entry points "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789" ], - "relayer": "0xprivateKey", # relayer private key, can access from here or via environment variables (SKANDHA_MUMBAI_RELAYER | SKANDHA_DEV_RELAYER | etc.) + "relayers": [ + "0xprivateKey", + "0xprivateKey2" + ], # relayers private keys, can access from here or via environment variables (SKANDHA_MUMBAI_RELAYERS | SKANDHA_DEV_RELAYERS | etc.) "beneficiary": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266", # optional, fee collector, avaiable via env var (SKANDHA_MUMBAI_BENEFICIARY | etc) - if not set, relayer will be used "rpcEndpoint": "http://localhost:8545", # rpc provider, also available via env variable (SKANDHA_MUMBAI_RPC | etc) "minInclusionDenominator": 10, # optional, see EIP-4337 From bcd71af3053de4e7d7e0298690885fe3328bb7e6 Mon Sep 17 00:00:00 2001 From: marie-fourier Date: Fri, 15 Dec 2023 16:36:51 +0500 Subject: [PATCH 4/6] update default config --- config.json.default | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/config.json.default b/config.json.default index a454020c..ef920e03 100644 --- a/config.json.default +++ b/config.json.default @@ -4,8 +4,9 @@ "entryPoints": [ "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789" ], - "relayer": "0xprivateKey", - "beneficiary": "0x690b9a9e9aa1c9db991c7721a92d351db4fac990", + "relayers": [ + "0xprivateKey" + ], "rpcEndpoint": "http://localhost:8545" } } From 6224c33375c03b2be2d6591f6995da95ec0bb77a Mon Sep 17 00:00:00 2001 From: marie-fourier Date: Fri, 15 Dec 2023 17:06:22 +0500 Subject: [PATCH 5/6] fix getUserOpByHash --- packages/executor/src/modules/eth.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/packages/executor/src/modules/eth.ts b/packages/executor/src/modules/eth.ts index dae4be2e..01876412 100644 --- a/packages/executor/src/modules/eth.ts +++ b/packages/executor/src/modules/eth.ts @@ -465,6 +465,13 @@ export class Eth { private async getUserOperationEvent( userOpHash: string ): Promise<[IEntryPoint | null, UserOperationEventEvent | null]> { + if (!userOpHash) { + throw new RpcError( + "Missing/invalid userOpHash", + RpcErrorCodes.METHOD_NOT_FOUND + ); + } + let event: UserOperationEventEvent[] = []; for (const addr of await this.getSupportedEntryPoints()) { const contract = IEntryPoint__factory.connect(addr, this.provider); From b8d4d0184e53534731316e582e6bd104f9f6cc65 Mon Sep 17 00:00:00 2001 From: marie-fourier Date: Mon, 18 Dec 2023 15:35:29 +0500 Subject: [PATCH 6/6] fix tests & update readme --- README.md | 4 ++-- config.json.default | 3 ++- packages/executor/src/executor.ts | 3 +++ packages/executor/src/services/BundlingService/service.ts | 5 +++++ 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 78cdb1d5..82cf967d 100644 --- a/README.md +++ b/README.md @@ -91,8 +91,8 @@ Or follow the steps below: "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789" ], "relayers": [ - "0xprivateKey", - "0xprivateKey2" + "0x0101010101010101010101010101010101010101010101010101010101010101", + "test test test test test test test test test test test junk" ], # relayers private keys, can access from here or via environment variables (SKANDHA_MUMBAI_RELAYERS | SKANDHA_DEV_RELAYERS | etc.) "beneficiary": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266", # optional, fee collector, avaiable via env var (SKANDHA_MUMBAI_BENEFICIARY | etc) - if not set, relayer will be used "rpcEndpoint": "http://localhost:8545", # rpc provider, also available via env variable (SKANDHA_MUMBAI_RPC | etc) diff --git a/config.json.default b/config.json.default index ef920e03..e16c2790 100644 --- a/config.json.default +++ b/config.json.default @@ -5,7 +5,8 @@ "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789" ], "relayers": [ - "0xprivateKey" + "test test test test test test test test test test test junk", + "0x0101010101010101010101010101010101010101010101010101010101010101" ], "rpcEndpoint": "http://localhost:8545" } diff --git a/packages/executor/src/executor.ts b/packages/executor/src/executor.ts index f69a52d6..b57c86ca 100644 --- a/packages/executor/src/executor.ts +++ b/packages/executor/src/executor.ts @@ -153,6 +153,9 @@ export class Executor { this.bundlingService.setBundlingMode("manual"); this.logger.info(`${this.networkName}: [X] MANUAL BUNDLING`); } + if (this.config.testingMode) { + this.bundlingService.setMaxBundleSize(10); + } if (this.networkConfig.relayingMode === "flashbots") { if (!this.networkConfig.rpcEndpointSubmit) diff --git a/packages/executor/src/services/BundlingService/service.ts b/packages/executor/src/services/BundlingService/service.ts index 73fed2d9..2a607396 100644 --- a/packages/executor/src/services/BundlingService/service.ts +++ b/packages/executor/src/services/BundlingService/service.ts @@ -84,6 +84,11 @@ export class BundlingService { this.restartCron(); } + setMaxBundleSize(size: number): void { + this.maxBundleSize = size; + this.restartCron(); + } + setBundlingMode(mode: BundlingMode): void { this.bundlingMode = mode; this.restartCron();