app

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: May 10, 2023 License: Apache-2.0 Imports: 149 Imported by: 4

Documentation

Index

Constants

View Source
const (

	// Custom prefix for application enviromental variables.
	// From cosmos version 0.46 is is possible to have custom prefix for application
	// enviromental variables - https://github.com/cosmos/cosmos-sdk/pull/10950
	BabylonAppEnvPrefix = ""

	// According to https://github.com/CosmWasm/wasmd#genesis-configuration chains
	// using smart contracts should configure proper gas limits per block.
	// https://medium.com/cosmwasm/cosmwasm-for-ctos-iv-native-integrations-713140bf75fc
	// suggests 50M as reasonable limits. Me may want to adjust it later.
	DefaultGasLimit int64 = 50000000
)

Variables

View Source
var (
	// WasmProposalsEnabled enables all x/wasm proposals when its value is "true"
	// and EnableSpecificWasmProposals is empty. Otherwise, all x/wasm proposals
	// are disabled.
	WasmProposalsEnabled = "true"

	// EnableSpecificWasmProposals, if set, must be comma-separated list of values
	// that are all a subset of "EnableAllProposals", which takes precedence over
	// WasmProposalsEnabled.
	//
	// See: https://github.com/CosmWasm/wasmd/blob/02a54d33ff2c064f3539ae12d75d027d9c665f05/x/wasm/internal/types/proposal.go#L28-L34
	EnableSpecificWasmProposals = ""

	// EmptyWasmOpts defines a type alias for a list of wasm options.
	EmptyWasmOpts []wasm.Option
)

Wasm related variables

Functions

func AddTestAddrs

func AddTestAddrs(app *BabylonApp, ctx sdk.Context, accNum int, accAmt math.Int) []sdk.AccAddress

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

func AddTestAddrsFromPubKeys

func AddTestAddrsFromPubKeys(app *BabylonApp, ctx sdk.Context, pubKeys []cryptotypes.PubKey, accAmt math.Int)

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

func AddTestAddrsIncremental

func AddTestAddrsIncremental(app *BabylonApp, ctx sdk.Context, accNum int, accAmt math.Int) []sdk.AccAddress

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

func BlockedAddresses added in v0.6.0

func BlockedAddresses() map[string]bool

BlockedAddresses returns all the app's blocked account addresses.

func CheckBalance

func CheckBalance(t *testing.T, app *BabylonApp, addr sdk.AccAddress, balances sdk.Coins)

CheckBalance checks the balance of an account.

func ConvertAddrsToValAddrs

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

ConvertAddrsToValAddrs converts the provided addresses to ValAddress.

func CreateClientConfig

func CreateClientConfig(chainID string, backend string, homePath string) (*config.ClientConfig, error)

func CreateTestPubKeys

func CreateTestPubKeys(numPubKeys int) []cryptotypes.PubKey

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

func FundAccount

func FundAccount(bankKeeper bankkeeper.Keeper, ctx sdk.Context, addr sdk.AccAddress, amounts sdk.Coins) error

FundAccount is a utility function that funds an account by minting and sending the coins to the address. This should be used for testing purposes only!

TODO: Instead of using the mint module account, which has the permission of minting, create a "faucet" account. (@fdymylja)

func FundModuleAccount

func FundModuleAccount(bankKeeper bankkeeper.Keeper, ctx sdk.Context, recipientMod string, amounts sdk.Coins) error

FundModuleAccount is a utility function that funds a module account by minting and sending the coins to the address. This should be used for testing purposes only!

TODO: Instead of using the mint module account, which has the permission of minting, create a "faucet" account. (@fdymylja)

func GenSequenceOfTxs

func GenSequenceOfTxs(txGen client.TxConfig, msgs []sdk.Msg, accNums []uint64, initSeqNums []uint64, numToGenerate int, priv ...cryptotypes.PrivKey) ([]sdk.Tx, error)

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

func GetEncodingConfig added in v0.6.0

func GetEncodingConfig() appparams.EncodingConfig

func GetMaccPerms

func GetMaccPerms() map[string][]string

GetMaccPerms returns a copy of the module account permissions

func GetWasmEnabledProposals added in v0.6.0

func GetWasmEnabledProposals() []wasm.ProposalType

