From 5267719eb16c5c7a817c1415a040952535c2005f Mon Sep 17 00:00:00 2001 From: Alex Forshtat Date: Sat, 3 Aug 2024 23:04:27 +0200 Subject: [PATCH] Fixes --- packages/bundler/src/BundlerServer.ts | 6 ++++-- packages/bundler/src/modules/BundleManager.ts | 19 +++++++++++++------ 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/packages/bundler/src/BundlerServer.ts b/packages/bundler/src/BundlerServer.ts index 872c3442..cb83dbe0 100644 --- a/packages/bundler/src/BundlerServer.ts +++ b/packages/bundler/src/BundlerServer.ts @@ -236,9 +236,11 @@ export class BundlerServer { if (this.config.useRip7560Mode == null) { throw new RpcError(`Method ${method} is not supported`, -32601) } - const [bundle] = await this.methodHandlerRip7560.getRip7560Bundle(params[0], params[1], params[2]) + const [bundle] = await this.methodHandlerRip7560.getRip7560Bundle( + params[0].MinBaseFee, params[0].MaxBundleGas, params[0].MaxBundleSize + ) // TODO: provide a correct value for 'validForBlock' - result = { bundle, validForBlock: 0 } + result = { bundle, validForBlock: '0x0' } console.log('handleMethod eth_getRip7560Bundle:\n', result) break } diff --git a/packages/bundler/src/modules/BundleManager.ts b/packages/bundler/src/modules/BundleManager.ts index 66fb68a7..be4e2e0e 100644 --- a/packages/bundler/src/modules/BundleManager.ts +++ b/packages/bundler/src/modules/BundleManager.ts @@ -199,9 +199,9 @@ export class BundleManager implements IBundleManager { } async createBundle ( - minBaseFee: BigNumberish, - maxBundleGas: BigNumberish, - maxBundleSize: BigNumberish + minBaseFee?: BigNumberish, + maxBundleGas?: BigNumberish, + maxBundleSize?: BigNumberish ): Promise<[OperationBase[], StorageMap]> { const entries = this.mempoolManager.getSortedForInclusion() const bundle: OperationBase[] = [] @@ -223,12 +223,16 @@ export class BundleManager implements IBundleManager { // eslint-disable-next-line no-labels mainLoop: for (const entry of entries) { - const maxBundleSizeNum = BigNumber.from(maxBundleSize).toNumber() + const maxBundleSizeNum = BigNumber.from(maxBundleSize ?? 0).toNumber() if (maxBundleSizeNum !== 0 && entries.length >= maxBundleSizeNum) { debug('exiting after maxBundleSize is reached', maxBundleSize, entries.length) break } - if (BigNumber.from(entry.userOp.maxFeePerGas).lt(minBaseFee)) { + if ( + minBaseFee != null && + !BigNumber.from(minBaseFee).eq(0) && + BigNumber.from(entry.userOp.maxFeePerGas).lt(minBaseFee) + ) { debug('skipping transaction not paying minBaseFee', minBaseFee, entry.userOp.maxFeePerGas) continue } @@ -318,7 +322,10 @@ export class BundleManager implements IBundleManager { .add(entry.userOp.paymasterPostOpGasLimit ?? 0) const newBundleGas = userOpGas.add(bundleGas) - if (newBundleGas.gte(maxBundleGas)) { + if ( + maxBundleGas != null && + !BigNumber.from(maxBundleGas).eq(0) && + newBundleGas.gte(maxBundleGas)) { debug('exiting after maxBundleGas is reached', maxBundleGas, bundleGas, userOpGas) break }