Documentation ¶
Overview ¶
Package kv defines a persistent backend for the validator service.
Index ¶
- Variables
- type AttestationRecordSaveRequest
- type Config
- type QueuedAttestationRecords
- type SlashingKind
- type Store
- func (s *Store) AttestationHistoryForPubKey(ctx context.Context, pubKey [fieldparams.BLSPubkeyLength]byte) ([]*common.AttestationRecord, error)
- func (s *Store) AttestedPublicKeys(ctx context.Context) ([][fieldparams.BLSPubkeyLength]byte, error)
- func (s *Store) Backup(ctx context.Context, outputDir string, permissionOverride bool) error
- func (s *Store) CheckSlashableAttestation(ctx context.Context, pubKey [fieldparams.BLSPubkeyLength]byte, ...) (SlashingKind, error)
- func (s *Store) ClearDB() error
- func (s *Store) Close() error
- func (s *Store) DatabasePath() string
- func (s *Store) EIPImportBlacklistedPublicKeys(ctx context.Context) ([][fieldparams.BLSPubkeyLength]byte, error)
- func (s *Store) GenesisValidatorsRoot(_ context.Context) ([]byte, error)
- func (s *Store) GraffitiFileHash() ([32]byte, bool, error)
- func (s *Store) GraffitiOrderedIndex(_ context.Context, fileHash [32]byte) (uint64, error)
- func (s *Store) HighestSignedProposal(ctx context.Context, publicKey [fieldparams.BLSPubkeyLength]byte) (primitives.Slot, bool, error)
- func (s *Store) ImportStandardProtectionJSON(ctx context.Context, r io.Reader) error
- func (s *Store) LowestSignedProposal(ctx context.Context, publicKey [fieldparams.BLSPubkeyLength]byte) (primitives.Slot, bool, error)
- func (s *Store) LowestSignedSourceEpoch(ctx context.Context, publicKey [fieldparams.BLSPubkeyLength]byte) (primitives.Epoch, bool, error)
- func (s *Store) LowestSignedTargetEpoch(ctx context.Context, publicKey [fieldparams.BLSPubkeyLength]byte) (primitives.Epoch, bool, error)
- func (s *Store) ProposalHistoryForPubKey(ctx context.Context, publicKey [fieldparams.BLSPubkeyLength]byte) ([]*common.Proposal, error)
- func (s *Store) ProposalHistoryForSlot(ctx context.Context, publicKey [fieldparams.BLSPubkeyLength]byte, ...) ([32]byte, bool, bool, error)
- func (s *Store) ProposedPublicKeys(ctx context.Context) ([][fieldparams.BLSPubkeyLength]byte, error)
- func (s *Store) ProposerSettings(ctx context.Context) (*proposer.Settings, error)
- func (s *Store) ProposerSettingsExists(ctx context.Context) (bool, error)
- func (s *Store) PruneAttestations(ctx context.Context) error
- func (s *Store) RunDownMigrations(ctx context.Context) error
- func (s *Store) RunUpMigrations(ctx context.Context) error
- func (s *Store) SaveAttestationForPubKey(ctx context.Context, pubKey [fieldparams.BLSPubkeyLength]byte, ...) error
- func (s *Store) SaveAttestationsForPubKey(ctx context.Context, pubKey [fieldparams.BLSPubkeyLength]byte, ...) error
- func (s *Store) SaveEIPImportBlacklistedPublicKeys(ctx context.Context, publicKeys [][fieldparams.BLSPubkeyLength]byte) error
- func (s *Store) SaveGenesisValidatorsRoot(_ context.Context, genValRoot []byte) error
- func (s *Store) SaveGraffitiOrderedIndex(_ context.Context, index uint64) error
- func (s *Store) SaveProposalHistoryForSlot(ctx context.Context, pubKey [fieldparams.BLSPubkeyLength]byte, ...) error
- func (s *Store) SaveProposerSettings(ctx context.Context, settings *proposer.Settings) error
- func (s *Store) SigningRootAtTargetEpoch(ctx context.Context, pubKey [fieldparams.BLSPubkeyLength]byte, ...) ([]byte, error)
- func (s *Store) Size() (int64, error)
- func (s *Store) SlashableAttestationCheck(ctx context.Context, indexedAtt *ethpb.IndexedAttestation, ...) error
- func (s *Store) SlashableProposalCheck(ctx context.Context, pubKey [fieldparams.BLSPubkeyLength]byte, ...) error
- func (s *Store) UpdatePublicKeysBuckets(pubKeys [][fieldparams.BLSPubkeyLength]byte) error
Constants ¶
This section is empty.
Variables ¶
var ErrNoProposerSettingsFound = errors.New("no proposer settings found in bucket")
ErrNoProposerSettingsFound is an error thrown when no settings are found in bucket
var (
ProtectionDbFileName = "validator.db"
)
ProtectionDbFileName Validator slashing protection db file name.
Functions ¶
This section is empty.
Types ¶
type AttestationRecordSaveRequest ¶
type AttestationRecordSaveRequest struct {
// contains filtered or unexported fields
}
AttestationRecordSaveRequest includes the attestation record to save along with the appropriate call context.
type Config ¶
type Config struct {
PubKeys [][fieldparams.BLSPubkeyLength]byte
}
Config represents store's config object.
type QueuedAttestationRecords ¶
type QueuedAttestationRecords struct {
// contains filtered or unexported fields
}
QueuedAttestationRecords is a thread-safe struct for managing a queue of attestation records to save to validator database.
func NewQueuedAttestationRecords ¶
func NewQueuedAttestationRecords() *QueuedAttestationRecords
NewQueuedAttestationRecords constructor allocates the underlying slice and required attributes for managing pending attestation records.
func (*QueuedAttestationRecords) Append ¶
func (p *QueuedAttestationRecords) Append(ar *common.AttestationRecord)
Append a new attestation record to the queue.
func (*QueuedAttestationRecords) Flush ¶
func (p *QueuedAttestationRecords) Flush() []*common.AttestationRecord
Flush all records. This method returns the current pending records and resets the pending records slice.
func (*QueuedAttestationRecords) Len ¶
func (p *QueuedAttestationRecords) Len() int
Len returns the current length of records.
type SlashingKind ¶
type SlashingKind int
SlashingKind used for helpful information upon detection.
const ( NotSlashable SlashingKind = iota DoubleVote SurroundingVote SurroundedVote )
Enums representing the types of slashable events for attesters.
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 nodes.
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) AttestationHistoryForPubKey ¶
func (s *Store) AttestationHistoryForPubKey(ctx context.Context, pubKey [fieldparams.BLSPubkeyLength]byte) ([]*common.AttestationRecord, error)
AttestationHistoryForPubKey retrieves a list of attestation records for data we have stored in the database for the given validator public key.
func (*Store) AttestedPublicKeys ¶
func (s *Store) AttestedPublicKeys(ctx context.Context) ([][fieldparams.BLSPubkeyLength]byte, error)
AttestedPublicKeys retrieves all public keys that have attested.
func (*Store) Backup ¶
Backup the database to the datadir backup directory. Example for backup: $DATADIR/backups/prysm_validatordb_1029019.backup
func (*Store) CheckSlashableAttestation ¶
func (s *Store) CheckSlashableAttestation( ctx context.Context, pubKey [fieldparams.BLSPubkeyLength]byte, signingRoot []byte, att *ethpb.IndexedAttestation, ) (SlashingKind, error)
CheckSlashableAttestation verifies an incoming attestation is not a double vote for a validator public key nor a surround vote.
func (*Store) ClearDB ¶
ClearDB removes any previously stored data at the configured data directory.
func (*Store) DatabasePath ¶
DatabasePath at which this database writes files.
func (*Store) EIPImportBlacklistedPublicKeys ¶
func (s *Store) EIPImportBlacklistedPublicKeys(ctx context.Context) ([][fieldparams.BLSPubkeyLength]byte, error)
EIPImportBlacklistedPublicKeys returns keys that were marked as blacklisted during EIP-3076 slashing protection imports, ensuring that we can prevent these keys from having duties at runtime.
func (*Store) GenesisValidatorsRoot ¶
GenesisValidatorsRoot retrieves the genesis validators root from db.
func (*Store) GraffitiFileHash ¶
GraffitiFileHash fetches the graffiti file hash.
func (*Store) GraffitiOrderedIndex ¶
GraffitiOrderedIndex fetches the ordered index, resetting if the file hash changed
func (*Store) HighestSignedProposal ¶
func (s *Store) HighestSignedProposal(ctx context.Context, publicKey [fieldparams.BLSPubkeyLength]byte) (primitives.Slot, bool, error)
HighestSignedProposal returns the highest signed proposal slot for a validator public key. If no data exists, a boolean of value false is returned.
func (*Store) ImportStandardProtectionJSON ¶
ImportStandardProtection takes in EIP-3076 compliant JSON file used for slashing protection by Ethereum validators and imports its data into Prysm's internal complete representation of slashing protection in the validator client's database.
func (*Store) LowestSignedProposal ¶
func (s *Store) LowestSignedProposal(ctx context.Context, publicKey [fieldparams.BLSPubkeyLength]byte) (primitives.Slot, bool, error)
LowestSignedProposal returns the lowest signed proposal slot for a validator public key. If no data exists, a boolean of value false is returned.
func (*Store) LowestSignedSourceEpoch ¶
func (s *Store) LowestSignedSourceEpoch(ctx context.Context, publicKey [fieldparams.BLSPubkeyLength]byte) (primitives.Epoch, bool, error)
LowestSignedSourceEpoch returns the lowest signed source epoch for a validator public key. If no data exists, returning 0 is a sensible default.
func (*Store) LowestSignedTargetEpoch ¶
func (s *Store) LowestSignedTargetEpoch(ctx context.Context, publicKey [fieldparams.BLSPubkeyLength]byte) (primitives.Epoch, bool, error)
LowestSignedTargetEpoch returns the lowest signed target epoch for a validator public key. If no data exists, returning 0 is a sensible default.
func (*Store) ProposalHistoryForPubKey ¶
func (s *Store) ProposalHistoryForPubKey(ctx context.Context, publicKey [fieldparams.BLSPubkeyLength]byte) ([]*common.Proposal, error)
ProposalHistoryForPubKey returns the entire proposal history for a given public key.
func (*Store) ProposalHistoryForSlot ¶
func (s *Store) ProposalHistoryForSlot(ctx context.Context, publicKey [fieldparams.BLSPubkeyLength]byte, slot primitives.Slot) ([32]byte, bool, bool, error)
ProposalHistoryForSlot accepts a validator public key and returns the corresponding signing root as well as a boolean that tells us if we have a proposal history stored at the slot and a boolean that tells us if we have a signed root at the slot.
func (*Store) ProposedPublicKeys ¶
func (s *Store) ProposedPublicKeys(ctx context.Context) ([][fieldparams.BLSPubkeyLength]byte, error)
ProposedPublicKeys retrieves all public keys in our proposals history bucket. Warning: A public key in this bucket does not necessarily mean it has signed a block.
func (*Store) ProposerSettings ¶
ProposerSettings gets the current proposer settings
func (*Store) ProposerSettingsExists ¶
ProposerSettingsExists returns true or false if the settings exist or not
func (*Store) PruneAttestations ¶
PruneAttestations loops through every public key in the public keys bucket and prunes all attestation data that has target epochs older the highest target epoch minus some constant of how many epochs we keep track of for slashing protection. This routine is meant to run on startup.
func (*Store) RunDownMigrations ¶
RunDownMigrations defined in the downMigrations list.
func (*Store) RunUpMigrations ¶
RunUpMigrations defined in the upMigrations list.
func (*Store) SaveAttestationForPubKey ¶
func (s *Store) SaveAttestationForPubKey( ctx context.Context, pubKey [fieldparams.BLSPubkeyLength]byte, signingRoot [fieldparams.RootLength]byte, att *ethpb.IndexedAttestation, ) error
SaveAttestationForPubKey saves an attestation for a validator public key for local validator slashing protection.
func (*Store) SaveAttestationsForPubKey ¶
func (s *Store) SaveAttestationsForPubKey( ctx context.Context, pubKey [fieldparams.BLSPubkeyLength]byte, signingRoots [][]byte, atts []*ethpb.IndexedAttestation, ) error
SaveAttestationsForPubKey stores a batch of attestations all at once.
func (*Store) SaveEIPImportBlacklistedPublicKeys ¶
func (s *Store) SaveEIPImportBlacklistedPublicKeys(ctx context.Context, publicKeys [][fieldparams.BLSPubkeyLength]byte) error
SaveEIPImportBlacklistedPublicKeys stores a list of blacklisted public keys that were determined during EIP-3076 slashing protection imports.
func (*Store) SaveGenesisValidatorsRoot ¶
SaveGenesisValidatorsRoot saves the genesis validators root to db.
func (*Store) SaveGraffitiOrderedIndex ¶
SaveGraffitiOrderedIndex writes the current graffiti index to the db
func (*Store) SaveProposalHistoryForSlot ¶
func (s *Store) SaveProposalHistoryForSlot(ctx context.Context, pubKey [fieldparams.BLSPubkeyLength]byte, slot primitives.Slot, signingRoot []byte) error
SaveProposalHistoryForSlot saves the proposal history for the requested validator public key. We also check if the incoming proposal slot is lower than the lowest signed proposal slot for the validator and override its value on disk.
func (*Store) SaveProposerSettings ¶
SaveProposerSettings saves the entire proposer setting overriding the existing settings
func (*Store) SigningRootAtTargetEpoch ¶
func (s *Store) SigningRootAtTargetEpoch(ctx context.Context, pubKey [fieldparams.BLSPubkeyLength]byte, target primitives.Epoch) ([]byte, error)
SigningRootAtTargetEpoch checks for an existing signing root at a specified target epoch for a given validator public key.
func (*Store) SlashableAttestationCheck ¶
func (s *Store) SlashableAttestationCheck( ctx context.Context, indexedAtt *ethpb.IndexedAttestation, pubKey [fieldparams.BLSPubkeyLength]byte, signingRoot32 [32]byte, emitAccountMetrics bool, validatorAttestFailVec *prometheus.CounterVec, ) error
SlashableAttestationCheck checks if an attestation is slashable by comparing it with the attesting history for the given public key in our complete slashing protection database defined by EIP-3076. If it is not, it updates the database.
func (*Store) SlashableProposalCheck ¶
func (s *Store) SlashableProposalCheck( ctx context.Context, pubKey [fieldparams.BLSPubkeyLength]byte, signedBlock interfaces.ReadOnlySignedBeaconBlock, signingRoot [fieldparams.RootLength]byte, emitAccountMetrics bool, validatorProposeFailVec *prometheus.CounterVec, ) error
SlashableProposalCheck checks if a block proposal is slashable by comparing it with the block proposals history for the given public key in our complete slashing protection database defined by EIP-3076. If it is not, we then update the history.
func (*Store) UpdatePublicKeysBuckets ¶
func (s *Store) UpdatePublicKeysBuckets(pubKeys [][fieldparams.BLSPubkeyLength]byte) error
UpdatePublicKeysBuckets for a specified list of keys.
Source Files ¶
- attester_protection.go
- backup.go
- db.go
- deprecated_attester_protection.go
- eip_blacklisted_keys.go
- genesis.go
- graffiti.go
- import.go
- log.go
- migration.go
- migration_optimal_attester_protection.go
- migration_source_target_epochs_bucket.go
- proposer_protection.go
- proposer_settings.go
- prune_attester_protection.go
- schema.go