Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
eunseong-theori opened this issue Oct 8, 2024 · 0 comments

Comments

@eunseong-theori
Copy link

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)).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant