app

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2021 License: GPL-3.0 Imports: 60 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// AppName denotes app name
	AppName = "Heimdall"
	// ABCIPubKeyTypeSecp256k1 denotes pub key type
	ABCIPubKeyTypeSecp256k1 = "secp256k1"
)

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 AddTestAddrs

func AddTestAddrs(app *HeimdallApp, ctx sdk.Context, accNum int, accAmt sdk.Int) []hmTypes.HeimdallAddress

AddTestAddrs constructs and returns accNum amount of accounts with an initial balance of accAmt in random order

func AddTestAddrsFromPubKeys

func AddTestAddrsFromPubKeys(app *HeimdallApp, ctx sdk.Context, pubKeys []crypto.PubKey, accAmt sdk.Int)

AddTestAddrsFromPubKeys adds the addresses into the SimApp providing only the public keys.

func AddTestAddrsIncremental

func AddTestAddrsIncremental(app *HeimdallApp, ctx sdk.Context, accNum int, accAmt sdk.Int) []hmTypes.HeimdallAddress

AddTestAddrsIncremental constructs and returns accNum amount of accounts with an initial balance of accAmt in random order

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 CheckBalance

func CheckBalance(t *testing.T, app *HeimdallApp, addr hmTypes.HeimdallAddress, balances sdk.Coins)

CheckBalance checks the balance of an account.

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 ConvertAddrsToValAddrs

func ConvertAddrsToValAddrs(addrs []sdk.AccAddress) []sdk.ValAddress

ConvertAddrsToValAddrs converts the provided addresses to ValAddress.

func CreateTestPubKeys

func CreateTestPubKeys(numPubKeys int) []crypto.PubKey

CreateTestPubKeys returns a total of numPubKeys public keys in ascending order.

func GenSequenceOfTxs

func GenSequenceOfTxs(msgs []sdk.Msg, accNums []uint64, initSeqNums []uint64, numToGenerate int, priv ...crypto.PrivKey) []authTypes.StdTx

GenSequenceOfTxs generates a set of signed transactions of messages, such that they differ only by having the sequence numbers incremented between every transaction.

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 NewPubKeyFromHex

func NewPubKeyFromHex(pk string) (res crypto.PubKey)

NewPubKeyFromHex returns a PubKey from a hex string.

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

func SignCheckDeliver

func SignCheckDeliver(
	t *testing.T, cdc *codec.Codec, app *bam.BaseApp, header abci.Header, msgs []sdk.Msg,
	accNums, seq []uint64, expSimPass, expPass bool, priv ...crypto.PrivKey,
) (sdk.Result, error)

SignCheckDeliver checks a generated signed transaction and simulates a block commitment with the given transaction. A test assertion is made using the parameter 'expPass' against the result. A corresponding result is returned.

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 shoult 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 addreses.
	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.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 key'd by a 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

func Setup(isCheckTx bool) *HeimdallApp

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

func SetupWithGenesisAccounts

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

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

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

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

GetModuleManager returns module manager

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

func (*HeimdallApp) GetSideRouter

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

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

PostDeliverTxHandler runs after deliver tx handler

func (*HeimdallApp) SetCodec

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

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

SetSideRouter sets side-tx router Testing ONLY

func (*HeimdallApp) SimulationManager

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

SimulationManager implements the SimulationApp interface

type ModuleCommunicator

type ModuleCommunicator struct {
	App *HeimdallApp
}

ModuleCommunicator retriever

func (ModuleCommunicator) CreateValiatorSigningInfo

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

Create ValidatorSigningInfo 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

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