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-01-11 23:59:17 +00:00
|
|
|
ethpb "github.com/prysmaticlabs/ethereumapis/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
|
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.
|
2020-11-25 21:37:39 +00:00
|
|
|
HighestSignedProposal(ctx context.Context, publicKey [48]byte) (uint64, error)
|
|
|
|
LowestSignedProposal(ctx context.Context, publicKey [48]byte) (uint64, error)
|
2020-11-25 22:24:07 +00:00
|
|
|
ProposalHistoryForSlot(ctx context.Context, publicKey [48]byte, slot uint64) ([32]byte, bool, error)
|
2020-11-25 20:04:43 +00:00
|
|
|
SaveProposalHistoryForSlot(ctx context.Context, pubKey [48]byte, slot uint64, 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.
|
2020-11-26 17:35:36 +00:00
|
|
|
LowestSignedTargetEpoch(ctx context.Context, publicKey [48]byte) (uint64, error)
|
|
|
|
LowestSignedSourceEpoch(ctx context.Context, publicKey [48]byte) (uint64, 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
|
2020-01-08 18:16:17 +00:00
|
|
|
}
|