Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
forshtat committed Aug 3, 2024
1 parent d6c58bc commit 5267719
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
6 changes: 4 additions & 2 deletions packages/bundler/src/BundlerServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
19 changes: 13 additions & 6 deletions packages/bundler/src/modules/BundleManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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[] = []
Expand All @@ -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
}
Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit 5267719

Please sign in to comment.