Skip to content

Commit

Permalink
(NOBIDS) fix pre-genesis ui issues
Browse files Browse the repository at this point in the history
  • Loading branch information
peterbitfly committed Sep 28, 2023
1 parent 0c5ae8a commit 993ed81
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion cmd/misc/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
})
}

Expand Down
2 changes: 1 addition & 1 deletion db/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -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++
}
Expand Down
6 changes: 4 additions & 2 deletions handlers/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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{}{
Expand Down
8 changes: 6 additions & 2 deletions rpc/lighthouse.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand Down Expand Up @@ -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,
}
Expand All @@ -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,
}
Expand Down

0 comments on commit 993ed81

Please sign in to comment.