GetWasmEnabledProposals parses the WasmProposalsEnabled and EnableSpecificWasmProposals values to produce a list of enabled proposals to pass into the application.

func NewPubKeyFromHex

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

NewPubKeyFromHex returns a PubKey from a hex string.

func SignCheckDeliver

func SignCheckDeliver(
	t *testing.T, txCfg client.TxConfig, app *bam.BaseApp, header tmproto.Header, msgs []sdk.Msg,
	chainID string, accNums, accSeqs []uint64, expSimPass, expPass bool, priv ...cryptotypes.PrivKey,
) (sdk.GasInfo, *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 TestAddr

func TestAddr(addr string, bech string) (sdk.AccAddress, error)

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.
	LegacyAmino() *codec.LegacyAmino

	// 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(
		forZeroHeight bool, jailAllowedAddrs []string, modulesToExport []string,
	) (types.ExportedApp, error)

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

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

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

type BabylonApp

type BabylonApp struct {
	*baseapp.BaseApp

	// keepers
	AccountKeeper         authkeeper.AccountKeeper
	BankKeeper            bankkeeper.Keeper
	CapabilityKeeper      *capabilitykeeper.Keeper
	StakingKeeper         *stakingkeeper.Keeper
	SlashingKeeper        slashingkeeper.Keeper
	MintKeeper            mintkeeper.Keeper
	DistrKeeper           distrkeeper.Keeper
	GovKeeper             govkeeper.Keeper
	CrisisKeeper          *crisiskeeper.Keeper
	UpgradeKeeper         *upgradekeeper.Keeper
	ParamsKeeper          paramskeeper.Keeper
	AuthzKeeper           authzkeeper.Keeper
	EvidenceKeeper        evidencekeeper.Keeper
	FeeGrantKeeper        feegrantkeeper.Keeper
	ConsensusParamsKeeper consensusparamkeeper.Keeper

	// Babylon modules
	EpochingKeeper       epochingkeeper.Keeper
	BTCLightClientKeeper btclightclientkeeper.Keeper
	BtcCheckpointKeeper  btccheckpointkeeper.Keeper
	CheckpointingKeeper  checkpointingkeeper.Keeper
	MonitorKeeper        monitorkeeper.Keeper

	// IBC-related modules
	IBCKeeper           *ibckeeper.Keeper        // IBC Keeper must be a pointer in the app, so we can SetRouter on it correctly
	TransferKeeper      ibctransferkeeper.Keeper // for cross-chain fungible token transfers
	ZoneConciergeKeeper zckeeper.Keeper          // for cross-chain fungible token transfers

	WasmKeeper wasm.Keeper
	// make scoped keepers public for test purposes
	ScopedIBCKeeper           capabilitykeeper.ScopedKeeper
	ScopedTransferKeeper      capabilitykeeper.ScopedKeeper
	ScopedZoneConciergeKeeper capabilitykeeper.ScopedKeeper
	ScopedWasmKeeper          capabilitykeeper.ScopedKeeper
	// contains filtered or unexported fields
}

BabylonApp extends an ABCI application, but with most of its parameters exported. They are exported for convenience in creating helper functions, as object capabilities aren't needed for testing.

func NewBabyblonAppWithCustomOptions

func NewBabyblonAppWithCustomOptions(t *testing.T, isCheckTx bool, privSigner *PrivSigner, options SetupOptions) *BabylonApp

NewBabyblonAppWithCustomOptions initializes a new BabylonApp with custom options. Created Babylon application will have one validator with hardoced amout of tokens. This is necessary as from cosmos-sdk 0.46 it is required that there is at least one validator in validator set during InitGenesis abci call - https://github.com/cosmos/cosmos-sdk/pull/9697

func NewBabylonApp

func NewBabylonApp(
	logger log.Logger, db dbm.DB, traceStore io.Writer, loadLatest bool, skipUpgradeHeights map[int64]bool,
	homePath string, invCheckPeriod uint, encodingConfig appparams.EncodingConfig, privSigner *PrivSigner,
	appOpts servertypes.AppOptions,
	wasmEnabledProposals []wasm.ProposalType,
	wasmOpts []wasm.Option,
	baseAppOptions ...func(*baseapp.BaseApp),
) *BabylonApp

