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"
|
2021-06-02 23:49:52 +00:00
|
|
|
ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1"
|
2020-12-03 22:28:57 +00:00
|
|
|
"github.com/prysmaticlabs/prysm/shared/backuputil"
|
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
|
2020-12-03 22:28:57 +00:00
|
|
|
backuputil.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
|
2020-08-31 23:38:20 +00:00
|
|
|
UpdatePublicKeysBuckets(publicKeys [][48]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.
|
2021-02-16 07:45:34 +00:00
|
|
|
HighestSignedProposal(ctx context.Context, publicKey [48]byte) (types.Slot, bool, error)
|
|
|
|
LowestSignedProposal(ctx context.Context, publicKey [48]byte) (types.Slot, bool, error)
|
2021-02-02 15:53:12 +00:00
|
|
|
ProposalHistoryForPubKey(ctx context.Context, publicKey [48]byte) ([]*kv.Proposal, error)
|
2021-02-16 07:45:34 +00:00
|
|
|
ProposalHistoryForSlot(ctx context.Context, publicKey [48]byte, slot types.Slot) ([32]byte, bool, error)
|
|
|
|
SaveProposalHistoryForSlot(ctx context.Context, pubKey [48]byte, slot types.Slot, signingRoot []byte) error
|
2020-11-25 21:37:39 +00:00
|
|
|
ProposedPublicKeys(ctx context.Context) ([][48]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.
|
|
|
|
EIPImportBlacklistedPublicKeys(ctx context.Context) ([][48]byte, error)
|
|
|
|
SaveEIPImportBlacklistedPublicKeys(ctx context.Context, publicKeys [][48]byte) error
|
2021-02-09 10:05:22 +00:00
|
|
|
SigningRootAtTargetEpoch(ctx context.Context, publicKey [48]byte, target types.Epoch) ([32]byte, error)
|
|
|
|
LowestSignedTargetEpoch(ctx context.Context, publicKey [48]byte) (types.Epoch, bool, error)
|
|
|
|
LowestSignedSourceEpoch(ctx context.Context, publicKey [48]byte) (types.Epoch, bool, error)
|
2020-11-25 21:37:39 +00:00
|
|
|
AttestedPublicKeys(ctx context.Context) ([][48]byte, error)
|
2021-01-11 23:59:17 +00:00
|
|
|
CheckSlashableAttestation(
|
|
|
|
ctx context.Context, pubKey [48]byte, signingRoot [32]byte, att *ethpb.IndexedAttestation,
|
|
|
|
) (kv.SlashingKind, error)
|
|
|
|
SaveAttestationForPubKey(
|
|
|
|
ctx context.Context, pubKey [48]byte, signingRoot [32]byte, att *ethpb.IndexedAttestation,
|
|
|
|
) error
|
2021-01-22 23:12:22 +00:00
|
|
|
SaveAttestationsForPubKey(
|
|
|
|
ctx context.Context, pubKey [48]byte, signingRoots [][32]byte, atts []*ethpb.IndexedAttestation,
|
|
|
|
) error
|
|
|
|
AttestationHistoryForPubKey(
|
|
|
|
ctx context.Context, pubKey [48]byte,
|
|
|
|
) ([]*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
|
|
|
}
|