Documentation ¶
Index ¶
- type Config
- type Store
- func (db *Store) AttesterSlashings(ctx context.Context, status types.SlashingStatus) ([]*ethpb.AttesterSlashing, error)
- func (db *Store) BlockHeaders(ctx context.Context, epoch uint64, validatorID uint64) ([]*ethpb.SignedBeaconBlockHeader, error)
- func (db *Store) ChainHead(ctx context.Context) (*ethpb.ChainHead, error)
- func (db *Store) ClearDB() error
- func (db *Store) ClearSpanCache()
- func (db *Store) Close() error
- func (db *Store) DatabasePath() string
- func (db *Store) DeleteAttesterSlashing(ctx context.Context, attesterSlashing *ethpb.AttesterSlashing) error
- func (db *Store) DeleteBlockHeader(ctx context.Context, validatorID uint64, ...) error
- func (db *Store) DeleteEpochSpans(ctx context.Context, epoch uint64) error
- func (db *Store) DeleteIndexedAttestation(ctx context.Context, idxAttestation *ethpb.IndexedAttestation) error
- func (db *Store) DeleteProposerSlashing(ctx context.Context, slashing *ethpb.ProposerSlashing) error
- func (db *Store) DeletePubKey(ctx context.Context, validatorID uint64) error
- func (db *Store) DeleteValidatorSpanByEpoch(ctx context.Context, validatorIdx uint64, epoch uint64) error
- func (db *Store) EpochSpanByValidatorIndex(ctx context.Context, validatorIdx uint64, epoch uint64) (types.Span, error)
- func (db *Store) EpochSpansMap(ctx context.Context, epoch uint64) (map[uint64]types.Span, error)
- func (db *Store) GetLatestEpochDetected(ctx context.Context) (uint64, error)
- func (db *Store) HasAttesterSlashing(ctx context.Context, slashing *ethpb.AttesterSlashing) (bool, types.SlashingStatus, error)
- func (db *Store) HasBlockHeader(ctx context.Context, epoch uint64, validatorID uint64) bool
- func (db *Store) HasIndexedAttestation(ctx context.Context, att *ethpb.IndexedAttestation) (bool, error)
- func (db *Store) HasProposerSlashing(ctx context.Context, slashing *ethpb.ProposerSlashing) (bool, types.SlashingStatus, error)
- func (db *Store) IndexedAttestationsForTarget(ctx context.Context, targetEpoch uint64) ([]*ethpb.IndexedAttestation, error)
- func (db *Store) IndexedAttestationsWithPrefix(ctx context.Context, targetEpoch uint64, sigBytes []byte) ([]*ethpb.IndexedAttestation, error)
- func (db *Store) LatestIndexedAttestationsTargetEpoch(ctx context.Context) (uint64, error)
- func (db *Store) ProposalSlashingsByStatus(ctx context.Context, status types.SlashingStatus) ([]*ethpb.ProposerSlashing, error)
- func (db *Store) PruneAttHistory(ctx context.Context, currentEpoch uint64, pruningEpochAge uint64) error
- func (db *Store) PruneBlockHistory(ctx context.Context, currentEpoch uint64, pruningEpochAge uint64) error
- func (db *Store) SaveAttesterSlashing(ctx context.Context, status types.SlashingStatus, ...) error
- func (db *Store) SaveAttesterSlashings(ctx context.Context, status types.SlashingStatus, ...) error
- func (db *Store) SaveBlockHeader(ctx context.Context, validatorID uint64, ...) error
- func (db *Store) SaveCachedSpansMaps(ctx context.Context) error
- func (db *Store) SaveChainHead(ctx context.Context, head *ethpb.ChainHead) error
- func (db *Store) SaveEpochSpansMap(ctx context.Context, epoch uint64, spanMap map[uint64]types.Span) error
- func (db *Store) SaveIndexedAttestation(ctx context.Context, idxAttestation *ethpb.IndexedAttestation) error
- func (db *Store) SaveIndexedAttestations(ctx context.Context, idxAttestations []*ethpb.IndexedAttestation) error
- func (db *Store) SaveProposerSlashing(ctx context.Context, status types.SlashingStatus, ...) error
- func (db *Store) SaveProposerSlashings(ctx context.Context, status types.SlashingStatus, ...) error
- func (db *Store) SavePubKey(ctx context.Context, validatorID uint64, pubKey []byte) error
- func (db *Store) SaveValidatorEpochSpan(ctx context.Context, validatorIdx uint64, epoch uint64, span types.Span) error
- func (db *Store) SetLatestEpochDetected(ctx context.Context, epoch uint64) error
- func (db *Store) Size() (int64, error)
- func (db *Store) ValidatorPubKey(ctx context.Context, validatorID uint64) ([]byte, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { // SpanCacheEnabled uses span cache to detect surround slashing. SpanCacheEnabled bool SpanCacheSize int }
Config options for the slasher db.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store defines an implementation of the slasher Database interface using BoltDB as the underlying persistent kv-store for eth2.
func NewKVStore ¶
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) AttesterSlashings ¶
func (db *Store) AttesterSlashings(ctx context.Context, status types.SlashingStatus) ([]*ethpb.AttesterSlashing, error)
AttesterSlashings accepts a status and returns all slashings with this status. returns empty []*ethpb.AttesterSlashing if no slashing has been found with this status.
func (*Store) BlockHeaders ¶
func (db *Store) BlockHeaders(ctx context.Context, epoch uint64, validatorID uint64) ([]*ethpb.SignedBeaconBlockHeader, error)
BlockHeaders accepts an epoch and validator id and returns the corresponding block header array. Returns nil if the block header for those values does not exist.
func (*Store) ChainHead ¶
ChainHead retrieves the persisted chain head from the database accordingly.
func (*Store) ClearDB ¶
ClearDB removes any previously stored data at the configured data directory.
func (*Store) ClearSpanCache ¶
func (db *Store) ClearSpanCache()
ClearSpanCache clears the spans cache.
func (*Store) DatabasePath ¶
DatabasePath at which this database writes files.
func (*Store) DeleteAttesterSlashing ¶
func (db *Store) DeleteAttesterSlashing(ctx context.Context, attesterSlashing *ethpb.AttesterSlashing) error
DeleteAttesterSlashing deletes an attester slashing proof from db.
func (*Store) DeleteBlockHeader ¶
func (db *Store) DeleteBlockHeader(ctx context.Context, validatorID uint64, blockHeader *ethpb.SignedBeaconBlockHeader) error
DeleteBlockHeader deletes a block header using the epoch and validator id.
func (*Store) DeleteEpochSpans ¶
DeleteEpochSpans deletes a epochs validators span map using a epoch index as bucket key.
func (*Store) DeleteIndexedAttestation ¶
func (db *Store) DeleteIndexedAttestation(ctx context.Context, idxAttestation *ethpb.IndexedAttestation) error
DeleteIndexedAttestation deletes a indexed attestation using the slot and its root as keys in their respective buckets.
func (*Store) DeleteProposerSlashing ¶
func (db *Store) DeleteProposerSlashing(ctx context.Context, slashing *ethpb.ProposerSlashing) error
DeleteProposerSlashing deletes a proposer slashing proof.
func (*Store) DeletePubKey ¶
DeletePubKey deletes a public key of a validator id.
func (*Store) DeleteValidatorSpanByEpoch ¶
func (db *Store) DeleteValidatorSpanByEpoch(ctx context.Context, validatorIdx uint64, epoch uint64) error
DeleteValidatorSpanByEpoch deletes a validator span for a certain epoch deletes spans from cache if caching is enabled. using a validator index as bucket key.
func (*Store) EpochSpanByValidatorIndex ¶
func (db *Store) EpochSpanByValidatorIndex(ctx context.Context, validatorIdx uint64, epoch uint64) (types.Span, error)
EpochSpanByValidatorIndex accepts validator index and epoch returns the corresponding spans for slashing detection. it reads the epoch spans from cache and gets the requested value from there if it exists when caching is enabled. Returns error if the spans for this validator index and epoch does not exist.
func (*Store) EpochSpansMap ¶
EpochSpansMap accepts epoch and returns the corresponding spans map epoch=>spans for slashing detection. This function reads spans from cache if caching is enabled and the epoch key exists. Returns nil if the span map for this validator index does not exist.
func (*Store) GetLatestEpochDetected ¶
GetLatestEpochDetected returns the latest detected epoch from db.
func (*Store) HasAttesterSlashing ¶
func (db *Store) HasAttesterSlashing(ctx context.Context, slashing *ethpb.AttesterSlashing) (bool, types.SlashingStatus, error)
HasAttesterSlashing returns true and slashing status if a slashing is found in the db.
func (*Store) HasBlockHeader ¶
HasBlockHeader accepts an epoch and validator id and returns true if the block header exists.
func (*Store) HasIndexedAttestation ¶
func (db *Store) HasIndexedAttestation(ctx context.Context, att *ethpb.IndexedAttestation) (bool, error)
HasIndexedAttestation accepts an attestation and returns true if it exists in the DB.
func (*Store) HasProposerSlashing ¶
func (db *Store) HasProposerSlashing(ctx context.Context, slashing *ethpb.ProposerSlashing) (bool, types.SlashingStatus, error)
HasProposerSlashing returns the slashing key if it is found in db.
func (*Store) IndexedAttestationsForTarget ¶
func (db *Store) IndexedAttestationsForTarget(ctx context.Context, targetEpoch uint64) ([]*ethpb.IndexedAttestation, error)
IndexedAttestationsForTarget accepts a target epoch and returns a list of indexed attestations. Returns nil if the indexed attestation does not exist with that target epoch.
func (*Store) IndexedAttestationsWithPrefix ¶
func (db *Store) IndexedAttestationsWithPrefix(ctx context.Context, targetEpoch uint64, sigBytes []byte) ([]*ethpb.IndexedAttestation, error)
IndexedAttestationsWithPrefix accepts a target epoch and signature bytes to find all attestations with the requested prefix. Returns nil if the indexed attestation does not exist with that target epoch.
func (*Store) LatestIndexedAttestationsTargetEpoch ¶
LatestIndexedAttestationsTargetEpoch returns latest target epoch in db returns 0 if there is no indexed attestations in db.
func (*Store) ProposalSlashingsByStatus ¶
func (db *Store) ProposalSlashingsByStatus(ctx context.Context, status types.SlashingStatus) ([]*ethpb.ProposerSlashing, error)
ProposalSlashingsByStatus returns all the proposal slashing proofs with a certain status.
func (*Store) PruneAttHistory ¶
func (db *Store) PruneAttHistory(ctx context.Context, currentEpoch uint64, pruningEpochAge uint64) error
PruneAttHistory removes all attestations from the DB older than the pruning epoch age.
func (*Store) PruneBlockHistory ¶
func (db *Store) PruneBlockHistory(ctx context.Context, currentEpoch uint64, pruningEpochAge uint64) error
PruneBlockHistory leaves only records younger then history size.
func (*Store) SaveAttesterSlashing ¶
func (db *Store) SaveAttesterSlashing(ctx context.Context, status types.SlashingStatus, slashing *ethpb.AttesterSlashing) error
SaveAttesterSlashing accepts a slashing proof and its status and writes it to disk.
func (*Store) SaveAttesterSlashings ¶
func (db *Store) SaveAttesterSlashings(ctx context.Context, status types.SlashingStatus, slashings []*ethpb.AttesterSlashing) error
SaveAttesterSlashings accepts a slice of slashing proof and its status and writes it to disk.
func (*Store) SaveBlockHeader ¶
func (db *Store) SaveBlockHeader(ctx context.Context, validatorID uint64, blockHeader *ethpb.SignedBeaconBlockHeader) error
SaveBlockHeader accepts a block header and writes it to disk.
func (*Store) SaveCachedSpansMaps ¶
SaveCachedSpansMaps saves all span maps that are currently in memory into the DB. if no span maps are in db or cache is disabled it returns nil.
func (*Store) SaveChainHead ¶
SaveChainHead accepts a beacon chain head object and persists it to the DB.
func (*Store) SaveEpochSpansMap ¶
func (db *Store) SaveEpochSpansMap(ctx context.Context, epoch uint64, spanMap map[uint64]types.Span) error
SaveEpochSpansMap accepts a epoch and span map epoch=>spans and writes it to disk. saves the spans to cache if caching is enabled. The key in the cache is the epoch and the value is the span map itself.
func (*Store) SaveIndexedAttestation ¶
func (db *Store) SaveIndexedAttestation(ctx context.Context, idxAttestation *ethpb.IndexedAttestation) error
SaveIndexedAttestation accepts an indexed attestation and writes it to the DB.
func (*Store) SaveIndexedAttestations ¶
func (db *Store) SaveIndexedAttestations(ctx context.Context, idxAttestations []*ethpb.IndexedAttestation) error
SaveIndexedAttestations accepts multiple indexed attestations and writes them to the DB.
func (*Store) SaveProposerSlashing ¶
func (db *Store) SaveProposerSlashing(ctx context.Context, status types.SlashingStatus, slashing *ethpb.ProposerSlashing) error
SaveProposerSlashing accepts a proposer slashing and its status header and writes it to disk.
func (*Store) SaveProposerSlashings ¶
func (db *Store) SaveProposerSlashings(ctx context.Context, status types.SlashingStatus, slashings []*ethpb.ProposerSlashing) error
SaveProposerSlashings accepts a slice of slashing proof and its status and writes it to disk.
func (*Store) SavePubKey ¶
SavePubKey accepts a validator id and its public key and writes it to disk.
func (*Store) SaveValidatorEpochSpan ¶ added in v0.3.4
func (db *Store) SaveValidatorEpochSpan( ctx context.Context, validatorIdx uint64, epoch uint64, span types.Span, ) error
SaveValidatorEpochSpan accepts validator index epoch and spans returns. it reads the epoch spans from cache, updates it and save it back to cache if caching is enabled. Returns error if the spans for this validator index and epoch does not exist.
func (*Store) SetLatestEpochDetected ¶
SetLatestEpochDetected sets the latest slashing detected epoch in db.