mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2025-01-08 18:51:19 +00:00
call LogValidatorGainsAndLosses at end of epoch (#7708)
* call LogValidatorGainsAndLosses at end of epoch * Reviewer fixes Co-authored-by: terence tsao <terence@prysmaticlabs.com>
This commit is contained in:
parent
0b0d77dd0c
commit
b996824446
@ -7,6 +7,7 @@ import (
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
"github.com/prometheus/client_golang/prometheus/promauto"
|
||||
ethpb "github.com/prysmaticlabs/ethereumapis/eth/v1alpha1"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/core/helpers"
|
||||
"github.com/prysmaticlabs/prysm/shared/bytesutil"
|
||||
"github.com/prysmaticlabs/prysm/shared/params"
|
||||
"github.com/sirupsen/logrus"
|
||||
@ -122,8 +123,8 @@ var (
|
||||
// and penalties over time, percentage gain/loss, and gives the end user a better idea
|
||||
// of how the validator performs with respect to the rest.
|
||||
func (v *validator) LogValidatorGainsAndLosses(ctx context.Context, slot uint64) error {
|
||||
if slot%params.BeaconConfig().SlotsPerEpoch != 0 || slot <= params.BeaconConfig().SlotsPerEpoch {
|
||||
// Do nothing unless we are at the start of the epoch, and not in the first epoch.
|
||||
if !helpers.IsEpochEnd(slot) || slot <= params.BeaconConfig().SlotsPerEpoch {
|
||||
// Do nothing unless we are at the end of the epoch, and not in the first epoch.
|
||||
return nil
|
||||
}
|
||||
if !v.logValidatorBalances {
|
||||
|
@ -114,12 +114,9 @@ func run(ctx context.Context, v Validator) {
|
||||
|
||||
deadline := v.SlotDeadline(slot)
|
||||
slotCtx, cancel := context.WithDeadline(ctx, deadline)
|
||||
// Report this validator client's rewards and penalties throughout its lifecycle.
|
||||
|
||||
log := log.WithField("slot", slot)
|
||||
log.WithField("deadline", deadline).Debug("Set deadline for proposals and attestations")
|
||||
if err := v.LogValidatorGainsAndLosses(slotCtx, slot); err != nil {
|
||||
log.WithError(err).Error("Could not report validator's rewards/penalties")
|
||||
}
|
||||
|
||||
// Keep trying to update assignments if they are nil or if we are past an
|
||||
// epoch transition in the beacon node's state.
|
||||
@ -176,6 +173,10 @@ func run(ctx context.Context, v Validator) {
|
||||
if err := v.SaveProtections(ctx); err != nil {
|
||||
log.WithError(err).Error("Could not save validator protection")
|
||||
}
|
||||
// Log this client performance in the previous epoch
|
||||
if err := v.LogValidatorGainsAndLosses(slotCtx, slot); err != nil {
|
||||
log.WithError(err).Error("Could not report validator's rewards/penalties")
|
||||
}
|
||||
span.End()
|
||||
}()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user