staking

package
v0.2.2-beta Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2021 License: GPL-3.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultValue = []byte{0x01} // Value to store in CacheCheckpoint and CacheCheckpointACK & ValidatorSetChange Flag

	ValidatorsKey          = []byte{0x21} // prefix for each key to a validator
	ValidatorMapKey        = []byte{0x22} // prefix for each key for validator map
	CurrentValidatorSetKey = []byte{0x23} // Key to store current validator set
	StakingSequenceKey     = []byte{0x24} // prefix for each key for staking sequence map
)

Functions

func ExportGenesis

func ExportGenesis(ctx sdk.Context, keeper Keeper) types.GenesisState

ExportGenesis returns a GenesisState for a given context and keeper.

func GetStakingSequenceKey

func GetStakingSequenceKey(sequence string) []byte

GetStakingSequenceKey returns staking sequence key

func GetValidatorKey

func GetValidatorKey(address []byte) []byte

GetValidatorKey drafts the validator key for addresses

func GetValidatorMapKey

func GetValidatorMapKey(address []byte) []byte

GetValidatorMapKey returns validator map

func HandleMsgSignerUpdate

func HandleMsgSignerUpdate(ctx sdk.Context, msg types.MsgSignerUpdate, k Keeper, contractCaller helper.IContractCaller) sdk.Result

HandleMsgSignerUpdate handles signer update message

func HandleMsgStakeUpdate

func HandleMsgStakeUpdate(ctx sdk.Context, msg types.MsgStakeUpdate, k Keeper, contractCaller helper.IContractCaller) sdk.Result

HandleMsgStakeUpdate handles stake update message

func HandleMsgValidatorExit

func HandleMsgValidatorExit(ctx sdk.Context, msg types.MsgValidatorExit, k Keeper, contractCaller helper.IContractCaller) sdk.Result

HandleMsgValidatorExit handle msg validator exit

func HandleMsgValidatorJoin

func HandleMsgValidatorJoin(ctx sdk.Context, msg types.MsgValidatorJoin, k Keeper, contractCaller helper.IContractCaller) sdk.Result

HandleMsgValidatorJoin msg validator join

func InitGenesis

func InitGenesis(ctx sdk.Context, keeper Keeper, data types.GenesisState)

InitGenesis sets distribution information for genesis.

func NewHandler

func NewHandler(k Keeper, contractCaller helper.IContractCaller) sdk.Handler

NewHandler new handler

func NewPostTxHandler added in v0.1.7

func NewPostTxHandler(k Keeper, contractCaller helper.IContractCaller) hmTypes.PostTxHandler

NewPostTxHandler returns a side handler for "bank" type messages.

func NewQuerier

func NewQuerier(keeper Keeper, contractCaller helper.IContractCaller) sdk.Querier

NewQuerier returns querier for staking Rest endpoints

func NewSideTxHandler added in v0.1.7

func NewSideTxHandler(k Keeper, contractCaller helper.IContractCaller) hmTypes.SideTxHandler

NewSideTxHandler returns a side handler for "staking" type messages.

func PostHandleMsgSignerUpdate added in v0.1.7

func PostHandleMsgSignerUpdate(ctx sdk.Context, k Keeper, msg types.MsgSignerUpdate, sideTxResult abci.SideTxResultType) sdk.Result

PostHandleMsgSignerUpdate handles signer update message

func PostHandleMsgStakeUpdate added in v0.1.7

func PostHandleMsgStakeUpdate(ctx sdk.Context, k Keeper, msg types.MsgStakeUpdate, sideTxResult abci.SideTxResultType) sdk.Result

PostHandleMsgStakeUpdate handles stake update message

func PostHandleMsgValidatorExit added in v0.1.7

func PostHandleMsgValidatorExit(ctx sdk.Context, k Keeper, msg types.MsgValidatorExit, sideTxResult abci.SideTxResultType) sdk.Result

PostHandleMsgValidatorExit handle msg validator exit

func PostHandleMsgValidatorJoin added in v0.1.7

func PostHandleMsgValidatorJoin(ctx sdk.Context, k Keeper, msg types.MsgValidatorJoin, sideTxResult abci.SideTxResultType) sdk.Result

PostHandleMsgValidatorJoin msg validator join

func SideHandleMsgSignerUpdate added in v0.1.7

func SideHandleMsgSignerUpdate(ctx sdk.Context, msg types.MsgSignerUpdate, k Keeper, contractCaller helper.IContractCaller) (result abci.ResponseDeliverSideTx)

