attestations

package
v0.3.4 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2020 License: GPL-3.0 Imports: 12 Imported by: 8

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

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) DetectSlashingsForAttestation added in v0.3.4

func (s *MockSpanDetector) DetectSlashingsForAttestation(
	ctx context.Context,
	att *ethpb.IndexedAttestation,
) ([]*types.DetectionResult, error)

DetectSlashingsForAttestation 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) (types.Span, 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]types.Span

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(db db.Database) *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) DetectSlashingsForAttestation added in v0.3.4

func (s *SpanDetector) DetectSlashingsForAttestation(
	ctx context.Context,
	att *ethpb.IndexedAttestation,
) ([]*types.DetectionResult, error)

DetectSlashingsForAttestation 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) UpdateSpans

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

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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