mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-25 04:47:18 +00:00
Allocate Fewer Large Slices (#7698)
Co-authored-by: Raul Jordan <raul@prysmaticlabs.com> Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
This commit is contained in:
parent
51b39420dc
commit
40368bedd3
@ -26,18 +26,20 @@ func ProcessSlashingsPrecompute(state *stateTrie.BeaconState, pBal *Balance) err
|
||||
minSlashing := mathutil.Min(totalSlashing*params.BeaconConfig().ProportionalSlashingMultiplier, pBal.ActiveCurrentEpoch)
|
||||
epochToWithdraw := currentEpoch + exitLength/2
|
||||
|
||||
vs := state.ValidatorsReadOnly()
|
||||
var hasSlashing bool
|
||||
// Iterate through validator list in state, stop until a validator satisfies slashing condition of current epoch.
|
||||
for _, v := range vs {
|
||||
if v == nil {
|
||||
err := state.ReadFromEveryValidator(func(idx int, val *stateTrie.ReadOnlyValidator) error {
|
||||
if val == nil {
|
||||
return errors.New("nil validator in state")
|
||||
}
|
||||
correctEpoch := epochToWithdraw == v.WithdrawableEpoch()
|
||||
if v.Slashed() && correctEpoch {
|
||||
correctEpoch := epochToWithdraw == val.WithdrawableEpoch()
|
||||
if val.Slashed() && correctEpoch {
|
||||
hasSlashing = true
|
||||
break
|
||||
}
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
// Exit early if there's no meaningful slashing to process.
|
||||
if !hasSlashing {
|
||||
|
@ -806,13 +806,17 @@ func (bs *Server) GetIndividualVotes(
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "Could not pre compute attestations: %v", err)
|
||||
}
|
||||
vals := requestedState.ValidatorsReadOnly()
|
||||
for _, index := range filteredIndices {
|
||||
if index >= uint64(len(v)) {
|
||||
votes = append(votes, ðpb.IndividualVotesRespond_IndividualVote{ValidatorIndex: index})
|
||||
continue
|
||||
}
|
||||
pb := vals[index].PublicKey()
|
||||
val, err := requestedState.ValidatorAtIndexReadOnly(index)
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "Could not retrieve validator: %v", err)
|
||||
|
||||
}
|
||||
pb := val.PublicKey()
|
||||
votes = append(votes, ðpb.IndividualVotesRespond_IndividualVote{
|
||||
Epoch: req.Epoch,
|
||||
PublicKey: pb[:],
|
||||
|
Loading…
Reference in New Issue
Block a user