Do Not Cache For Non Active Public Keys (#13581)

* fix it

* clean up
This commit is contained in:
Nishant Das
2024-02-03 13:19:54 +08:00
committed by GitHub
parent 74f5452a64
commit 9d1189b222

View File

@@ -10,6 +10,7 @@ import (
"time"
"github.com/pkg/errors"
"github.com/prysmaticlabs/prysm/v4/beacon-chain/core/helpers"
"github.com/prysmaticlabs/prysm/v4/beacon-chain/db"
"github.com/prysmaticlabs/prysm/v4/beacon-chain/forkchoice"
"github.com/prysmaticlabs/prysm/v4/beacon-chain/state"
@@ -18,6 +19,7 @@ import (
"github.com/prysmaticlabs/prysm/v4/consensus-types/primitives"
"github.com/prysmaticlabs/prysm/v4/crypto/bls"
"github.com/prysmaticlabs/prysm/v4/encoding/bytesutil"
"github.com/prysmaticlabs/prysm/v4/time/slots"
"go.opencensus.io/trace"
)
@@ -144,6 +146,7 @@ func (s *State) Resume(ctx context.Context, fState state.BeaconState) (state.Bea
}()
s.finalizedInfo = &finalizedInfo{slot: fState.Slot(), root: fRoot, state: fState.Copy()}
fEpoch := slots.ToEpoch(fState.Slot())
// Pre-populate the pubkey cache with the validator public keys from the finalized state.
// This process takes about 30 seconds on mainnet with 450,000 validators.
@@ -154,6 +157,10 @@ func (s *State) Resume(ctx context.Context, fState state.BeaconState) (state.Bea
if ctx.Err() != nil {
return ctx.Err()
}
// Do not cache for non-active validators.
if !helpers.IsActiveValidatorUsingTrie(val, fEpoch) {
return nil
}
pub := val.PublicKey()
_, err := bls.PublicKeyFromBytes(pub[:])
return err