Documentation ¶
Overview ¶
Package attestations defines an implementation of a slashable attestation detector using min-max surround vote checking.
Index ¶
- type MockSpanDetector
- func (m *MockSpanDetector) DeleteValidatorSpansByEpoch(_ context.Context, _, _ uint64) error
- func (m *MockSpanDetector) DetectSlashingsForAttestation(_ context.Context, att *ethpb.IndexedAttestation) ([]*types.DetectionResult, error)
- func (m *MockSpanDetector) SpanForEpochByValidator(_ context.Context, _, _ uint64) (types.Span, error)
- func (m *MockSpanDetector) UpdateSpans(_ context.Context, _ *ethpb.IndexedAttestation) error
- func (m *MockSpanDetector) ValidatorSpansByEpoch(_ context.Context, _ 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{}
MockSpanDetector defines a struct which can detect slashable attestation offenses by tracking validator min-max spans from validators.
func (*MockSpanDetector) DeleteValidatorSpansByEpoch ¶
func (m *MockSpanDetector) DeleteValidatorSpansByEpoch(_ context.Context, _, _ uint64) error
DeleteValidatorSpansByEpoch mocks the delete spans by epoch function.
func (*MockSpanDetector) DetectSlashingsForAttestation ¶ added in v0.3.4
func (m *MockSpanDetector) DetectSlashingsForAttestation( _ 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 (m *MockSpanDetector) SpanForEpochByValidator(_ context.Context, _, _ uint64) (types.Span, error)
SpanForEpochByValidator returns the specific min-max span for a validator index in a given epoch.
func (*MockSpanDetector) UpdateSpans ¶
func (m *MockSpanDetector) UpdateSpans(_ context.Context, _ *ethpb.IndexedAttestation) error
UpdateSpans is a mock for updating the spans for a given attestation..
func (*MockSpanDetector) ValidatorSpansByEpoch ¶
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, ) ([]*slashertypes.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 |
---|---|
Package iface defines an interface for a slashable attestation detector struct.
|
Package iface defines an interface for a slashable attestation detector struct. |
Package types includes important type definitions for slashable objects detected by slasher.
|
Package types includes important type definitions for slashable objects detected by slasher. |