From befe8d88b891a45e9e6f374813165d1ad31ee660 Mon Sep 17 00:00:00 2001 From: terence tsao Date: Wed, 20 Jan 2021 10:27:10 -0800 Subject: [PATCH] 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 --- beacon-chain/blockchain/process_attestation.go | 7 +++---- beacon-chain/blockchain/process_attestation_test.go | 5 ----- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/beacon-chain/blockchain/process_attestation.go b/beacon-chain/blockchain/process_attestation.go index 231209e8854..62cc81a1a1e 100644 --- a/beacon-chain/blockchain/process_attestation.go +++ b/beacon-chain/blockchain/process_attestation.go @@ -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. diff --git a/beacon-chain/blockchain/process_attestation_test.go b/beacon-chain/blockchain/process_attestation_test.go index 34398d89207..5ae42b390cf 100644 --- a/beacon-chain/blockchain/process_attestation_test.go +++ b/beacon-chain/blockchain/process_attestation_test.go @@ -76,11 +76,6 @@ func TestStore_OnAttestation_ErrorConditions(t *testing.T) { a: testutil.HydrateAttestation(ðpb.Attestation{Data: ðpb.AttestationData{Slot: params.BeaconConfig().SlotsPerEpoch, Target: ðpb.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(ðpb.Attestation{Data: ðpb.AttestationData{Target: ðpb.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(ðpb.Attestation{Data: ðpb.AttestationData{Target: ðpb.Checkpoint{Root: BlkWithOutStateRoot[:]}}}),