Documentation ¶
Overview ¶
Package kv defines a persistent backend for the validator service.
Index ¶
- Variables
- type AttestationRecord
- type AttestationRecordSaveRequest
- type Config
- type Proposal
- type ProposalHistoryForPubkey
- type QueuedAttestationRecords
- type SlashingKind
- type Store
- func (s *Store) AttestationHistoryForPubKey(ctx context.Context, pubKey [fieldparams.BLSPubkeyLength]byte) ([]*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) 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) 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) ([]*Proposal, error)
- func (s *Store) ProposalHistoryForSlot(ctx context.Context, publicKey [fieldparams.BLSPubkeyLength]byte, ...) ([32]byte, bool, error)
- func (s *Store) ProposedPublicKeys(ctx context.Context) ([][fieldparams.BLSPubkeyLength]byte, error)
- func (s *Store) ProposerSettings(ctx context.Context) (*validatorServiceConfig.ProposerSettings, 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 *validatorServiceConfig.ProposerSettings) error
- func (s *Store) SigningRootAtTargetEpoch(ctx context.Context, pubKey [fieldparams.BLSPubkeyLength]byte, ...) ([32]byte, error)
- func (s *Store) Size() (int64, error)
- func (s *Store) UpdateProposerSettingsDefault(ctx context.Context, options *validatorServiceConfig.ProposerOption) error
- func (s *Store) UpdateProposerSettingsForPubkey(ctx context.Context, pubkey [fieldparams.BLSPubkeyLength]byte, ...) error
- func (s *Store) UpdatePublicKeysBuckets(pubKeys [][fieldparams.BLSPubkeyLength]byte) error
Constants ¶
This section is empty.
Variables ¶
var NoProposerSettingsFound = errors.New("no proposer settings found in bucket")
NoProposerSettingsFound 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 AttestationRecord ¶
type AttestationRecord struct { PubKey [fieldparams.BLSPubkeyLength]byte Source primitives.Epoch Target primitives.Epoch SigningRoot [32]byte }
AttestationRecord which can be represented by these simple values for manipulation by database methods.
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 Proposal ¶
type Proposal struct { Slot primitives.Slot `json:"slot"` SigningRoot []byte `json:"signing_root"` }
Proposal representation for a validator public key.
type ProposalHistoryForPubkey ¶
type ProposalHistoryForPubkey struct {
Proposals []Proposal
}
ProposalHistoryForPubkey for a validator public key.
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 *AttestationRecord)
Append a new attestation record to the queue.
func (*QueuedAttestationRecords) Flush ¶
func (p *QueuedAttestationRecords) Flush() []*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) ([]*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 [32]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) 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) 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) ([]*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, 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. It is possible we have proposed a slot but stored a nil signing root, so the boolean helps give full information.
func (*Store) ProposedPublicKeys ¶
func (s *Store) ProposedPublicKeys(ctx context.Context) ([][fieldparams.BLSPubkeyLength]byte, error)
ProposedPublicKeys retrieves all public keys in our proposals history bucket.
func (*Store) ProposerSettings ¶ added in v4.0.5
func (s *Store) ProposerSettings(ctx context.Context) (*validatorServiceConfig.ProposerSettings, error)
ProposerSettings gets the current proposer settings
func (*Store) ProposerSettingsExists ¶ added in v4.0.5
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 [32]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 [][32]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 ¶ added in v4.0.5
func (s *Store) SaveProposerSettings(ctx context.Context, settings *validatorServiceConfig.ProposerSettings) error
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) ([32]byte, error)
SigningRootAtTargetEpoch checks for an existing signing root at a specified target epoch for a given validator public key.
func (*Store) UpdateProposerSettingsDefault ¶ added in v4.0.5
func (s *Store) UpdateProposerSettingsDefault(ctx context.Context, options *validatorServiceConfig.ProposerOption) error
UpdateProposerSettingsDefault updates the existing default settings for proposer settings
func (*Store) UpdateProposerSettingsForPubkey ¶ added in v4.0.5
func (s *Store) UpdateProposerSettingsForPubkey(ctx context.Context, pubkey [fieldparams.BLSPubkeyLength]byte, options *validatorServiceConfig.ProposerOption) error
UpdateProposerSettingsForPubkey updates the existing settings for an internal representation of the proposers settings file at a particular public key
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
- 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