runtime

package module
v2.0.0-...-6ea50ef Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2024 License: Apache-2.0 Imports: 41 Imported by: 0

Documentation

Index

Constants

View Source
const ModuleName = "runtime"

Variables

This section is empty.

Functions

func NewKVStoreService

func NewKVStoreService(storeKey string) store.KVStoreService

NewKVStoreService creates a new KVStoreService. This wrapper is kept for backwards compatibility. When migrating from runtime to runtime/v2, use runtimev2.NewKVStoreService(storeKey.Name()) instead of runtime.NewKVStoreService(storeKey).

func ProvideCometService

func ProvideCometService() comet.Service

func ProvideEnvironment

func ProvideEnvironment(logger log.Logger, config *runtimev2.Module, key depinject.ModuleKey, appBuilder *AppBuilder) (
	appmodulev2.Environment,
	store.KVStoreService,
	store.MemoryStoreService,
)

ProvideEnvironment provides the environment for keeper modules, while maintaining backward compatibility and provide services directly as well.

func ProvideGenesisTxHandler

func ProvideGenesisTxHandler(appBuilder *AppBuilder) genesis.TxHandler

func SetupAppBuilder

func SetupAppBuilder(inputs AppInputs)

Types

type App

type App struct {
	*appmanager.AppManager[transaction.Tx]
	// contains filtered or unexported fields
}

App is a wrapper around AppManager and ModuleManager that can be used in hybrid app.go/app config scenarios or directly as a servertypes.Application instance. To get an instance of *App, *AppBuilder must be requested as a dependency in a container which declares the runtime module and the AppBuilder.Build() method must be called.

App can be used to create a hybrid app.go setup where some configuration is done declaratively with an app config and the rest of it is done the old way. See simapp/app_v2.go for an example of this setup.

func (*App) Close

func (a *App) Close() error

Close is called in start cmd to gracefully cleanup resources.

func (*App) DefaultGenesis

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

DefaultGenesis returns a default genesis from the registered modules.

func (*App) ExecuteGenesisTx

func (a *App) ExecuteGenesisTx(_ []byte) error

func (*App) GetLogger

func (a *App) GetLogger() log.Logger

GetLogger returns the app logger.

func (*App) GetStore

func (a *App) GetStore() Store

GetStore returns the app store.

func (*App) GetStoreKeys

func (a *App) GetStoreKeys() []string

GetStoreKeys returns all the app store keys.

func (*App) LoadHeight

func (a *App) LoadHeight(height uint64) error

LoadHeight loads a particular height

func (*App) LoadLatest

func (a *App) LoadLatest() error

LoadLatest loads the latest version.

func (*App) Logger

func (a *App) Logger() log.Logger

Logger returns the app logger.

func (*App) ModuleManager

func (a *App) ModuleManager() *MM

ModuleManager returns the module manager.

func (*App) UnsafeFindStoreKey

func (a *App) UnsafeFindStoreKey(storeKey string) (string, error)

UnsafeFindStoreKey fetches a registered StoreKey from the App in linear time. NOTE: This should only be used in testing.

type AppBuilder

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

AppBuilder is a type that is injected into a container by the runtime/v2 module (as *AppBuilder) which can be used to create an app which is compatible with the existing app.go initialization conventions.

func ProvideAppBuilder

func (*AppBuilder) Build

func (a *AppBuilder) Build(opts ...AppBuilderOption) (*App, error)

Build builds an *App instance.

func (*AppBuilder) DefaultGenesis

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

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

func (*AppBuilder) RegisterModules

func (a *AppBuilder) RegisterModules(modules ...appmodulev2.AppModule) error

RegisterModules registers the provided modules with the module manager. This is the primary hook for integrating with modules which are not registered using the app config.

func (*AppBuilder) RegisterStores

func (a *AppBuilder) RegisterStores(keys ...string)

RegisterStores registers the provided store keys. This method should only be used for registering extra stores wiich is necessary for modules that not registered using the app config. To be used in combination of RegisterModules.

type AppBuilderOption

type AppBuilderOption func(*AppBuilder)

AppBuilderOption is a function that can be passed to AppBuilder.Build to customize the resulting app.

func AppBuilderWithBranch

func AppBuilderWithBranch(branch func(state store.ReaderMap) store.WriterMap) AppBuilderOption

AppBuilderWithBranch sets a custom branch implementation for the app.

func AppBuilderWithPostTxExec

func AppBuilderWithPostTxExec(
	postTxExec func(
		ctx context.Context,
		tx transaction.Tx,
		success bool,
	) error,
) AppBuilderOption

AppBuilderWithPostTxExec sets logic that will be executed after each transaction. When not provided, a no-op function will be used.

func AppBuilderWithTxValidator

func AppBuilderWithTxValidator(txValidators func(ctx context.Context, tx transaction.Tx) error) AppBuilderOption

AppBuilderWithTxValidator sets the tx validator for the app. It overrides all default tx validators defined by modules.

type AppI

