attestations

package
v0.0.0-...-ab12051 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2020 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DetectAndUpdateSpans

func DetectAndUpdateSpans(
	ctx context.Context,
	spanMap *slashpb.EpochSpanMap,
	att *ethpb.IndexedAttestation,
) (*slashpb.EpochSpanMap, uint64, error)

DetectAndUpdateSpans runs detection and updating for both min and max epoch spans, this is used for attestation slashing detection. Detailed here: https://github.com/protolambda/eth2-surround/blob/master/README.md#min-max-surround

Types

type MockSpanDetector

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

MockSpanDetector defines a struct which can detect slashable attestation offenses by tracking validator min-max spans from validators.

func (*MockSpanDetector) DeleteValidatorSpansByEpoch

func (s *MockSpanDetector) DeleteValidatorSpansByEpoch(ctx context.Context, validatorIdx uint64, epoch uint64) error

DeleteValidatorSpansByEpoch mocks the delete spans by epoch function.

func (*MockSpanDetector) DetectSlashingForValidator

func (s *MockSpanDetector) DetectSlashingForValidator(
	ctx context.Context,
	validatorIdx uint64,
	attData *ethpb.AttestationData,
) (*types.DetectionResult, error)

DetectSlashingForValidator mocks a detected slashing, if the sent attestation data has a source epoch of 0, nothing will be detected. If the sent attestation data has a target epoch equal to or greater than 6, it will "detect" a surrounded vote for the target epoch + 1. If the target epoch is greater than 12, it will "detect" a surrounding vote for target epoch - 1. Lastly, if it has a target epoch less than 6, it will "detect" a double vote for the target epoch.

func (*MockSpanDetector) SpanForEpochByValidator

func (s *MockSpanDetector) SpanForEpochByValidator(ctx context.Context, valIdx uint64, epoch uint64) ([3]uint16, error)

SpanForEpochByValidator returns the specific min-max span for a validator index in a given epoch.

func (*MockSpanDetector) UpdateSpans

func (s *MockSpanDetector) UpdateSpans(ctx context.Context, att *ethpb.IndexedAttestation) error

UpdateSpans is a mock for updating the spans for a given attestation..

func (*MockSpanDetector) ValidatorSpansByEpoch

func (s *MockSpanDetector) ValidatorSpansByEpoch(ctx context.Context, epoch uint64) map[uint64][3]uint16

ValidatorSpansByEpoch returns a list of all validator spans in a given epoch.

type SpanDetector

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

SpanDetector defines a struct which can detect slashable attestation offenses by tracking validator min-max spans from validators and attestation data roots.

func NewSpanDetector

func NewSpanDetector() *SpanDetector

NewSpanDetector creates a new instance of a struct tracking several epochs of min-max spans for each validator in the beacon state.

func (*SpanDetector) DeleteValidatorSpansByEpoch

func (s *SpanDetector) DeleteValidatorSpansByEpoch(ctx context.Context, validatorIdx uint64, epoch uint64) error

DeleteValidatorSpansByEpoch deletes a min-max span for a validator index from a min-max span in a given epoch.

func (*SpanDetector) DetectSlashingForValidator

func (s *SpanDetector) DetectSlashingForValidator(
	ctx context.Context,
	validatorIdx uint64,
	attData *ethpb.AttestationData,
) (*types.DetectionResult, error)

DetectSlashingForValidator uses a validator index and its corresponding min-max spans during an epoch to detect an epoch in which the validator committed a slashable attestation.

func (*SpanDetector) SpanForEpochByValidator

func (s *SpanDetector) SpanForEpochByValidator(ctx context.Context, valIdx uint64, epoch uint64) ([3]uint16, error)

SpanForEpochByValidator returns the specific min-max span for a validator index in a given epoch.

func (*SpanDetector) UpdateSpans

func (s *SpanDetector) UpdateSpans(ctx context.Context, att *ethpb.IndexedAttestation) error

UpdateSpans given an indexed attestation for all of its attesting indices.

func (*SpanDetector) ValidatorSpansByEpoch

func (s *SpanDetector) ValidatorSpansByEpoch(ctx context.Context, epoch uint64) map[uint64][3]uint16

ValidatorSpansByEpoch returns a list of all validator spans in a given epoch.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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