* move GenesisState generators to modules * minor change on slashing genState generator * move simulation params back to modules (#4839) move simulation params back to modules (#4839) * cleanup params * various fixes * move store decoders to modules * fix * module pattern * split generators for param change * param changes * revert util pkg * banksim * compile * update Decoders params * fix * address @colin-axner comments * move weighted operations to modules * cleanup * cleanup * Update cmd_test.go * simulation manager * mino fixes * cleanup * add GenerateGenesisState to simulation manager * Apply suggestions from code review Co-Authored-By: frog power 4000 <rigel.rozanski@gmail.com> * address @rigelrozanski comments * changelog * Apply suggestions from code review Co-Authored-By: colin axner <colinaxner@berkeley.edu> * restructure modules simulation pkgs * remove cycle deps * rename funcs and add missing params * modularize simulator param changes * build * fix params keys * make format * various fixes * fix tests * minor updates to sim_test * cleanup * more cleanup * modularize genesis generators * minor cleanup * remove cdc from generators * remove cdc * add get or generate * fix non-determinism in simulation * changelog and x/simulation godoc * cleanup operations * update operations to use baseapp * updates and cleanup operations * update operations * restructure sim ops params * rename sim /operations/msg.go to /operations.go * move GenTx to a helper pkg to avoid circle deps * rm msg.ValidateBasic * changelog * random fees; delete auth's DeductFees sim operation * add chain-id for sig verification * Update x/simulation/account.go Co-Authored-By: colin axner <colinaxner@berkeley.edu> * fix bank, gov and distr errors * fix staking and slashing errors; increase prob for send enabled * increase gas x10 * make format * fix some distr and staking edge cases * fix all edge cases * golang ci * rename acc vars; default no fees to 0stake * cleanup; check for exchange rate and skip invalid ops * fixes * check for max entries * add pubkey to genaccounts * fix gov bug * update staking sim ops * fix small redelegation error * fix small self delegation on unjail * rm inf loop on random val/accs * copy array * add ok boolean to RandomValidator return values * format * build * add WeightedOperations to AppModuleSimulation * define each module proposals content as part of the module pattern * Update x/bank/simulation/operations.go Co-Authored-By: colin axner <colinaxner@berkeley.edu> * Update simapp/helpers/test_helpers.go Co-Authored-By: colin axner <colinaxner@berkeley.edu> * address @colin-axner comments * add genaccount pubkey validation * fix test * update operations and move RandomFees to x/simulation * update gov ops * address @alexanderbez comments * avoid modifications to config * reorder params * modularized sim operations working * changelog * Update types/module/simulation.go Co-Authored-By: frog power 4000 <rigel.rozanski@gmail.com> * Update x/simulation/params.go Co-Authored-By: frog power 4000 <rigel.rozanski@gmail.com> * Update x/simulation/params.go Co-Authored-By: frog power 4000 <rigel.rozanski@gmail.com> * update /types/module * Update x/distribution/simulation/genesis.go Co-Authored-By: Alexander Bezobchuk <alexanderbez@users.noreply.github.com> * remove named return values * ensure all operations are simulated * golangci * add nolint * disable whitespace and funlen linter * disable godox * add TODO on unjail * update ops weights * remove dup * update godoc * remove unused func * build fixes * move weights to the same file * scopelint * changelog * address @AdityaSripal comments * address @alexanderbez comments
93 lines
2.9 KiB
Go
93 lines
2.9 KiB
Go
package params
|
|
|
|
import (
|
|
"encoding/json"
|
|
"math/rand"
|
|
|
|
"github.com/gorilla/mux"
|
|
"github.com/spf13/cobra"
|
|
|
|
"github.com/cosmos/cosmos-sdk/client/context"
|
|
"github.com/cosmos/cosmos-sdk/codec"
|
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
"github.com/cosmos/cosmos-sdk/types/module"
|
|
"github.com/cosmos/cosmos-sdk/x/params/simulation"
|
|
"github.com/cosmos/cosmos-sdk/x/params/types"
|
|
sim "github.com/cosmos/cosmos-sdk/x/simulation"
|
|
)
|
|
|
|
var (
|
|
_ module.AppModuleBasic = AppModuleBasic{}
|
|
_ module.AppModuleSimulation = AppModule{}
|
|
)
|
|
|
|
// AppModuleBasic defines the basic application module used by the params module.
|
|
type AppModuleBasic struct{}
|
|
|
|
// Name returns the params module's name.
|
|
func (AppModuleBasic) Name() string {
|
|
return ModuleName
|
|
}
|
|
|
|
// RegisterCodec registers the params module's types for the given codec.
|
|
func (AppModuleBasic) RegisterCodec(cdc *codec.Codec) {
|
|
types.RegisterCodec(cdc)
|
|
}
|
|
|
|
// DefaultGenesis returns default genesis state as raw bytes for the params
|
|
// module.
|
|
func (AppModuleBasic) DefaultGenesis() json.RawMessage { return nil }
|
|
|
|
// ValidateGenesis performs genesis state validation for the params module.
|
|
func (AppModuleBasic) ValidateGenesis(_ json.RawMessage) error { return nil }
|
|
|
|
// RegisterRESTRoutes registers the REST routes for the params module.
|
|
func (AppModuleBasic) RegisterRESTRoutes(_ context.CLIContext, _ *mux.Router) {}
|
|
|
|
// GetTxCmd returns no root tx command for the params module.
|
|
func (AppModuleBasic) GetTxCmd(_ *codec.Codec) *cobra.Command { return nil }
|
|
|
|
// GetQueryCmd returns no root query command for the params module.
|
|
func (AppModuleBasic) GetQueryCmd(_ *codec.Codec) *cobra.Command { return nil }
|
|
|
|
//____________________________________________________________________________
|
|
|
|
// AppModule implements an application module for the distribution module.
|
|
type AppModule struct {
|
|
AppModuleBasic
|
|
}
|
|
|
|
// NewAppModule creates a new AppModule object
|
|
func NewAppModule() AppModule {
|
|
return AppModule{
|
|
AppModuleBasic: AppModuleBasic{},
|
|
}
|
|
}
|
|
|
|
//____________________________________________________________________________
|
|
|
|
// AppModuleSimulation functions
|
|
|
|
// GenerateGenesisState performs a no-op.
|
|
func (AppModule) GenerateGenesisState(simState *module.SimulationState) {
|
|
}
|
|
|
|
// ProposalContents returns all the params content functions used to
|
|
// simulate governance proposals.
|
|
func (am AppModule) ProposalContents(simState module.SimulationState) []sim.WeightedProposalContent {
|
|
return simulation.ProposalContents(simState.ParamChanges)
|
|
}
|
|
|
|
// RandomizedParams creates randomized distribution param changes for the simulator.
|
|
func (AppModule) RandomizedParams(r *rand.Rand) []sim.ParamChange {
|
|
return nil
|
|
}
|
|
|
|
// RegisterStoreDecoder doesn't register any type.
|
|
func (AppModule) RegisterStoreDecoder(sdr sdk.StoreDecoderRegistry) {}
|
|
|
|
// WeightedOperations returns the all the gov module operations with their respective weights.
|
|
func (am AppModule) WeightedOperations(_ module.SimulationState) []sim.WeightedOperation {
|
|
return nil
|
|
}
|