Better logging for "Produced attestation..." (#2301)

This commit is contained in:
terence tsao 2019-04-19 11:52:41 -07:00 committed by GitHub
parent a1e4199e3a
commit b3742544ee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 12 deletions

View File

@ -126,26 +126,26 @@ func (v *validator) AttestToBlockHead(ctx context.Context, slot uint64, idx stri
// TODO(#1366): Use BLS to generate an aggregate signature.
attestation.AggregateSignature = []byte("signed")
log.WithField(
"blockRoot", fmt.Sprintf("%#x", attData.BeaconBlockRootHash32),
).Info("Current beacon chain head block")
log.WithFields(logrus.Fields{
"justifiedEpoch": attData.JustifiedEpoch - params.BeaconConfig().GenesisEpoch,
"shard": attData.Shard,
"slot": slot - params.BeaconConfig().GenesisSlot,
}).Infof("%v Attesting to beacon chain head...", truncatedPk)
"shard": attData.Shard,
"slot": slot - params.BeaconConfig().GenesisSlot,
"validator": truncatedPk,
}).Info("Attesting to beacon chain head...")
log.Infof("Produced attestation with block root: %#x", attestation.Data.BeaconBlockRootHash32)
attResp, err := v.attesterClient.AttestHead(ctx, attestation)
if err != nil {
log.Errorf("Could not submit attestation to beacon node: %v", err)
return
}
log.WithFields(logrus.Fields{
"attestationHash": fmt.Sprintf("%#x", attResp.AttestationHash),
"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,
"slot": slot - params.BeaconConfig().GenesisSlot,
}).Infof("%v successfully attested", truncatedPk)
"attestationHash": fmt.Sprintf("%#x", attResp.AttestationHash),
"validator": truncatedPk,
}).Info("Attested latest head")
span.AddAttributes(
trace.Int64Attribute("slot", int64(slot-params.BeaconConfig().GenesisSlot)),
trace.StringAttribute("attestationHash", fmt.Sprintf("%#x", attResp.AttestationHash)),

View File

@ -154,7 +154,7 @@ func TestAttestToBlockHead_AttestsCorrectly(t *testing.T) {
if !proto.Equal(generatedAttestation, expectedAttestation) {
t.Errorf("Incorrectly attested head, wanted %v, received %v", expectedAttestation, generatedAttestation)
}
testutil.AssertLogsContain(t, hook, "successfully attested")
testutil.AssertLogsContain(t, hook, "Attested latest head")
}
func TestAttestToBlockHead_DoesNotAttestBeforeDelay(t *testing.T) {