diff --git a/beacon-chain/state/stategen/service.go b/beacon-chain/state/stategen/service.go index a6ffb36c61..a7e7e4694d 100644 --- a/beacon-chain/state/stategen/service.go +++ b/beacon-chain/state/stategen/service.go @@ -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