Documentation ¶
Overview ¶
Package types includes important type definitions for slashable objects detected by slasher.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrWrongSize = errors.New("wrong data length for min max span byte array")
ErrWrongSize appears when attempting to use epoch store byte array with size that is not a multiple of spanner encoded length.
var SpannerEncodedLength = uint64(7)
SpannerEncodedLength the byte length of validator span data structure.
Functions ¶
This section is empty.
Types ¶
type DetectionKind ¶
type DetectionKind uint8
DetectionKind defines an enum type that gives us information on the type of slashable offense found when analyzing validator min-max spans.
const ( // DoubleVote denotes a slashable offense in which // a validator cast two conflicting attestations within // the same target epoch. DoubleVote DetectionKind = iota // SurroundVote denotes a slashable offense in which // a validator surrounded or was surrounded by a previous // attestation created by the same validator. SurroundVote )
type DetectionResult ¶
type DetectionResult struct { ValidatorIndex uint64 SlashableEpoch uint64 Kind DetectionKind SigBytes [2]byte }
DetectionResult tells us the kind of slashable offense found from detecting on min-max spans + the slashable epoch for the offense. Also includes the signature bytes for assistance in finding the attestation for the slashing proof.
func (*DetectionResult) Marshal ¶ added in v0.3.4
func (result *DetectionResult) Marshal() []byte
Marshal the result into bytes, used for removing duplicates.
type EpochStore ¶ added in v1.0.0
type EpochStore struct {
// contains filtered or unexported fields
}
EpochStore defines an implementation of the slasher data access interface using byte array as data source to extract and put validator spans into.
func EpochStoreFromMap ¶ added in v1.0.0
func EpochStoreFromMap(spanMap map[uint64]Span) (*EpochStore, error)
EpochStoreFromMap is a helper function to turn a map into a epoch store, mainly used for testing.
func NewEpochStore ¶ added in v1.0.0
func NewEpochStore(spans []byte) (*EpochStore, error)
NewEpochStore initialize epoch store from a byte array returns error if byte length is not a multiple of encoded spanner length.
func (*EpochStore) Bytes ¶ added in v1.0.0
func (es *EpochStore) Bytes() []byte
Bytes returns the underlying bytes of an EpochStore.
func (*EpochStore) GetValidatorSpan ¶ added in v1.0.0
func (es *EpochStore) GetValidatorSpan(idx uint64) (Span, error)
GetValidatorSpan unmarshal a span from an encoded, flattened array.
func (*EpochStore) HighestObservedIdx ¶ added in v1.0.0
func (es *EpochStore) HighestObservedIdx() uint64
HighestObservedIdx returns the highest idx the EpochStore has been used for.
func (*EpochStore) SetValidatorSpan ¶ added in v1.0.0
func (es *EpochStore) SetValidatorSpan(idx uint64, newSpan Span) (*EpochStore, error)
SetValidatorSpan marshal a validator span into an encoded, flattened array.
type Span ¶
Span defines the structure used for detecting surround and double votes.
func UnmarshalSpan ¶ added in v1.0.0
UnmarshalSpan returns a span from an encoded, flattened byte array. Note: This is a very often used function, so it is as optimized as possible.