Documentation ¶
Index ¶
- type MockSpanDetector
- func (s *MockSpanDetector) DeleteValidatorSpansByEpoch(ctx context.Context, validatorIdx uint64, epoch uint64) error
- func (s *MockSpanDetector) DetectSlashingForValidator(ctx context.Context, validatorIdx uint64, attData *ethpb.AttestationData) (*types.DetectionResult, error)
- func (s *MockSpanDetector) SpanForEpochByValidator(ctx context.Context, valIdx uint64, epoch uint64) (types.Span, error)
- func (s *MockSpanDetector) UpdateSpans(ctx context.Context, att *ethpb.IndexedAttestation) error
- func (s *MockSpanDetector) ValidatorSpansByEpoch(ctx context.Context, epoch uint64) map[uint64]types.Span
- type SpanDetector
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) 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) (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) 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) UpdateSpans ¶
func (s *SpanDetector) UpdateSpans(ctx context.Context, att *ethpb.IndexedAttestation) error
UpdateSpans given an indexed attestation for all of its attesting indices.