NewBabylonApp returns a reference to an initialized BabylonApp.

func Setup

func Setup(t *testing.T, isCheckTx bool) *BabylonApp

Setup initializes a new BabylonApp. A Nop logger is set in BabylonApp. Created Babylon application will have one validator with hardoced amout of tokens. This is necessary as from cosmos-sdk 0.46 it is required that there is at least one validator in validator set during InitGenesis abci call - https://github.com/cosmos/cosmos-sdk/pull/9697

func SetupWithGenesisAccounts

func SetupWithGenesisAccounts(genAccs []authtypes.GenesisAccount, balances ...banktypes.Balance) *BabylonApp

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

func SetupWithGenesisValSet

func SetupWithGenesisValSet(t *testing.T, valSet *tmtypes.ValidatorSet, genAccs []authtypes.GenesisAccount, balances ...banktypes.Balance) *BabylonApp

SetupWithGenesisValSet initializes a new BabylonApp with a validator set and genesis accounts that also act as delegators. For simplicity, each validator is bonded with a delegation of one consensus engine unit (10^6) in the default token of the babylon app from first genesis account. A Nop logger is set in BabylonApp.

func (*BabylonApp) AppCodec

func (app *BabylonApp) AppCodec() codec.Codec

AppCodec returns BabylonApp's app 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 (*BabylonApp) BeginBlocker

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

BeginBlocker application updates every begin block

func (*BabylonApp) DefaultGenesis added in v0.6.0

func (a *BabylonApp) DefaultGenesis() map[string]json.RawMessage

DefaultGenesis returns a default genesis from the registered AppModuleBasic's.

func (*BabylonApp) EndBlocker

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

EndBlocker application updates every end block

func (*BabylonApp) ExportAppStateAndValidators

func (app *BabylonApp) ExportAppStateAndValidators(
	forZeroHeight bool,
	jailAllowedAddrs []string,
	modulesToExport []string) (servertypes.ExportedApp, error)

ExportAppStateAndValidators exports the state of the application for a genesis file.

func (*BabylonApp) GetBaseApp

func (app *BabylonApp) GetBaseApp() *baseapp.BaseApp

GetBaseApp returns the BaseApp of BabylonApp required by ibctesting

func (*BabylonApp) GetIBCKeeper

func (app *BabylonApp) GetIBCKeeper() *ibckeeper.Keeper

func (*BabylonApp) GetKey

func (app *BabylonApp) GetKey(storeKey string) *storetypes.KVStoreKey

GetKey returns the KVStoreKey for the provided store key.

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

func (*BabylonApp) GetMemKey

func (app *BabylonApp) GetMemKey(storeKey string) *storetypes.MemoryStoreKey

GetMemKey returns the MemStoreKey for the provided mem key.

NOTE: This is solely used for testing purposes.

func (*BabylonApp) GetScopedIBCKeeper

func (app *BabylonApp) GetScopedIBCKeeper() capabilitykeeper.ScopedKeeper

func (*BabylonApp) GetStakingKeeper

func (app *BabylonApp) GetStakingKeeper() ibctestingtypes.StakingKeeper

func (*BabylonApp) GetSubspace

func (app *BabylonApp) GetSubspace(moduleName string) paramstypes.Subspace

GetSubspace returns a param subspace for a given module name.

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

func (*BabylonApp) GetTKey

func (app *BabylonApp) GetTKey(storeKey string) *storetypes.TransientStoreKey

GetTKey returns the TransientStoreKey for the provided store key.

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

func (*BabylonApp) GetTxConfig

func (app *BabylonApp) GetTxConfig() client.TxConfig

func (*BabylonApp) InitChainer

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

InitChainer application update at chain initialization

func (*BabylonApp) InterfaceRegistry

func (app *BabylonApp) InterfaceRegistry() types.InterfaceRegistry

InterfaceRegistry returns babylonApp's InterfaceRegistry

func (*BabylonApp) LegacyAmino

func (app *BabylonApp) LegacyAmino() *codec.LegacyAmino

LegacyAmino returns BabylonApp's amino 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 (*BabylonApp) LoadHeight

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

LoadHeight loads a particular height

