slasherkv

package
v2.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2021 License: GPL-3.0 Imports: 26 Imported by: 0

Documentation

Overview

Package slasherkv defines a bolt-db, key-value store implementation of the slasher database interface for Prysm.

Index

Constants

View Source
const (
	// DatabaseFileName is the name of the beacon node database.
	DatabaseFileName = "slasher.db"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	InitialMMapSize int
}

Config for the bolt db kv store.

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.

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

func (s *Store) AttestationRecordForValidator(
	ctx context.Context, validatorIdx types.ValidatorIndex, targetEpoch types.Epoch,
) (*slashertypes.IndexedAttestationWrapper, error)

AttestationRecordForValidator given a validator index and a target epoch, retrieves an existing attestation record we have stored in the database.

func (*Store) BlockProposalForValidator

func (s *Store) BlockProposalForValidator(
	ctx context.Context, validatorIdx types.ValidatorIndex, slot types.Slot,
) (*slashertypes.SignedBlockHeaderWrapper, error)

BlockProposalForValidator given a validator index and a slot retrieves an existing proposal record we have stored in the database.

func (*Store) CheckAttesterDoubleVotes

func (s *Store) CheckAttesterDoubleVotes(
	ctx context.Context, attestations []*slashertypes.IndexedAttestationWrapper,
) ([]*slashertypes.AttesterDoubleVote, error)

CheckAttesterDoubleVotes retries any slashable double votes that exist for a series of input attestations.

func (*Store) CheckDoubleBlockProposals

func (s *Store) CheckDoubleBlockProposals(
	ctx context.Context, proposals []*slashertypes.SignedBlockHeaderWrapper,
) ([]*ethpb.ProposerSlashing, error)

CheckDoubleBlockProposals takes in a list of proposals and for each, checks if there already exists a proposal at the same slot+validatorIndex combination. If so, We check if the existing signing root is not-empty and is different than the incoming proposal signing root. If so, we return a double block proposal object.

func (*Store) ClearDB

func (s *Store) ClearDB() error

ClearDB removes the previously stored database in the 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) HighestAttestations

func (s *Store) HighestAttestations(
	ctx context.Context,
	indices []types.ValidatorIndex,
) ([]*slashpb.HighestAttestation, error)

HighestAttestations retrieves the last attestation data from the database for all indices.

func (*Store) LastEpochWrittenForValidators

func (s *Store) LastEpochWrittenForValidators(
	ctx context.Context, validatorIndices []types.ValidatorIndex,
) ([]*slashertypes.AttestedEpochForValidator, error)

LastEpochWrittenForValidators given a list of validator indices returns the latest epoch we have recorded the validators writing data for.

func (*Store) LoadSlasherChunks

func (s *Store) LoadSlasherChunks(
	ctx context.Context, kind slashertypes.ChunkKind, diskKeys [][]byte,
) ([][]uint16, []bool, error)

LoadSlasherChunks given a chunk kind and a disk keys, retrieves chunks for a validator min or max span used by slasher from our database.

func (*Store) PruneAttestationsAtEpoch

func (s *Store) PruneAttestationsAtEpoch(
	ctx context.Context, maxEpoch types.Epoch,
) (numPruned uint, err error)

PruneAttestationsAtEpoch deletes all attestations from the slasher DB with target epoch less than or equal to the specified epoch.

func (*Store) PruneProposalsAtEpoch

func (s *Store) PruneProposalsAtEpoch(
	ctx context.Context, maxEpoch types.Epoch,
) (numPruned uint, err error)

PruneProposalsAtEpoch deletes all proposals from the slasher DB with epoch less than or equal to the specified epoch.

func (*Store) SaveAttestationRecordsForValidators

func (s *Store) SaveAttestationRecordsForValidators(
	ctx context.Context,
	attestations []*slashertypes.IndexedAttestationWrapper,
) error

SaveAttestationRecordsForValidators saves attestation records for the specified indices.

func (*Store) SaveBlockProposals

func (s *Store) SaveBlockProposals(
	ctx context.Context, proposals []*slashertypes.SignedBlockHeaderWrapper,
) error

SaveBlockProposals takes in a list of block proposals and saves them to our proposal records bucket in the database.

func (*Store) SaveLastEpochWrittenForValidators

func (s *Store) SaveLastEpochWrittenForValidators(
	ctx context.Context, validatorIndices []types.ValidatorIndex, epoch types.Epoch,
) error

SaveLastEpochWrittenForValidators updates the latest epoch a slice of validator indices has attested to.

func (*Store) SaveSlasherChunks

func (s *Store) SaveSlasherChunks(
	ctx context.Context, kind slashertypes.ChunkKind, chunkKeys [][]byte, chunks [][]uint16,
) error

SaveSlasherChunks given a chunk kind, list of disk keys, and list of chunks, saves the chunks to our database for use by slasher in slashing detection.

Jump to

Keyboard shortcuts

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