app

package
v0.1.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 21, 2025 License: GPL-3.0 Imports: 56 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// AppName denotes app name
	AppName = "Iris"
)
View Source
const (
	SimAppChainID = "simulation-app"
)

SimAppChainID hardcoded chainID for simulation

Variables

View Source
var (
	FlagGenesisFileValue        string
	FlagParamsFileValue         string
	FlagExportParamsPathValue   string
	FlagExportParamsHeightValue int
	FlagExportStatePathValue    string
	FlagExportStatsPathValue    string
	FlagSeedValue               int64
	FlagInitialBlockHeightValue int
	FlagNumBlocksValue          int
	FlagBlockSizeValue          int
	FlagLeanValue               bool
	FlagCommitValue             bool
	FlagOnOperationValue        bool // TODO: Remove in favor of binary search for invariant violation
	FlagAllInvariantsValue      bool

	FlagEnabledValue     bool
	FlagVerboseValue     bool
	FlagPeriodValue      uint
	FlagGenesisTimeValue int64
)

List of available flags for the simulator

View Source
var (
	// ModuleBasics defines the module BasicManager is in charge of setting up basic,
	// non-dependant module elements, such as codec registration
	// and genesis verification.
	ModuleBasics = module.NewBasicManager(
		params.AppModuleBasic{},
		sidechannel.AppModuleBasic{},
		auth.AppModuleBasic{},
		bank.AppModuleBasic{},
		supply.AppModuleBasic{},
		chainmanager.AppModuleBasic{},
		staking.AppModuleBasic{},
		checkpoint.AppModuleBasic{},
		zena.AppModuleBasic{},
		clerk.AppModuleBasic{},
		topup.AppModuleBasic{},
		slashing.AppModuleBasic{},
		gov.NewAppModuleBasic(paramsClient.ProposalHandler),
	)
)

Functions

func AppStateFn

func AppStateFn(cdc *codec.Codec, simManager *module.SimulationManager) simtypes.AppStateFn

AppStateFn returns the initial application state using a genesis or the simulation parameters. It panics if the user provides files for both of them. If a file is not given for the genesis or the sim params, it creates a randomized one.

func AppStateFromGenesisFileFn

func AppStateFromGenesisFileFn(r io.Reader, cdc *codec.Codec, genesisFile string) (tmtypes.GenesisDoc, []simtypes.Account)

AppStateFromGenesisFileFn util function to generate the genesis AppState from a genesis.json file.

func AppStateRandomizedFn

func AppStateRandomizedFn(
	simManager *module.SimulationManager, r *rand.Rand, cdc *codec.Codec,
	accs []simtypes.Account, genesisTimestamp time.Time, appParams simtypes.AppParams,
) (json.RawMessage, []simtypes.Account)

AppStateRandomizedFn creates calls each module's GenesisState generator function and creates the simulation params

func CheckExportSimulation

func CheckExportSimulation(app App, config simTypes.Config, params simTypes.Params) error

CheckExportSimulation exports the app state and simulation parameters to JSON if the export paths are defined.

func GetMaccPerms

func GetMaccPerms() map[string][]string

GetMaccPerms returns a copy of the module account permissions

func GetSimulationLog

func GetSimulationLog(storeName string, sdr module.StoreDecoderRegistry, cdc *codec.Codec, kvAs, kvBs []sdk.KVPair) (log string)

GetSimulationLog unmarshals the KVPair's Value to the corresponding type based on the each's module store key and the prefix bytes of the KVPair's key.

func GetSimulatorFlags

func GetSimulatorFlags()

GetSimulatorFlags gets the values of all the available simulation flags

func MakeCodec

func MakeCodec() *codec.Codec

MakeCodec create codec

func NewConfigFromFlags

func NewConfigFromFlags() simulation.Config

NewConfigFromFlags creates a simulation from the retrieved values of the flags.

func PrintStats

func PrintStats(db dbm.DB)

PrintStats prints the corresponding statistics from the app DB.

func SetupSimulation

func SetupSimulation(dirPrefix, dbName string) (simTypes.Config, dbm.DB, string, log.Logger, bool, error)

SetupSimulation creates the config, db (levelDB), temporary directory and logger for the simulation tests. If `FlagEnabledValue` is false it skips the current test. Returns error on an invalid db instantiation or temp dir creation.

func SimulationOperations

func SimulationOperations(app App, cdc *codec.Codec, config simTypes.Config) []simTypes.WeightedOperation

SimulationOperations retrieves the simulation params from the provided file path and returns all the modules weighted operations