SideHandleMsgSignerUpdate handles signer update message

func SideHandleMsgStakeUpdate added in v0.1.7

func SideHandleMsgStakeUpdate(ctx sdk.Context, msg types.MsgStakeUpdate, k Keeper, contractCaller helper.IContractCaller) (result abci.ResponseDeliverSideTx)

SideHandleMsgStakeUpdate handles stake update message

func SideHandleMsgValidatorExit added in v0.1.7

func SideHandleMsgValidatorExit(ctx sdk.Context, msg types.MsgValidatorExit, k Keeper, contractCaller helper.IContractCaller) (result abci.ResponseDeliverSideTx)

SideHandleMsgValidatorExit handle side msg validator exit

func SideHandleMsgValidatorJoin added in v0.1.7

func SideHandleMsgValidatorJoin(ctx sdk.Context, msg types.MsgValidatorJoin, k Keeper, contractCaller helper.IContractCaller) (result abci.ResponseDeliverSideTx)

SideHandleMsgValidatorJoin side msg validator join

Types

type AppModule

type AppModule struct {
	AppModuleBasic
	// contains filtered or unexported fields
}

AppModule implements an application module for the supply module.

func NewAppModule

func NewAppModule(keeper Keeper, contractCaller helper.IContractCaller) AppModule

NewAppModule creates a new AppModule object

func (AppModule) BeginBlock

func (AppModule) BeginBlock(_ sdk.Context, _ abci.RequestBeginBlock)

BeginBlock returns the begin blocker for the auth module.

func (AppModule) EndBlock

EndBlock returns the end blocker for the auth module. It returns no validator updates.

func (AppModule) ExportGenesis

func (am AppModule) ExportGenesis(ctx sdk.Context) json.RawMessage

ExportGenesis returns the exported genesis state as raw bytes for the auth module.

func (AppModule) GenerateGenesisState added in v0.1.7

func (AppModule) GenerateGenesisState(simState *hmModule.SimulationState)

GenerateGenesisState creates a randomized GenState of the Staking module

func (AppModule) InitGenesis

func (am AppModule) InitGenesis(ctx sdk.Context, data json.RawMessage) []abci.ValidatorUpdate

InitGenesis performs genesis initialization for the auth module. It returns no validator updates.

func (AppModule) Name

func (AppModule) Name() string

Name returns the module's name.

func (AppModule) NewHandler

func (am AppModule) NewHandler() sdk.Handler

NewHandler returns an sdk.Handler for the module.

func (AppModule) NewPostTxHandler added in v0.1.7

func (am AppModule) NewPostTxHandler() hmTypes.PostTxHandler

NewPostTxHandler side tx handler

func (AppModule) NewQuerierHandler

func (am AppModule) NewQuerierHandler() sdk.Querier

NewQuerierHandler returns the auth module sdk.Querier.

func (AppModule) NewSideTxHandler added in v0.1.7

func (am AppModule) NewSideTxHandler() hmTypes.SideTxHandler

func (AppModule) ProposalContents added in v0.1.7

func (AppModule) ProposalContents(simState hmModule.SimulationState) []simTypes.WeightedProposalContent

ProposalContents doesn't return any content functions.

func (AppModule) QuerierRoute

func (AppModule) QuerierRoute() string

QuerierRoute returns the staking module's querier route name.

func (AppModule) RandomizedParams added in v0.1.7

func (AppModule) RandomizedParams(r *rand.Rand) []simTypes.ParamChange

RandomizedParams creates randomized param changes for the simulator.

func (AppModule) RegisterInvariants

func (AppModule) RegisterInvariants(_ sdk.InvariantRegistry)

RegisterInvariants performs a no-op.

func (AppModule) RegisterStoreDecoder added in v0.1.7

func (AppModule) RegisterStoreDecoder(sdr hmModule.StoreDecoderRegistry)

RegisterStoreDecoder registers a decoder for chainmanager module's types

func (AppModule) Route

func (AppModule) Route() string

Route returns the message routing key for the module.

func (AppModule) WeightedOperations added in v0.1.7

WeightedOperations doesn't return any chainmanager module operation.

type AppModuleBasic

type AppModuleBasic struct{}

AppModuleBasic defines the basic application module used by the auth module.

func (AppModuleBasic) DefaultGenesis

func (AppModuleBasic) DefaultGenesis() json.RawMessage

DefaultGenesis returns default genesis state as raw bytes for the auth module.

