From 993ed812f9defcacabe2b51e07556df217a7d5f2 Mon Sep 17 00:00:00 2001 From: peter <1674920+peterbitfly@users.noreply.github.com> Date: Thu, 28 Sep 2023 13:06:12 +0200 Subject: [PATCH] (NOBIDS) fix pre-genesis ui issues --- cmd/misc/main.go | 2 +- db/db.go | 2 +- handlers/validator.go | 6 ++++-- rpc/lighthouse.go | 8 ++++++-- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/cmd/misc/main.go b/cmd/misc/main.go index 2ee39146c4..4a4c79ee9f 100644 --- a/cmd/misc/main.go +++ b/cmd/misc/main.go @@ -243,7 +243,7 @@ func main() { ActivationEpoch: uint64(validator.Validator.ActivationEpoch), ExitEpoch: uint64(validator.Validator.ExitEpoch), WithdrawableEpoch: uint64(validator.Validator.WithdrawableEpoch), - Status: validator.Status, + Status: "active_online", }) } diff --git a/db/db.go b/db/db.go index 1edbf3c173..f1c6db5040 100644 --- a/db/db.go +++ b/db/db.go @@ -1210,7 +1210,7 @@ func SaveValidators(data *types.EpochData, tx *sqlx.Tx, client rpc.Client, activ if c.Status != v.Status { logger.Tracef("Status changed for validator %v from %v to %v", v.Index, c.Status, v.Status) - // logger.Infof("v.ActivationEpoch, latestEpoch, lastAttestationSlots[v.Index], thresholdSlot", v.ActivationEpoch, latestEpoch, lastAttestationSlots[v.Index], thresholdSlot) + // logger.Tracef("v.ActivationEpoch %v, latestEpoch %v, lastAttestationSlots[v.Index] %v, thresholdSlot %v", v.ActivationEpoch, latestEpoch, lastAttestationSlots[v.Index], thresholdSlot) queries.WriteString(fmt.Sprintf("UPDATE validators SET status = '%s' WHERE validatorindex = %d;\n", v.Status, c.Index)) updates++ } diff --git a/handlers/validator.go b/handlers/validator.go index df26f731c7..a3f7d2fc1c 100644 --- a/handlers/validator.go +++ b/handlers/validator.go @@ -575,8 +575,10 @@ func Validator(w http.ResponseWriter, r *http.Request) { // Special care needs to be take for exited and pending validators if validatorPageData.ExitEpoch != 9223372036854775807 && validatorPageData.ExitEpoch <= validatorPageData.Epoch { validatorPageData.AttestationsCount = validatorPageData.ExitEpoch - validatorPageData.ActivationEpoch - } else if validatorPageData.ActivationEpoch > validatorPageData.Epoch || isPreGenesis { + } else if validatorPageData.ActivationEpoch > validatorPageData.Epoch { validatorPageData.AttestationsCount = 0 + } else if isPreGenesis { + validatorPageData.AttestationsCount = 1 } else { validatorPageData.AttestationsCount = validatorPageData.Epoch - validatorPageData.ActivationEpoch + 1 @@ -1152,7 +1154,7 @@ func ValidatorAttestations(w http.ResponseWriter, r *http.Request) { for i, history := range attestationData[index] { - if history.Status == 0 && history.Epoch < epoch-1 { + if history.Status == 0 && int64(history.Epoch) < int64(epoch)-1 { history.Status = 2 } tableData[i] = []interface{}{ diff --git a/rpc/lighthouse.go b/rpc/lighthouse.go index 52f938d492..e0083241d8 100644 --- a/rpc/lighthouse.go +++ b/rpc/lighthouse.go @@ -296,6 +296,10 @@ func (lc *LighthouseClient) GetEpochData(epoch uint64, skipHistoricBalances bool data.Finalized = true } + if head.FinalizedEpoch == 0 && epoch == 0 { + data.Finalized = false + } + validatorsResp, err := lc.get(fmt.Sprintf("%s/eth/v1/beacon/states/%d/validators", lc.endpoint, epoch*utils.Config.Chain.Config.SlotsPerEpoch)) if err != nil && epoch == 0 { validatorsResp, err = lc.get(fmt.Sprintf("%s/eth/v1/beacon/states/%v/validators", lc.endpoint, "genesis")) @@ -376,7 +380,7 @@ func (lc *LighthouseClient) GetEpochData(epoch uint64, skipHistoricBalances bool } data.EpochParticipationStats = &types.ValidatorParticipation{ Epoch: epoch, - GlobalParticipationRate: 1.0, + GlobalParticipationRate: 0.0, VotedEther: 0, EligibleEther: 0, } @@ -386,7 +390,7 @@ func (lc *LighthouseClient) GetEpochData(epoch uint64, skipHistoricBalances bool } else { data.EpochParticipationStats = &types.ValidatorParticipation{ Epoch: epoch, - GlobalParticipationRate: 1.0, + GlobalParticipationRate: 0.0, VotedEther: 0, EligibleEther: 0, }