kv

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2020 License: GPL-3.0 Imports: 16 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 EncHistoryData

type EncHistoryData []byte

EncHistoryData encapsulated history data.

func MarkAllAsAttestedSinceLatestWrittenEpoch

func MarkAllAsAttestedSinceLatestWrittenEpoch(
	ctx context.Context,
	hist EncHistoryData,
	incomingTarget uint64,
	incomingAtt *HistoryData,
) (EncHistoryData, error)

MarkAllAsAttestedSinceLatestWrittenEpoch returns an attesting history with specified target+epoch pairs since the latest written epoch up to the incoming attestation's target epoch as attested for.

func NewAttestationHistoryArray

func NewAttestationHistoryArray(target uint64) EncHistoryData

NewAttestationHistoryArray creates a new encapsulated attestation history byte array sized by the latest epoch written.

func (EncHistoryData) GetLatestEpochWritten

func (hd EncHistoryData) GetLatestEpochWritten(ctx context.Context) (uint64, error)

func (EncHistoryData) GetTargetData

func (hd EncHistoryData) GetTargetData(ctx context.Context, target uint64) (*HistoryData, error)

func (EncHistoryData) SetLatestEpochWritten

func (hd EncHistoryData) SetLatestEpochWritten(ctx context.Context, latestEpochWritten uint64) (EncHistoryData, error)

func (EncHistoryData) SetTargetData

func (hd EncHistoryData) SetTargetData(ctx context.Context, target uint64, historyData *HistoryData) (EncHistoryData, error)

type HistoryData

type HistoryData struct {
	Source      uint64
	SigningRoot []byte
}

HistoryData stores the needed data to confirm if an attestation is slashable or repeated.

func (*HistoryData) IsEmpty

func (h *HistoryData) IsEmpty() bool

type Proposal

type Proposal struct {
	Slot        uint64 `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 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 eth2.

func NewKVStore

func NewKVStore(dirPath string, pubKeys [][48]byte) (*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) AttestationHistoryForPubKeysV2

func (store *Store) AttestationHistoryForPubKeysV2(ctx context.Context, publicKeys [][48]byte) (map[[48]byte]EncHistoryData, error)

AttestationHistoryForPubKeysV2 accepts an array of validator public keys and returns a mapping of corresponding attestation history.

func (*Store) AttestedPublicKeys added in v1.0.1

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

AttestedPublicKeys retrieves all public keys in our attestation history bucket.

func (*Store) Backup added in v1.0.4

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

Backup the database to the datadir backup directory. Example for backup: $DATADIR/backups/prysm_validatordb_1029019.backup

func (*Store) ClearDB

func (store *Store) ClearDB() error

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

func (*Store) Close

func (store *Store) Close() error

Close closes the underlying boltdb database.

func (*Store) DatabasePath

func (store *Store) DatabasePath() string

DatabasePath at which this database writes files.

func (*Store) GenesisValidatorsRoot

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

GenesisValidatorsRoot retrieves the genesis validator root from db.

func (*Store) HighestSignedProposal added in v1.0.1

func (store *Store) HighestSignedProposal(ctx context.Context, publicKey [48]byte) (uint64, error)

HighestSignedProposal returns the highest signed proposal slot for a validator public key. If no data exists, returning 0 is a sensible default.

func (*Store) LowestSignedProposal added in v1.0.1

func (store *Store) LowestSignedProposal(ctx context.Context, publicKey [48]byte) (uint64, error)

LowestSignedProposal returns the lowest signed proposal slot for a validator public key. If no data exists, returning 0 is a sensible default.

func (*Store) LowestSignedSourceEpoch added in v1.0.1

func (store *Store) LowestSignedSourceEpoch(ctx context.Context, publicKey [48]byte) (uint64, 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 (store *Store) LowestSignedTargetEpoch(ctx context.Context, publicKey [48]byte) (uint64, 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) ProposalHistoryForSlot

func (store *Store) ProposalHistoryForSlot(ctx context.Context, publicKey [48]byte, slot uint64) ([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 (store *Store) ProposedPublicKeys(ctx context.Context) ([][48]byte, error)

ProposedPublicKeys retrieves all public keys in our proposals history bucket.

func (*Store) SaveAttestationHistoryForPubKeyV2

func (store *Store) SaveAttestationHistoryForPubKeyV2(ctx context.Context, pubKey [48]byte, history EncHistoryData) error

SaveAttestationHistoryForPubKeyV2 saves the attestation history for the requested validator public key.

func (*Store) SaveAttestationHistoryForPubKeysV2

func (store *Store) SaveAttestationHistoryForPubKeysV2(ctx context.Context, historyByPubKeys map[[48]byte]EncHistoryData) error

SaveAttestationHistoryForPubKeysV2 saves the attestation histories for the requested validator public keys.

func (*Store) SaveGenesisValidatorsRoot

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

SaveGenesisValidatorsRoot saves the genesis validator root to db.

func (*Store) SaveLowestSignedSourceEpoch added in v1.0.1

func (store *Store) SaveLowestSignedSourceEpoch(ctx context.Context, publicKey [48]byte, epoch uint64) error

SaveLowestSignedSourceEpoch saves the lowest signed source epoch for a validator public key.

func (*Store) SaveLowestSignedTargetEpoch added in v1.0.1

func (store *Store) SaveLowestSignedTargetEpoch(ctx context.Context, publicKey [48]byte, epoch uint64) error

SaveLowestSignedTargetEpoch saves the lowest signed target epoch for a validator public key.

func (*Store) SaveProposalHistoryForSlot

func (store *Store) SaveProposalHistoryForSlot(ctx context.Context, pubKey [48]byte, slot uint64, 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) Size

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

Size returns the db size in bytes.

func (*Store) UpdatePublicKeysBuckets

func (store *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