2020-04-29 21:32:39 +00:00
|
|
|
// Package iface defines an interface for the validator database.
|
2020-01-08 18:16:17 +00:00
|
|
|
package iface
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"io"
|
|
|
|
|
2021-02-22 23:20:57 +00:00
|
|
|
types "github.com/prysmaticlabs/eth2-types"
|
2022-01-06 17:33:08 +00:00
|
|
|
fieldparams "github.com/prysmaticlabs/prysm/config/fieldparams"
|
2021-09-14 20:59:51 +00:00
|
|
|
"github.com/prysmaticlabs/prysm/monitoring/backup"
|
2021-07-21 21:34:07 +00:00
|
|
|
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
|
2020-11-10 14:14:11 +00:00
|
|
|
"github.com/prysmaticlabs/prysm/validator/db/kv"
|
2020-01-08 18:16:17 +00:00
|
|
|
)
|
|
|
|
|
2020-12-03 22:28:57 +00:00
|
|
|
// Ensure the kv store implements the interface.
|
|
|
|
var _ = ValidatorDB(&kv.Store{})
|
|
|
|
|
2020-01-08 18:16:17 +00:00
|
|
|
// ValidatorDB defines the necessary methods for a Prysm validator DB.
|
|
|
|
type ValidatorDB interface {
|
|
|
|
io.Closer
|
2021-09-14 20:59:51 +00:00
|
|
|
backup.BackupExporter
|
2020-01-08 18:16:17 +00:00
|
|
|
DatabasePath() string
|
|
|
|
ClearDB() error
|
2021-01-22 23:12:22 +00:00
|
|
|
RunUpMigrations(ctx context.Context) error
|
|
|
|
RunDownMigrations(ctx context.Context) error
|
2022-01-06 17:33:08 +00:00
|
|
|
UpdatePublicKeysBuckets(publicKeys [][fieldparams.BLSPubkeyLength]byte) error
|
2020-11-20 18:06:12 +00:00
|
|
|
|
|
|
|
// Genesis information related methods.
|
|
|
|
GenesisValidatorsRoot(ctx context.Context) ([]byte, error)
|
|
|
|
SaveGenesisValidatorsRoot(ctx context.Context, genValRoot []byte) error
|
|
|
|
|
2020-01-08 18:16:17 +00:00
|
|
|
// Proposer protection related methods.
|
2022-01-06 17:33:08 +00:00
|
|
|
HighestSignedProposal(ctx context.Context, publicKey [fieldparams.BLSPubkeyLength]byte) (types.Slot, bool, error)
|
|
|
|
LowestSignedProposal(ctx context.Context, publicKey [fieldparams.BLSPubkeyLength]byte) (types.Slot, bool, error)
|
|
|
|
ProposalHistoryForPubKey(ctx context.Context, publicKey [fieldparams.BLSPubkeyLength]byte) ([]*kv.Proposal, error)
|
|
|
|
ProposalHistoryForSlot(ctx context.Context, publicKey [fieldparams.BLSPubkeyLength]byte, slot types.Slot) ([32]byte, bool, error)
|
|
|
|
SaveProposalHistoryForSlot(ctx context.Context, pubKey [fieldparams.BLSPubkeyLength]byte, slot types.Slot, signingRoot []byte) error
|
|
|
|
ProposedPublicKeys(ctx context.Context) ([][fieldparams.BLSPubkeyLength]byte, error)
|
2020-09-14 01:55:33 +00:00
|
|
|
|
2020-01-19 22:05:48 +00:00
|
|
|
// Attester protection related methods.
|
2021-01-22 23:12:22 +00:00
|
|
|
// Methods to store and read blacklisted public keys from EIP-3076
|
|
|
|
// slashing protection imports.
|
2022-01-06 17:33:08 +00:00
|
|
|
EIPImportBlacklistedPublicKeys(ctx context.Context) ([][fieldparams.BLSPubkeyLength]byte, error)
|
|
|
|
SaveEIPImportBlacklistedPublicKeys(ctx context.Context, publicKeys [][fieldparams.BLSPubkeyLength]byte) error
|
|
|
|
SigningRootAtTargetEpoch(ctx context.Context, publicKey [fieldparams.BLSPubkeyLength]byte, target types.Epoch) ([32]byte, error)
|
|
|
|
LowestSignedTargetEpoch(ctx context.Context, publicKey [fieldparams.BLSPubkeyLength]byte) (types.Epoch, bool, error)
|
|
|
|
LowestSignedSourceEpoch(ctx context.Context, publicKey [fieldparams.BLSPubkeyLength]byte) (types.Epoch, bool, error)
|
|
|
|
AttestedPublicKeys(ctx context.Context) ([][fieldparams.BLSPubkeyLength]byte, error)
|
2021-01-11 23:59:17 +00:00
|
|
|
CheckSlashableAttestation(
|
2022-01-06 17:33:08 +00:00
|
|
|
ctx context.Context, pubKey [fieldparams.BLSPubkeyLength]byte, signingRoot [32]byte, att *ethpb.IndexedAttestation,
|
2021-01-11 23:59:17 +00:00
|
|
|
) (kv.SlashingKind, error)
|
|
|
|
SaveAttestationForPubKey(
|
2022-01-06 17:33:08 +00:00
|
|
|
ctx context.Context, pubKey [fieldparams.BLSPubkeyLength]byte, signingRoot [32]byte, att *ethpb.IndexedAttestation,
|
2021-01-11 23:59:17 +00:00
|
|
|
) error
|
2021-01-22 23:12:22 +00:00
|
|
|
SaveAttestationsForPubKey(
|
2022-01-06 17:33:08 +00:00
|
|
|
ctx context.Context, pubKey [fieldparams.BLSPubkeyLength]byte, signingRoots [][32]byte, atts []*ethpb.IndexedAttestation,
|
2021-01-22 23:12:22 +00:00
|
|
|
) error
|
|
|
|
AttestationHistoryForPubKey(
|
2022-01-06 17:33:08 +00:00
|
|
|
ctx context.Context, pubKey [fieldparams.BLSPubkeyLength]byte,
|
2021-01-22 23:12:22 +00:00
|
|
|
) ([]*kv.AttestationRecord, error)
|
2021-02-24 22:50:47 +00:00
|
|
|
|
|
|
|
// Graffiti ordered index related methods
|
|
|
|
SaveGraffitiOrderedIndex(ctx context.Context, index uint64) error
|
|
|
|
GraffitiOrderedIndex(ctx context.Context, fileHash [32]byte) (uint64, error)
|
2020-01-08 18:16:17 +00:00
|
|
|
}
|