Enhance Logging for Validator Registration (#2085)

* better logging for validator registration

* gaz

* Update beacon-chain/core/validators/validator.go

Co-Authored-By: terenc3t <terence@prysmaticlabs.com>
This commit is contained in:
terence tsao 2019-03-26 21:22:23 -07:00 committed by Preston Van Loon
parent b2fb22f31f
commit 2f4cddeb28
2 changed files with 17 additions and 0 deletions

View File

@ -11,6 +11,7 @@ go_library(
"//shared/bytesutil:go_default_library",
"//shared/params:go_default_library",
"//shared/sliceutil:go_default_library",
"@com_github_sirupsen_logrus//:go_default_library",
"@io_opencensus_go//trace:go_default_library",
],
)

View File

@ -14,9 +14,12 @@ import (
"github.com/prysmaticlabs/prysm/shared/bytesutil"
"github.com/prysmaticlabs/prysm/shared/params"
"github.com/prysmaticlabs/prysm/shared/sliceutil"
"github.com/sirupsen/logrus"
"go.opencensus.io/trace"
)
var log = logrus.WithField("prefix", "powchain")
var (
// ActivatedValidators is a mapping that tracks epoch to activated validators indexes.
// Where key is epoch, value is a list of activated validator indexes.
@ -160,6 +163,12 @@ func ActivateValidator(state *pb.BeaconState, idx uint64, genesis bool) (*pb.Bea
}
state.ValidatorRegistry[idx] = validator
log.WithFields(logrus.Fields{
"index": idx,
"activationEpoch": validator.ActivationEpoch - params.BeaconConfig().GenesisEpoch,
}).Info("Validator activated")
return state, nil
}
@ -314,6 +323,13 @@ func UpdateRegistry(ctx context.Context, state *pb.BeaconState) (*pb.BeaconState
if validator.ActivationEpoch == params.BeaconConfig().FarFutureEpoch &&
state.ValidatorBalances[idx] >= params.BeaconConfig().MaxDepositAmount {
balChurn += helpers.EffectiveBalance(state, uint64(idx))
log.WithFields(logrus.Fields{
"index": idx,
"currentBalanceChurn": balChurn,
"maxBalanceChurn": maxBalChurn,
"currentEpoch": currentEpoch - params.BeaconConfig().GenesisEpoch,
}).Info("Attempting to activate validator")
if balChurn > maxBalChurn {
break
}