func (AppModuleBasic) GetQueryCmd

func (AppModuleBasic) GetQueryCmd(cdc *codec.Codec) *cobra.Command

GetQueryCmd returns the root query command for the auth module.

func (AppModuleBasic) GetTxCmd

func (AppModuleBasic) GetTxCmd(cdc *codec.Codec) *cobra.Command

GetTxCmd returns the root tx command for the auth module.

func (AppModuleBasic) Name

func (AppModuleBasic) Name() string

Name returns the auth module's name.

func (AppModuleBasic) RegisterCodec

func (AppModuleBasic) RegisterCodec(cdc *codec.Codec)

RegisterCodec registers the auth module's types for the given codec.

func (AppModuleBasic) RegisterRESTRoutes

func (AppModuleBasic) RegisterRESTRoutes(ctx context.CLIContext, rtr *mux.Router)

RegisterRESTRoutes registers the REST routes for the auth module.

func (AppModuleBasic) ValidateGenesis

func (AppModuleBasic) ValidateGenesis(bz json.RawMessage) error

ValidateGenesis performs genesis state validation for the auth module.

func (AppModuleBasic) VerifyGenesis

func (AppModuleBasic) VerifyGenesis(bz map[string]json.RawMessage) error

VerifyGenesis performs verification on auth module state.

type Keeper

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

Keeper stores all related data

func NewKeeper

func NewKeeper(
	cdc *codec.Codec,
	storeKey sdk.StoreKey,
	paramSpace subspace.Subspace,
	codespace sdk.CodespaceType,
	chainKeeper chainmanager.Keeper,
	moduleCommunicator ModuleCommunicator,
) Keeper

NewKeeper create new keeper

func (*Keeper) AddValidator

func (k *Keeper) AddValidator(ctx sdk.Context, validator hmTypes.Validator) error

AddValidator adds validator indexed with address

func (*Keeper) AddValidatorSigningInfo added in v0.1.7

func (k *Keeper) AddValidatorSigningInfo(ctx sdk.Context, valID hmTypes.ValidatorID, valSigningInfo hmTypes.ValidatorSigningInfo) error

Slashing api's AddValidatorSigningInfo creates a signing info for validator

func (Keeper) Codespace

func (k Keeper) Codespace() sdk.CodespaceType

Codespace returns the codespace

func (*Keeper) GetActiveValidatorInfo

func (k *Keeper) GetActiveValidatorInfo(ctx sdk.Context, address []byte) (validator hmTypes.Validator, err error)

GetActiveValidatorInfo returns active validator

func (*Keeper) GetAllValidators

func (k *Keeper) GetAllValidators(ctx sdk.Context) (validators []*hmTypes.Validator)

GetAllValidators returns all validators

func (*Keeper) GetCurrentProposer

func (k *Keeper) GetCurrentProposer(ctx sdk.Context) *hmTypes.Validator

GetCurrentProposer returns current proposer

func (*Keeper) GetCurrentValidators

func (k *Keeper) GetCurrentValidators(ctx sdk.Context) (validators []hmTypes.Validator)

GetCurrentValidators returns all validators who are in validator set

func (*Keeper) GetLastUpdated

func (k *Keeper) GetLastUpdated(ctx sdk.Context, valID hmTypes.ValidatorID) (updatedAt string, found bool)

GetLastUpdated get last updated at for validator

func (*Keeper) GetNextProposer

func (k *Keeper) GetNextProposer(ctx sdk.Context) *hmTypes.Validator

GetNextProposer returns next proposer

func (*Keeper) GetSignerFromValidatorID

func (k *Keeper) GetSignerFromValidatorID(ctx sdk.Context, valID hmTypes.ValidatorID) (common.Address, bool)

GetSignerFromValidatorID get signer address from validator ID

func (*Keeper) GetSpanEligibleValidators

func (k *Keeper) GetSpanEligibleValidators(ctx sdk.Context) (validators []hmTypes.Validator)

GetSpanEligibleValidators returns current validators who are not getting deactivated in between next span

func (*Keeper) GetStakingSequences

func (k *Keeper) GetStakingSequences(ctx sdk.Context) (sequences []string)

GetStakingSequences checks if Staking already exists

func (*Keeper) GetTotalPower added in v0.1.7

func (k *Keeper) GetTotalPower(ctx sdk.Context) (totalPower int64)

func (*Keeper) GetValidatorFromValID

func (k *Keeper) GetValidatorFromValID(ctx sdk.Context, valID hmTypes.ValidatorID) (validator hmTypes.Validator, ok bool)

GetValidatorFromValID returns signer from validator ID

func (*Keeper) GetValidatorInfo

func (k *Keeper) GetValidatorInfo(ctx sdk.Context, address []byte) (validator hmTypes.Validator, err error)

GetValidatorInfo returns validator

func (*Keeper) GetValidatorSet

func (k *Keeper) GetValidatorSet(ctx sdk.Context) (validatorSet hmTypes.ValidatorSet)

GetValidatorSet returns current Validator Set from store

func (*Keeper) HasStakingSequence

func (k *Keeper) HasStakingSequence(ctx sdk.Context, sequence string) bool

HasStakingSequence checks if staking sequence already exists

func (*Keeper) IncrementAccum

func (k *Keeper) IncrementAccum(ctx sdk.Context, times int)

IncrementAccum increments accum for validator set by n times and replace validator set in store

func (*Keeper) IsCurrentValidatorByAddress

func (k *Keeper) IsCurrentValidatorByAddress(ctx sdk.Context, address []byte) bool

IsCurrentValidatorByAddress check if validator is in current validator set by signer address

func (*Keeper) IterateCurrentValidatorsAndApplyFn

func (k *Keeper) IterateCurrentValidatorsAndApplyFn(ctx sdk.Context, f func(validator *hmTypes.Validator) bool)

IterateCurrentValidatorsAndApplyFn iterate through current validators

func (*Keeper) IterateStakingSequencesAndApplyFn

func (k *Keeper) IterateStakingSequencesAndApplyFn(ctx sdk.Context, f func(sequence string) error)

IterateStakingSequencesAndApplyFn interate validators and apply the given function.

func (*Keeper) IterateValidatorsAndApplyFn

func (k *Keeper) IterateValidatorsAndApplyFn(ctx sdk.Context, f func(validator hmTypes.Validator) error)

IterateValidatorsAndApplyFn interate validators and apply the given function.

func (Keeper) Logger

func (k Keeper) Logger(ctx sdk.Context) log.Logger

Logger returns a module-specific logger

func (*Keeper) SetStakingSequence

func (k *Keeper) SetStakingSequence(ctx sdk.Context, sequence string)

SetStakingSequence sets staking sequence

func (*Keeper) SetValidatorIDToSignerAddr

func (k *Keeper) SetValidatorIDToSignerAddr(ctx sdk.Context, valID hmTypes.ValidatorID, signerAddr hmTypes.HeimdallAddress)

SetValidatorIDToSignerAddr sets mapping for validator ID to signer address

func (*Keeper) Slash added in v0.1.7

func (k *Keeper) Slash(ctx sdk.Context, valSlashingInfo hmTypes.ValidatorSlashingInfo) error

UpdatePower updates validator with signer and pubkey + validator => signer map

func (*Keeper) Unjail added in v0.1.7

func (k *Keeper) Unjail(ctx sdk.Context, valID hmTypes.ValidatorID)

unjail a validator

func (*Keeper) UpdateSigner

func (k *Keeper) UpdateSigner(ctx sdk.Context, newSigner hmTypes.HeimdallAddress, newPubkey hmTypes.PubKey, prevSigner hmTypes.HeimdallAddress) error

UpdateSigner updates validator with signer and pubkey + validator => signer map

func (*Keeper) UpdateValidatorSetInStore

func (k *Keeper) UpdateValidatorSetInStore(ctx sdk.Context, newValidatorSet hmTypes.ValidatorSet) error

UpdateValidatorSetInStore adds validator set to store

type ModuleCommunicator

type ModuleCommunicator interface {
	GetACKCount(ctx sdk.Context) uint64
	SetCoins(ctx sdk.Context, addr hmTypes.HeimdallAddress, amt sdk.Coins) sdk.Error
	GetCoins(ctx sdk.Context, addr hmTypes.HeimdallAddress) sdk.Coins
	SendCoins(ctx sdk.Context, from hmTypes.HeimdallAddress, to hmTypes.HeimdallAddress, amt sdk.Coins) sdk.Error
	CreateValiatorSigningInfo(ctx sdk.Context, valID hmTypes.ValidatorID, valSigningInfo hmTypes.ValidatorSigningInfo)
}

ModuleCommunicator manages different module interaction

Directories

Path Synopsis
client
cli

Jump to

Keyboard shortcuts

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