Skip to content

Commit

Permalink
tmp_save
Browse files Browse the repository at this point in the history
  • Loading branch information
avery committed Dec 19, 2024
2 parents 9a49845 + 684f347 commit ef12bd8
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 6 deletions.
17 changes: 14 additions & 3 deletions app/ante/decorators.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,15 @@ func (vtd ValidateTokenDecorator) AnteHandle(
}

// ValidateServiceDecorator is responsible for checking the permission to execute MsgCallService
type ValidateServiceDecorator struct{}
type ValidateServiceDecorator struct {
SimulateTest bool
}

// NewValidateServiceDecorator returns an instance of ServiceAuthDecorator
func NewValidateServiceDecorator() ValidateServiceDecorator {
return ValidateServiceDecorator{}
func NewValidateServiceDecorator(simulateTest bool) ValidateServiceDecorator {
return ValidateServiceDecorator{
SimulateTest: simulateTest,
}
}

// AnteHandle checks the transaction
Expand All @@ -77,9 +81,16 @@ func (vsd ValidateServiceDecorator) AnteHandle(
simulate bool,
next sdk.AnteHandler,
) (sdk.Context, error) {
<<<<<<< HEAD
if simulate {
return next(ctx, tx, simulate)
}
=======
if vsd.SimulateTest {
return next(ctx, tx, simulate)
}

>>>>>>> 684f3471c7649a941b8984dde1bebe293375e67a
for _, msg := range tx.GetMsgs() {
switch msg := msg.(type) {
case *servicetypes.MsgCallService:
Expand Down
6 changes: 5 additions & 1 deletion app/ante/handler_options.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@ type HandlerOptions struct {
FeeMarketKeeper ethante.FeeMarketKeeper
BypassMinFeeMsgTypes []string
MaxTxGasWanted uint64
<<<<<<< HEAD
Simulate bool
=======
SimulationTest bool
>>>>>>> 684f3471c7649a941b8984dde1bebe293375e67a
}

// newCosmosAnteHandler creates the default ante handler for Ethereum transactions
Expand Down Expand Up @@ -86,7 +90,7 @@ func newCosmosAnteHandler(options HandlerOptions) sdk.AnteHandler {
NewValidateTokenDecorator(options.TokenKeeper),
tokenkeeper.NewValidateTokenFeeDecorator(options.TokenKeeper, options.BankKeeper),
oraclekeeper.NewValidateOracleAuthDecorator(options.OracleKeeper, options.GuardianKeeper),
NewValidateServiceDecorator(),
NewValidateServiceDecorator(options.SimulationTest),
ante.NewIncrementSequenceDecorator(options.AccountKeeper),
ibcante.NewRedundantRelayDecorator(options.IBCKeeper),
)
Expand Down
11 changes: 11 additions & 0 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,13 @@ func NewIrisApp(
app.MountMemoryStores(app.MemoryStoreKeys())

maxGasWanted := cast.ToUint64(appOpts.Get(srvflags.EVMMaxTxGasWanted))

simulationTest := false
opt = appOpts.Get(params.SimulationTest)
if opt, ok := opt.(bool); ok {
simulationTest = opt
}

anteHandler := irishubante.NewAnteHandler(
irishubante.HandlerOptions{
HandlerOptions: ante.HandlerOptions{
Expand All @@ -196,7 +203,11 @@ func NewIrisApp(
FeeMarketKeeper: app.FeeMarketKeeper,
BypassMinFeeMsgTypes: []string{},
MaxTxGasWanted: maxGasWanted,
<<<<<<< HEAD
Simulate: simulate,
=======
SimulationTest: simulationTest,
>>>>>>> 684f3471c7649a941b8984dde1bebe293375e67a
},
)

Expand Down
1 change: 1 addition & 0 deletions app/params/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ package params
const (
StakePerAccount = "stake_per_account"
InitiallyBondedValidators = "initially_bonded_validators"
SimulationTest = "simulation_test"
)
14 changes: 14 additions & 0 deletions app/sim_bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import (
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
"github.com/cosmos/cosmos-sdk/x/simulation"
simcli "github.com/cosmos/cosmos-sdk/x/simulation/client/cli"

"github.com/irisnet/irishub/v4/app/params"
)

// Profile with:
Expand Down Expand Up @@ -51,8 +53,14 @@ func BenchmarkFullAppSimulation(b *testing.B) {
nil,
true,
encfg,
<<<<<<< HEAD
EmptyAppOptions{},
true,
=======
SimTestAppOptions{
options: map[string]interface{}{params.SimulationTest: true},
},
>>>>>>> 684f3471c7649a941b8984dde1bebe293375e67a
interBlockCacheOpt(),
)

Expand Down Expand Up @@ -119,8 +127,14 @@ func BenchmarkInvariants(b *testing.B) {
nil,
true,
encfg,
<<<<<<< HEAD
EmptyAppOptions{},
true,
=======
SimTestAppOptions{
options: map[string]interface{}{params.SimulationTest: true},
},
>>>>>>> 684f3471c7649a941b8984dde1bebe293375e67a
interBlockCacheOpt(),
)

Expand Down
15 changes: 13 additions & 2 deletions app/sim_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,16 @@ func (ao EmptyAppOptions) Get(o string) interface{} {
return nil
}

// SimTestAppOptions is a stub implementing AppOptions
type SimTestAppOptions struct {
options map[string]interface{}
}

// Get implements AppOptions
func (o SimTestAppOptions) Get(key string) interface{} {
return o.options[key]
}

func createApp(
logger log.Logger,
db dbm.DB,
Expand All @@ -493,8 +503,9 @@ func createApp(
nil,
true,
encodingConfig,
EmptyAppOptions{},
true,
SimTestAppOptions{
options: map[string]interface{}{params.SimulationTest: true},
},
baseAppOptions...,
)
}

0 comments on commit ef12bd8

Please sign in to comment.