cosmos/ethermint

ctx.blockGasMeter is not supposed to be set to infinite in AnteHandle

banishee opened this issue · 0 comments

System info: [Include Ethermint commit, operating system name, and other relevant details]
branch: development
commit: before be66483

Steps to reproduce:

  1. Run a private chain on local
  2. Send a cosmos transaction, like MsgEthermint or something else from other module, then send a MsgEthereumTx transferring transaction, which is better to be made up from Metamask. (just make sure there are more than two transactions in one block)
  3. User could noticed that the balance of account has changed.
  4. There are two way of knowing the result of the panic
    • If the chain is running on the debug mode, user could set a break point at cosmos-sdk/baseapp/baseapp.go#L585, then the latter MsgEthereumTx will trigger this break point.
      image

    • Run the rest cli with debug mode, and make a break point at rpc/namespaces/eth/api.go#L828. After sending the MsgEthereumTx, user will get a txhash. Based on this txhash, user could use eth_getTransactionReceipt api to query the tx result. User will notice that receipt["status"]iszero, and there is a panic message in tx.TxResult.Log.
      image

Root of problem:

  1. ctx.blockGasMeter is set to infinite in every tx ante-handler.
    ctx = ctx.WithBlockGasMeter(sdk.NewInfiniteGasMeter())
  2. When committing a regular cosmos transactions, then committing the specific MsgEthereumTx on the chain, the last transaction will end up with a panic message in the cosmos-sdk.
    Because the value of gas_consumed in cosmos transactions will be added up to ctx.blockGasMeter, but ctx.blockGasMeter is reset into zero when executing MsgEthereumTx transaction, causing the judgement ctx.BlockGasMeter().GasConsumed() < startingGas pass through.
    https://github.com/cosmos/cosmos-sdk/blob/2727c14183d05f5c31ca11f2dcd52b0aa683fadf/baseapp/baseapp.go#L585
  3. Though it doesn't cause a quite severe problem, it just set a panic log in the this transaction, and it will cause user think his own transaction failed, which is actually successful.

Expected behavior: [What you expected to happen]

  • every transactions to be commited successfully in one block should be set the correct status.

Actual behavior: [What actually happened]

Additional info: [Include gist of relevant config, logs, etc.]
What I recommend is just removing this code ctx = ctx.WithBlockGasMeter(sdk.NewInfiniteGasMeter())