Skip to content

Conversation

@kvhnuke
Copy link

@kvhnuke kvhnuke commented May 20, 2020

There are multiple occasions where you have to estimate the gas limit in a sequential order, meaning estimate should take state changes made by previous calls into consideration. Current eth_estimateGas creates a copy of the pending state on each call. Because of this, it is not possible to send out multiple txs that depends on each other at the same time.
Good example will be DEXs which requires tokens to be approve(spender, amount) before executing the trade. Currently some DEXs maintains a gas limit map since the gas limit cannot be estimated using eth_estimateGas without having the tokens approved.
At MEW we have to guess the gas limit for batch transactions where we will guess extreme amounts just to be on the safe side and this adds txs that are set with unnecessarily higher gas limits to the pending pool.

This PR will let users estimate gas on the same state. Also it is backwards compatible with current ethereum rpc standard.
{"jsonrpc":"2.0","method":"eth_estimateGasList","params":[[{call0-0}, {call0-1}, {call0-2}]],"id":1}

{
  "id":1,
  "jsonrpc": "2.0",
  "result": ["0xvalue0-0", "0xvalue0-1", "0xvalue0-2"]
}

in this case call0s depends on previous call to be executed on the state.

backwards compatible
{"jsonrpc":"2.0","method":"eth_estimateGas","params":[{call1-0}],"id":1}

{
  "id":1,
  "jsonrpc": "2.0",
  "result": "0xvalue1-0"
}

@rjl493456442 rjl493456442 self-assigned this May 21, 2020
@adamschmideg
Copy link
Contributor

Closing in favor of #21268

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants