module

package
v2.1.2-rc0 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

README

app/module

This directory contains a module manager (Manager) and configurator (Configurator) that enables the application to add or remove modules during app version changes.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewVersionedIBCModule

func NewVersionedIBCModule(
	wrappedModule, nextModule porttypes.IBCModule,
	fromVersion, toVersion uint64,
) porttypes.IBCModule

Types

type Configurator

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

Configurator is a struct used at startup to register all the message and query servers for all modules. It allows the module to register any migrations from one consensus version of the module to the next. Finally it maps all the messages to the app versions that they are accepted in. This then gets used in the antehandler to prevent users from submitting messages that can not yet be executed.

func NewConfigurator

func NewConfigurator(cdc codec.Codec, msgServer, queryServer pbgrpc.Server) Configurator

NewConfigurator returns a new Configurator instance.

func (Configurator) GetAcceptedMessages

func (c Configurator) GetAcceptedMessages() map[uint64]map[string]struct{}

GetAcceptedMessages returns the accepted messages for all versions. acceptedMessages is a map from appVersion -> msgTypeURL -> struct{}.

func (Configurator) MsgServer

func (c Configurator) MsgServer() pbgrpc.Server

MsgServer implements the Configurator.MsgServer method.

func (Configurator) QueryServer

func (c Configurator) QueryServer() pbgrpc.Server

QueryServer implements the Configurator.QueryServer method.

func (Configurator) RegisterMigration

func (c Configurator) RegisterMigration(moduleName string, fromVersion uint64, handler module.MigrationHandler) error

RegisterMigration implements the Configurator.RegisterMigration method.

func (*Configurator) WithVersions

func (c *Configurator) WithVersions(fromVersion, toVersion uint64) module.Configurator

type Manager

type Manager struct {
	OrderInitGenesis   []string
	OrderExportGenesis []string
	OrderBeginBlockers []string
	OrderEndBlockers   []string
	OrderMigrations    []string
	// contains filtered or unexported fields
}

Manager defines a module manager that provides the high level utility for managing and executing operations for a group of modules. This implementation was originally inspired by the module manager defined in Cosmos SDK but this implemention maps the state machine version to different versions of the module. It also provides a way to run migrations between different versions of a module.

func NewManager

func NewManager(modules []VersionedModule) (*Manager, error)

NewManager returns a new Manager object.

func (*Manager) AssertMatchingModules

func (m *Manager) AssertMatchingModules(basicModuleManager sdkmodule.BasicManager) error

assertMatchingModules performs a sanity check that the basic module manager contains all the same modules present in the module manager

func (*Manager) BeginBlock

BeginBlock performs begin block functionality for all modules. It creates a child context with an event manager to aggregate events emitted from all modules.

func (*Manager) EndBlock

EndBlock performs end block functionality for all modules. It creates a child context with an event manager to aggregate events emitted from all modules.

func (*Manager) ExportGenesis

func (m *Manager) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec, version uint64) map[string]json.RawMessage

ExportGenesis performs export genesis functionality for the modules supported in a particular version.

func (*Manager) GetVersionMap

func (m *Manager) GetVersionMap(version uint64) sdkmodule.VersionMap

GetVersionMap gets consensus version from all modules

func (*Manager) InitGenesis

func (m *Manager) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, genesisData map[string]json.RawMessage, appVersion uint64) abci.ResponseInitChain

InitGenesis performs init genesis functionality for modules. Exactly one module must return a non-empty validator set update to correctly initialize the chain.

func (*Manager) ModuleNames

func (m *Manager) ModuleNames(version uint64) []string

ModuleNames returns the list of module names that are supported for a particular version in no particular order.

func (*Manager) RegisterInvariants

func (m *Manager) RegisterInvariants(ir sdk.InvariantRegistry)

RegisterInvariants registers all module invariants.

func (*Manager) RegisterServices

func (m *Manager) RegisterServices(cfg Configurator)

RegisterServices registers all module services.

func (Manager) RunMigrations

func (m Manager) RunMigrations(ctx sdk.Context, cfg sdkmodule.Configurator, fromVersion, toVersion uint64) error

RunMigrations performs in-place store migrations for all modules. This function MUST be called when the state machine changes appVersion

