diff --git a/app/ante/ante.go b/app/ante/ante.go index 7b0884f86..53a26d42a 100644 --- a/app/ante/ante.go +++ b/app/ante/ante.go @@ -21,6 +21,10 @@ func NewAnteHandler(options HandlerOptions) sdk.AnteHandler { defer ethante.Recover(ctx.Logger(), &err) + if options.Simulate { + sim = true + } + txWithExtensions, ok := tx.(authante.HasExtensionOptionsTx) if ok { opts := txWithExtensions.GetExtensionOptions() diff --git a/app/ante/decorators.go b/app/ante/decorators.go index d288b3dee..29efe9c90 100644 --- a/app/ante/decorators.go +++ b/app/ante/decorators.go @@ -10,6 +10,7 @@ import ( ibctransfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types" coinswaptypes "mods.irisnet.org/modules/coinswap/types" + servicetypes "mods.irisnet.org/modules/service/types" tokenkeeper "mods.irisnet.org/modules/token/keeper" tokentypesv1 "mods.irisnet.org/modules/token/types/v1" tokentypesv1beta1 "mods.irisnet.org/modules/token/types/v1beta1" @@ -76,6 +77,17 @@ func (vsd ValidateServiceDecorator) AnteHandle( simulate bool, next sdk.AnteHandler, ) (sdk.Context, error) { + if simulate { + return next(ctx, tx, simulate) + } + for _, msg := range tx.GetMsgs() { + switch msg := msg.(type) { + case *servicetypes.MsgCallService: + if msg.Repeated { + return ctx, sdkerrors.Wrap(errortypes.ErrInvalidRequest, "currently does not support to create repeatable service invocation") + } + } + } return next(ctx, tx, simulate) } diff --git a/app/ante/handler_options.go b/app/ante/handler_options.go index 38f13e4ae..54f50e825 100644 --- a/app/ante/handler_options.go +++ b/app/ante/handler_options.go @@ -31,6 +31,7 @@ type HandlerOptions struct { FeeMarketKeeper ethante.FeeMarketKeeper BypassMinFeeMsgTypes []string MaxTxGasWanted uint64 + Simulate bool } // newCosmosAnteHandler creates the default ante handler for Ethereum transactions diff --git a/app/app.go b/app/app.go index acdf3686b..7f80fb6b4 100644 --- a/app/app.go +++ b/app/app.go @@ -78,6 +78,7 @@ func NewIrisApp( loadLatest bool, encodingConfig params.EncodingConfig, appOpts servertypes.AppOptions, + simulate bool, baseAppOptions ...func(*baseapp.BaseApp), ) *IrisApp { appCodec := encodingConfig.Marshaler @@ -195,6 +196,7 @@ func NewIrisApp( FeeMarketKeeper: app.FeeMarketKeeper, BypassMinFeeMsgTypes: []string{}, MaxTxGasWanted: maxGasWanted, + Simulate: simulate, }, ) diff --git a/app/sim_bench_test.go b/app/sim_bench_test.go index 0e3524145..0f3555d5f 100644 --- a/app/sim_bench_test.go +++ b/app/sim_bench_test.go @@ -52,6 +52,7 @@ func BenchmarkFullAppSimulation(b *testing.B) { true, encfg, EmptyAppOptions{}, + true, interBlockCacheOpt(), ) @@ -119,6 +120,7 @@ func BenchmarkInvariants(b *testing.B) { true, encfg, EmptyAppOptions{}, + true, interBlockCacheOpt(), ) diff --git a/app/sim_test.go b/app/sim_test.go index 9ec16fda7..ab1eda5b7 100644 --- a/app/sim_test.go +++ b/app/sim_test.go @@ -297,7 +297,6 @@ func TestAppSimulationAfterImport(t *testing.T) { config := simcli.NewConfigFromFlags() config.ChainID = AppChainID encfg := RegisterEncodingConfig() - db, dir, logger, skip, err := simtestutil.SetupSimulation( config, "goleveldb-app-sim", @@ -495,6 +494,7 @@ func createApp( true, encodingConfig, EmptyAppOptions{}, + true, baseAppOptions..., ) } diff --git a/cmd/iris/cmd/root.go b/cmd/iris/cmd/root.go index 867730312..a867053e4 100644 --- a/cmd/iris/cmd/root.go +++ b/cmd/iris/cmd/root.go @@ -43,7 +43,7 @@ import ( // main function. func NewRootCmd() (*cobra.Command, params.EncodingConfig) { - tempApplication := app.NewIrisApp(log.NewNopLogger(), dbm.NewMemDB(), nil, true, app.RegisterEncodingConfig(), testutil.EmptyAppOptions{}) + tempApplication := app.NewIrisApp(log.NewNopLogger(), dbm.NewMemDB(), nil, true, app.RegisterEncodingConfig(), testutil.EmptyAppOptions{}, false) encodingConfig := app.RegisterEncodingConfig() initClientCtx := client.Context{}. @@ -263,6 +263,7 @@ func (ac appCreator) newApp( true, ac.encCfg, appOpts, + false, baseappOptions..., ) } @@ -295,6 +296,7 @@ func (ac appCreator) appExport( loadLatest, ac.encCfg, appOpts, + false, ) if height != -1 { diff --git a/sims.mk b/sims.mk index f0c112203..fc9f544ef 100644 --- a/sims.mk +++ b/sims.mk @@ -25,6 +25,11 @@ test-sim-after-import: runsim @echo "Running Iris simulation-after-import. This may take several minutes..." @$(BINDIR)/runsim -Jobs=4 -SimAppPkg=$(SIMAPP) 25 5 TestIrisSimulationAfterImport +test-sim-custom-genesis-multi-seed: runsim + @echo "Running multi-seed custom genesis simulation..." + @echo "By default, ${HOME}/.iris/config/genesis.json will be used." + @$(BINDIR)/runsim -Jobs=4 -Genesis=${HOME}/.iris/config/genesis.json 400 5 TestFullIrisSimulation + test-sim-multi-seed-long: runsim @echo "Running multi-seed application simulation. This may take awhile!" @$(BINDIR)/runsim -Jobs=4 -SimAppPkg=$(SIMAPP) 500 50 TestFullAppSimulation diff --git a/testutil/app.go b/testutil/app.go index b392347da..75b23b86b 100644 --- a/testutil/app.go +++ b/testutil/app.go @@ -42,6 +42,7 @@ func setup( true, encCdc, appOpts, + true, baseAppOptions..., ) return &AppWrapper{app}