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

Commit 73d6c41

Browse files
authored
fix handler csdb usage, fixes consensus error again (#516)
1 parent 244d836 commit 73d6c41

File tree

2 files changed

+25
-17
lines changed

2 files changed

+25
-17
lines changed

tests/rpc_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -758,7 +758,7 @@ func TestEth_EstimateGas(t *testing.T) {
758758
err := json.Unmarshal(rpcRes.Result, &gas)
759759
require.NoError(t, err, string(rpcRes.Result))
760760

761-
require.Equal(t, "0xf76c", gas)
761+
require.Equal(t, "0xef7e", gas)
762762
}
763763

764764
func TestEth_EstimateGas_ContractDeployment(t *testing.T) {
@@ -777,7 +777,7 @@ func TestEth_EstimateGas_ContractDeployment(t *testing.T) {
777777
err := json.Unmarshal(rpcRes.Result, &gas)
778778
require.NoError(t, err, string(rpcRes.Result))
779779

780-
require.Equal(t, "0x1cab2", gas.String())
780+
require.Equal(t, "0x1c2c4", gas.String())
781781
}
782782

783783
func TestEth_ExportAccount(t *testing.T) {

x/evm/handler.go

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,10 @@ func handleMsgEthereumTx(ctx sdk.Context, k Keeper, msg types.MsgEthereumTx) (*s
6262

6363
// Prepare db for logs
6464
// TODO: block hash
65-
k.CommitStateDB.Prepare(ethHash, common.Hash{}, k.TxCount)
66-
k.TxCount++
65+
if !st.Simulate {
66+
k.CommitStateDB.Prepare(ethHash, common.Hash{}, k.TxCount)
67+
k.TxCount++
68+
}
6769

6870
config, found := k.GetChainConfig(ctx)
6971
if !found {
@@ -75,13 +77,15 @@ func handleMsgEthereumTx(ctx sdk.Context, k Keeper, msg types.MsgEthereumTx) (*s
7577
return nil, err
7678
}
7779

78-
// update block bloom filter
79-
k.Bloom.Or(k.Bloom, executionResult.Bloom)
80+
if !st.Simulate {
81+
// update block bloom filter
82+
k.Bloom.Or(k.Bloom, executionResult.Bloom)
8083

81-
// update transaction logs in KVStore
82-
err = k.SetLogs(ctx, common.BytesToHash(txHash), executionResult.Logs)
83-
if err != nil {
84-
panic(err)
84+
// update transaction logs in KVStore
85+
err = k.SetLogs(ctx, common.BytesToHash(txHash), executionResult.Logs)
86+
if err != nil {
87+
panic(err)
88+
}
8589
}
8690

8791
// log successful execution
@@ -143,8 +147,10 @@ func handleMsgEthermint(ctx sdk.Context, k Keeper, msg types.MsgEthermint) (*sdk
143147
}
144148

145149
// Prepare db for logs
146-
k.CommitStateDB.Prepare(ethHash, common.Hash{}, k.TxCount)
147-
k.TxCount++
150+
if !st.Simulate {
151+
k.CommitStateDB.Prepare(ethHash, common.Hash{}, k.TxCount)
152+
k.TxCount++
153+
}
148154

149155
config, found := k.GetChainConfig(ctx)
150156
if !found {
@@ -157,12 +163,14 @@ func handleMsgEthermint(ctx sdk.Context, k Keeper, msg types.MsgEthermint) (*sdk
157163
}
158164

159165
// update block bloom filter
160-
k.Bloom.Or(k.Bloom, executionResult.Bloom)
166+
if !st.Simulate {
167+
k.Bloom.Or(k.Bloom, executionResult.Bloom)
161168

162-
// update transaction logs in KVStore
163-
err = k.SetLogs(ctx, common.BytesToHash(txHash), executionResult.Logs)
164-
if err != nil {
165-
panic(err)
169+
// update transaction logs in KVStore
170+
err = k.SetLogs(ctx, common.BytesToHash(txHash), executionResult.Logs)
171+
if err != nil {
172+
panic(err)
173+
}
166174
}
167175

168176
// log successful execution

0 commit comments

Comments
 (0)