Skip to content

The createBundle() function should process UserOperations in order of highest gas price first. #229

Description

@eunseong-theori

In https://github.com/eth-infinitism/bundler/blob/master/packages/bundler/src/modules/BundleManager.ts#L206, createBundle() calls this.mempoolManager.getSortedForInclusion() to obtain sorted UserOperations from mempool.

However, getSortedForInclusion() performs copy.sort((a, b) => cost(a.userOp) - cost(b.userOp)), which sorts the operations so that those with lower maxPriorityFeePerGas values come first.

  getSortedForInclusion (): MempoolEntry[] {
    const copy = Array.from(this.mempool)

    function cost (op: OperationBase): number {
      // TODO: need to consult basefee and maxFeePerGas
      return BigNumber.from(op.maxPriorityFeePerGas).toNumber()
    }

    copy.sort((a, b) => cost(a.userOp) - cost(b.userOp))
    return copy
  }

To maximize profits for the Bundler, it should process gas prices in descending order. Therefore, it should be changed to copy.sort((a, b) => cost(b.userOp) - cost(a.userOp)).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions