slashing

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2020 License: GPL-3.0 Imports: 32 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BeginBlocker

func BeginBlocker(ctx sdk.Context, req abci.RequestBeginBlock, k Keeper)

func ExportGenesis

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

ExportGenesis writes the current store values to a genesis file, which can be imported again with InitGenesis

func InitGenesis

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

InitGenesis initialize default parameters and the keeper's address to pubkey map

func NewHandler

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

NewHandler creates an sdk.Handler for all the slashing type messages

func NewPostTxHandler

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

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

func NewQuerier

func NewQuerier(k Keeper) sdk.Querier

NewQuerier creates a new querier for slashing clients.

func NewSideTxHandler

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

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

func PostHandleMsgTick

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

PostHandleMsgTick - handles slashing of validators 1. copy slashBuffer into latestTickData 2. flush slashBuffer, totalSlashedAmount 3. iterate and reduce the power of slashed validators. 4. Also update the jailStatus of Validator 5. emit event TickConfirmation

func PostHandleMsgTickAck

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

PostHandleMsgTickAck - handles slashing of validators

handleMsgTickAck - handle msg tick ack event
1. validate the tx hash in the event
2. flush the last tick slashing info

func PostHandleMsgUnjail

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

Validators must submit a transaction to unjail itself after having been jailed (and thus unbonded) for downtime

func SideHandleMsgTick

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

SideHandleMsgTick handles MsgTick message for external call

func SideHandleMsgTickAck

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

SideHandleMsgTick handles MsgTick message for external call

func SideHandleMsgUnjail

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

SideHandleMsgUnjail handles MsgUnjail message for external call

Types

type AppModule

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

AppModule implements an application module for the slashing module.

func NewAppModule

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

NewAppModule creates a new AppModule object

func (AppModule) BeginBlock

func (am AppModule) BeginBlock(ctx sdk.Context, req abci.RequestBeginBlock)

BeginBlock returns the begin blocker for the slashing module.

func (AppModule) EndBlock

EndBlock returns the end blocker for the slashing 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

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

GenerateGenesisState creates a randomized GenState of the auth module

func (AppModule) InitGenesis

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

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

func (AppModule) Name

func (AppModule) Name() string

Name returns the slashing module's name.

func (AppModule) NewHandler

func (am AppModule) NewHandler() sdk.Handler

NewHandler returns an sdk.Handler for the slashing module.

func (AppModule) NewPostTxHandler

func (am AppModule) NewPostTxHandler() hmTypes.PostTxHandler

NewPostTxHandler side tx handler

func (AppModule) NewQuerierHandler

func (am AppModule) NewQuerierHandler() sdk.Querier

NewQuerierHandler returns the slashing module sdk.Querier.

func (AppModule) NewSideTxHandler

func (am AppModule) NewSideTxHandler() hmTypes.SideTxHandler

NewSideTxHandler side tx handler

func (AppModule) ProposalContents

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

ProposalContents doesn't return any content functions for governance proposals.

func (AppModule) QuerierRoute

func (AppModule) QuerierRoute() string

QuerierRoute returns the slashing module's querier route name.

func (AppModule) RandomizedParams

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

RandomizedParams creates randomized auth param changes for the simulator.

func (AppModule) RegisterInvariants

func (am AppModule) RegisterInvariants(_ sdk.InvariantRegistry)

RegisterInvariants registers the slashing module invariants.

func (AppModule) RegisterStoreDecoder

func (AppModule) RegisterStoreDecoder(sdr hmModule.StoreDecoderRegistry)

RegisterStoreDecoder registers a decoder for auth module's types

func (AppModule) Route

func (AppModule) Route() string

Route returns the message routing key for the slashing module.

func (AppModule) WeightedOperations

WeightedOperations doesn't return any auth module operation.

type AppModuleBasic

type AppModuleBasic struct{}

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

func (AppModuleBasic) DefaultGenesis

func (AppModuleBasic) DefaultGenesis() json.RawMessage

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

func (AppModuleBasic) GetQueryCmd

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

GetQueryCmd returns no root query command for the slashing module.

func (AppModuleBasic) GetTxCmd

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

GetTxCmd returns the root tx command for the slashing module.

func (AppModuleBasic) Name

func (AppModuleBasic) Name() string

Name returns the slashing module's name.

func (AppModuleBasic) RegisterCodec

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

RegisterCodec registers the slashing 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 slashing module.

func (AppModuleBasic) ValidateGenesis

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

ValidateGenesis performs genesis state validation for the slashing module.

func (AppModuleBasic) VerifyGenesis

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

VerifyGenesis performs verification on slashing module state.

type Keeper

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

Keeper of the slashing store

func NewKeeper

func NewKeeper(cdc *codec.Codec, key sdk.StoreKey, sk staking.Keeper, paramSpace subspace.Subspace, codespace sdk.CodespaceType, chainKeeper chainmanager.Keeper) Keeper

NewKeeper creates a slashing keeper

func (Keeper) Codespace

func (k Keeper) Codespace() sdk.CodespaceType

Codespace returns the codespace

func (*Keeper) CopyBufferValSlashingInfosToTickData

func (k *Keeper) CopyBufferValSlashingInfosToTickData(ctx sdk.Context) error

CopyValSlashingInfosToTickData copies all validator slashing infos in buffer to tickdata

func (*Keeper) FlushBufferValSlashingInfos

func (k *Keeper) FlushBufferValSlashingInfos(ctx sdk.Context) error

FlushBufferValSlashingInfos removes all validator slashing infos in buffer

func (*Keeper) FlushTickValSlashingInfos

func (k *Keeper) FlushTickValSlashingInfos(ctx sdk.Context) error

FlushTickValSlashingInfos removes all validator slashing infos in last Tick

func (*Keeper) FlushTotalSlashedAmount

func (k *Keeper) FlushTotalSlashedAmount(ctx sdk.Context)

FlushBufferValSlashingInfos removes all validator slashing infos in buffer

func (*Keeper) GetBufferValSlashingInfo

func (k *Keeper) GetBufferValSlashingInfo(ctx sdk.Context, valId hmTypes.ValidatorID) (info hmTypes.ValidatorSlashingInfo, found bool)

GetBufferValSlashingInfo gets the validator slashing info for a validator ID key

func (*Keeper) GetBufferValSlashingInfos

func (k *Keeper) GetBufferValSlashingInfos(ctx sdk.Context) (valSlashingInfos []*hmTypes.ValidatorSlashingInfo, err error)

GetBufferValSlashingInfos returns all validator slashing infos in buffer

func (*Keeper) GetParams

func (k *Keeper) GetParams(ctx sdk.Context) (params types.Params)

GetParams gets the slashing module's parameters.

func (*Keeper) GetSlashingSequences

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

GetSlashingSequences checks if Slashing already exists

func (Keeper) GetTickCount

func (k Keeper) GetTickCount(ctx sdk.Context) uint64

GetTickCount returns current Tick count

func (*Keeper) GetTickValSlashingInfo

func (k *Keeper) GetTickValSlashingInfo(ctx sdk.Context, valId hmTypes.ValidatorID) (info hmTypes.ValidatorSlashingInfo, found bool)

GetTickValSlashingInfo gets the validator slashing info for a validator ID key

func (*Keeper) GetTickValSlashingInfos

func (k *Keeper) GetTickValSlashingInfos(ctx sdk.Context) (valSlashingInfos []*hmTypes.ValidatorSlashingInfo, err error)

GetTickValSlashingInfos returns all validator slashing infos in tick

func (*Keeper) GetTotalSlashedAmount

func (k *Keeper) GetTotalSlashedAmount(ctx sdk.Context) uint64

func (*Keeper) GetValidatorMissedBlockBitArray

func (k *Keeper) GetValidatorMissedBlockBitArray(ctx sdk.Context, valID hmTypes.ValidatorID, index int64) bool

GetValidatorMissedBlockBitArray gets the bit for the missed blocks array

func (*Keeper) GetValidatorSigningInfo

func (k *Keeper) GetValidatorSigningInfo(ctx sdk.Context, valID hmTypes.ValidatorID) (info hmTypes.ValidatorSigningInfo, found bool)

GetValidatorSigningInfo retruns the ValidatorSigningInfo for a specific validator ConsAddress

func (*Keeper) HandleDoubleSign

func (k *Keeper) HandleDoubleSign(ctx sdk.Context, evidence types.Equivocation) error

HandleDoubleSign implements an equivocation evidence handler. Assuming the evidence is valid, the validator committing the misbehavior will be slashed, jailed

The evidence is considered invalid if: - the evidence is too old - the validator does not exist - the signing info does not exist (will panic) - is already jailed

func (*Keeper) HandleValidatorSignature

func (k *Keeper) HandleValidatorSignature(ctx sdk.Context, addr []byte, power int64, signed bool) error

HandleValidatorSignature handles a validator signature, must be called once per validator per block.

func (*Keeper) HasSlashingSequence

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

HasSlashingSequence checks if Slashing sequence already exists

func (*Keeper) HasValidatorSigningInfo

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

HasValidatorSigningInfo returns if a given validator has signing information persited.

func (Keeper) IncrementTickCount

func (k Keeper) IncrementTickCount(ctx sdk.Context)

IncrementTickCount updates Tick count by 1

func (*Keeper) IsJailLimitExceeded

func (k *Keeper) IsJailLimitExceeded(ctx sdk.Context, valSlashingInfo hmTypes.ValidatorSlashingInfo) bool

IsJailLimitExceeded - if jail limit is exceeded or not

func (*Keeper) IsSlashedLimitExceeded

func (k *Keeper) IsSlashedLimitExceeded(ctx sdk.Context) bool

IsSlashedLimitExceeded - if total slashed amount exceeded slash limit or not

func (*Keeper) IterateBufferValSlashingInfos

func (k *Keeper) IterateBufferValSlashingInfos(ctx sdk.Context,
	handler func(slashingInfo hmTypes.ValidatorSlashingInfo) (stop bool))

IterateBufferValSlashingInfos iterates over the stored ValidatorSlashingInfo

func (*Keeper) IterateBufferValSlashingInfosAndApplyFn

func (k *Keeper) IterateBufferValSlashingInfosAndApplyFn(ctx sdk.Context, f func(slashingInfo hmTypes.ValidatorSlashingInfo) error) error

IterateBufferValSlashingInfosAndApplyFn interate ValidatorSlashingInfo and apply the given function.

func (*Keeper) IterateSlashingSequencesAndApplyFn

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

IterateSlashingSequencesAndApplyFn interate validators and apply the given function.

func (*Keeper) IterateTickValSlashingInfos

func (k *Keeper) IterateTickValSlashingInfos(ctx sdk.Context,
	handler func(slashingInfo hmTypes.ValidatorSlashingInfo) (stop bool))

IterateTickValSlashingInfos iterates over the stored ValidatorSlashingInfo

func (*Keeper) IterateTickValSlashingInfosAndApplyFn

func (k *Keeper) IterateTickValSlashingInfosAndApplyFn(ctx sdk.Context, f func(slashingInfo hmTypes.ValidatorSlashingInfo) error) error

IterateTickValSlashingInfosAndApplyFn interate ValidatorSlashingInfo and apply the given function.

func (*Keeper) IterateValidatorMissedBlockBitArray

func (k *Keeper) IterateValidatorMissedBlockBitArray(ctx sdk.Context,
	valID hmTypes.ValidatorID, handler func(index int64, missed bool) (stop bool))

IterateValidatorMissedBlockBitArray iterates over the signed blocks window and performs a callback function

func (*Keeper) IterateValidatorSigningInfos

func (k *Keeper) IterateValidatorSigningInfos(ctx sdk.Context,
	handler func(valID hmTypes.ValidatorID, info hmTypes.ValidatorSigningInfo) (stop bool))

IterateValidatorSigningInfos iterates over the stored ValidatorSigningInfo

func (Keeper) Logger

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

Logger returns a module-specific logger.

func (*Keeper) MinSignedPerWindow

func (k *Keeper) MinSignedPerWindow(ctx sdk.Context) int64

MinSignedPerWindow - minimum blocks signed per window

func (*Keeper) RemoveBufferValSlashingInfo

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

RemoveBufferValSlashingInfo removes the validator slashing info for a validator ID key

func (*Keeper) RemoveTickValSlashingInfo

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

RemoveTickValSlashingInfo removes the validator slashing info for a validator ID key

func (*Keeper) SetBufferValSlashingInfo

func (k *Keeper) SetBufferValSlashingInfo(ctx sdk.Context, valID hmTypes.ValidatorID, info hmTypes.ValidatorSlashingInfo)

SetBufferValSlashingInfo sets the validator slashing info to a validator ID key

func (*Keeper) SetParams

func (k *Keeper) SetParams(ctx sdk.Context, params types.Params)

SetParams sets the slashing module's parameters.

func (*Keeper) SetSlashingSequence

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

SetSlashingSequence sets Slashing sequence

func (*Keeper) SetTickValSlashingInfo

func (k *Keeper) SetTickValSlashingInfo(ctx sdk.Context, valID hmTypes.ValidatorID, info hmTypes.ValidatorSlashingInfo)

SetTickValSlashingInfo sets the validator slashing info to a validator ID key

func (*Keeper) SetValidatorMissedBlockBitArray

func (k *Keeper) SetValidatorMissedBlockBitArray(ctx sdk.Context, valID hmTypes.ValidatorID, index int64, missed bool)

SetValidatorMissedBlockBitArray sets the bit that checks if the validator has missed a block in the current window

func (*Keeper) SetValidatorSigningInfo

func (k *Keeper) SetValidatorSigningInfo(ctx sdk.Context, valID hmTypes.ValidatorID, info hmTypes.ValidatorSigningInfo)

SetValidatorSigningInfo sets the validator signing info to a consensus address key

func (*Keeper) SlashAndJailTickValSlashingInfos

func (k *Keeper) SlashAndJailTickValSlashingInfos(ctx sdk.Context) error

SlashAndJailTickValSlashingInfos reduces power of all validator slashing infos in tick data

func (*Keeper) SlashInterim

func (k *Keeper) SlashInterim(ctx sdk.Context, valID hmTypes.ValidatorID, slashPercent sdk.Dec) uint64

SlashInterim - Add slash amounts to a buffer and emit <slash-limit> event if exceeded

func (Keeper) UpdateTickCountWithValue

func (k Keeper) UpdateTickCountWithValue(ctx sdk.Context, value uint64)

UpdateTickCountWithValue updates TickCount with value

func (*Keeper) UpdateTotalSlashedAmount

func (k *Keeper) UpdateTotalSlashedAmount(ctx sdk.Context, slashedAmount uint64)

Directories

Path Synopsis
client
cli
noalias
noalias

Jump to

Keyboard shortcuts

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