diff --git a/packages/bundler/src/BundlerConfig.ts b/packages/bundler/src/BundlerConfig.ts index 0b80891..cbef8b1 100644 --- a/packages/bundler/src/BundlerConfig.ts +++ b/packages/bundler/src/BundlerConfig.ts @@ -12,6 +12,7 @@ export interface BundlerConfig { network: string port: string unsafe: boolean + debugRpc?: boolean conditionalRpc: boolean whitelist?: string[] @@ -33,6 +34,7 @@ export const BundlerConfigShape = { network: ow.string, port: ow.string, unsafe: ow.boolean, + debugRpc: ow.optional.boolean, conditionalRpc: ow.boolean, whitelist: ow.optional.array.ofType(ow.string), diff --git a/packages/bundler/src/runBundler.ts b/packages/bundler/src/runBundler.ts index 442330a..b03c672 100644 --- a/packages/bundler/src/runBundler.ts +++ b/packages/bundler/src/runBundler.ts @@ -1,7 +1,7 @@ import fs from 'fs' import { Command } from 'commander' -import { erc4337RuntimeVersion, supportsRpcMethod } from '@account-abstraction/utils' +import { erc4337RuntimeVersion, RpcError, supportsRpcMethod } from '@account-abstraction/utils' import { ethers, Wallet, Signer } from 'ethers' import { BundlerServer } from './BundlerServer' @@ -70,6 +70,7 @@ export async function runBundler (argv: string[], overrideExit = true): Promise< .option('--config ', 'path to config file', CONFIG_FILE_NAME) .option('--auto', 'automatic bundling (bypass config.autoBundleMempoolSize)', false) .option('--unsafe', 'UNSAFE mode: no storage or opcode checks (safe mode requires geth)') + .option('--debugRpc', 'enable debug rpc methods (auto-enabled for test node') .option('--conditionalRpc', 'Use eth_sendRawTransactionConditional RPC)') .option('--show-stack-traces', 'Show stack traces.') .option('--createMnemonic ', 'create the mnemonic file') @@ -98,6 +99,12 @@ export async function runBundler (argv: string[], overrideExit = true): Promise< } = await provider.getNetwork() if (chainId === 31337 || chainId === 1337) { + if (config.debugRpc == null) { + console.log('== debugrpc was', config.debugRpc) + config.debugRpc = true + } else { + console.log('== debugrpc already st', config.debugRpc) + } await new DeterministicDeployer(provider as any).deterministicDeploy(EntryPoint__factory.bytecode) if ((await wallet.getBalance()).eq(0)) { console.log('=== testnet: fund signer') @@ -138,7 +145,13 @@ export async function runBundler (argv: string[], overrideExit = true): Promise< entryPoint ) eventsManager.initEventListener() - const debugHandler = new DebugMethodHandler(execManager, eventsManager, reputationManager, mempoolManager) + const debugHandler = config.debugRpc ?? false + ? new DebugMethodHandler(execManager, eventsManager, reputationManager, mempoolManager) + : new Proxy({}, { + get (target: {}, method: string, receiver: any): any { + throw new RpcError(`method debug_bundler_${method} is not supported`, -32601) + } + }) as DebugMethodHandler const bundlerServer = new BundlerServer( methodHandler, diff --git a/packages/sdk/src/Provider.ts b/packages/sdk/src/Provider.ts index 8f3cecd..e6485f0 100644 --- a/packages/sdk/src/Provider.ts +++ b/packages/sdk/src/Provider.ts @@ -34,7 +34,6 @@ export async function wrapProvider ( factoryAddress: SimpleAccountFactory, paymasterAPI: config.paymasterAPI }) - debug('config=', config) const chainId = await originalProvider.getNetwork().then(net => net.chainId) const httpRpcClient = new HttpRpcClient(config.bundlerUrl, config.entryPointAddress, chainId) return await new ERC4337EthersProvider(