Skip to content

Commit

Permalink
Remove duplicated target root check for fork choice attestation (#8277)
Browse files Browse the repository at this point in the history
* Rm redundant target root check for fork choice attestation

* Comments

* Revert back verifyBeaconBlock

Co-authored-by: Raul Jordan <raul@prysmaticlabs.com>
  • Loading branch information
terencechain and rauljordan committed Jan 20, 2021
1 parent 1537378 commit befe8d8
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 9 deletions.
7 changes: 3 additions & 4 deletions beacon-chain/blockchain/process_attestation.go
Expand Up @@ -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.
Expand Down
5 changes: 0 additions & 5 deletions beacon-chain/blockchain/process_attestation_test.go
Expand Up @@ -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[:]}}}),
Expand Down

0 comments on commit befe8d8

Please sign in to comment.