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

New RPC endpoint: eth_estimateGasBundle #100

Closed
epheph opened this issue Dec 15, 2021 · 3 comments
Closed

New RPC endpoint: eth_estimateGasBundle #100

epheph opened this issue Dec 15, 2021 · 3 comments

Comments

@epheph
Copy link

epheph commented Dec 15, 2021

Rationale

eth_estimateGas is an important RPC endpoint: one that simulates the specified transaction description and returns an estimate for how what gasLimit is required to allow a contract call to finish.

The problem for mev-geth is that it only operates on a single transaction, while bundles operate on a sequential set of transactions that influence gas usage of latter transactions. For example, in the bundle:

[
  approve,
  transferFrom
]

You can call eth_estimateGas(approve), but there's no way to estimate gas on transferFrom, since it requires the state of approve to be applied first.

We should make an API that accepts a bundle of transactions and returns an array of gas estimates.

This is particularly important for whitehat, as we often leave excess ETH in compromised accounts when we are required to overestimate the required gas limits.

Implementation

We already have:

  • eth_sendBundle
  • eth_callBundle

We should probably call this eth_estimateBundle or eth_estimateGasBundle.

One design consideration is whether we should be using signed transactions (like eth_callBundle) or unsigned transaction descriptions (like eth_estimateGas). I imagine using unsigned transaction descriptions would be more useful and faster to call (skipping a needless signing step on client, and a needless recovery step on server). The bundle being forwarded is going to be re-signed AFTER this call (to apply better gas limits returned), so signing first is a bit wasteful.

@jparyani
Copy link

This was added in #102.

NOTE: This differs from eth_estimateGas in that it does not binary search to find an optimal gasLimit. It only reports what the gas used by each tx in the bundle was.

@libevm
Copy link

libevm commented Dec 21, 2021

NOTE: This differs from eth_estimateGas in that it does not binary search to find an optimal gasLimit. It only reports what the gas used by each tx in the bundle was.

What does the binary search do in this case? Is it necessary? I can add that in, looks interesting to dissect

@jparyani
Copy link

I think I’m fine skipping on it, but I’ll let @epheph have the final say.

I believe the intention is that setting a gasLimit can actually change the execution of the call. The binary search finds the smallest gasLimit where the call succeeds without running out of gas. See https://github.com/ethereum/go-ethereum/blob/master/internal/ethapi/api.go#L1081

jparyani pushed a commit that referenced this issue Dec 22, 2021
jparyani pushed a commit that referenced this issue Dec 22, 2021
Ruteri pushed a commit that referenced this issue Jan 6, 2022
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

3 participants