Files
prysm/validator/client/log.go
Victor Farazdagi a069738c20 ETH2 Types: Slot (#8408)
* update shared/params

* update eth2-types deps

* update protobufs

* update shared/*

* fix testutil/state

* update beacon-chain/state

* update beacon-chain/db

* update tests

* fix test

* update beacon-chain/core

* update beacon-chain/blockchain

* update beacon-chain/cache

* beacon-chain/forkchoice

* update beacon-chain/operations

* update beacon-chain/p2p

* update beacon-chain/rpc

* update sync/initial-sync

* update deps

* update deps

* go fmt

* update beacon-chain/sync

* update endtoend/

* bazel build //beacon-chain - works w/o issues

* update slasher code

* udpate tools/

* update validator/

* update fastssz

* fix build

* fix test building

* update tests

* update ethereumapis deps

* fix tests

* update state/stategen

* fix build

* fix test

* add FarFutureSlot

* go imports

* Radek's suggestions

* Ivan's suggestions

* type conversions

* Nishant's suggestions

* add more tests to rpc_send_request

* fix test

* clean up

* fix conflicts

Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
Co-authored-by: nisdas <nishdas93@gmail.com>
2021-02-16 07:45:34 +00:00

95 lines
2.8 KiB
Go

package client
import (
"fmt"
"time"
"github.com/prysmaticlabs/eth2-types"
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/prysmaticlabs/prysm/shared/timeutils"
"github.com/sirupsen/logrus"
)
var log = logrus.WithField("prefix", "validator")
type attSubmitted struct {
data *ethpb.AttestationData
attesterIndices []uint64
aggregatorIndices []uint64
}
func (v *validator) LogAttestationsSubmitted() {
v.attLogsLock.Lock()
defer v.attLogsLock.Unlock()
for _, attLog := range v.attLogs {
log.WithFields(logrus.Fields{
"Slot": attLog.data.Slot,
"CommitteeIndex": attLog.data.CommitteeIndex,
"BeaconBlockRoot": fmt.Sprintf("%#x", bytesutil.Trunc(attLog.data.BeaconBlockRoot)),
"SourceEpoch": attLog.data.Source.Epoch,
"SourceRoot": fmt.Sprintf("%#x", bytesutil.Trunc(attLog.data.Source.Root)),
"TargetEpoch": attLog.data.Target.Epoch,
"TargetRoot": fmt.Sprintf("%#x", bytesutil.Trunc(attLog.data.Target.Root)),
"AttesterIndices": attLog.attesterIndices,
"AggregatorIndices": attLog.aggregatorIndices,
}).Info("Submitted new attestations")
}
v.attLogs = make(map[[32]byte]*attSubmitted)
}
func (v *validator) LogNextDutyTimeLeft(slot types.Slot) error {
if !v.logDutyCountDown {
return nil
}
if v.duties == nil {
return nil
}
var nextDutySlot types.Slot
attestingCounts := make(map[types.Slot]uint64)
proposingCounts := make(map[types.Slot]uint64)
for _, duty := range v.duties.CurrentEpochDuties {
attestingCounts[duty.AttesterSlot]++
if duty.AttesterSlot > slot && (nextDutySlot > duty.AttesterSlot || nextDutySlot == 0) {
nextDutySlot = duty.AttesterSlot
}
for _, proposerSlot := range duty.ProposerSlots {
proposingCounts[proposerSlot]++
if proposerSlot > slot && (nextDutySlot > proposerSlot || nextDutySlot == 0) {
nextDutySlot = proposerSlot
}
}
}
if nextDutySlot == 0 {
log.WithField("slotInEpoch", slot%params.BeaconConfig().SlotsPerEpoch).Info("No duty until next epoch")
} else {
nextDutyTime, err := helpers.SlotToTime(v.genesisTime, nextDutySlot)
if err != nil {
return err
}
timeLeft := time.Duration(nextDutyTime.Unix() - timeutils.Now().Unix()).Nanoseconds()
// There is not much value to log if time left is less than one slot.
if uint64(timeLeft) >= params.BeaconConfig().SecondsPerSlot {
log.WithFields(
logrus.Fields{
"currentSlot": slot,
"dutySlot": nextDutySlot,
"attesting": attestingCounts[nextDutySlot],
"proposing": proposingCounts[nextDutySlot],
"slotInEpoch": slot % params.BeaconConfig().SlotsPerEpoch,
"secondsLeft": timeLeft,
}).Info("Next duty")
}
}
return nil
}