Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
mmsqe committed Dec 11, 2024
1 parent 1526ab9 commit 67986bd
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 40 deletions.
23 changes: 5 additions & 18 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,13 @@ import (
"github.com/cosmos/cosmos-sdk/server"
sigtypes "github.com/cosmos/cosmos-sdk/types/tx/signing"
"github.com/cosmos/gogoproto/proto"
blockstm "github.com/crypto-org-chain/go-block-stm"

"github.com/gorilla/mux"
"github.com/spf13/cast"

"cosmossdk.io/log"
abci "github.com/cometbft/cometbft/abci/types"
tmos "github.com/cometbft/cometbft/libs/os"
cmtproto "github.com/cometbft/cometbft/proto/tendermint/types"
dbm "github.com/cosmos/cosmos-db"

"github.com/cosmos/cosmos-sdk/baseapp"
Expand Down Expand Up @@ -820,22 +818,11 @@ func NewEthermintApp(
preEstimate := cast.ToBool(appOpts.Get(server.FlagBlockSTMPreEstimate))
txDecoder := txConfig.TxDecoder()
stores := app.GetStoreKeys()
app.SetTxExecutor(baseapp.STMTxExecutor(stores, workers, preEstimate, txDecoder,
func(txs [][]byte, workers int, txDecoder sdk.TxDecoder, ms storetypes.MultiStore) ([]sdk.Tx, []blockstm.MultiLocations) {
var authStore, bankStore int
index := make(map[storetypes.StoreKey]int, len(stores))
for i, k := range stores {
switch k.Name() {
case authtypes.StoreKey:
authStore = i
case banktypes.StoreKey:
bankStore = i
}
index[k] = i
}
evmDenom := app.EvmKeeper.GetParams(sdk.NewContext(ms, cmtproto.Header{}, false, log.NewNopLogger())).EvmDenom
return preEstimates(txs, workers, authStore, bankStore, evmDenom, txDecoder)
}))
var preEstimateFn PreEstimateFunc
if preEstimate {
preEstimateFn = GetPreEstimateFunc(stores, app.EvmKeeper)
}
app.SetTxExecutor(baseapp.STMTxExecutor(stores, workers, txDecoder, preEstimateFn))

Check warning on line 825 in app/app.go

View check run for this annotation

Codecov / codecov/patch

app/app.go#L817-L825

Added lines #L817 - L825 were not covered by tests
case "", config.BlockExecutorSequential:
app.SetTxExecutor(baseapp.DefaultTxExecutor)
default:
Expand Down
25 changes: 22 additions & 3 deletions app/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,36 @@ import (
"sync"

"cosmossdk.io/collections"
"cosmossdk.io/log"
storetypes "cosmossdk.io/store/types"
cmtproto "github.com/cometbft/cometbft/proto/tendermint/types"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
evmtypes "github.com/evmos/ethermint/x/evm/types"
evmkeeper "github.com/evmos/ethermint/x/evm/keeper"

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

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

type evmKeeper interface {
GetParams(ctx sdk.Context) evmtypes.Params
type PreEstimateFunc func(txs [][]byte, workers int, txDecoder sdk.TxDecoder, ms storetypes.MultiStore) ([]sdk.Tx, []blockstm.MultiLocations)

func GetPreEstimateFunc(stores []storetypes.StoreKey, evmKeeper *evmkeeper.Keeper) PreEstimateFunc {
return func(txs [][]byte, workers int, txDecoder sdk.TxDecoder, ms storetypes.MultiStore) ([]sdk.Tx, []blockstm.MultiLocations) {
var authStore, bankStore int
index := make(map[storetypes.StoreKey]int, len(stores))
for i, k := range stores {
switch k.Name() {
case authtypes.StoreKey:
authStore = i
case banktypes.StoreKey:
bankStore = i

Check warning on line 30 in app/executor.go

View check run for this annotation

Codecov / codecov/patch

app/executor.go#L21-L30

Added lines #L21 - L30 were not covered by tests
}
index[k] = i

Check warning on line 32 in app/executor.go

View check run for this annotation

Codecov / codecov/patch

app/executor.go#L32

Added line #L32 was not covered by tests
}
evmDenom := evmKeeper.GetParams(sdk.NewContext(ms, cmtproto.Header{}, false, log.NewNopLogger())).EvmDenom
return preEstimates(txs, workers, authStore, bankStore, evmDenom, txDecoder)

Check warning on line 35 in app/executor.go

View check run for this annotation

Codecov / codecov/patch

app/executor.go#L34-L35

Added lines #L34 - L35 were not covered by tests
}
}

// preEstimates returns a static estimation of the written keys for each transaction.
Expand Down
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -242,9 +242,9 @@ require (

replace (
// release/v0.50.x
cosmossdk.io/store => github.com/mmsqe/cosmos-sdk/store v0.0.0-20241211071648-a1364555c691
cosmossdk.io/x/tx => github.com/mmsqe/cosmos-sdk/x/tx v0.0.0-20241211071648-a1364555c691
github.com/cosmos/cosmos-sdk => github.com/mmsqe/cosmos-sdk v0.46.0-beta2.0.20241211071648-a1364555c691
cosmossdk.io/store => github.com/mmsqe/cosmos-sdk/store v0.0.0-20241211125423-756926949166
cosmossdk.io/x/tx => github.com/mmsqe/cosmos-sdk/x/tx v0.0.0-20241211125423-756926949166
github.com/cosmos/cosmos-sdk => github.com/mmsqe/cosmos-sdk v0.46.0-beta2.0.20241211125423-756926949166
)

replace (
Expand Down
12 changes: 6 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -867,12 +867,12 @@ github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyua
github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
github.com/mitchellh/pointerstructure v1.2.0 h1:O+i9nHnXS3l/9Wu7r4NrEdwA2VFTicjUEN1uBnDo34A=
github.com/mitchellh/pointerstructure v1.2.0/go.mod h1:BRAsLI5zgXmw97Lf6s25bs8ohIXc3tViBH44KcwB2g4=
github.com/mmsqe/cosmos-sdk v0.46.0-beta2.0.20241211071648-a1364555c691 h1:dsHxkRgPYkpvULAmatJuZestt/AR6g3B9MMnlgJfbG0=
github.com/mmsqe/cosmos-sdk v0.46.0-beta2.0.20241211071648-a1364555c691/go.mod h1:u+LHV+8Y4uVyVbAGNxWjLYuP3vYXVqTJCk0dx3uC0pM=
github.com/mmsqe/cosmos-sdk/store v0.0.0-20241211071648-a1364555c691 h1:b2RwVoB5zHr+GqrPGiVe3mVxFwEaOPwUIVIxb8DAL+w=
github.com/mmsqe/cosmos-sdk/store v0.0.0-20241211071648-a1364555c691/go.mod h1:8DwVTz83/2PSI366FERGbWSH7hL6sB7HbYp8bqksNwM=
github.com/mmsqe/cosmos-sdk/x/tx v0.0.0-20241211071648-a1364555c691 h1:iMghgVFWtj/BgTluwUcN9sHXxnbPsktiWVM5Wl8ImWk=
github.com/mmsqe/cosmos-sdk/x/tx v0.0.0-20241211071648-a1364555c691/go.mod h1:V6DImnwJMTq5qFjeGWpXNiT/fjgE4HtmclRmTqRVM3w=
github.com/mmsqe/cosmos-sdk v0.46.0-beta2.0.20241211125423-756926949166 h1:V4V18HyEijuRDU2yYs7d4ISg3PskaYzkxQLFJuD4KKQ=
github.com/mmsqe/cosmos-sdk v0.46.0-beta2.0.20241211125423-756926949166/go.mod h1:bkUh1YaLvBd4WAYd8iE0xwpHecaqH8A7vg6v/YCj0yo=
github.com/mmsqe/cosmos-sdk/store v0.0.0-20241211125423-756926949166 h1:33rsrNKVmEu859tr4sDBpAiafhyNWSblX5vpaQjoafE=
github.com/mmsqe/cosmos-sdk/store v0.0.0-20241211125423-756926949166/go.mod h1:8DwVTz83/2PSI366FERGbWSH7hL6sB7HbYp8bqksNwM=
github.com/mmsqe/cosmos-sdk/x/tx v0.0.0-20241211125423-756926949166 h1:fufnTgFbNYXISiTY1ZGE5S4IKEFd379DF8uKJgX4B4g=
github.com/mmsqe/cosmos-sdk/x/tx v0.0.0-20241211125423-756926949166/go.mod h1:V6DImnwJMTq5qFjeGWpXNiT/fjgE4HtmclRmTqRVM3w=
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
Expand Down
10 changes: 5 additions & 5 deletions gomod2nix.toml

Large diffs are not rendered by default.

6 changes: 1 addition & 5 deletions x/evm/types/response.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,8 @@ import (

type EvmTxResponsePatcher struct{}

// Patch fills the evm tx index and log indexes in the tx result
func (p EvmTxResponsePatcher) Patch(input []*abci.ExecTxResult) []*abci.ExecTxResult {

Check warning on line 15 in x/evm/types/response.go

View check run for this annotation

Codecov / codecov/patch

x/evm/types/response.go#L15

Added line #L15 was not covered by tests
return PatchTxResponses(input)
}

// PatchTxResponses fills the evm tx index and log indexes in the tx result
func PatchTxResponses(input []*abci.ExecTxResult) []*abci.ExecTxResult {
var (
txIndex uint64
logIndex uint64
Expand Down

0 comments on commit 67986bd

Please sign in to comment.