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:
- Run a private chain on local
- Send a cosmos transaction, like
MsgEthermint
or something else from other module, then send aMsgEthereumTx
transferring transaction, which is better to be made up from Metamask. (just make sure there are more than two transactions in one block) - User could noticed that the balance of account has changed.
- 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 latterMsgEthereumTx
will trigger this break point.
-
Run the rest cli with debug mode, and make a break point at
rpc/namespaces/eth/api.go#L828
. After sending theMsgEthereumTx
, user will get atxhash
. Based on thistxhash
, user could useeth_getTransactionReceipt
api to query the tx result. User will notice thatreceipt["status"]
iszero
, and there is a panic message intx.TxResult.Log
.
-
Root of problem:
ctx.blockGasMeter
is set to infinite in every tx ante-handler.
Line 42 in be66483
- When committing a regular cosmos transactions, then committing the specific
MsgEthereumTx
on the chain, the last transaction will end up with apanic
message in thecosmos-sdk
.
Because the value ofgas_consumed
in cosmos transactions will be added up toctx.blockGasMeter
, butctx.blockGasMeter
is reset into zero when executingMsgEthereumTx
transaction, causing the judgementctx.BlockGasMeter().GasConsumed() < startingGas
pass through.
https://github.com/cosmos/cosmos-sdk/blob/2727c14183d05f5c31ca11f2dcd52b0aa683fadf/baseapp/baseapp.go#L585 - 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())