type AppI[T transaction.Tx] interface {
	DeliverBlock(
		ctx context.Context,
		block *coreappmanager.BlockRequest[T],
	) (*coreappmanager.BlockResponse, store.WriterMap, error)
	ValidateTx(ctx context.Context, tx T) (coreappmanager.TxResult, error)
	Simulate(ctx context.Context, tx T) (coreappmanager.TxResult, store.WriterMap, error)
	Query(ctx context.Context, version uint64, request transaction.Msg) (transaction.Msg, error)
	QueryWithState(ctx context.Context, state store.ReaderMap, request transaction.Msg) (transaction.Msg, error)

	Logger() log.Logger
	ModuleManager() *MM
	Close() error
}

AppI is an interface that defines the methods required by the App.

type AppInputs

type AppInputs struct {
	depinject.In

	AppConfig          *appv1alpha1.Config
	Config             *runtimev2.Module
	AppBuilder         *AppBuilder
	ModuleManager      *MM
	InterfaceRegistrar registry.InterfaceRegistrar
	LegacyAmino        legacy.Amino
	Logger             log.Logger
	StoreOptions       *rootstorev2.FactoryOptions `optional:"true"`
}

type MM

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

func NewModuleManager

func NewModuleManager(
	logger log.Logger,
	config *runtimev2.Module,
	modules map[string]appmodulev2.AppModule,
) *MM

NewModuleManager is the constructor for the module manager It handles all the interactions between the modules and the application

func ProvideModuleManager

func ProvideModuleManager(
	logger log.Logger,
	config *runtimev2.Module,
	modules map[string]appmodulev2.AppModule,
) *MM

func (*MM) BeginBlock

func (m *MM) BeginBlock() func(ctx context.Context) error

BeginBlock runs the begin-block logic of all modules

func (*MM) DefaultGenesis

func (m *MM) DefaultGenesis() map[string]json.RawMessage

DefaultGenesis provides default genesis information for all modules

func (*MM) EndBlock

func (m *MM) EndBlock() (endBlockFunc func(ctx context.Context) error, valUpdateFunc func(ctx context.Context) ([]appmodulev2.ValidatorUpdate, error))

EndBlock runs the end-block logic of all modules and tx validator updates

func (*MM) ExportGenesisForModules

func (m *MM) ExportGenesisForModules(
	ctx context.Context,
	modulesToExport ...string,
) (map[string]json.RawMessage, error)

ExportGenesisForModules performs export genesis functionality for modules

func (*MM) InitGenesisJSON

func (m *MM) InitGenesisJSON(
	ctx context.Context,
	genesisData map[string]json.RawMessage,
	txHandler func(json.RawMessage) error,
) error

InitGenesisJSON performs init genesis functionality for modules from genesis data in JSON format

func (*MM) Modules

func (m *MM) Modules() map[string]appmodulev2.AppModule

Modules returns the modules registered in the module manager

func (*MM) PreBlocker

func (m *MM) PreBlocker() func(ctx context.Context, txs []transaction.Tx) error

PreBlocker runs the pre-block logic of all modules

func (*MM) RegisterInterfaces

func (m *MM) RegisterInterfaces(registry registry.InterfaceRegistrar)

RegisterInterfaces registers all module interface types

func (*MM) RegisterLegacyAminoCodec

func (m *MM) RegisterLegacyAminoCodec(cdc legacy.Amino)

RegisterLegacyAminoCodec registers all module codecs

func (*MM) RegisterServices

func (m *MM) RegisterServices(app *App) error

RegisterServices registers all module services.

func (*MM) RunMigrations

func (m *MM) RunMigrations(ctx context.Context, fromVM appmodulev2.VersionMap) (appmodulev2.VersionMap, error)

TODO write as descriptive godoc as module manager v1. TODO include feedback from https://github.com/cosmos/cosmos-sdk/issues/15120

func (*MM) TxValidators

func (m *MM) TxValidators() func(ctx context.Context, tx transaction.Tx) error

TxValidators validates incoming transactions

func (*MM) ValidateGenesis

func (m *MM) ValidateGenesis(genesisData map[string]json.RawMessage) error

ValidateGenesis performs genesis state validation for all modules

type Store

type Store interface {
	// GetLatestVersion returns the latest version that consensus has been made on
	GetLatestVersion() (uint64, error)
	// StateLatest returns a readonly view over the latest
	// committed state of the store. Alongside the version
	// associated with it.
	StateLatest() (uint64, store.ReaderMap, error)

	// StateAt returns a readonly view over the provided
	// state. Must error when the version does not exist.
	StateAt(version uint64) (store.ReaderMap, error)

	Commit(changeset *store.Changeset) (store.Hash, error)

	// Query is a key/value query directly to the underlying database. This skips the appmanager
	Query(storeKey []byte, version uint64, key []byte, prove bool) (storev2.QueryResult, error)

	// GetStateStorage returns the SS backend.
	GetStateStorage() storev2.VersionedDatabase

	// GetStateCommitment returns the SC backend.
	GetStateCommitment() storev2.Committer

	// LoadVersion loads the RootStore to the given version.
	LoadVersion(version uint64) error

	// LoadLatestVersion behaves identically to LoadVersion except it loads the
	// latest version implicitly.
	LoadLatestVersion() error

	LastCommitID() (proof.CommitID, error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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