Skip to content

Commit 67986bd

Browse files
committed
cleanup
1 parent 1526ab9 commit 67986bd

File tree

6 files changed

+42
-40
lines changed

6 files changed

+42
-40
lines changed

app/app.go

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,13 @@ import (
3434
"github.com/cosmos/cosmos-sdk/server"
3535
sigtypes "github.com/cosmos/cosmos-sdk/types/tx/signing"
3636
"github.com/cosmos/gogoproto/proto"
37-
blockstm "github.com/crypto-org-chain/go-block-stm"
3837

3938
"github.com/gorilla/mux"
4039
"github.com/spf13/cast"
4140

4241
"cosmossdk.io/log"
4342
abci "github.com/cometbft/cometbft/abci/types"
4443
tmos "github.com/cometbft/cometbft/libs/os"
45-
cmtproto "github.com/cometbft/cometbft/proto/tendermint/types"
4644
dbm "github.com/cosmos/cosmos-db"
4745

4846
"github.com/cosmos/cosmos-sdk/baseapp"
@@ -820,22 +818,11 @@ func NewEthermintApp(
820818
preEstimate := cast.ToBool(appOpts.Get(server.FlagBlockSTMPreEstimate))
821819
txDecoder := txConfig.TxDecoder()
822820
stores := app.GetStoreKeys()
823-
app.SetTxExecutor(baseapp.STMTxExecutor(stores, workers, preEstimate, txDecoder,
824-
func(txs [][]byte, workers int, txDecoder sdk.TxDecoder, ms storetypes.MultiStore) ([]sdk.Tx, []blockstm.MultiLocations) {
825-
var authStore, bankStore int
826-
index := make(map[storetypes.StoreKey]int, len(stores))
827-
for i, k := range stores {
828-
switch k.Name() {
829-
case authtypes.StoreKey:
830-
authStore = i
831-
case banktypes.StoreKey:
832-
bankStore = i
833-
}
834-
index[k] = i
835-
}
836-
evmDenom := app.EvmKeeper.GetParams(sdk.NewContext(ms, cmtproto.Header{}, false, log.NewNopLogger())).EvmDenom
837-
return preEstimates(txs, workers, authStore, bankStore, evmDenom, txDecoder)
838-
}))
821+
var preEstimateFn PreEstimateFunc
822+
if preEstimate {
823+
preEstimateFn = GetPreEstimateFunc(stores, app.EvmKeeper)
824+
}
825+
app.SetTxExecutor(baseapp.STMTxExecutor(stores, workers, txDecoder, preEstimateFn))
839826
case "", config.BlockExecutorSequential:
840827
app.SetTxExecutor(baseapp.DefaultTxExecutor)
841828
default:

app/executor.go

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,36 @@ import (
44
"sync"
55

66
"cosmossdk.io/collections"
7+
"cosmossdk.io/log"
8+
storetypes "cosmossdk.io/store/types"
9+
cmtproto "github.com/cometbft/cometbft/proto/tendermint/types"
710
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
811
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
9-
evmtypes "github.com/evmos/ethermint/x/evm/types"
12+
evmkeeper "github.com/evmos/ethermint/x/evm/keeper"
1013

1114
sdk "github.com/cosmos/cosmos-sdk/types"
1215

1316
blockstm "github.com/crypto-org-chain/go-block-stm"
1417
)
1518

16-
type evmKeeper interface {
17-
GetParams(ctx sdk.Context) evmtypes.Params
19+
type PreEstimateFunc func(txs [][]byte, workers int, txDecoder sdk.TxDecoder, ms storetypes.MultiStore) ([]sdk.Tx, []blockstm.MultiLocations)
20+
21+
func GetPreEstimateFunc(stores []storetypes.StoreKey, evmKeeper *evmkeeper.Keeper) PreEstimateFunc {
22+
return func(txs [][]byte, workers int, txDecoder sdk.TxDecoder, ms storetypes.MultiStore) ([]sdk.Tx, []blockstm.MultiLocations) {
23+
var authStore, bankStore int
24+
index := make(map[storetypes.StoreKey]int, len(stores))
25+
for i, k := range stores {
26+
switch k.Name() {
27+
case authtypes.StoreKey:
28+
authStore = i
29+
case banktypes.StoreKey:
30+
bankStore = i
31+
}
32+
index[k] = i
33+
}
34+
evmDenom := evmKeeper.GetParams(sdk.NewContext(ms, cmtproto.Header{}, false, log.NewNopLogger())).EvmDenom
35+
return preEstimates(txs, workers, authStore, bankStore, evmDenom, txDecoder)
36+
}
1837
}
1938

2039
// preEstimates returns a static estimation of the written keys for each transaction.

go.mod

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -242,9 +242,9 @@ require (
242242

243243
replace (
244244
// release/v0.50.x
245-
cosmossdk.io/store => github.com/mmsqe/cosmos-sdk/store v0.0.0-20241211071648-a1364555c691
246-
cosmossdk.io/x/tx => github.com/mmsqe/cosmos-sdk/x/tx v0.0.0-20241211071648-a1364555c691
247-
github.com/cosmos/cosmos-sdk => github.com/mmsqe/cosmos-sdk v0.46.0-beta2.0.20241211071648-a1364555c691
245+
cosmossdk.io/store => github.com/mmsqe/cosmos-sdk/store v0.0.0-20241211125423-756926949166
246+
cosmossdk.io/x/tx => github.com/mmsqe/cosmos-sdk/x/tx v0.0.0-20241211125423-756926949166
247+
github.com/cosmos/cosmos-sdk => github.com/mmsqe/cosmos-sdk v0.46.0-beta2.0.20241211125423-756926949166
248248
)
249249

250250
replace (

go.sum

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -867,12 +867,12 @@ github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyua
867867
github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
868868
github.com/mitchellh/pointerstructure v1.2.0 h1:O+i9nHnXS3l/9Wu7r4NrEdwA2VFTicjUEN1uBnDo34A=
869869
github.com/mitchellh/pointerstructure v1.2.0/go.mod h1:BRAsLI5zgXmw97Lf6s25bs8ohIXc3tViBH44KcwB2g4=
870-
github.com/mmsqe/cosmos-sdk v0.46.0-beta2.0.20241211071648-a1364555c691 h1:dsHxkRgPYkpvULAmatJuZestt/AR6g3B9MMnlgJfbG0=
871-
github.com/mmsqe/cosmos-sdk v0.46.0-beta2.0.20241211071648-a1364555c691/go.mod h1:u+LHV+8Y4uVyVbAGNxWjLYuP3vYXVqTJCk0dx3uC0pM=
872-
github.com/mmsqe/cosmos-sdk/store v0.0.0-20241211071648-a1364555c691 h1:b2RwVoB5zHr+GqrPGiVe3mVxFwEaOPwUIVIxb8DAL+w=
873-
github.com/mmsqe/cosmos-sdk/store v0.0.0-20241211071648-a1364555c691/go.mod h1:8DwVTz83/2PSI366FERGbWSH7hL6sB7HbYp8bqksNwM=
874-
github.com/mmsqe/cosmos-sdk/x/tx v0.0.0-20241211071648-a1364555c691 h1:iMghgVFWtj/BgTluwUcN9sHXxnbPsktiWVM5Wl8ImWk=
875-
github.com/mmsqe/cosmos-sdk/x/tx v0.0.0-20241211071648-a1364555c691/go.mod h1:V6DImnwJMTq5qFjeGWpXNiT/fjgE4HtmclRmTqRVM3w=
870+
github.com/mmsqe/cosmos-sdk v0.46.0-beta2.0.20241211125423-756926949166 h1:V4V18HyEijuRDU2yYs7d4ISg3PskaYzkxQLFJuD4KKQ=
871+
github.com/mmsqe/cosmos-sdk v0.46.0-beta2.0.20241211125423-756926949166/go.mod h1:bkUh1YaLvBd4WAYd8iE0xwpHecaqH8A7vg6v/YCj0yo=
872+
github.com/mmsqe/cosmos-sdk/store v0.0.0-20241211125423-756926949166 h1:33rsrNKVmEu859tr4sDBpAiafhyNWSblX5vpaQjoafE=
873+
github.com/mmsqe/cosmos-sdk/store v0.0.0-20241211125423-756926949166/go.mod h1:8DwVTz83/2PSI366FERGbWSH7hL6sB7HbYp8bqksNwM=
874+
github.com/mmsqe/cosmos-sdk/x/tx v0.0.0-20241211125423-756926949166 h1:fufnTgFbNYXISiTY1ZGE5S4IKEFd379DF8uKJgX4B4g=
875+
github.com/mmsqe/cosmos-sdk/x/tx v0.0.0-20241211125423-756926949166/go.mod h1:V6DImnwJMTq5qFjeGWpXNiT/fjgE4HtmclRmTqRVM3w=
876876
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
877877
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
878878
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=

gomod2nix.toml

Lines changed: 5 additions & 5 deletions
Large diffs are not rendered by default.

x/evm/types/response.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,8 @@ import (
1111

1212
type EvmTxResponsePatcher struct{}
1313

14+
// Patch fills the evm tx index and log indexes in the tx result
1415
func (p EvmTxResponsePatcher) Patch(input []*abci.ExecTxResult) []*abci.ExecTxResult {
15-
return PatchTxResponses(input)
16-
}
17-
18-
// PatchTxResponses fills the evm tx index and log indexes in the tx result
19-
func PatchTxResponses(input []*abci.ExecTxResult) []*abci.ExecTxResult {
2016
var (
2117
txIndex uint64
2218
logIndex uint64

0 commit comments

Comments
 (0)