Change Logging of Failed Attestations (#2599)

* change logging

* review comments

* gazelle
This commit is contained in:
Nishant Das 2019-05-15 09:09:39 +08:00 committed by GitHub
parent d672a06026
commit 56130404fc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 4 deletions

View File

@ -38,6 +38,8 @@ go_test(
"//shared/bytesutil:go_default_library",
"//shared/hashutil:go_default_library",
"//shared/params:go_default_library",
"//shared/testutil:go_default_library",
"@com_github_sirupsen_logrus//:go_default_library",
"@com_github_sirupsen_logrus//hooks/test:go_default_library",
],
)

View File

@ -309,11 +309,13 @@ func (a *Service) updateAttestation(ctx context.Context, headRoot [32]byte, beac
}
if i >= len(committee) {
return fmt.Errorf("bitfield points to an invalid index in the committee: bitfield %08b", bitfield)
log.Debugf("bitfield points to an invalid index in the committee: bitfield %08b", bitfield)
return nil
}
if int(committee[i]) >= len(beaconState.ValidatorRegistry) {
return fmt.Errorf("index doesn't exist in validator registry: index %d", committee[i])
log.Debugf("index doesn't exist in validator registry: index %d", committee[i])
return nil
}
// If the attestation came from this attester. We use the slot committee to find the

View File

@ -14,7 +14,9 @@ import (
"github.com/prysmaticlabs/prysm/shared/bytesutil"
"github.com/prysmaticlabs/prysm/shared/hashutil"
"github.com/prysmaticlabs/prysm/shared/params"
"github.com/prysmaticlabs/prysm/shared/testutil"
"github.com/sirupsen/logrus"
logTest "github.com/sirupsen/logrus/hooks/test"
)
func init() {
@ -366,6 +368,7 @@ func TestUpdateLatestAttestation_CacheEnabledAndHit(t *testing.T) {
func TestUpdateLatestAttestation_InvalidIndex(t *testing.T) {
beaconDB := internal.SetupDB(t)
hook := logTest.NewGlobal()
defer internal.TeardownDB(t, beaconDB)
ctx := context.Background()
@ -403,9 +406,11 @@ func TestUpdateLatestAttestation_InvalidIndex(t *testing.T) {
wanted := "bitfield points to an invalid index in the committee"
if err := service.UpdateLatestAttestation(ctx, attestation); !strings.Contains(err.Error(), wanted) {
t.Errorf("Wanted: %s but got %s", wanted, err)
if err := service.UpdateLatestAttestation(ctx, attestation); err != nil {
t.Error(err)
}
testutil.AssertLogsContain(t, hook, wanted)
}
func TestBatchUpdate_FromSync(t *testing.T) {