Skip to content

Commit

Permalink
Merge branch 'feature/up_simulate' into feature/up_simulate_1
Browse files Browse the repository at this point in the history
  • Loading branch information
avery committed Dec 18, 2024
2 parents 6aa7620 + 0410b37 commit 9a49845
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 2 deletions.
4 changes: 4 additions & 0 deletions app/ante/ante.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
12 changes: 12 additions & 0 deletions app/ante/decorators.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
}
Expand Down
1 change: 1 addition & 0 deletions app/ante/handler_options.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ func NewIrisApp(
loadLatest bool,
encodingConfig params.EncodingConfig,
appOpts servertypes.AppOptions,
simulate bool,
baseAppOptions ...func(*baseapp.BaseApp),
) *IrisApp {
appCodec := encodingConfig.Marshaler
Expand Down Expand Up @@ -195,6 +196,7 @@ func NewIrisApp(
FeeMarketKeeper: app.FeeMarketKeeper,
BypassMinFeeMsgTypes: []string{},
MaxTxGasWanted: maxGasWanted,
Simulate: simulate,
},
)

Expand Down
2 changes: 2 additions & 0 deletions app/sim_bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ func BenchmarkFullAppSimulation(b *testing.B) {
true,
encfg,
EmptyAppOptions{},
true,
interBlockCacheOpt(),
)

Expand Down Expand Up @@ -119,6 +120,7 @@ func BenchmarkInvariants(b *testing.B) {
true,
encfg,
EmptyAppOptions{},
true,
interBlockCacheOpt(),
)

Expand Down
2 changes: 1 addition & 1 deletion app/sim_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -495,6 +494,7 @@ func createApp(
true,
encodingConfig,
EmptyAppOptions{},
true,
baseAppOptions...,
)
}
4 changes: 3 additions & 1 deletion cmd/iris/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{}.
Expand Down Expand Up @@ -263,6 +263,7 @@ func (ac appCreator) newApp(
true,
ac.encCfg,
appOpts,
false,
baseappOptions...,
)
}
Expand Down Expand Up @@ -295,6 +296,7 @@ func (ac appCreator) appExport(
loadLatest,
ac.encCfg,
appOpts,
false,
)

if height != -1 {
Expand Down
5 changes: 5 additions & 0 deletions sims.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions testutil/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ func setup(
true,
encCdc,
appOpts,
true,
baseAppOptions...,
)
return &AppWrapper{app}
Expand Down

0 comments on commit 9a49845

Please sign in to comment.