kv

package
v0.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 19, 2023 License: GPL-3.0 Imports: 30 Imported by: 0

Documentation

Overview

Package kv defines a persistent backend for the validator service.

Index

Constants

This section is empty.

Variables

View Source
var NoProposerSettingsFound = errors.New("no proposer settings found in bucket")

NoProposerSettingsFound is an error thrown when no settings are found in bucket

View Source
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

Append a new attestation record to the queue.

func (*QueuedAttestationRecords) Flush

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

func NewKVStore(ctx context.Context, dirPath string, config *Config) (*Store, error)

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

func (s *Store) Backup(ctx context.Context, outputDir string, permissionOverride bool) error

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

func (s *Store) ClearDB() error

ClearDB removes any previously stored data at the configured data directory.

func (*Store) Close

func (s *Store) Close() error

Close closes the underlying boltdb database.

func (*Store) DatabasePath

func (s *Store) DatabasePath() string

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

func (s *Store) GenesisValidatorsRoot(_ context.Context) ([]byte, error)

GenesisValidatorsRoot retrieves the genesis validators root from db.

func (*Store) GraffitiOrderedIndex

func (s *Store) GraffitiOrderedIndex(_ context.Context, fileHash [32]byte) (uint64, error)

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

func (s *Store) ProposerSettings(ctx context.Context) (*validatorServiceConfig.ProposerSettings, error)

ProposerSettings gets the current proposer settings

func (*Store) ProposerSettingsExists

func (s *Store) ProposerSettingsExists(ctx context.Context) (bool, error)

ProposerSettingsExists returns true or false if the settings exist or not

func (*Store) PruneAttestations

func (s *Store) PruneAttestations(ctx context.Context) error

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

func (s *Store) RunDownMigrations(ctx context.Context) error

RunDownMigrations defined in the downMigrations list.

func (*Store) RunUpMigrations

func (s *Store) RunUpMigrations(ctx context.Context) error

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

func (s *Store) SaveGenesisValidatorsRoot(_ context.Context, genValRoot []byte) error

SaveGenesisValidatorsRoot saves the genesis validators root to db.

func (*Store) SaveGraffitiOrderedIndex

func (s *Store) SaveGraffitiOrderedIndex(_ context.Context, index uint64) error

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

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) Size

func (s *Store) Size() (int64, error)

Size returns the db size in bytes.

func (*Store) UpdateProposerSettingsDefault

func (s *Store) UpdateProposerSettingsDefault(ctx context.Context, options *validatorServiceConfig.ProposerOption) error

UpdateProposerSettingsDefault updates the existing default settings for proposer settings

func (*Store) UpdateProposerSettingsForPubkey

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL