mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-10 07:58:22 -05:00
Various Logging Improvements (#2454)
This commit is contained in:
committed by
terence tsao
parent
acf2d0699c
commit
aa74b1dca3
@@ -196,7 +196,9 @@ func (c *ChainService) ApplyForkChoiceRule(
|
||||
return fmt.Errorf("could not hash head: %v", err)
|
||||
}
|
||||
log.WithFields(logrus.Fields{
|
||||
"headRoot": fmt.Sprintf("%#x", bytesutil.Trunc(h[:])),
|
||||
"headRoot": fmt.Sprintf("%#x", bytesutil.Trunc(h[:])),
|
||||
"headSlot": newHead.Slot - params.BeaconConfig().GenesisSlot,
|
||||
"stateSlot": newState.Slot - params.BeaconConfig().GenesisSlot,
|
||||
}).Info("Chain head block and state updated")
|
||||
|
||||
return nil
|
||||
|
||||
@@ -57,6 +57,7 @@ go_test(
|
||||
"@com_github_ethereum_go_ethereum//core/types:go_default_library",
|
||||
"@com_github_ethereum_go_ethereum//crypto:go_default_library",
|
||||
"@com_github_gogo_protobuf//proto:go_default_library",
|
||||
"@com_github_sirupsen_logrus//:go_default_library",
|
||||
"@com_github_sirupsen_logrus//hooks/test:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
@@ -79,7 +79,7 @@ func (w *Web3Service) ProcessDepositLog(depositLog gethTypes.Log) {
|
||||
validData := true
|
||||
depositInput, err := helpers.DecodeDepositInput(depositData)
|
||||
if err != nil {
|
||||
log.Errorf("Could not decode deposit input %v", err)
|
||||
log.Debugf("Could not decode deposit input %v", err)
|
||||
validData = false
|
||||
}
|
||||
|
||||
@@ -110,12 +110,12 @@ func (w *Web3Service) ProcessDepositLog(depositLog gethTypes.Log) {
|
||||
log.WithFields(logrus.Fields{
|
||||
"publicKey": fmt.Sprintf("%#x", depositInput.Pubkey),
|
||||
"merkleTreeIndex": index,
|
||||
}).Info("Deposit registered from deposit contract")
|
||||
}).Debug("Deposit registered from deposit contract")
|
||||
validDepositsCount.Inc()
|
||||
} else {
|
||||
log.WithFields(logrus.Fields{
|
||||
"merkleTreeIndex": index,
|
||||
}).Info("Invalid deposit registered in deposit contract")
|
||||
}).Debug("Invalid deposit registered in deposit contract")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ import (
|
||||
"github.com/prysmaticlabs/prysm/shared/featureconfig"
|
||||
"github.com/prysmaticlabs/prysm/shared/ssz"
|
||||
"github.com/prysmaticlabs/prysm/shared/testutil"
|
||||
"github.com/sirupsen/logrus"
|
||||
logTest "github.com/sirupsen/logrus/hooks/test"
|
||||
)
|
||||
|
||||
@@ -24,6 +25,7 @@ func init() {
|
||||
featureconfig.InitFeatureConfig(&featureconfig.FeatureFlagConfig{
|
||||
CacheTreeHash: false,
|
||||
})
|
||||
logrus.SetLevel(logrus.DebugLevel)
|
||||
}
|
||||
|
||||
func TestProcessDepositLog_OK(t *testing.T) {
|
||||
|
||||
@@ -14,6 +14,7 @@ import (
|
||||
"github.com/prysmaticlabs/prysm/shared/featureconfig"
|
||||
"github.com/prysmaticlabs/prysm/shared/hashutil"
|
||||
"github.com/prysmaticlabs/prysm/shared/params"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
// ProposerServer defines a server implementation of the gRPC Proposer service,
|
||||
@@ -82,8 +83,11 @@ func (ps *ProposerServer) ProposeBlock(ctx context.Context, blk *pbp2p.BeaconBlo
|
||||
if err := ps.beaconDB.UpdateChainHead(ctx, blk, beaconState); err != nil {
|
||||
return nil, fmt.Errorf("failed to update chain: %v", err)
|
||||
}
|
||||
log.WithField("headRoot", fmt.Sprintf("0x%x", bytesutil.Trunc(h[:]))).Info(
|
||||
"Chain head block and state updated")
|
||||
log.WithFields(logrus.Fields{
|
||||
"headRoot": fmt.Sprintf("0x%x", bytesutil.Trunc(h[:])),
|
||||
"headSlot": blk.Slot - params.BeaconConfig().GenesisSlot,
|
||||
"stateSlot": beaconState.Slot - params.BeaconConfig().GenesisSlot,
|
||||
}).Info("Chain head block and state updated")
|
||||
|
||||
if err := ps.beaconDB.SaveHistoricalState(ctx, beaconState); err != nil {
|
||||
log.Errorf("Could not save new historical state: %v", err)
|
||||
|
||||
@@ -128,7 +128,7 @@ func (q *Querier) listenForStateInitialization() {
|
||||
for {
|
||||
select {
|
||||
case <-q.chainStartBuf:
|
||||
queryLog.Info("state initialized")
|
||||
queryLog.Info("State has been initialized")
|
||||
q.chainStarted = true
|
||||
return
|
||||
case <-sub.Err():
|
||||
@@ -154,10 +154,11 @@ func (q *Querier) run() {
|
||||
}()
|
||||
|
||||
timeout := time.After(5 * time.Second)
|
||||
log.Info("Polling peers for latest chain head...")
|
||||
for {
|
||||
select {
|
||||
case <-q.ctx.Done():
|
||||
queryLog.Info("Exiting goroutine")
|
||||
queryLog.Info("Finished querying state of the network, importing blocks...")
|
||||
return
|
||||
case <-ticker.C:
|
||||
q.RequestLatestHead()
|
||||
|
||||
@@ -16,6 +16,7 @@ go_library(
|
||||
"//proto/beacon/p2p/v1:go_default_library",
|
||||
"//proto/beacon/rpc/v1:go_default_library",
|
||||
"//shared/bitutil:go_default_library",
|
||||
"//shared/bytesutil:go_default_library",
|
||||
"//shared/forkutil:go_default_library",
|
||||
"//shared/hashutil:go_default_library",
|
||||
"//shared/keystore:go_default_library",
|
||||
|
||||
@@ -107,7 +107,7 @@ func (v *validator) WaitForActivation(ctx context.Context) error {
|
||||
}
|
||||
for _, pk := range validatorActivatedRecords {
|
||||
log.WithFields(logrus.Fields{
|
||||
"public key": fmt.Sprintf("%#x", pk),
|
||||
"publicKey": fmt.Sprintf("%#x", pk),
|
||||
}).Info("Validator activated")
|
||||
}
|
||||
return nil
|
||||
|
||||
@@ -9,6 +9,7 @@ import (
|
||||
pbp2p "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
pb "github.com/prysmaticlabs/prysm/proto/beacon/rpc/v1"
|
||||
"github.com/prysmaticlabs/prysm/shared/bitutil"
|
||||
"github.com/prysmaticlabs/prysm/shared/bytesutil"
|
||||
"github.com/prysmaticlabs/prysm/shared/mathutil"
|
||||
"github.com/prysmaticlabs/prysm/shared/params"
|
||||
"github.com/sirupsen/logrus"
|
||||
@@ -138,13 +139,10 @@ func (v *validator) AttestToBlockHead(ctx context.Context, slot uint64, idx stri
|
||||
return
|
||||
}
|
||||
log.WithFields(logrus.Fields{
|
||||
"headHash": fmt.Sprintf("%#x", attData.BeaconBlockRootHash32),
|
||||
"sourceHash": fmt.Sprintf("%#x", attData.JustifiedBlockRootHash32),
|
||||
"targetHash": fmt.Sprintf("%#x", attData.EpochBoundaryRootHash32),
|
||||
"slot": attData.Slot - params.BeaconConfig().GenesisSlot,
|
||||
"shard": attData.Shard,
|
||||
"attestationHash": fmt.Sprintf("%#x", attResp.AttestationHash),
|
||||
"validator": truncatedPk,
|
||||
"headRoot": fmt.Sprintf("%#x", bytesutil.Trunc(attData.BeaconBlockRootHash32)),
|
||||
"slot": attData.Slot - params.BeaconConfig().GenesisSlot,
|
||||
"shard": attData.Shard,
|
||||
"validator": truncatedPk,
|
||||
}).Info("Attested latest head")
|
||||
span.AddAttributes(
|
||||
trace.Int64Attribute("slot", int64(slot-params.BeaconConfig().GenesisSlot)),
|
||||
|
||||
@@ -64,8 +64,8 @@ func (v *validator) LogValidatorGainsAndLosses(ctx context.Context, slot uint64)
|
||||
log.WithFields(logrus.Fields{
|
||||
"prevBalance": prevBalance,
|
||||
"newBalance": newBalance,
|
||||
"delta": fmt.Sprintf("%f", newBalance-prevBalance),
|
||||
"percentChange": fmt.Sprintf("%.2f%%", percentNet*100),
|
||||
"delta": fmt.Sprintf("%.8f", newBalance-prevBalance),
|
||||
"percentChange": fmt.Sprintf("%.5f%%", percentNet*100),
|
||||
"pubKey": tpk,
|
||||
}).Info("Net gains/losses in eth")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user