Documentation ¶
Overview ¶
Package slasherkv defines a bolt-db, key-value store implementation of the slasher database interface for Prysm.
Index ¶
- Constants
- type Config
- type Store
- func (s *Store) AttestationRecordForValidator(ctx context.Context, validatorIdx types.ValidatorIndex, ...) (*slashertypes.IndexedAttestationWrapper, 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(ctx context.Context, indices []types.ValidatorIndex) ([]*slashpb.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) PruneAttestations(ctx context.Context, ...) error
- func (s *Store) PruneProposals(ctx context.Context, ...) 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) SaveLastEpochWrittenForValidators(ctx context.Context, validatorIndices []types.ValidatorIndex, ...) 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) 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( ctx context.Context, indices []types.ValidatorIndex, ) ([]*slashpb.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) PruneAttestations ¶
func (s *Store) PruneAttestations( ctx context.Context, currentEpoch, pruningEpochIncrements, historyLength types.Epoch, ) error
PruneAttestations prunes all proposal data older than historyLength.
func (*Store) PruneProposals ¶
func (s *Store) PruneProposals( ctx context.Context, currentEpoch, pruningEpochIncrements, historyLength types.Epoch, ) error
PruneProposals prunes all proposal data older than currentEpoch - historyLength in specified epoch increments. BoltDB cannot handle long-running transactions, so we instead use a cursor-based mechanism to prune at pruningEpochIncrements by opening individual bolt transactions for each pruning iteration.
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) SaveLastEpochWrittenForValidators ¶
func (s *Store) SaveLastEpochWrittenForValidators( ctx context.Context, validatorIndices []types.ValidatorIndex, epoch types.Epoch, ) error
SaveLastEpochWrittenForValidators 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.