From aa2bafbc9e6b2ec09b85c3dc1663b0dace9b780c Mon Sep 17 00:00:00 2001 From: Dror Tirosh Date: Tue, 31 Oct 2023 19:31:55 +0200 Subject: [PATCH 1/2] debug method: add UserOps directly to mempool bypass allchecks. debug_bundler_addUserOperations add an array of UserOps directly in to the mempool, without any validation or throttling. --- packages/bundler/src/BundlerServer.ts | 4 ++++ packages/bundler/src/DebugMethodHandler.ts | 18 +++++++++++++++++- .../bundler/src/modules/ExecutionManager.ts | 1 - packages/bundler/src/modules/MempoolManager.ts | 3 --- 4 files changed, 21 insertions(+), 5 deletions(-) diff --git a/packages/bundler/src/BundlerServer.ts b/packages/bundler/src/BundlerServer.ts index 49fff687..1b77d6a9 100644 --- a/packages/bundler/src/BundlerServer.ts +++ b/packages/bundler/src/BundlerServer.ts @@ -207,6 +207,10 @@ export class BundlerServer { await this.debugHandler.setBundleInterval(params[0], params[1]) result = 'ok' break + case 'debug_bundler_addUserOperations': + await this.debugHandler.addUserOperations(params[0]) + result = 'ok' + break case 'debug_bundler_sendBundleNow': result = await this.debugHandler.sendBundleNow() if (result == null) { diff --git a/packages/bundler/src/DebugMethodHandler.ts b/packages/bundler/src/DebugMethodHandler.ts index 8a0b1abf..5c8fb355 100644 --- a/packages/bundler/src/DebugMethodHandler.ts +++ b/packages/bundler/src/DebugMethodHandler.ts @@ -3,7 +3,8 @@ import { ReputationDump, ReputationManager } from './modules/ReputationManager' import { MempoolManager } from './modules/MempoolManager' import { SendBundleReturn } from './modules/BundleManager' import { EventsManager } from './modules/EventsManager' -import { StakeInfo } from '@account-abstraction/utils' +import { ReferencedCodeHashes, StakeInfo, UserOperation } from '@account-abstraction/utils' +import { UserOperationStruct } from '@account-abstraction/contracts' export class DebugMethodHandler { constructor ( @@ -76,4 +77,19 @@ export class DebugMethodHandler { }> { return await this.repManager.getStakeStatus(address, entryPoint) } + + addUserOperations (userOps: UserOperation[]): void { + userOps.forEach(userOp => { + const refs: ReferencedCodeHashes = { addresses: [], hash: '' } + const userOpHash = '' // used only by removeUserOp() when processing events. + + // we treat sender as "staked", and ignore any factory or paymaster, to bypass any reputation issues + const senderInfo: StakeInfo = { + addr: userOp.sender, + stake: this.repManager.minStake, + unstakeDelaySec: this.repManager.minUnstakeDelay + } + this.mempoolMgr.addUserOp(userOp, userOpHash, refs, senderInfo, undefined, undefined, undefined) + }) + } } diff --git a/packages/bundler/src/modules/ExecutionManager.ts b/packages/bundler/src/modules/ExecutionManager.ts index 673c7743..54f599f4 100644 --- a/packages/bundler/src/modules/ExecutionManager.ts +++ b/packages/bundler/src/modules/ExecutionManager.ts @@ -40,7 +40,6 @@ export class ExecutionManager { const userOpHash = await this.validationManager.entryPoint.getUserOpHash(userOp) this.mempoolManager.addUserOp(userOp, userOpHash, - validationResult.returnInfo.prefund, validationResult.referencedContracts, validationResult.senderInfo, validationResult.paymasterInfo, diff --git a/packages/bundler/src/modules/MempoolManager.ts b/packages/bundler/src/modules/MempoolManager.ts index 92dc2438..ff632554 100644 --- a/packages/bundler/src/modules/MempoolManager.ts +++ b/packages/bundler/src/modules/MempoolManager.ts @@ -16,7 +16,6 @@ const debug = Debug('aa.mempool') export interface MempoolEntry { userOp: UserOperation userOpHash: string - prefund: BigNumberish referencedContracts: ReferencedCodeHashes // aggregator, if one was found during simulation aggregator?: string @@ -71,7 +70,6 @@ export class MempoolManager { addUserOp ( userOp: UserOperation, userOpHash: string, - prefund: BigNumberish, referencedContracts: ReferencedCodeHashes, senderInfo: StakeInfo, paymasterInfo?: StakeInfo, @@ -81,7 +79,6 @@ export class MempoolManager { const entry: MempoolEntry = { userOp, userOpHash, - prefund, referencedContracts, aggregator: aggregatorInfo?.addr } From a5a95d0528fe6800cf6423b2e4ce85a49e5fec04 Mon Sep 17 00:00:00 2001 From: Dror Tirosh Date: Mon, 6 Nov 2023 17:19:24 +0200 Subject: [PATCH 2/2] debug_bundler_addUserOps --- packages/bundler/src/BundlerServer.ts | 4 ++-- packages/bundler/src/DebugMethodHandler.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/bundler/src/BundlerServer.ts b/packages/bundler/src/BundlerServer.ts index 1b77d6a9..fb773bab 100644 --- a/packages/bundler/src/BundlerServer.ts +++ b/packages/bundler/src/BundlerServer.ts @@ -207,8 +207,8 @@ export class BundlerServer { await this.debugHandler.setBundleInterval(params[0], params[1]) result = 'ok' break - case 'debug_bundler_addUserOperations': - await this.debugHandler.addUserOperations(params[0]) + case 'debug_bundler_addUserOps': + await this.debugHandler.addUserOps(params[0]) result = 'ok' break case 'debug_bundler_sendBundleNow': diff --git a/packages/bundler/src/DebugMethodHandler.ts b/packages/bundler/src/DebugMethodHandler.ts index 5c8fb355..d8bdbbc6 100644 --- a/packages/bundler/src/DebugMethodHandler.ts +++ b/packages/bundler/src/DebugMethodHandler.ts @@ -78,7 +78,7 @@ export class DebugMethodHandler { return await this.repManager.getStakeStatus(address, entryPoint) } - addUserOperations (userOps: UserOperation[]): void { + addUserOps (userOps: UserOperation[]): void { userOps.forEach(userOp => { const refs: ReferencedCodeHashes = { addresses: [], hash: '' } const userOpHash = '' // used only by removeUserOp() when processing events.