slashingprotection

package
v1.4.1 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2024 License: GPL-3.0 Imports: 3 Imported by: 0

README

Blox Eth Key Manager - Slashing Protector

Slashing protection implementation for eth 2.0

Slashing Rules

Slashing can occur for validators proposing a block or signing attestations which can conflict with a previous signature.

Attestation - Double Vote

Description: Do not sign 2 attestations for the same block height. eth 2 spec.

def is_slashable_attestation_data(data_1: AttestationData, data_2: AttestationData) -> bool:
   """
   Check if ``data_1`` and ``data_2`` are slashable according to Casper FFG rules.
   """
   return (
       # Double vote
       (data_1 != data_2 and data_1.target.epoch == data_2.target.epoch) or
   )
Attestation - Surrounding/Surrounded Vote

Description: Do not surround an already existing attestation/s, a.k.a do not forget them. eth 2 spec.

Surrounded:

Surrounding:

def is_slashable_attestation_data(data_1: AttestationData, data_2: AttestationData) -> bool:
   """
   Check if ``data_1`` and ``data_2`` are slashable according to Casper FFG rules.
   """
   return (
       # Surround vote
       (data_1.source.epoch < data_2.source.epoch and data_2.target.epoch < data_1.target.epoch)
   )
Proposal - Duplicate

Description: Do not propose 2 blocks for the same block height. eth 2 spec.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type NoProtection

type NoProtection struct {
}

NoProtection implements slashing protector interface with dummy implementation

func (*NoProtection) FetchHighestAttestation added in v1.3.0

func (p *NoProtection) FetchHighestAttestation(pubKey []byte) (*phase0.AttestationData, bool, error)

FetchHighestAttestation does nothing

func (*NoProtection) FetchHighestProposal added in v1.3.0

func (p *NoProtection) FetchHighestProposal(pubKey []byte) (phase0.Slot, bool, error)

FetchHighestProposal returns highest proposal data

func (*NoProtection) IsSlashableAttestation

func (p *NoProtection) IsSlashableAttestation(pubKey []byte, attestation *phase0.AttestationData) (*core.AttestationSlashStatus, error)

IsSlashableAttestation returns always nils

func (*NoProtection) IsSlashableProposal

func (p *NoProtection) IsSlashableProposal(pubKey []byte, slot phase0.Slot) (*core.ProposalSlashStatus, error)

IsSlashableProposal returns always valid result

func (*NoProtection) UpdateHighestAttestation

func (p *NoProtection) UpdateHighestAttestation(pubKey []byte, attestation *phase0.AttestationData) error

UpdateHighestAttestation does nothing

func (*NoProtection) UpdateHighestProposal

func (p *NoProtection) UpdateHighestProposal(pubKey []byte, slot phase0.Slot) error

UpdateHighestProposal does nothing

type NormalProtection

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

NormalProtection implements normal protection logic

func NewNormalProtection

func NewNormalProtection(store core.SlashingStore) *NormalProtection

NewNormalProtection is the constructor of NormalProtection

func (*NormalProtection) FetchHighestAttestation added in v1.3.0

func (protector *NormalProtection) FetchHighestAttestation(pubKey []byte) (*phase0.AttestationData, bool, error)

FetchHighestAttestation returns highest attestation data

func (*NormalProtection) FetchHighestProposal added in v1.3.0

func (protector *NormalProtection) FetchHighestProposal(pubKey []byte) (phase0.Slot, bool, error)

FetchHighestProposal returns highest proposal data

func (*NormalProtection) IsSlashableAttestation

func (protector *NormalProtection) IsSlashableAttestation(pubKey []byte, attestation *phase0.AttestationData) (*core.AttestationSlashStatus, error)

IsSlashableAttestation detects double, surround and surrounded slashable events

func (*NormalProtection) IsSlashableProposal

func (protector *NormalProtection) IsSlashableProposal(pubKey []byte, slot phase0.Slot) (*core.ProposalSlashStatus, error)

IsSlashableProposal detects slashable proposal request

func (*NormalProtection) UpdateHighestAttestation

func (protector *NormalProtection) UpdateHighestAttestation(pubKey []byte, attestation *phase0.AttestationData) error

UpdateHighestAttestation potentially updates the highest attestation given this latest attestation.

func (*NormalProtection) UpdateHighestProposal

func (protector *NormalProtection) UpdateHighestProposal(key []byte, slot phase0.Slot) error

UpdateHighestProposal updates highest proposal

Jump to

Keyboard shortcuts

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