Types

type App

type App interface {
	// The assigned name of the app.
	Name() string

	// The application types codec.
	// NOTE: This should not be sealed before being returned.
	Codec() *codec.Codec

	// Application updates every begin block.
	BeginBlocker(ctx sdk.Context, req abci.RequestBeginBlock) abci.ResponseBeginBlock

	// Application updates every end block.
	EndBlocker(ctx sdk.Context, req abci.RequestEndBlock) abci.ResponseEndBlock

	// Application update at chain (i.e app) initialization.
	InitChainer(ctx sdk.Context, req abci.RequestInitChain) abci.ResponseInitChain

	// Loads the app at a given height.
	LoadHeight(height int64) error

	// Exports the state of the application for a genesis file.
	ExportAppStateAndValidators() (json.RawMessage, []tmTypes.GenesisValidator, error)

	// All the registered module account addresses.
	ModuleAccountAddrs() map[string]bool

	// Helper for the simulation framework.
	SimulationManager() *hmModule.SimulationManager
}

App implements the common methods for a Cosmos SDK-based application specific blockchain.

type GenerateAccountStrategy

type GenerateAccountStrategy func(int) []hmTypes.IrisAddress

GenerateAccountStrategy account strategy

type GenesisState

type GenesisState map[string]json.RawMessage

GenesisState the genesis state of the blockchain is represented here as a map of raw json messages keyed by an identifier string

func NewDefaultGenesisState

func NewDefaultGenesisState() GenesisState

NewDefaultGenesisState generates the default state for the application.

type IrisApp

type IrisApp struct {
	*bam.BaseApp

	// keepers
	SidechannelKeeper sidechannel.Keeper
	AccountKeeper     auth.AccountKeeper
	BankKeeper        bank.Keeper
	SupplyKeeper      supply.Keeper
	GovKeeper         gov.Keeper
	ChainKeeper       chainmanager.Keeper
	CheckpointKeeper  checkpoint.Keeper
	StakingKeeper     staking.Keeper
	ZenaKeeper        zena.Keeper
	ClerkKeeper       clerk.Keeper
	TopupKeeper       topup.Keeper
	SlashingKeeper    slashing.Keeper

	// param keeper
	ParamsKeeper params.Keeper

	//  total coins supply
	TotalCoinsSupply sdk.Coins
	// contains filtered or unexported fields
}

IrisApp main iris app

func NewIrisApp

func NewIrisApp(logger log.Logger, db dbm.DB, baseAppOptions ...func(*bam.BaseApp)) *IrisApp

NewIrisApp creates iris app

func Setup

func Setup(isCheckTx bool, testOpts ...*helper.TestOpts) *IrisApp

Setup initializes a new App. A Nop logger is set in App.

func SetupWithGenesisAccounts

func SetupWithGenesisAccounts(genAccs []authTypes.GenesisAccount) *IrisApp

SetupWithGenesisAccounts initializes a new Iris with the provided genesis accounts and possible balances.

func (*IrisApp) BeginBlocker

func (app *IrisApp) BeginBlocker(ctx sdk.Context, req abci.RequestBeginBlock) abci.ResponseBeginBlock

BeginBlocker application updates every begin block

func (*IrisApp) BeginSideBlocker

func (app *IrisApp) BeginSideBlocker(ctx sdk.Context, req abci.RequestBeginSideBlock) (res abci.ResponseBeginSideBlock)

BeginSideBlocker runs before side block

func (*IrisApp) Codec

func (app *IrisApp) Codec() *codec.Codec

Codec returns IrisApp's codec.

NOTE: This is solely to be used for testing purposes as it may be desirable for modules to register their own custom testing types.

func (*IrisApp) DeliverSideTxHandler

func (app *IrisApp) DeliverSideTxHandler(ctx sdk.Context, tx sdk.Tx, req abci.RequestDeliverSideTx) (res abci.ResponseDeliverSideTx)

DeliverSideTxHandler runs for each side tx

func (*IrisApp) EndBlocker

func (app *IrisApp) EndBlocker(ctx sdk.Context, req abci.RequestEndBlock) abci.ResponseEndBlock

EndBlocker executes on each end block

func (*IrisApp) ExportAppStateAndValidators

func (app *IrisApp) ExportAppStateAndValidators() (
	appState json.RawMessage,
	validators []tmTypes.GenesisValidator,
	err error,
)

ExportAppStateAndValidators exports the state of iris for a genesis file

func (*IrisApp) GetKey

