Skip to content

Commit 12b4390

Browse files
committed
(BIDS-2981) fix activation estimation for eip-7514
1 parent 9adaa87 commit 12b4390

File tree

6 files changed

+26
-2
lines changed

6 files changed

+26
-2
lines changed

handlers/dashboard.go

+7-2
Original file line numberDiff line numberDiff line change
@@ -776,7 +776,12 @@ func DashboardDataValidators(w http.ResponseWriter, r *http.Request) {
776776
latestEpoch := services.LatestEpoch()
777777

778778
stats := services.GetLatestStats()
779-
churnRate := stats.ValidatorChurnLimit
779+
activationChurnRate := stats.ValidatorActivationChurnLimit
780+
if activationChurnRate == nil {
781+
utils.LogError(fmt.Errorf("activation churn rate not available"), "error retrieving validator activation churn rate", 0, errFieldMap)
782+
http.Error(w, "Internal server error", http.StatusInternalServerError)
783+
return
784+
}
780785

781786
if len(validatorIndexArr) > 0 {
782787
balances, err := db.BigtableClient.GetValidatorBalanceHistory(validatorIndexArr, latestEpoch, latestEpoch)
@@ -842,7 +847,7 @@ func DashboardDataValidators(w http.ResponseWriter, r *http.Request) {
842847
http.Error(w, "Internal server error", http.StatusInternalServerError)
843848
return
844849
}
845-
epochsToWait := queueAhead / *churnRate
850+
epochsToWait := queueAhead / *activationChurnRate
846851
// calculate dequeue epoch
847852
estimatedActivationEpoch := latestEpoch + epochsToWait + 1
848853
// add activation offset

services/stats.go

+15
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,21 @@ func eth1UniqueValidatorsCount() (*uint64, error) {
199199
}
200200

201201
// GetValidatorChurnLimit returns the rate at which validators can enter or leave the system
202+
func getValidatorActivationChurnLimit(validatorCount, epoch uint64) (uint64, error) {
203+
vcl, err := getValidatorChurnLimit(validatorCount)
204+
if err != nil {
205+
return 0, err
206+
}
207+
if utils.Config.Chain.ClConfig.DenebForkEpoch >= epoch {
208+
return vcl, nil
209+
}
210+
if vcl > utils.Config.Chain.ClConfig.MaxPerEpochActivationChurnLimit {
211+
return utils.Config.Chain.ClConfig.MaxPerEpochActivationChurnLimit, nil
212+
}
213+
return vcl, nil
214+
}
215+
216+
// GetValidatorChurnLimit returns the rate at which validators can leave the system
202217
func getValidatorChurnLimit(validatorCount uint64) (uint64, error) {
203218
min := utils.Config.Chain.ClConfig.MinPerEpochChurnLimit
204219

types/chain.go

+1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ type ClChainConfig struct {
4545
EjectionBalance uint64 `yaml:"EJECTION_BALANCE"`
4646
MinPerEpochChurnLimit uint64 `yaml:"MIN_PER_EPOCH_CHURN_LIMIT"`
4747
ChurnLimitQuotient uint64 `yaml:"CHURN_LIMIT_QUOTIENT"`
48+
MaxPerEpochActivationChurnLimit uint64 `yaml:"MAX_PER_EPOCH_ACTIVATION_CHURN_LIMIT"`
4849
// fork choice
4950
ProposerScoreBoost uint64 `yaml:"PROPOSER_SCORE_BOOST"`
5051
// deposit contract

types/config.go

+1
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,7 @@ type ConfigJsonResponse struct {
286286
EjectionBalance string `json:"EJECTION_BALANCE"`
287287
MinPerEpochChurnLimit string `json:"MIN_PER_EPOCH_CHURN_LIMIT"`
288288
ChurnLimitQuotient string `json:"CHURN_LIMIT_QUOTIENT"`
289+
MaxPerEpochActivationChurnLimit string `json:"MAX_PER_EPOCH_ACTIVATION_CHURN_LIMIT"`
289290
ProposerScoreBoost string `json:"PROPOSER_SCORE_BOOST"`
290291
DepositChainID string `json:"DEPOSIT_CHAIN_ID"`
291292
DepositNetworkID string `json:"DEPOSIT_NETWORK_ID"`

types/templates.go

+1
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ type Stats struct {
143143
ActiveValidatorCount *uint64 `db:"count"`
144144
PendingValidatorCount *uint64 `db:"count"`
145145
ValidatorChurnLimit *uint64
146+
ValidatorActivationChurnLimit *uint64
146147
LatestValidatorWithdrawalIndex *uint64 `db:"index"`
147148
WithdrawableValidatorCount *uint64 `db:"count"`
148149
// WithdrawableAmount *uint64 `db:"amount"`

utils/utils.go

+1
Original file line numberDiff line numberDiff line change
@@ -502,6 +502,7 @@ func ReadConfig(cfg *types.Config, path string) error {
502502
EjectionBalance: mustParseUint(jr.Data.EjectionBalance),
503503
MinPerEpochChurnLimit: mustParseUint(jr.Data.MinPerEpochChurnLimit),
504504
ChurnLimitQuotient: mustParseUint(jr.Data.ChurnLimitQuotient),
505+
MaxPerEpochActivationChurnLimit: mustParseUint(jr.Data.MaxPerEpochActivationChurnLimit),
505506
ProposerScoreBoost: mustParseUint(jr.Data.ProposerScoreBoost),
506507
DepositChainID: mustParseUint(jr.Data.DepositChainID),
507508
DepositNetworkID: mustParseUint(jr.Data.DepositNetworkID),

0 commit comments

Comments
 (0)