diff --git a/x/evm/handler.go b/x/evm/handler.go index 180f9e08..b29b1d61 100644 --- a/x/evm/handler.go +++ b/x/evm/handler.go @@ -60,9 +60,12 @@ func handleMsgEthereumTx(ctx sdk.Context, k Keeper, msg types.MsgEthereumTx) (*s Simulate: ctx.IsCheckTx(), } - // Prepare db for logs - // TODO: block hash + // since the txCount is used by the stateDB, and a simulated tx is run only on the node it's submitted to, + // then this will cause the txCount/stateDB of the node that ran the simulated tx to be different than the + // other nodes, causing a consensus error if !st.Simulate { + // Prepare db for logs + // TODO: block hash k.CommitStateDB.Prepare(ethHash, common.Hash{}, k.TxCount) k.TxCount++ } @@ -146,8 +149,8 @@ func handleMsgEthermint(ctx sdk.Context, k Keeper, msg types.MsgEthermint) (*sdk st.Recipient = &to } - // Prepare db for logs if !st.Simulate { + // Prepare db for logs k.CommitStateDB.Prepare(ethHash, common.Hash{}, k.TxCount) k.TxCount++ } diff --git a/x/evm/types/msg_test.go b/x/evm/types/msg_test.go index cd81db39..f4c8ff5c 100644 --- a/x/evm/types/msg_test.go +++ b/x/evm/types/msg_test.go @@ -47,6 +47,7 @@ func TestMsgEthermintValidation(t *testing.T) { {amount: sdk.NewInt(0), gasPrice: sdk.NewInt(100000), expectPass: true}, {amount: sdk.NewInt(-1), gasPrice: sdk.NewInt(100000), expectPass: false}, {amount: sdk.NewInt(100), gasPrice: sdk.NewInt(-1), expectPass: false}, + {amount: sdk.NewInt(100), gasPrice: sdk.NewInt(0), expectPass: false}, } for i, tc := range testCases { @@ -116,6 +117,7 @@ func TestMsgEthereumTxValidation(t *testing.T) { {msg: "pass", amount: big.NewInt(100), gasPrice: big.NewInt(100000), expectPass: true}, {msg: "invalid amount", amount: big.NewInt(-1), gasPrice: big.NewInt(100000), expectPass: false}, {msg: "invalid gas price", amount: big.NewInt(100), gasPrice: big.NewInt(-1), expectPass: false}, + {msg: "invalid gas price", amount: big.NewInt(100), gasPrice: big.NewInt(0), expectPass: false}, } for i, tc := range testCases {