filesystem

package
v5.0.3 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2024 License: GPL-3.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DatabaseDirName = "validator-client-data"
)

Variables

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

ErrNoProposerSettingsFound is an error thrown when no settings are found.

Functions

This section is empty.

Types

type Config

type Config struct {
	PubKeys [][fieldparams.BLSPubkeyLength]byte
}

Config represents store's config object.

type Configuration

type Configuration struct {
	GenesisValidatorsRoot *string                              `yaml:"genesisValidatorsRoot,omitempty"`
	ProposerSettings      *validatorpb.ProposerSettingsPayload `yaml:"proposerSettings,omitempty"`
	Graffiti              *Graffiti                            `yaml:"graffiti,omitempty"`
}

Configuration contains the genesis information, the proposer settings and the graffiti.

type Graffiti

type Graffiti struct {
	// In BoltDB implementation, calling GraffitiOrderedIndex with
	// the filehash stored in DB, but without an OrderedIndex already
	// stored in DB returns 0.
	// ==> Using the default value of uint64 is OK.
	OrderedIndex uint64
	FileHash     *string
}

Graffiti contains the graffiti information.

type Store

type Store struct {
	// contains filtered or unexported fields
}

Store is a filesystem implementation of the validator client database.

func NewStore

func NewStore(databaseParentPath string, config *Config) (*Store, error)

NewStore creates a new filesystem store.

func (*Store) AttestationHistoryForPubKey

func (s *Store) AttestationHistoryForPubKey(
	_ context.Context,
	pubKey [fieldparams.BLSPubkeyLength]byte,
) ([]*common.AttestationRecord, error)

AttestationHistoryForPubKey returns the attestation history for a public key.

func (*Store) AttestedPublicKeys

func (s *Store) AttestedPublicKeys(_ context.Context) ([][fieldparams.BLSPubkeyLength]byte, error)

AttestedPublicKeys returns the list of public keys in the database.

func (*Store) Backup

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

Backup creates a backup of the database.

func (*Store) ClearDB

func (s *Store) ClearDB() error

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

func (*Store) Close

func (*Store) Close() error

Close only exists to satisfy the interface.

func (*Store) DatabasePath

func (s *Store) DatabasePath() string

DatabasePath returns the path at which this database writes files.

func (*Store) EIPImportBlacklistedPublicKeys

func (*Store) EIPImportBlacklistedPublicKeys(_ context.Context) ([][fieldparams.BLSPubkeyLength]byte, error)

EIPImportBlacklistedPublicKeys is implemented only to satisfy the interface.

func (*Store) GenesisValidatorsRoot

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

func (*Store) GraffitiFileHash

func (s *Store) GraffitiFileHash() ([32]byte, bool, error)

func (*Store) GraffitiOrderedIndex

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

func (*Store) HighestSignedProposal

func (*Store) HighestSignedProposal(_ context.Context, _ [fieldparams.BLSPubkeyLength]byte) (primitives.Slot, bool, error)

HighestSignedProposal is implemented only to satisfy the interface.

func (*Store) ImportStandardProtectionJSON

func (s *Store) ImportStandardProtectionJSON(ctx context.Context, r io.Reader) error

ImportStandardProtectionJSON takes in EIP-3076 compliant JSON file used for slashing protection by Ethereum validators and imports its data into Prysm's internal minimal representation of slashing protection in the validator client's database.

func (*Store) LowestSignedProposal

func (*Store) LowestSignedProposal(_ context.Context, _ [fieldparams.BLSPubkeyLength]byte) (primitives.Slot, bool, error)

LowestSignedProposal is implemented only to satisfy the interface.

func (*Store) LowestSignedSourceEpoch

func (s *Store) LowestSignedSourceEpoch(_ context.Context, pubKey [fieldparams.BLSPubkeyLength]byte) (primitives.Epoch, bool, error)

LowestSignedSourceEpoch is implemented only to satisfy the interface.

func (*Store) LowestSignedTargetEpoch

func (s *Store) LowestSignedTargetEpoch(_ context.Context, pubKey [fieldparams.BLSPubkeyLength]byte) (primitives.Epoch, bool, error)

LowestSignedTargetEpoch returns the lowest signed target epoch for a public key, a boolean indicating if it exists and an error.

func (*Store) ProposalHistoryForPubKey

func (s *Store) ProposalHistoryForPubKey(_ context.Context, publicKey [fieldparams.BLSPubkeyLength]byte) ([]*common.Proposal, error)

ProposalHistoryForPubKey returns the proposal history for a given public key.

func (*Store) ProposalHistoryForSlot

ProposalHistoryForSlot is implemented only to satisfy the interface.

func (*Store) ProposedPublicKeys

func (s *Store) ProposedPublicKeys(_ context.Context) ([][fieldparams.BLSPubkeyLength]byte, error)

ProposedPublicKeys returns the list of public keys we have in the database. To be consistent with the complete, BoltDB implementation, pubkeys returned by this function do not necessarily have proposed a block.

