Skip to content
This repository was archived by the owner on Nov 30, 2021. It is now read-only.

Commit a54c2dc

Browse files
nootfedekunze
andauthored
add gas price=0 unit test, comments (#528)
* add handler comment * add gas price=0 test Co-authored-by: Federico Kunze <[email protected]>
1 parent 1f4f7fb commit a54c2dc

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

x/evm/handler.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,12 @@ func handleMsgEthereumTx(ctx sdk.Context, k Keeper, msg types.MsgEthereumTx) (*s
6060
Simulate: ctx.IsCheckTx(),
6161
}
6262

63-
// Prepare db for logs
64-
// TODO: block hash
63+
// since the txCount is used by the stateDB, and a simulated tx is run only on the node it's submitted to,
64+
// then this will cause the txCount/stateDB of the node that ran the simulated tx to be different than the
65+
// other nodes, causing a consensus error
6566
if !st.Simulate {
67+
// Prepare db for logs
68+
// TODO: block hash
6669
k.CommitStateDB.Prepare(ethHash, common.Hash{}, k.TxCount)
6770
k.TxCount++
6871
}
@@ -146,8 +149,8 @@ func handleMsgEthermint(ctx sdk.Context, k Keeper, msg types.MsgEthermint) (*sdk
146149
st.Recipient = &to
147150
}
148151

149-
// Prepare db for logs
150152
if !st.Simulate {
153+
// Prepare db for logs
151154
k.CommitStateDB.Prepare(ethHash, common.Hash{}, k.TxCount)
152155
k.TxCount++
153156
}

x/evm/types/msg_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ func TestMsgEthermintValidation(t *testing.T) {
4747
{amount: sdk.NewInt(0), gasPrice: sdk.NewInt(100000), expectPass: true},
4848
{amount: sdk.NewInt(-1), gasPrice: sdk.NewInt(100000), expectPass: false},
4949
{amount: sdk.NewInt(100), gasPrice: sdk.NewInt(-1), expectPass: false},
50+
{amount: sdk.NewInt(100), gasPrice: sdk.NewInt(0), expectPass: false},
5051
}
5152

5253
for i, tc := range testCases {
@@ -116,6 +117,7 @@ func TestMsgEthereumTxValidation(t *testing.T) {
116117
{msg: "pass", amount: big.NewInt(100), gasPrice: big.NewInt(100000), expectPass: true},
117118
{msg: "invalid amount", amount: big.NewInt(-1), gasPrice: big.NewInt(100000), expectPass: false},
118119
{msg: "invalid gas price", amount: big.NewInt(100), gasPrice: big.NewInt(-1), expectPass: false},
120+
{msg: "invalid gas price", amount: big.NewInt(100), gasPrice: big.NewInt(0), expectPass: false},
119121
}
120122

121123
for i, tc := range testCases {

0 commit comments

Comments
 (0)