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 primitives.ValidatorIndex, ...) (*slashertypes.IndexedAttestationWrapper, error)
- func (s *Store) BlockProposalForValidator(ctx context.Context, validatorIdx primitives.ValidatorIndex, ...) (*slashertypes.SignedBlockHeaderWrapper, error)
- func (s *Store) CheckAttesterDoubleVotes(ctx context.Context, attestations []*slashertypes.IndexedAttestationWrapper) ([]*slashertypes.AttesterDoubleVote, error)
- func (s *Store) CheckDoubleBlockProposals(ctx context.Context, ...) ([]*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 []primitives.ValidatorIndex) ([]*ethpb.HighestAttestation, error)
- func (s *Store) LastEpochWrittenForValidators(ctx context.Context, validatorIndexes []primitives.ValidatorIndex) ([]*slashertypes.AttestedEpochForValidator, error)
- func (s *Store) LoadSlasherChunks(ctx context.Context, kind slashertypes.ChunkKind, chunkKeys [][]byte) ([][]uint16, []bool, error)
- func (s *Store) Migrate(ctx context.Context, headEpoch, maxPruningEpoch primitives.Epoch, ...) error
- func (s *Store) PruneAttestationsAtEpoch(_ context.Context, maxEpoch primitives.Epoch) (numPruned uint, err error)
- func (s *Store) PruneProposalsAtEpoch(ctx context.Context, maxEpoch primitives.Epoch) (numPruned uint, err error)
- func (s *Store) SaveAttestationRecordsForValidators(ctx context.Context, attWrappers []*slashertypes.IndexedAttestationWrapper) error
- func (s *Store) SaveBlockProposals(ctx context.Context, proposals []*slashertypes.SignedBlockHeaderWrapper) error
- func (s *Store) SaveLastEpochWrittenForValidators(ctx context.Context, ...) 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 primitives.ValidatorIndex, targetEpoch primitives.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 primitives.ValidatorIndex, slot primitives.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 retrieves any slashable double votes that exist for a series of input attestations with respect to the database.
func (*Store) CheckDoubleBlockProposals ¶
func (s *Store) CheckDoubleBlockProposals( ctx context.Context, incomingProposals []*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, it checks if the existing signing root is not-empty and is different than the incoming proposal signing root. If so, it returns 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 []primitives.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, validatorIndexes []primitives.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, chunkKeys [][]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) Migrate ¶ added in v5.1.0
func (s *Store) Migrate(ctx context.Context, headEpoch, maxPruningEpoch primitives.Epoch, batchSize int) error
Migrate , its corresponding usage and tests can be totally removed once Electra is on mainnet. Previously, the first 8 bytes of keys of `attestation-data-roots` and `proposal-records` buckets were stored as little-endian respectively epoch and slots. It was the source of https://github.com/prysmaticlabs/prysm/issues/14142 and potentially https://github.com/prysmaticlabs/prysm/issues/13658. To solve this (or these) issue(s), we decided to store the first 8 bytes of keys as big-endian. See https://github.com/prysmaticlabs/prysm/pull/14151. However, not to break the backward compatibility, we need to migrate the existing data. The strategy is quite simple: If, for these bucket keys in the store, we detect a slot (resp. epoch) higher, than the current slot (resp. epoch), then we consider that the data is stored in little-endian. We create a new entry with the same value, but with the slot (resp. epoch) part in the key stored as a big-endian. We start the iterate by the highest key and iterate down until we reach the current slot (resp. epoch).
func (*Store) PruneAttestationsAtEpoch ¶
func (s *Store) PruneAttestationsAtEpoch( _ context.Context, maxEpoch primitives.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 primitives.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, attWrappers []*slashertypes.IndexedAttestationWrapper, ) error
SaveAttestationRecordsForValidators saves attestation records for the specified indices. If multiple attestations are provided for the same validator index + target epoch combination, then only the first one is (arbitrarily) saved in the `attestationDataRootsBucket` bucket.
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. If multiple proposals are provided for the same slot + validatorIndex combination, then only the last one is saved in the database.
func (*Store) SaveLastEpochWrittenForValidators ¶ added in v5.0.3
func (s *Store) SaveLastEpochWrittenForValidators( ctx context.Context, epochByValIndex map[primitives.ValidatorIndex]primitives.Epoch, ) error
SaveLastEpochWrittenForValidators saves the latest epoch that each validator has attested to in the provided map.
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.