func (*BabylonApp) ModuleAccountAddrs

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

ModuleAccountAddrs returns all the app's module account addresses.

func (*BabylonApp) ModuleManager

func (app *BabylonApp) ModuleManager() *module.Manager

func (*BabylonApp) Name

func (app *BabylonApp) Name() string

Name returns the name of the App

func (*BabylonApp) RegisterAPIRoutes

func (app *BabylonApp) RegisterAPIRoutes(apiSvr *api.Server, apiConfig config.APIConfig)

RegisterAPIRoutes registers all application module routes with the provided API server.

func (*BabylonApp) RegisterNodeService added in v0.6.0

func (app *BabylonApp) RegisterNodeService(clientCtx client.Context)

func (*BabylonApp) RegisterTendermintService

func (app *BabylonApp) RegisterTendermintService(clientCtx client.Context)

RegisterTendermintService implements the Application.RegisterTendermintService method.

func (*BabylonApp) RegisterTxService

func (app *BabylonApp) RegisterTxService(clientCtx client.Context)

RegisterTxService implements the Application.RegisterTxService method.

func (*BabylonApp) SimulationManager

func (app *BabylonApp) SimulationManager() *module.SimulationManager

SimulationManager implements the SimulationApp interface

func (*BabylonApp) TxConfig added in v0.6.0

func (app *BabylonApp) TxConfig() client.TxConfig

type BtcValidationDecorator

type BtcValidationDecorator struct {
	BtcCfg bbn.BtcConfig
	// contains filtered or unexported fields
}

func (BtcValidationDecorator) AnteHandle

func (bvd BtcValidationDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (newCtx sdk.Context, err error)

type EmptyAppOptions

type EmptyAppOptions struct{}

EmptyAppOptions is a stub implementing AppOptions

func (EmptyAppOptions) Get

func (ao EmptyAppOptions) Get(o string) interface{}

Get implements AppOptions

type GenerateAccountStrategy

type GenerateAccountStrategy func(int) []sdk.AccAddress

type GenesisState

type GenesisState map[string]json.RawMessage

GenesisState of the blockchain is represented here as a map of raw json messages key'd by a identifier string. The identifier is used to determine which module genesis information belongs to so it may be appropriately routed during init chain. Within this application default genesis information is retrieved from the ModuleBasicManager which populates json from each BasicModule object provided to it during init.

func NewDefaultGenesisState

func NewDefaultGenesisState(cdc codec.JSONCodec) GenesisState

NewDefaultGenesisState generates the default state for the application.

type PrivSigner

type PrivSigner struct {
	WrappedPV *privval.WrappedFilePV
	ClientCtx client.Context
}

func InitPrivSigner

func InitPrivSigner(clientCtx client.Context, nodeDir string, kr keyring.Keyring, feePayer string, encodingCfg appparams.EncodingConfig) (*PrivSigner, error)

func SetupPrivSigner

func SetupPrivSigner() (*PrivSigner, error)

SetupPrivSigner sets up a PrivSigner for testing

type SetupOptions

type SetupOptions struct {
	Logger             log.Logger
	DB                 *dbm.MemDB
	InvCheckPeriod     uint
	HomePath           string
	SkipUpgradeHeights map[int64]bool
	EncConfig          params.EncodingConfig
	AppOpts            types.AppOptions
}

SetupOptions defines arguments that are passed into `Simapp` constructor.

type WrappedAnteHandler

type WrappedAnteHandler struct {
	// contains filtered or unexported fields
}

WrappedAnteHandler is the wrapped AnteHandler that implements the `AnteDecorator` interface, which has a single function `AnteHandle`. It allows us to chain an existing AnteHandler with other decorators by using `sdk.ChainAnteDecorators`.

func NewWrappedAnteHandler

func NewWrappedAnteHandler(ah sdk.AnteHandler) WrappedAnteHandler

NewWrappedAnteHandler creates a new WrappedAnteHandler for a given AnteHandler.

func (WrappedAnteHandler) AnteHandle

func (wah WrappedAnteHandler) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (newCtx sdk.Context, err error)

Directories

Path Synopsis
Package params defines the simulation parameters in the babylon app.
Package params defines the simulation parameters in the babylon app.

Jump to

Keyboard shortcuts

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