mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-25 12:57:18 +00:00
Validator DB cleanup: remove obsolete buckets (#8122)
This commit is contained in:
parent
508c5fcf2f
commit
ad7d3c74cc
@ -16,7 +16,7 @@ func (store *Store) AttestedPublicKeys(ctx context.Context) ([][48]byte, error)
|
|||||||
var err error
|
var err error
|
||||||
attestedPublicKeys := make([][48]byte, 0)
|
attestedPublicKeys := make([][48]byte, 0)
|
||||||
err = store.view(func(tx *bolt.Tx) error {
|
err = store.view(func(tx *bolt.Tx) error {
|
||||||
bucket := tx.Bucket(newHistoricAttestationsBucket)
|
bucket := tx.Bucket(historicAttestationsBucket)
|
||||||
return bucket.ForEach(func(key []byte, _ []byte) error {
|
return bucket.ForEach(func(key []byte, _ []byte) error {
|
||||||
pubKeyBytes := [48]byte{}
|
pubKeyBytes := [48]byte{}
|
||||||
copy(pubKeyBytes[:], key)
|
copy(pubKeyBytes[:], key)
|
||||||
@ -42,7 +42,7 @@ func (store *Store) AttestationHistoryForPubKeyV2(ctx context.Context, publicKey
|
|||||||
var err error
|
var err error
|
||||||
var attestationHistory EncHistoryData
|
var attestationHistory EncHistoryData
|
||||||
err = store.view(func(tx *bolt.Tx) error {
|
err = store.view(func(tx *bolt.Tx) error {
|
||||||
bucket := tx.Bucket(newHistoricAttestationsBucket)
|
bucket := tx.Bucket(historicAttestationsBucket)
|
||||||
enc := bucket.Get(publicKey[:])
|
enc := bucket.Get(publicKey[:])
|
||||||
if len(enc) == 0 {
|
if len(enc) == 0 {
|
||||||
attestationHistory = NewAttestationHistoryArray(0)
|
attestationHistory = NewAttestationHistoryArray(0)
|
||||||
@ -63,7 +63,7 @@ func (store *Store) SaveAttestationHistoryForPubKeyV2(ctx context.Context, pubKe
|
|||||||
ctx, span := trace.StartSpan(ctx, "Validator.SaveAttestationHistoryForPubKeyV2")
|
ctx, span := trace.StartSpan(ctx, "Validator.SaveAttestationHistoryForPubKeyV2")
|
||||||
defer span.End()
|
defer span.End()
|
||||||
err := store.update(func(tx *bolt.Tx) error {
|
err := store.update(func(tx *bolt.Tx) error {
|
||||||
bucket := tx.Bucket(newHistoricAttestationsBucket)
|
bucket := tx.Bucket(historicAttestationsBucket)
|
||||||
return bucket.Put(pubKey[:], history)
|
return bucket.Put(pubKey[:], history)
|
||||||
})
|
})
|
||||||
if !featureconfig.Get().DisableAttestingHistoryDBCache {
|
if !featureconfig.Get().DisableAttestingHistoryDBCache {
|
||||||
|
@ -96,10 +96,8 @@ func NewKVStore(ctx context.Context, dirPath string, pubKeys [][48]byte) (*Store
|
|||||||
return createBuckets(
|
return createBuckets(
|
||||||
tx,
|
tx,
|
||||||
genesisInfoBucket,
|
genesisInfoBucket,
|
||||||
historicProposalsBucket,
|
|
||||||
historicAttestationsBucket,
|
historicAttestationsBucket,
|
||||||
newHistoricAttestationsBucket,
|
historicProposalsBucket,
|
||||||
newHistoricProposalsBucket,
|
|
||||||
lowestSignedSourceBucket,
|
lowestSignedSourceBucket,
|
||||||
lowestSignedTargetBucket,
|
lowestSignedTargetBucket,
|
||||||
lowestSignedProposalsBucket,
|
lowestSignedProposalsBucket,
|
||||||
@ -135,7 +133,7 @@ func NewKVStore(ctx context.Context, dirPath string, pubKeys [][48]byte) (*Store
|
|||||||
// UpdatePublicKeysBuckets for a specified list of keys.
|
// UpdatePublicKeysBuckets for a specified list of keys.
|
||||||
func (store *Store) UpdatePublicKeysBuckets(pubKeys [][48]byte) error {
|
func (store *Store) UpdatePublicKeysBuckets(pubKeys [][48]byte) error {
|
||||||
return store.update(func(tx *bolt.Tx) error {
|
return store.update(func(tx *bolt.Tx) error {
|
||||||
bucket := tx.Bucket(newHistoricProposalsBucket)
|
bucket := tx.Bucket(historicProposalsBucket)
|
||||||
for _, pubKey := range pubKeys {
|
for _, pubKey := range pubKeys {
|
||||||
if _, err := bucket.CreateBucketIfNotExists(pubKey[:]); err != nil {
|
if _, err := bucket.CreateBucketIfNotExists(pubKey[:]); err != nil {
|
||||||
return errors.Wrap(err, "failed to create proposal history bucket")
|
return errors.Wrap(err, "failed to create proposal history bucket")
|
||||||
|
@ -30,7 +30,7 @@ func (store *Store) ProposedPublicKeys(ctx context.Context) ([][48]byte, error)
|
|||||||
var err error
|
var err error
|
||||||
proposedPublicKeys := make([][48]byte, 0)
|
proposedPublicKeys := make([][48]byte, 0)
|
||||||
err = store.view(func(tx *bolt.Tx) error {
|
err = store.view(func(tx *bolt.Tx) error {
|
||||||
bucket := tx.Bucket(newHistoricProposalsBucket)
|
bucket := tx.Bucket(historicProposalsBucket)
|
||||||
return bucket.ForEach(func(key []byte, _ []byte) error {
|
return bucket.ForEach(func(key []byte, _ []byte) error {
|
||||||
pubKeyBytes := [48]byte{}
|
pubKeyBytes := [48]byte{}
|
||||||
copy(pubKeyBytes[:], key)
|
copy(pubKeyBytes[:], key)
|
||||||
@ -52,7 +52,7 @@ func (store *Store) ProposalHistoryForSlot(ctx context.Context, publicKey [48]by
|
|||||||
var proposalExists bool
|
var proposalExists bool
|
||||||
signingRoot := [32]byte{}
|
signingRoot := [32]byte{}
|
||||||
err = store.update(func(tx *bolt.Tx) error {
|
err = store.update(func(tx *bolt.Tx) error {
|
||||||
bucket := tx.Bucket(newHistoricProposalsBucket)
|
bucket := tx.Bucket(historicProposalsBucket)
|
||||||
valBucket, err := bucket.CreateBucketIfNotExists(publicKey[:])
|
valBucket, err := bucket.CreateBucketIfNotExists(publicKey[:])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("could not create bucket for public key %#x", publicKey[:])
|
return fmt.Errorf("could not create bucket for public key %#x", publicKey[:])
|
||||||
@ -76,7 +76,7 @@ func (store *Store) SaveProposalHistoryForSlot(ctx context.Context, pubKey [48]b
|
|||||||
defer span.End()
|
defer span.End()
|
||||||
|
|
||||||
err := store.update(func(tx *bolt.Tx) error {
|
err := store.update(func(tx *bolt.Tx) error {
|
||||||
bucket := tx.Bucket(newHistoricProposalsBucket)
|
bucket := tx.Bucket(historicProposalsBucket)
|
||||||
valBucket, err := bucket.CreateBucketIfNotExists(pubKey[:])
|
valBucket, err := bucket.CreateBucketIfNotExists(pubKey[:])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("could not create bucket for public key %#x", pubKey)
|
return fmt.Errorf("could not create bucket for public key %#x", pubKey)
|
||||||
|
@ -5,13 +5,9 @@ var (
|
|||||||
genesisInfoBucket = []byte("genesis-info-bucket")
|
genesisInfoBucket = []byte("genesis-info-bucket")
|
||||||
|
|
||||||
// Validator slashing protection from double proposals.
|
// Validator slashing protection from double proposals.
|
||||||
historicProposalsBucket = []byte("proposal-history-bucket")
|
historicProposalsBucket = []byte("proposal-history-bucket-interchange")
|
||||||
// Validator slashing protection from double proposals.
|
|
||||||
newHistoricProposalsBucket = []byte("proposal-history-bucket-interchange")
|
|
||||||
// Validator slashing protection from slashable attestations.
|
|
||||||
historicAttestationsBucket = []byte("attestation-history-bucket")
|
|
||||||
// New Validator slashing protection from slashable attestations.
|
// New Validator slashing protection from slashable attestations.
|
||||||
newHistoricAttestationsBucket = []byte("attestation-history-bucket-interchange")
|
historicAttestationsBucket = []byte("attestation-history-bucket-interchange")
|
||||||
|
|
||||||
// Buckets for lowest signed source and target epoch for individual validator.
|
// Buckets for lowest signed source and target epoch for individual validator.
|
||||||
lowestSignedSourceBucket = []byte("lowest-signed-source-bucket")
|
lowestSignedSourceBucket = []byte("lowest-signed-source-bucket")
|
||||||
|
Loading…
Reference in New Issue
Block a user