Skip to content

Commit

Permalink
(BIDS-2981) fix using activationChurnRate
Browse files Browse the repository at this point in the history
  • Loading branch information
guybrush committed Jan 31, 2024
1 parent 2fe62e6 commit 3e227eb
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
12 changes: 11 additions & 1 deletion handlers/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,16 @@ func Validator(w http.ResponseWriter, r *http.Request) {
}
validatorPageData.ChurnRate = *churnRate

activationChurnRate := stats.ValidatorActivationChurnLimit
if activationChurnRate == nil {
activationChurnRate = new(uint64)
}

if *activationChurnRate == 0 {
*activationChurnRate = 4
logger.Warning("Activation Churn rate not set in config using 4 as default please set minPerEpochChurnLimit")
}

pendingCount := stats.PendingValidatorCount
if pendingCount == nil {
pendingCount = new(uint64)
Expand Down Expand Up @@ -558,7 +568,7 @@ func Validator(w http.ResponseWriter, r *http.Request) {
return fmt.Errorf("failed to retrieve queue ahead of validator %v: %w", validatorPageData.ValidatorIndex, err)
}
validatorPageData.QueuePosition = queueAhead + 1
epochsToWait := queueAhead / *churnRate
epochsToWait := queueAhead / *activationChurnRate
// calculate dequeue epoch
estimatedActivationEpoch := validatorPageData.Epoch + epochsToWait + 1
// add activation offset
Expand Down
1 change: 1 addition & 0 deletions services/services.go
Original file line number Diff line number Diff line change
Expand Up @@ -1229,6 +1229,7 @@ func GetLatestStats() *types.Stats {
ActiveValidatorCount: new(uint64),
PendingValidatorCount: new(uint64),
ValidatorChurnLimit: new(uint64),
ValidatorActivationChurnLimit: new(uint64),
LatestValidatorWithdrawalIndex: new(uint64),
}
}
Expand Down
10 changes: 9 additions & 1 deletion services/stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,21 @@ func calculateStats() (*types.Stats, error) {

stats.ValidatorChurnLimit = &validatorChurnLimit

epoch := LatestEpoch()
validatorActivationChurnLimit, err := getValidatorActivationChurnLimit(activeValidatorCount, epoch)
if err != nil {
logger.WithError(err).Error("error getting total validator churn limit")
}

stats.ValidatorActivationChurnLimit = &validatorActivationChurnLimit

LatestValidatorWithdrawalIndex, err := db.GetMostRecentWithdrawalValidator()
if err != nil {
logger.WithError(err).Error("error getting most recent withdrawal validator index")
}

stats.LatestValidatorWithdrawalIndex = &LatestValidatorWithdrawalIndex

epoch := LatestEpoch()
WithdrawableValidatorCount, err := db.GetWithdrawableValidatorCount(epoch)
if err != nil {
logger.WithError(err).Error("error getting withdrawable validator count")
Expand Down Expand Up @@ -204,6 +211,7 @@ func getValidatorActivationChurnLimit(validatorCount, epoch uint64) (uint64, err
if err != nil {
return 0, err
}
logger.WithField("vcl", vcl).WithField("epoch", epoch).WithField("mpeacl", utils.Config.Chain.ClConfig.MaxPerEpochActivationChurnLimit).Info("getValidatorActivationChurnLimit")
if utils.Config.Chain.ClConfig.DenebForkEpoch > epoch {
return vcl, nil
}
Expand Down

0 comments on commit 3e227eb

Please sign in to comment.