func (app *IrisApp) GetKey(storeKey string) *sdk.KVStoreKey

GetKey returns the KVStoreKey for the provided store key.

NOTE: This is solely to be used for testing purposes.

func (*IrisApp) GetModuleManager

func (app *IrisApp) GetModuleManager() *module.Manager

GetModuleManager returns module manager

NOTE: This is solely to be used for testing purposes.

func (*IrisApp) GetSideRouter

func (app *IrisApp) GetSideRouter() types.SideRouter

GetSideRouter returns side-tx router

func (*IrisApp) GetSubspace

func (app *IrisApp) GetSubspace(moduleName string) subspace.Subspace

GetSubspace returns a param subspace for a given module name.

NOTE: This is solely to be used for testing purposes.

func (*IrisApp) GetTKey

func (app *IrisApp) GetTKey(storeKey string) *sdk.TransientStoreKey

GetTKey returns the TransientStoreKey for the provided store key.

NOTE: This is solely to be used for testing purposes.

func (*IrisApp) InitChainer

func (app *IrisApp) InitChainer(ctx sdk.Context, req abci.RequestInitChain) abci.ResponseInitChain

InitChainer initializes chain

func (*IrisApp) LoadHeight

func (app *IrisApp) LoadHeight(height int64) error

LoadHeight loads a particular height

func (*IrisApp) ModuleAccountAddrs

func (app *IrisApp) ModuleAccountAddrs() map[string]bool

ModuleAccountAddrs returns all the app's module account addresses.

func (*IrisApp) Name

func (app *IrisApp) Name() string

Name returns the name of the App

func (*IrisApp) PostDeliverTxHandler

func (app *IrisApp) PostDeliverTxHandler(ctx sdk.Context, tx sdk.Tx, result sdk.Result)

PostDeliverTxHandler runs after deliver tx handler

func (*IrisApp) SetCodec

func (app *IrisApp) SetCodec(cdc *codec.Codec)

SetCodec set codec to app

NOTE: This is solely to be used for testing purposes as it may be desirable for modules to register their own custom testing types.

func (*IrisApp) SetSideRouter

func (app *IrisApp) SetSideRouter(r types.SideRouter)

SetSideRouter sets side-tx router Testing ONLY

func (*IrisApp) SimulationManager

func (app *IrisApp) SimulationManager() *hmModule.SimulationManager

SimulationManager implements the SimulationApp interface

type ModuleCommunicator

type ModuleCommunicator struct {
	App *IrisApp
}

ModuleCommunicator retriever

func (ModuleCommunicator) CreateValidatorSigningInfo

func (d ModuleCommunicator) CreateValidatorSigningInfo(ctx sdk.Context, valID types.ValidatorID, valSigningInfo types.ValidatorSigningInfo)

CreateValidatorSigningInfo used by slashing module

func (ModuleCommunicator) GetACKCount

func (d ModuleCommunicator) GetACKCount(ctx sdk.Context) uint64

GetACKCount returns ack count

func (ModuleCommunicator) GetAllDividendAccounts

func (d ModuleCommunicator) GetAllDividendAccounts(ctx sdk.Context) []types.DividendAccount

GetAllDividendAccounts fetches all dividend accounts from topup module

func (ModuleCommunicator) GetCoins

func (d ModuleCommunicator) GetCoins(ctx sdk.Context, addr types.IrisAddress) sdk.Coins

GetCoins gets coins

func (ModuleCommunicator) GetValidatorFromValID

func (d ModuleCommunicator) GetValidatorFromValID(ctx sdk.Context, valID types.ValidatorID) (validator types.Validator, ok bool)

GetValidatorFromValID get validator from validator id

func (ModuleCommunicator) IsCurrentValidatorByAddress

func (d ModuleCommunicator) IsCurrentValidatorByAddress(ctx sdk.Context, address []byte) bool

IsCurrentValidatorByAddress check if validator is current validator

func (ModuleCommunicator) SendCoins

func (d ModuleCommunicator) SendCoins(ctx sdk.Context, fromAddr types.IrisAddress, toAddr types.IrisAddress, amt sdk.Coins) sdk.Error

SendCoins transfers coins

func (ModuleCommunicator) SetCoins

func (d ModuleCommunicator) SetCoins(ctx sdk.Context, addr types.IrisAddress, amt sdk.Coins) sdk.Error

SetCoins sets coins

Directories

Path Synopsis
Package params defines the simulation parameters in the simapp.
Package params defines the simulation parameters in the simapp.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL