kv

package
v1.4.4 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2021 License: GPL-3.0 Imports: 26 Imported by: 2

Documentation

Overview

Package kv defines a persistent backend for the validator service.

Index

Constants

This section is empty.

Variables

View Source
var (
	ProtectionDbFileName = "validator.db"
)

ProtectionDbFileName Validator slashing protection db file name.

Functions

This section is empty.

Types

type AttestationRecord added in v1.2.0

type AttestationRecord struct {
	PubKey      [48]byte
	Source      types.Epoch
	Target      types.Epoch
	SigningRoot [32]byte
}

AttestationRecord which can be represented by these simple values for manipulation by database methods.

type Config added in v1.2.2

type Config struct {
	PubKeys         [][48]byte
	InitialMMapSize int
}

Config represents store's config object.

type Proposal

type Proposal struct {
	Slot        types.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 added in v1.2.2

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 added in v1.2.2

func NewQueuedAttestationRecords() *QueuedAttestationRecords

NewQueuedAttestationRecords constructor allocates the underlying slice and required attributes for managing pending attestation records.

func (*QueuedAttestationRecords) Append added in v1.2.2

Append a new attestation record to the queue.

func (*QueuedAttestationRecords) Flush added in v1.2.2

Flush all records. This method returns the current pending records and resets the pending records slice.

func (*QueuedAttestationRecords) Len added in v1.2.2

func (p *QueuedAttestationRecords) Len() int

Len returns the current length of records.

type SlashingKind added in v1.1.0

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 added in v1.2.0

func (s *Store) AttestationHistoryForPubKey(ctx context.Context, pubKey [48]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 added in v1.0.1

func (s *Store) AttestedPublicKeys(ctx context.Context) ([][48]byte, error)

AttestedPublicKeys retrieves all public keys that have attested.

func (*Store) Backup added in v1.0.4

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 added in v1.1.0

func (s *Store) CheckSlashableAttestation(
	ctx context.Context, pubKey [48]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 added in v1.2.0

func (s *Store) EIPImportBlacklistedPublicKeys(ctx context.Context) ([][48]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(ctx context.Context) ([]byte, error)

GenesisValidatorsRoot retrieves the genesis validator root from db.

func (*Store) GraffitiOrderedIndex added in v1.3.2

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

GraffitiOrderedIndex fetches the ordered index, resetting if the file hash changed

func (*Store) HighestSignedProposal added in v1.0.1

func (s *Store) HighestSignedProposal(ctx context.Context, publicKey [48]byte) (types.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 added in v1.0.1

func (s *Store) LowestSignedProposal(ctx context.Context, publicKey [48]byte) (types.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 added in v1.0.1

func (s *Store) LowestSignedSourceEpoch(ctx context.Context, publicKey [48]byte) (types.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 added in v1.0.1

func (s *Store) LowestSignedTargetEpoch(ctx context.Context, publicKey [48]byte) (types.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 added in v1.2.0

func (s *Store) ProposalHistoryForPubKey(ctx context.Context, publicKey [48]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 [48]byte, slot types.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 added in v1.0.1

func (s *Store) ProposedPublicKeys(ctx context.Context) ([][48]byte, error)

ProposedPublicKeys retrieves all public keys in our proposals history bucket.

func (*Store) PruneAttestations added in v1.3.4

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 added in v1.1.0

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

RunDownMigrations defined in the downMigrations list.

func (*Store) RunUpMigrations added in v1.1.0

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

RunUpMigrations defined in the upMigrations list.

func (*Store) SaveAttestationForPubKey added in v1.1.0

func (s *Store) SaveAttestationForPubKey(
	ctx context.Context, pubKey [48]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 added in v1.2.0

func (s *Store) SaveAttestationsForPubKey(
	ctx context.Context, pubKey [48]byte, signingRoots [][32]byte, atts []*ethpb.IndexedAttestation,
) error

SaveAttestationsForPubKey stores a batch of attestations all at once.

func (*Store) SaveEIPImportBlacklistedPublicKeys added in v1.2.0

func (s *Store) SaveEIPImportBlacklistedPublicKeys(ctx context.Context, publicKeys [][48]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(ctx context.Context, genValRoot []byte) error

SaveGenesisValidatorsRoot saves the genesis validator root to db.

func (*Store) SaveGraffitiOrderedIndex added in v1.3.2

func (s *Store) SaveGraffitiOrderedIndex(ctx 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 [48]byte, slot types.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) SigningRootAtTargetEpoch added in v1.2.0

func (s *Store) SigningRootAtTargetEpoch(ctx context.Context, pubKey [48]byte, target types.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) UpdatePublicKeysBuckets

func (s *Store) UpdatePublicKeysBuckets(pubKeys [][48]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