Remove duplicated target root check for fork choice attestation (#8277)

* Rm redundant target root check for fork choice attestation

* Comments

* Revert back verifyBeaconBlock

Co-authored-by: Raul Jordan <raul@prysmaticlabs.com>
This commit is contained in:
terence tsao 2021-01-20 10:27:10 -08:00 committed by GitHub
parent 153737803a
commit befe8d88b8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 9 deletions

View File

@ -52,10 +52,9 @@ func (s *Service) onAttestation(ctx context.Context, a *ethpb.Attestation) ([]ui
}
tgt := stateTrie.CopyCheckpoint(a.Data.Target)
// Verify beacon node has seen the target block before.
if !s.hasBlock(ctx, bytesutil.ToBytes32(tgt.Root)) {
return nil, ErrTargetRootNotInDB
}
// Note that target root check is ignored here because it was performed in sync's validation pipeline:
// validate_aggregate_proof.go and validate_beacon_attestation.go
// If missing target root were to fail in this method, it would have just failed in `getAttPreState`.
// Retrieve attestation's data beacon block pre state. Advance pre state to latest epoch if necessary and
// save it to the cache.

View File

@ -76,11 +76,6 @@ func TestStore_OnAttestation_ErrorConditions(t *testing.T) {
a: testutil.HydrateAttestation(&ethpb.Attestation{Data: &ethpb.AttestationData{Slot: params.BeaconConfig().SlotsPerEpoch, Target: &ethpb.Checkpoint{Root: make([]byte, 32)}}}),
wantedErr: "slot 32 does not match target epoch 0",
},
{
name: "attestation's target root not in db",
a: testutil.HydrateAttestation(&ethpb.Attestation{Data: &ethpb.AttestationData{Target: &ethpb.Checkpoint{Root: bytesutil.PadTo([]byte{'A'}, 32)}}}),
wantedErr: "target root does not exist in db",
},
{
name: "no pre state for attestations's target block",
a: testutil.HydrateAttestation(&ethpb.Attestation{Data: &ethpb.AttestationData{Target: &ethpb.Checkpoint{Root: BlkWithOutStateRoot[:]}}}),