func (*Manager) SetOrderBeginBlockers

func (m *Manager) SetOrderBeginBlockers(moduleNames ...string)

SetOrderBeginBlockers sets the order of begin-blocker calls.

func (*Manager) SetOrderEndBlockers

func (m *Manager) SetOrderEndBlockers(moduleNames ...string)

SetOrderEndBlockers sets the order of end-blocker calls.

func (*Manager) SetOrderExportGenesis

func (m *Manager) SetOrderExportGenesis(moduleNames ...string)

SetOrderExportGenesis sets the order of export genesis calls.

func (*Manager) SetOrderInitGenesis

func (m *Manager) SetOrderInitGenesis(moduleNames ...string)

SetOrderInitGenesis sets the order of init genesis calls.

func (*Manager) SetOrderMigrations

func (m *Manager) SetOrderMigrations(moduleNames ...string)

SetOrderMigrations sets the order of migrations to be run. If not set then migrations will be run with an order defined in `defaultMigrationsOrder`.

func (*Manager) SupportedVersions

func (m *Manager) SupportedVersions() []uint64

SupportedVersions returns all the supported versions for the module manager

type MigrationHandler

type MigrationHandler func(sdk.Context) error

MigrationHandler is the migration function that each module registers.

type VersionedIBCModule

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

func (*VersionedIBCModule) OnAcknowledgementPacket

func (v *VersionedIBCModule) OnAcknowledgementPacket(
	ctx sdk.Context,
	packet channeltypes.Packet,
	acknowledgement []byte,
	relayer sdk.AccAddress,
) error

func (*VersionedIBCModule) OnChanCloseConfirm

func (v *VersionedIBCModule) OnChanCloseConfirm(
	ctx sdk.Context,
	portID,
	channelID string,
) error

func (*VersionedIBCModule) OnChanCloseInit

func (v *VersionedIBCModule) OnChanCloseInit(
	ctx sdk.Context,
	portID,
	channelID string,
) error

func (*VersionedIBCModule) OnChanOpenAck

func (v *VersionedIBCModule) OnChanOpenAck(
	ctx sdk.Context,
	portID,
	channelID string,
	counterpartyChannelID string,
	counterpartyVersion string,
) error

func (*VersionedIBCModule) OnChanOpenConfirm

func (v *VersionedIBCModule) OnChanOpenConfirm(
	ctx sdk.Context,
	portID,
	channelID string,
) error

func (*VersionedIBCModule) OnChanOpenInit

func (v *VersionedIBCModule) OnChanOpenInit(
	ctx sdk.Context,
	order channeltypes.Order,
	connectionHops []string,
	portID string,
	channelID string,
	channelCap *capabilitytypes.Capability,
	counterparty channeltypes.Counterparty,
	version string,
) (string, error)

func (*VersionedIBCModule) OnChanOpenTry

func (v *VersionedIBCModule) OnChanOpenTry(
	ctx sdk.Context,
	order channeltypes.Order,
	connectionHops []string,
	portID,
	channelID string,
	channelCap *capabilitytypes.Capability,
	counterparty channeltypes.Counterparty,
	counterpartyVersion string,
) (version string, err error)

func (*VersionedIBCModule) OnRecvPacket

func (v *VersionedIBCModule) OnRecvPacket(
	ctx sdk.Context,
	packet channeltypes.Packet,
	relayer sdk.AccAddress,
) exported.Acknowledgement

func (*VersionedIBCModule) OnTimeoutPacket

func (v *VersionedIBCModule) OnTimeoutPacket(
	ctx sdk.Context,
	packet channeltypes.Packet,
	relayer sdk.AccAddress,
) error

type VersionedModule

type VersionedModule struct {
	Module sdkmodule.AppModule
	// FromVersion and ToVersion indicate the continuous range of app versions
	// that this particular module is part of. The range is inclusive.
	// FromVersion should not be smaller than ToVersion. 0 is not a valid app
	// version.
	FromVersion, ToVersion uint64
}

Directories

Path Synopsis
Package mock_types is a generated GoMock package.
Package mock_types is a generated GoMock package.

Jump to

Keyboard shortcuts

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