func (*Store) ProposerSettings

func (s *Store) ProposerSettings(_ context.Context) (*proposer.Settings, error)

ProposerSettings returns the proposer settings.

func (*Store) ProposerSettingsExists

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

ProposerSettingsExists returns true if proposer settings exists, false otherwise.

func (*Store) RunDownMigrations

func (*Store) RunDownMigrations(_ context.Context) error

RunDownMigrations only exists to satisfy the interface.

func (*Store) RunUpMigrations

func (*Store) RunUpMigrations(_ context.Context) error

RunUpMigrations only exists to satisfy the interface.

func (*Store) SaveAttestationForPubKey

func (s *Store) SaveAttestationForPubKey(
	_ context.Context,
	pubkey [fieldparams.BLSPubkeyLength]byte,
	_ [32]byte,
	att *ethpb.IndexedAttestation,
) error

SaveAttestationForPubKey checks if the incoming attestation is valid regarding EIP-3076 minimal slashing protection. If so, it updates the database with the incoming source and target, and returns nil. If not, it does not modify the database and return an error.

func (*Store) SaveAttestationsForPubKey

func (s *Store) SaveAttestationsForPubKey(
	_ context.Context,
	pubkey [fieldparams.BLSPubkeyLength]byte,
	_ [][]byte,
	atts []*ethpb.IndexedAttestation,
) error

SaveAttestationsForPubKey saves the attestation history for a list of public keys WITHOUT checking if the incoming attestations are valid regarding EIP-3076 minimal slashing protection. For each public key, incoming sources and targets epochs are compared with recorded source and target epochs, and maximums are saved.

func (*Store) SaveEIPImportBlacklistedPublicKeys

func (*Store) SaveEIPImportBlacklistedPublicKeys(_ context.Context, _ [][fieldparams.BLSPubkeyLength]byte) error

SaveEIPImportBlacklistedPublicKeys is implemented only to satisfy the interface.

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

func (*Store) SaveProposalHistoryForSlot

func (s *Store) SaveProposalHistoryForSlot(
	_ context.Context,
	pubKey [fieldparams.BLSPubkeyLength]byte,
	slot primitives.Slot,
	_ []byte,
) error

SaveProposalHistoryForSlot checks if the incoming proposal is valid regarding EIP-3076 minimal slashing protection. If so, it updates the database with the incoming slot, and returns nil. If not, it does not modify the database and return an error.

func (*Store) SaveProposerSettings

func (s *Store) SaveProposerSettings(_ context.Context, proposerSettings *proposer.Settings) error

SaveProposerSettings saves the proposer settings.

func (*Store) SigningRootAtTargetEpoch

func (*Store) SigningRootAtTargetEpoch(_ context.Context, _ [fieldparams.BLSPubkeyLength]byte, _ primitives.Epoch) ([]byte, error)

SigningRootAtTargetEpoch is implemented only to satisfy the interface.

func (*Store) SlashableAttestationCheck

func (s *Store) SlashableAttestationCheck(
	ctx context.Context,
	indexedAtt *ethpb.IndexedAttestation,
	pubKey [fieldparams.BLSPubkeyLength]byte,
	signingRoot32 [32]byte,
	_ bool,
	_ *prometheus.CounterVec,
) error

SlashableAttestationCheck checks if an attestation is slashable by comparing it with the attesting history for the given public key in our minimal slashing protection database defined by EIP-3076. If it is not, it updates the database.

func (*Store) SlashableProposalCheck

func (s *Store) SlashableProposalCheck(
	ctx context.Context,
	pubKey [fieldparams.BLSPubkeyLength]byte,
	signedBlock interfaces.ReadOnlySignedBeaconBlock,
	signingRoot [fieldparams.RootLength]byte,
	emitAccountMetrics bool,
	validatorProposeFailVec *prometheus.CounterVec,
) error

SlashableProposalCheck checks if a block proposal is slashable by comparing it with the block proposals history for the given public key in our minimal slashing protection database defined by EIP-3076. If it is not, it update the database.

func (*Store) UpdatePublicKeysBuckets

func (s *Store) UpdatePublicKeysBuckets(pubKeys [][fieldparams.BLSPubkeyLength]byte) error

UpdatePublicKeysBuckets creates a file for each public key in the database directory if needed.

type ValidatorSlashingProtection

type ValidatorSlashingProtection struct {
	LatestSignedBlockSlot            *uint64 `yaml:"latestSignedBlockSlot,omitempty"`
	LastSignedAttestationSourceEpoch uint64  `yaml:"lastSignedAttestationSourceEpoch"`
	LastSignedAttestationTargetEpoch *uint64 `yaml:"lastSignedAttestationTargetEpoch,omitempty"`
}

ValidatorSlashingProtection contains the latest signed block slot, the last signed attestation. It is used to protect against validator slashing, implementing the EIP-3076 minimal slashing protection database. https://eips.ethereum.org/EIPS/eip-3076

Jump to

Keyboard shortcuts

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