Skip to content

Commit

Permalink
use single worker (#13007)
Browse files Browse the repository at this point in the history
Co-authored-by: shota.silagadze <[email protected]>
  • Loading branch information
shotasilagadze and shotasilagadzetaal authored Dec 7, 2024
1 parent 836ce24 commit ed2e248
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 12 deletions.
4 changes: 1 addition & 3 deletions cl/transition/impl/eth2/statechange/process_epoch.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
package statechange

import (
"runtime"

"github.com/erigontech/erigon/cl/abstract"
"github.com/erigontech/erigon/cl/clparams"
"github.com/erigontech/erigon/cl/cltypes/solid"
Expand All @@ -34,7 +32,7 @@ func GetUnslashedIndiciesSet(cfg *clparams.BeaconChainConfig, previousEpoch uint
flagsUnslashedIndiciesSet[i] = make([]bool, validatorSet.Length())
}

threading.ParallellForLoop(runtime.NumCPU(), 0, validatorSet.Length(), func(validatorIndex int) error {
threading.ParallellForLoop(1, 0, validatorSet.Length(), func(validatorIndex int) error {
for i := range weights {
flagsUnslashedIndiciesSet[i][validatorIndex] = state.IsUnslashedParticipatingIndex(validatorSet, previousEpochParticipation, previousEpoch, uint64(validatorIndex), i)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
package statechange

import (
"runtime"

"github.com/erigontech/erigon/cl/abstract"
"github.com/erigontech/erigon/cl/monitor"
"github.com/erigontech/erigon/cl/phase1/core/state"
Expand All @@ -32,7 +30,7 @@ func ProcessInactivityScores(s abstract.BeaconState, eligibleValidatorsIndicies
return nil
}

return threading.ParallellForLoop(runtime.NumCPU(), 0, len(eligibleValidatorsIndicies), func(i int) error {
return threading.ParallellForLoop(1, 0, len(eligibleValidatorsIndicies), func(i int) error {
validatorIndex := eligibleValidatorsIndicies[i]

// retrieve validator inactivity score index.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
package statechange

import (
"runtime"
"sort"
"sync"

Expand Down Expand Up @@ -49,7 +48,7 @@ func ProcessRegistryUpdates(s abstract.BeaconState) error {
var m sync.Mutex
activationQueue := make([]minimizeQueuedValidator, 0)
// Process activation eligibility and ejections.
if err := threading.ParallellForLoop(runtime.NumCPU(), 0, s.ValidatorSet().Length(), func(i int) error {
if err := threading.ParallellForLoop(1, 0, s.ValidatorSet().Length(), func(i int) error {
validator := s.ValidatorSet().Get(i)
if state.IsValidatorEligibleForActivationQueue(s, validator) {
s.SetActivationEligibilityEpochForValidatorAtIndex(i, currentEpoch+1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func processRewardsAndPenaltiesPostAltair(s abstract.BeaconState, eligibleValida
rewardDenominator := (totalActiveBalance / beaconConfig.EffectiveBalanceIncrement) * beaconConfig.WeightDenominator
inactivityLeaking := state.InactivityLeaking(s)

return threading.ParallellForLoop(runtime.NumCPU(), 0, len(eligibleValidators), func(i int) error {
return threading.ParallellForLoop(1, 0, len(eligibleValidators), func(i int) error {
index := eligibleValidators[i]
baseReward, err := s.BaseReward(index)
if err != nil {
Expand Down
4 changes: 1 addition & 3 deletions cl/transition/impl/eth2/statechange/process_slashings.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
package statechange

import (
"runtime"

"github.com/erigontech/erigon/cl/abstract"
"github.com/erigontech/erigon/cl/clparams"
"github.com/erigontech/erigon/cl/monitor"
Expand All @@ -45,7 +43,7 @@ func ProcessSlashings(s abstract.BeaconState) error {
}
beaconConfig := s.BeaconConfig()
// Apply penalties to validators who have been slashed and reached the withdrawable epoch
return threading.ParallellForLoop(runtime.NumCPU(), 0, s.ValidatorSet().Length(), func(i int) error {
return threading.ParallellForLoop(1, 0, s.ValidatorSet().Length(), func(i int) error {
validator := s.ValidatorSet().Get(i)
if !validator.Slashed() || epoch+beaconConfig.EpochsPerSlashingsVector/2 != validator.WithdrawableEpoch() {
return nil
Expand Down

0 comments on commit ed2e248

Please sign in to comment.