app

package
v1.0.3-beta Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2023 License: GPL-3.0 Imports: 56 Imported by: 2

Documentation

Index

Constants

View Source
const (
	// AppName denotes app name
	AppName = "Heimdall"
)
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{},
		bor.AppModuleBasic{},
		clerk.AppModuleBasic{},
		topup.AppModuleBasic{},
		slashing.AppModuleBasic{},
		gov.NewAppModuleBasic(paramsClient.ProposalHandler),
	)
)

Functions

func AppStateFn added in v0.1.7

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 added in v0.1.7

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 added in v0.1.7

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 added in v0.1.7

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 added in v0.1.7

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 added in v0.1.7

func GetSimulatorFlags()

GetSimulatorFlags gets the values of all the available simulation flags

func MakeCodec

func MakeCodec() *codec.Codec

MakeCodec create codec

func NewConfigFromFlags added in v0.1.7

func NewConfigFromFlags() simulation.Config

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

func PrintStats added in v0.1.7

func PrintStats(db dbm.DB)

PrintStats prints the corresponding statistics from the app DB.

func SetupSimulation added in v0.1.7

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 intantiation or temp dir creation.

func SimulationOperations added in v0.1.7

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 added in v0.1.7

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 added in v0.1.7

type GenerateAccountStrategy func(int) []hmTypes.HeimdallAddress

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 HeimdallApp

type HeimdallApp 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
	BorKeeper         bor.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
}

HeimdallApp main heimdall app

func NewHeimdallApp

func NewHeimdallApp(logger log.Logger, db dbm.DB, baseAppOptions ...func(*bam.BaseApp)) *HeimdallApp

NewHeimdallApp creates heimdall app

func Setup added in v0.1.7

func Setup(isCheckTx bool) *HeimdallApp

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

func SetupWithGenesisAccounts added in v0.1.7

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

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

func (*HeimdallApp) BeginBlocker

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

BeginBlocker application updates every begin block

func (*HeimdallApp) BeginSideBlocker added in v0.1.7

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

BeginSideBlocker runs before side block

func (*HeimdallApp) Codec

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

Codec returns HeimdallApp'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 (*HeimdallApp) DeliverSideTxHandler added in v0.1.7

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

DeliverSideTxHandler runs for each side tx

func (*HeimdallApp) EndBlocker

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

EndBlocker executes on each end block

func (*HeimdallApp) ExportAppStateAndValidators

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

ExportAppStateAndValidators exports the state of heimdall for a genesis file

func (*HeimdallApp) GetKey

func (app *HeimdallApp) 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 (*HeimdallApp) GetModuleManager added in v0.1.7

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

GetModuleManager returns module manager

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

func (*HeimdallApp) GetSideRouter added in v0.1.7

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

GetSideRouter returns side-tx router

func (*HeimdallApp) GetSubspace

func (app *HeimdallApp) 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 (*HeimdallApp) GetTKey

func (app *HeimdallApp) 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 (*HeimdallApp) InitChainer

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

InitChainer initializes chain

func (*HeimdallApp) LoadHeight

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

LoadHeight loads a particular height

func (*HeimdallApp) ModuleAccountAddrs

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

ModuleAccountAddrs returns all the app's module account addresses.

func (*HeimdallApp) Name

func (app *HeimdallApp) Name() string

Name returns the name of the App

func (*HeimdallApp) PostDeliverTxHandler added in v0.1.7

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

PostDeliverTxHandler runs after deliver tx handler

func (*HeimdallApp) SetCodec added in v0.1.7

func (app *HeimdallApp) 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 (*HeimdallApp) SetSideRouter added in v0.1.7

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

SetSideRouter sets side-tx router Testing ONLY

func (*HeimdallApp) SimulationManager added in v0.1.7

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

SimulationManager implements the SimulationApp interface

type ModuleCommunicator

type ModuleCommunicator struct {
	App *HeimdallApp
}

ModuleCommunicator retriever

func (ModuleCommunicator) CreateValidatorSigningInfo added in v0.3.2

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 added in v0.1.7

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

GetAllDividendAccounts fetches all dividend accounts from topup module

func (ModuleCommunicator) GetCoins

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.HeimdallAddress, toAddr types.HeimdallAddress, amt sdk.Coins) sdk.Error

SendCoins transfers coins

func (ModuleCommunicator) SetCoins

func (d ModuleCommunicator) SetCoins(ctx sdk.Context, addr types.HeimdallAddress, 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