Documentation ¶
Overview ¶
Package slasherkv defines a bolt-db, key-value store implementation of the slasher database interface for Prysm.
Index ¶
- Constants
- type Store
- func (s *Store) AttestationRecordForValidator(ctx context.Context, validatorIdx types.ValidatorIndex, ...) (*slashertypes.IndexedAttestationWrapper, error)
- func (s *Store) BlockProposalForValidator(ctx context.Context, validatorIdx types.ValidatorIndex, slot types.Slot) (*slashertypes.SignedBlockHeaderWrapper, error)
- func (s *Store) CheckAttesterDoubleVotes(ctx context.Context, attestations []*slashertypes.IndexedAttestationWrapper) ([]*slashertypes.AttesterDoubleVote, error)
- func (s *Store) CheckDoubleBlockProposals(ctx context.Context, proposals []*slashertypes.SignedBlockHeaderWrapper) ([]*ethpb.ProposerSlashing, error)
- func (s *Store) ClearDB() error
- func (s *Store) Close() error
- func (s *Store) DatabasePath() string
- func (s *Store) HighestAttestations(_ context.Context, indices []types.ValidatorIndex) ([]*ethpb.HighestAttestation, error)
- func (s *Store) LastEpochWrittenForValidators(ctx context.Context, validatorIndices []types.ValidatorIndex) ([]*slashertypes.AttestedEpochForValidator, error)
- func (s *Store) LoadSlasherChunks(ctx context.Context, kind slashertypes.ChunkKind, diskKeys [][]byte) ([][]uint16, []bool, error)
- func (s *Store) PruneAttestationsAtEpoch(_ context.Context, maxEpoch types.Epoch) (numPruned uint, err error)
- func (s *Store) PruneProposalsAtEpoch(ctx context.Context, maxEpoch types.Epoch) (numPruned uint, err error)
- func (s *Store) SaveAttestationRecordsForValidators(ctx context.Context, attestations []*slashertypes.IndexedAttestationWrapper) error
- func (s *Store) SaveBlockProposals(ctx context.Context, proposals []*slashertypes.SignedBlockHeaderWrapper) error
- func (s *Store) SaveLastEpochsWrittenForValidators(ctx context.Context, epochByValidator map[types.ValidatorIndex]types.Epoch) error
- func (s *Store) SaveSlasherChunks(ctx context.Context, kind slashertypes.ChunkKind, chunkKeys [][]byte, ...) error
Constants ¶
const (
// DatabaseFileName is the name of the beacon node database.
DatabaseFileName = "slasher.db"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store defines an implementation of the Prysm Database interface using BoltDB as the underlying persistent kv-store for Ethereum consensus.
func NewKVStore ¶
NewKVStore initializes a new boltDB key-value store at the directory path specified, creates the kv-buckets based on the schema, and stores an open connection db object as a property of the Store struct.
func (*Store) AttestationRecordForValidator ¶
func (s *Store) AttestationRecordForValidator( ctx context.Context, validatorIdx types.ValidatorIndex, targetEpoch types.Epoch, ) (*slashertypes.IndexedAttestationWrapper, error)
AttestationRecordForValidator given a validator index and a target epoch, retrieves an existing attestation record we have stored in the database.
func (*Store) BlockProposalForValidator ¶
func (s *Store) BlockProposalForValidator( ctx context.Context, validatorIdx types.ValidatorIndex, slot types.Slot, ) (*slashertypes.SignedBlockHeaderWrapper, error)
BlockProposalForValidator given a validator index and a slot retrieves an existing proposal record we have stored in the database.
func (*Store) CheckAttesterDoubleVotes ¶
func (s *Store) CheckAttesterDoubleVotes( ctx context.Context, attestations []*slashertypes.IndexedAttestationWrapper, ) ([]*slashertypes.AttesterDoubleVote, error)
CheckAttesterDoubleVotes retries any slashable double votes that exist for a series of input attestations.
func (*Store) CheckDoubleBlockProposals ¶
func (s *Store) CheckDoubleBlockProposals( ctx context.Context, proposals []*slashertypes.SignedBlockHeaderWrapper, ) ([]*ethpb.ProposerSlashing, error)
CheckDoubleBlockProposals takes in a list of proposals and for each, checks if there already exists a proposal at the same slot+validatorIndex combination. If so, We check if the existing signing root is not-empty and is different than the incoming proposal signing root. If so, we return a double block proposal object.
func (*Store) DatabasePath ¶
DatabasePath at which this database writes files.
func (*Store) HighestAttestations ¶
func (s *Store) HighestAttestations( _ context.Context, indices []types.ValidatorIndex, ) ([]*ethpb.HighestAttestation, error)
HighestAttestations retrieves the last attestation data from the database for all indices.
func (*Store) LastEpochWrittenForValidators ¶
func (s *Store) LastEpochWrittenForValidators( ctx context.Context, validatorIndices []types.ValidatorIndex, ) ([]*slashertypes.AttestedEpochForValidator, error)
LastEpochWrittenForValidators given a list of validator indices returns the latest epoch we have recorded the validators writing data for.
func (*Store) LoadSlasherChunks ¶
func (s *Store) LoadSlasherChunks( ctx context.Context, kind slashertypes.ChunkKind, diskKeys [][]byte, ) ([][]uint16, []bool, error)
LoadSlasherChunks given a chunk kind and a disk keys, retrieves chunks for a validator min or max span used by slasher from our database.
func (*Store) PruneAttestationsAtEpoch ¶
func (s *Store) PruneAttestationsAtEpoch( _ context.Context, maxEpoch types.Epoch, ) (numPruned uint, err error)
PruneAttestationsAtEpoch deletes all attestations from the slasher DB with target epoch less than or equal to the specified epoch.
func (*Store) PruneProposalsAtEpoch ¶
func (s *Store) PruneProposalsAtEpoch( ctx context.Context, maxEpoch types.Epoch, ) (numPruned uint, err error)
PruneProposalsAtEpoch deletes all proposals from the slasher DB with epoch less than or equal to the specified epoch.
func (*Store) SaveAttestationRecordsForValidators ¶
func (s *Store) SaveAttestationRecordsForValidators( ctx context.Context, attestations []*slashertypes.IndexedAttestationWrapper, ) error
SaveAttestationRecordsForValidators saves attestation records for the specified indices.
func (*Store) SaveBlockProposals ¶
func (s *Store) SaveBlockProposals( ctx context.Context, proposals []*slashertypes.SignedBlockHeaderWrapper, ) error
SaveBlockProposals takes in a list of block proposals and saves them to our proposal records bucket in the database.
func (*Store) SaveLastEpochsWrittenForValidators ¶
func (s *Store) SaveLastEpochsWrittenForValidators( ctx context.Context, epochByValidator map[types.ValidatorIndex]types.Epoch, ) error
SaveLastEpochsWrittenForValidators updates the latest epoch a slice of validator indices has attested to.
func (*Store) SaveSlasherChunks ¶
func (s *Store) SaveSlasherChunks( ctx context.Context, kind slashertypes.ChunkKind, chunkKeys [][]byte, chunks [][]uint16, ) error
SaveSlasherChunks given a chunk kind, list of disk keys, and list of chunks, saves the chunks to our database for use by slasher in slashing detection.