Skip to content

Commit 67a2214

Browse files
authored
Remove the unused Cosmos SDK simulation framework (#4429)
sei-chain still carries the Cosmos SDK simulation framework: `App.sm` built a `module.SimulationManager` over twelve modules, every module implemented `AppModuleSimulation`, and `sei-cosmos/x/simulation`, `sei-cosmos/types/simulation` and the per-module `simulation` packages (randomized genesis, weighted operations, store decoders, proposal contents) came along with it. Nothing runs it anymore. There is no simapp, no CI job or root Makefile target invokes a simulation, and the `test-sim-*` targets in `sei-cosmos/Makefile` point at a `./simapp` package that no longer exists. It is about 6.4k lines of dead code that every module change has to keep compiling. This deletes the framework and the hooks that only existed to feed it: `AppModuleSimulation`, `SimulationManager`, `sdk.StoreDecoderRegistry`, `authtypes.RandomGenesisAccountsFn`, the `app/params` and `sei-wasmd/app/params` operation weights, the dead `test-sim-*` targets and `/simulation` package filters in the `sei-cosmos` and `sei-wasmd` Makefiles, and the now-uncalled `stakingkeeper.RandomValidator` test helper. `auth.NewAppModule` drops its `randGenAccountsFn` argument and `wasm.NewAppModule` drops the account and bank keepers it held only for simulation. `app/test_helpers.go` no longer sets a random memo on generated test txs. Wasm's `LimitSimulationGasDecorator` and the `wasm.simulation_gas_limit` flag are tx-simulation gas behaviour, not part of this framework, and are left alone. No state, store keys, genesis, messages or begin/end-block logic change, so this is not app-hash breaking. Validated with `go vet ./...`, `make fmtcheck`, golangci-lint on the touched trees, and `go test` across app, the affected sei-cosmos modules, wasm, mint, epoch and tokenfactory.
1 parent 2198ea7 commit 67a2214

84 files changed

Lines changed: 31 additions & 6459 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎app/app.go‎

Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ import (
5252
"github.com/sei-protocol/sei-chain/sei-cosmos/x/auth/ante"
5353
authrest "github.com/sei-protocol/sei-chain/sei-cosmos/x/auth/client/rest"
5454
authkeeper "github.com/sei-protocol/sei-chain/sei-cosmos/x/auth/keeper"
55-
authsims "github.com/sei-protocol/sei-chain/sei-cosmos/x/auth/simulation"
5655
authtx "github.com/sei-protocol/sei-chain/sei-cosmos/x/auth/tx"
5756
authtypes "github.com/sei-protocol/sei-chain/sei-cosmos/x/auth/types"
5857
"github.com/sei-protocol/sei-chain/sei-cosmos/x/authz"
@@ -392,9 +391,6 @@ type App struct {
392391
// mm is the module manager
393392
mm *module.Manager
394393

395-
// sm is the simulation manager
396-
sm *module.SimulationManager
397-
398394
configurator module.Configurator
399395

400396
optimisticProcessingInfo OptimisticProcessingInfo
@@ -804,7 +800,7 @@ func New(
804800
app.AccountKeeper, app.StakingKeeper, app.BaseApp.DeliverTx,
805801
encodingConfig.TxConfig,
806802
),
807-
auth.NewAppModule(appCodec, app.AccountKeeper, nil),
803+
auth.NewAppModule(appCodec, app.AccountKeeper),
808804
bank.NewAppModule(appCodec, app.BankKeeper, app.AccountKeeper),
809805
gov.NewAppModule(appCodec, app.GovKeeper, app.AccountKeeper, app.BankKeeper),
810806
mint.NewAppModule(appCodec, app.MintKeeper, app.AccountKeeper),
@@ -814,7 +810,7 @@ func New(
814810
upgrade.NewAppModule(app.UpgradeKeeper),
815811
evidence.NewAppModule(app.EvidenceKeeper),
816812
params.NewAppModule(app.ParamsKeeper),
817-
wasm.NewAppModule(appCodec, &app.WasmKeeper, app.StakingKeeper, app.AccountKeeper, app.BankKeeper),
813+
wasm.NewAppModule(appCodec, &app.WasmKeeper, app.StakingKeeper),
818814
evm.NewAppModule(appCodec, &app.EvmKeeper),
819815
epochModule,
820816
tokenfactorymodule.NewAppModule(app.TokenFactoryKeeper, app.AccountKeeper, app.BankKeeper),
@@ -878,24 +874,6 @@ func New(
878874
app.configurator = module.NewConfigurator(app.appCodec, app.MsgServiceRouter(), app.GRPCQueryRouter())
879875
app.mm.RegisterServices(app.configurator)
880876

881-
// create the simulation manager and define the order of the modules for deterministic simulations
882-
app.sm = module.NewSimulationManager(
883-
auth.NewAppModule(appCodec, app.AccountKeeper, authsims.RandomGenesisAccounts),
884-
bank.NewAppModule(appCodec, app.BankKeeper, app.AccountKeeper),
885-
gov.NewAppModule(appCodec, app.GovKeeper, app.AccountKeeper, app.BankKeeper),
886-
mint.NewAppModule(appCodec, app.MintKeeper, app.AccountKeeper),
887-
staking.NewAppModule(appCodec, app.StakingKeeper, app.AccountKeeper, app.BankKeeper),
888-
distr.NewAppModule(appCodec, app.DistrKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper),
889-
slashing.NewAppModule(appCodec, app.SlashingKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper),
890-
params.NewAppModule(app.ParamsKeeper),
891-
evidence.NewAppModule(app.EvidenceKeeper),
892-
wasm.NewAppModule(appCodec, &app.WasmKeeper, app.StakingKeeper, app.AccountKeeper, app.BankKeeper),
893-
epochModule,
894-
tokenfactorymodule.NewAppModule(app.TokenFactoryKeeper, app.AccountKeeper, app.BankKeeper),
895-
// this line is used by starport scaffolding # stargate/app/appModule
896-
)
897-
app.sm.RegisterStoreDecoders()
898-
899877
app.RegisterUpgradeHandlers()
900878
app.SetStoreUpgradeHandlers()
901879

@@ -2736,11 +2714,6 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino
27362714
return paramsKeeper
27372715
}
27382716

2739-
// SimulationManager implements the SimulationApp interface
2740-
func (app *App) SimulationManager() *module.SimulationManager {
2741-
return app.sm
2742-
}
2743-
27442717
func (app *App) BlacklistedAccAddrs() map[string]bool {
27452718
blacklistedAddrs := make(map[string]bool)
27462719
for acc := range maccPerms {

‎app/params/doc.go‎

Lines changed: 0 additions & 19 deletions
This file was deleted.

‎app/params/params.go‎

Lines changed: 0 additions & 7 deletions
This file was deleted.

‎app/params/weights.go‎

Lines changed: 0 additions & 24 deletions
This file was deleted.

‎app/test_helpers.go‎

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66
"encoding/hex"
77
"encoding/json"
88
"fmt"
9-
"math/rand"
109
"os"
1110
"path/filepath"
1211
"strconv"
@@ -38,7 +37,6 @@ import (
3837
cryptotypes "github.com/sei-protocol/sei-chain/sei-cosmos/crypto/types"
3938
sdk "github.com/sei-protocol/sei-chain/sei-cosmos/types"
4039
"github.com/sei-protocol/sei-chain/sei-cosmos/types/errors"
41-
"github.com/sei-protocol/sei-chain/sei-cosmos/types/simulation"
4240
"github.com/sei-protocol/sei-chain/sei-cosmos/types/tx/signing"
4341
authsign "github.com/sei-protocol/sei-chain/sei-cosmos/x/auth/signing"
4442
authtypes "github.com/sei-protocol/sei-chain/sei-cosmos/x/auth/types"
@@ -897,11 +895,6 @@ func TestAddr(addr string, bech string) (sdk.AccAddress, error) {
897895
func GenTx(gen client.TxConfig, msgs []sdk.Msg, feeAmt sdk.Coins, gas uint64, chainID string, accNums, accSeqs []uint64, priv ...cryptotypes.PrivKey) (sdk.Tx, error) {
898896
sigs := make([]signing.SignatureV2, len(priv))
899897

900-
// create a random length memo
901-
r := rand.New(rand.NewSource(time.Now().UnixNano()))
902-
903-
memo := simulation.RandStringOfLength(r, simulation.RandIntBetween(r, 0, 100))
904-
905898
signMode := gen.SignModeHandler().DefaultMode()
906899

907900
// 1st round: set SignatureV2 with empty signatures, to set correct
@@ -925,7 +918,6 @@ func GenTx(gen client.TxConfig, msgs []sdk.Msg, feeAmt sdk.Coins, gas uint64, ch
925918
if err != nil {
926919
return nil, err
927920
}
928-
tx.SetMemo(memo)
929921
tx.SetFeeAmount(feeAmt)
930922
tx.SetGasLimit(gas)
931923

‎sei-cosmos/Makefile‎

Lines changed: 1 addition & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
#!/usr/bin/make -f
22

3-
PACKAGES_NOSIMULATION=$(shell go list ./... | grep -v '/simulation')
4-
PACKAGES_SIMTEST=$(shell go list ./... | grep '/simulation')
53
VERSION := $(shell echo $(shell git describe --always --match "v*") | sed 's/^v//')
64
TMVERSION := $(shell go list -m github.com/tendermint/tendermint | sed 's:.* ::')
75
COMMIT := $(shell git log -1 --format='%H')
86
LEDGER_ENABLED ?= true
97
BINDIR ?= $(GOPATH)/bin
108
BUILDDIR ?= $(CURDIR)/build
11-
SIMAPP = ./simapp
129
MOCKS_DIR = $(CURDIR)/tests/mocks
1310
HTTPS_GIT := https://github.com/cosmos/cosmos-sdk.git
1411
DOCKER := $(shell which docker)
@@ -207,7 +204,6 @@ test-unit-amino: ARGS=-tags='ledger test_ledger_mock test_amino norace'
207204
test-ledger: ARGS=-tags='cgo ledger norace'
208205
test-ledger-mock: ARGS=-tags='ledger test_ledger_mock norace'
209206
test-race: ARGS=-race -tags='cgo ledger test_ledger_mock'
210-
test-race: TEST_PACKAGES=$(PACKAGES_NOSIMULATION)
211207
$(TEST_TARGETS): run-tests
212208

213209
# check-* compiles and collects tests without running them
@@ -227,70 +223,6 @@ endif
227223

228224
.PHONY: run-tests test test-all $(TEST_TARGETS)
229225

230-
test-sim-nondeterminism:
231-
@echo "Running non-determinism test..."
232-
@go test -mod=readonly $(SIMAPP) -run TestAppStateDeterminism -Enabled=true \
233-
-NumBlocks=100 -BlockSize=200 -Commit=true -Period=0 -v -timeout 24h
234-
235-
test-sim-custom-genesis-fast:
236-
@echo "Running custom genesis simulation..."
237-
@echo "By default, ${HOME}/.gaiad/config/genesis.json will be used."
238-
@go test -mod=readonly $(SIMAPP) -run TestFullAppSimulation -Genesis=${HOME}/.gaiad/config/genesis.json \
239-
-Enabled=true -NumBlocks=100 -BlockSize=200 -Commit=true -Seed=99 -Period=5 -v -timeout 24h
240-
241-
test-sim-import-export: runsim
242-
@echo "Running application import/export simulation. This may take several minutes..."
243-
@$(BINDIR)/runsim -Jobs=4 -SimAppPkg=$(SIMAPP) -ExitOnFail 50 5 TestAppImportExport
244-
245-
test-sim-after-import: runsim
246-
@echo "Running application simulation-after-import. This may take several minutes..."
247-
@$(BINDIR)/runsim -Jobs=4 -SimAppPkg=$(SIMAPP) -ExitOnFail 50 5 TestAppSimulationAfterImport
248-
249-
test-sim-custom-genesis-multi-seed: runsim
250-
@echo "Running multi-seed custom genesis simulation..."
251-
@echo "By default, ${HOME}/.gaiad/config/genesis.json will be used."
252-
@$(BINDIR)/runsim -Genesis=${HOME}/.gaiad/config/genesis.json -SimAppPkg=$(SIMAPP) -ExitOnFail 400 5 TestFullAppSimulation
253-
254-
test-sim-multi-seed-long: runsim
255-
@echo "Running long multi-seed application simulation. This may take awhile!"
256-
@$(BINDIR)/runsim -Jobs=4 -SimAppPkg=$(SIMAPP) -ExitOnFail 500 50 TestFullAppSimulation
257-
258-
test-sim-multi-seed-short: runsim
259-
@echo "Running short multi-seed application simulation. This may take awhile!"
260-
@$(BINDIR)/runsim -Jobs=4 -SimAppPkg=$(SIMAPP) -ExitOnFail 50 10 TestFullAppSimulation
261-
262-
test-sim-benchmark-invariants:
263-
@echo "Running simulation invariant benchmarks..."
264-
@go test -mod=readonly $(SIMAPP) -benchmem -bench=BenchmarkInvariants -run=^$ \
265-
-Enabled=true -NumBlocks=1000 -BlockSize=200 \
266-
-Period=1 -Commit=true -Seed=57 -v -timeout 24h
267-
268-
.PHONY: \
269-
test-sim-nondeterminism \
270-
test-sim-custom-genesis-fast \
271-
test-sim-import-export \
272-
test-sim-after-import \
273-
test-sim-custom-genesis-multi-seed \
274-
test-sim-multi-seed-short \
275-
test-sim-multi-seed-long \
276-
test-sim-benchmark-invariants
277-
278-
SIM_NUM_BLOCKS ?= 500
279-
SIM_BLOCK_SIZE ?= 200
280-
SIM_COMMIT ?= true
281-
282-
test-sim-benchmark:
283-
@echo "Running application benchmark for numBlocks=$(SIM_NUM_BLOCKS), blockSize=$(SIM_BLOCK_SIZE). This may take awhile!"
284-
@go test -mod=readonly -benchmem -run=^$$ $(SIMAPP) -bench ^BenchmarkFullAppSimulation$$ \
285-
-Enabled=true -NumBlocks=$(SIM_NUM_BLOCKS) -BlockSize=$(SIM_BLOCK_SIZE) -Commit=$(SIM_COMMIT) -timeout 24h
286-
287-
test-sim-profile:
288-
@echo "Running application benchmark for numBlocks=$(SIM_NUM_BLOCKS), blockSize=$(SIM_BLOCK_SIZE). This may take awhile!"
289-
@go test -mod=readonly -benchmem -run=^$$ $(SIMAPP) -bench ^BenchmarkFullAppSimulation$$ \
290-
-Enabled=true -NumBlocks=$(SIM_NUM_BLOCKS) -BlockSize=$(SIM_BLOCK_SIZE) -Commit=$(SIM_COMMIT) -timeout 24h -cpuprofile cpu.out -memprofile mem.out
291-
292-
.PHONY: test-sim-profile test-sim-benchmark
293-
294226
test-cover:
295227
@export VERSION=$(VERSION); bash -x contrib/test_cover.sh
296228
.PHONY: test-cover
@@ -301,7 +233,7 @@ test-rosetta:
301233
.PHONY: test-rosetta
302234

303235
benchmark:
304-
@go test -mod=readonly -bench=. $(PACKAGES_NOSIMULATION)
236+
@go test -mod=readonly -bench=. ./...
305237
.PHONY: benchmark
306238

307239
###############################################################################

‎sei-cosmos/types/module/module.go‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ Package module contains application module patterns and associated "manager" fun
33
The module pattern has been broken down by:
44
- independent module functionality (AppModuleBasic)
55
- inter-dependent module genesis functionality (AppModuleGenesis)
6-
- inter-dependent module simulation functionality (AppModuleSimulation)
76
- inter-dependent module full functionality (AppModule)
87
98
inter-dependent module functionality is module functionality which somehow

0 commit comments

Comments
 (0)