github.com/cosmos/cosmos-sdk@v0.50.10/x/simulation/client/cli/flags.go (about)

     1  package cli
     2  
     3  import (
     4  	"flag"
     5  
     6  	"github.com/cosmos/cosmos-sdk/types/simulation"
     7  )
     8  
     9  const DefaultSeedValue = 42
    10  
    11  // List of available flags for the simulator
    12  var (
    13  	FlagGenesisFileValue        string
    14  	FlagParamsFileValue         string
    15  	FlagExportParamsPathValue   string
    16  	FlagExportParamsHeightValue int
    17  	FlagExportStatePathValue    string
    18  	FlagExportStatsPathValue    string
    19  	FlagSeedValue               int64
    20  	FlagInitialBlockHeightValue int
    21  	FlagNumBlocksValue          int
    22  	FlagBlockSizeValue          int
    23  	FlagLeanValue               bool
    24  	FlagCommitValue             bool
    25  	FlagOnOperationValue        bool // TODO: Remove in favor of binary search for invariant violation
    26  	FlagAllInvariantsValue      bool
    27  	FlagDBBackendValue          string
    28  
    29  	FlagEnabledValue     bool
    30  	FlagVerboseValue     bool
    31  	FlagPeriodValue      uint
    32  	FlagGenesisTimeValue int64
    33  	FlagSigverifyTxValue bool
    34  )
    35  
    36  // GetSimulatorFlags gets the values of all the available simulation flags
    37  func GetSimulatorFlags() {
    38  	// config fields
    39  	flag.StringVar(&FlagGenesisFileValue, "Genesis", "", "custom simulation genesis file; cannot be used with params file")
    40  	flag.StringVar(&FlagParamsFileValue, "Params", "", "custom simulation params file which overrides any random params; cannot be used with genesis")
    41  	flag.StringVar(&FlagExportParamsPathValue, "ExportParamsPath", "", "custom file path to save the exported params JSON")
    42  	flag.IntVar(&FlagExportParamsHeightValue, "ExportParamsHeight", 0, "height to which export the randomly generated params")
    43  	flag.StringVar(&FlagExportStatePathValue, "ExportStatePath", "", "custom file path to save the exported app state JSON")
    44  	flag.StringVar(&FlagExportStatsPathValue, "ExportStatsPath", "", "custom file path to save the exported simulation statistics JSON")
    45  	flag.Int64Var(&FlagSeedValue, "Seed", DefaultSeedValue, "simulation random seed")
    46  	flag.IntVar(&FlagInitialBlockHeightValue, "InitialBlockHeight", 1, "initial block to start the simulation")
    47  	flag.IntVar(&FlagNumBlocksValue, "NumBlocks", 500, "number of new blocks to simulate from the initial block height")
    48  	flag.IntVar(&FlagBlockSizeValue, "BlockSize", 200, "operations per block")
    49  	flag.BoolVar(&FlagLeanValue, "Lean", false, "lean simulation log output")
    50  	flag.BoolVar(&FlagCommitValue, "Commit", false, "have the simulation commit")
    51  	flag.BoolVar(&FlagOnOperationValue, "SimulateEveryOperation", false, "run slow invariants every operation")
    52  	flag.BoolVar(&FlagAllInvariantsValue, "PrintAllInvariants", false, "print all invariants if a broken invariant is found")
    53  	flag.StringVar(&FlagDBBackendValue, "DBBackend", "goleveldb", "custom db backend type")
    54  
    55  	// simulation flags
    56  	flag.BoolVar(&FlagEnabledValue, "Enabled", false, "enable the simulation")
    57  	flag.BoolVar(&FlagVerboseValue, "Verbose", false, "verbose log output")
    58  	flag.UintVar(&FlagPeriodValue, "Period", 0, "run slow invariants only once every period assertions")
    59  	flag.Int64Var(&FlagGenesisTimeValue, "GenesisTime", 0, "override genesis UNIX time instead of using a random UNIX time")
    60  	flag.BoolVar(&FlagSigverifyTxValue, "SigverifyTx", true, "whether to sigverify check for transaction ")
    61  }
    62  
    63  // NewConfigFromFlags creates a simulation from the retrieved values of the flags.
    64  func NewConfigFromFlags() simulation.Config {
    65  	return simulation.Config{
    66  		GenesisFile:        FlagGenesisFileValue,
    67  		ParamsFile:         FlagParamsFileValue,
    68  		ExportParamsPath:   FlagExportParamsPathValue,
    69  		ExportParamsHeight: FlagExportParamsHeightValue,
    70  		ExportStatePath:    FlagExportStatePathValue,
    71  		ExportStatsPath:    FlagExportStatsPathValue,
    72  		Seed:               FlagSeedValue,
    73  		InitialBlockHeight: FlagInitialBlockHeightValue,
    74  		NumBlocks:          FlagNumBlocksValue,
    75  		BlockSize:          FlagBlockSizeValue,
    76  		Lean:               FlagLeanValue,
    77  		Commit:             FlagCommitValue,
    78  		OnOperation:        FlagOnOperationValue,
    79  		AllInvariants:      FlagAllInvariantsValue,
    80  		DBBackend:          FlagDBBackendValue,
    81  	}
    82  }