telosnetwork / telos-evm-rpc

2 stars 3 forks source link

Fix gas estimation being reverted on call revert. #13

Closed tomtomcrypto closed 1 year ago

tomtomcrypto commented 1 year ago

Description

Currently on 1.5 Telos if we try and estimateGas on a call that reverts, the transaction reverts.

Error: cannot estimate gas; transaction may fail or may require manual gas limit [ See: https://links.ethers.org/v5-errors-UNPREDICTABLE_GAS_LIMIT ] (reason="execution reverted: This is a very big problem!", method="estimateGas", transaction={"from":"0xc51fE232a0153F1F44572369Cefe7b90f2BA08a5","to":"0xf5b66612B9C1CeD82EDDa61aAE860a5D296BC07f","data":"0x15431614","accessList":null}, error={"name":"ProviderError","_stack":"ProviderError: execution reverted: This is a very big problem!\n    at HttpProvider.request (/home/tom/evm-tests/node_modules/hardhat/src/internal/core/providers/http.ts:88:21)\n    at processTicksAndRejections (node:internal/process/task_queues:96:5)\n    at EthersProviderWrapper.send (/home/tom/evm-tests/node_modules/@nomiclabs/hardhat-ethers/src/internal/ethers-provider-wrapper.ts:13:20)","code":3,"_isProviderError":true,"data":"08c379a00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000001b5468697320697320612076657279206269672070726f626c656d210000000000"}, code=UNPREDICTABLE_GAS_LIMIT, version=providers/5.7.2)
    at Logger.makeError (/home/tom/evm-tests/node_modules/@ethersproject/logger/src.ts/index.ts:269:28)
    at Logger.throwError (/home/tom/evm-tests/node_modules/@ethersproject/logger/src.ts/index.ts:281:20)
    at checkError (/home/tom/evm-tests/node_modules/@ethersproject/providers/src.ts/json-rpc-provider.ts:78:20)
    at EthersProviderWrapper.<anonymous> (/home/tom/evm-tests/node_modules/@ethersproject/providers/src.ts/json-rpc-provider.ts:642:20)
    at step (/home/tom/evm-tests/node_modules/@ethersproject/providers/lib/json-rpc-provider.js:48:23)
    at Object.throw (/home/tom/evm-tests/node_modules/@ethersproject/providers/lib/json-rpc-provider.js:29:53)
    at rejected (/home/tom/evm-tests/node_modules/@ethersproject/providers/lib/json-rpc-provider.js:21:65)
    at processTicksAndRejections (node:internal/process/task_queues:96:5) {
  reason: 'execution reverted: This is a very big problem!',
  code: 'UNPREDICTABLE_GAS_LIMIT',
  method: 'estimateGas',
  transaction: {
    from: '0xc51fE232a0153F1F44572369Cefe7b90f2BA08a5',
    to: '0xf5b66612B9C1CeD82EDDa61aAE860a5D296BC07f',
    data: '0x15431614',
    accessList: null
  },
  error: ProviderError: execution reverted: This is a very big problem!
      at HttpProvider.request (/home/tom/evm-tests/node_modules/hardhat/src/internal/core/providers/http.ts:88:21)
      at processTicksAndRejections (node:internal/process/task_queues:96:5)
      at EthersProviderWrapper.send (/home/tom/evm-tests/node_modules/@nomiclabs/hardhat-ethers/src/internal/ethers-provider-wrapper.ts:13:20)
}

On Sepolia, the same transaction doesn't revert BigNumber { value: "21064" }

We should have Telos conform to Sepolia and estimate gas even if the estimated call reverses.

tomtomcrypto commented 1 year ago

Check the GAS_OVER_ESTIMATE_MULTIPLIER. Does Sepolia over estimate gas used ?

tomtomcrypto commented 1 year ago

We probably just need to get rid of https://github.com/telosnetwork/telos.evm/blob/975ce2791be9c4d1c662d4cb1768fd68ae57a734/eosio.evm/src/eosio.evm.cpp#L146

tomtomcrypto commented 1 year ago

Actually the reth client does revert gas estimation on call revert