From 9c6efe4abd7dbf49f909c8b7630d7683868e444a Mon Sep 17 00:00:00 2001 From: terencechain Date: Thu, 11 Aug 2022 19:35:37 -0700 Subject: [PATCH] Don't insert attestations to forkchoice store (#11201) --- beacon-chain/blockchain/process_block.go | 21 +++++---------------- beacon-chain/blockchain/service_test.go | 8 ++++---- 2 files changed, 9 insertions(+), 20 deletions(-) diff --git a/beacon-chain/blockchain/process_block.go b/beacon-chain/blockchain/process_block.go index 411178712..88f36017f 100644 --- a/beacon-chain/blockchain/process_block.go +++ b/beacon-chain/blockchain/process_block.go @@ -136,7 +136,7 @@ func (s *Service) onBlock(ctx context.Context, signed interfaces.SignedBeaconBlo return err } - if err := s.insertBlockAndAttestationsToForkChoiceStore(ctx, signed.Block(), blockRoot, postState); err != nil { + if err := s.insertBlockToForkchoiceStore(ctx, signed.Block(), blockRoot, postState); err != nil { return errors.Wrapf(err, "could not insert block %d to fork choice store", signed.Block().Slot()) } s.InsertSlashingsToForkChoiceStore(ctx, signed.Block().Body().AttesterSlashings()) @@ -495,10 +495,10 @@ func (s *Service) handleEpochBoundary(ctx context.Context, postState state.Beaco return nil } -// This feeds in the block and block's attestations to fork choice store. It's allows fork choice store +// This feeds in the block to fork choice store. It's allows fork choice store // to gain information on the most current chain. -func (s *Service) insertBlockAndAttestationsToForkChoiceStore(ctx context.Context, blk interfaces.BeaconBlock, root [32]byte, st state.BeaconState) error { - ctx, span := trace.StartSpan(ctx, "blockChain.insertBlockAndAttestationsToForkChoiceStore") +func (s *Service) insertBlockToForkchoiceStore(ctx context.Context, blk interfaces.BeaconBlock, root [32]byte, st state.BeaconState) error { + ctx, span := trace.StartSpan(ctx, "blockChain.insertBlockToForkchoiceStore") defer span.End() if !s.cfg.ForkChoiceStore.HasNode(bytesutil.ToBytes32(blk.ParentRoot())) { @@ -512,18 +512,7 @@ func (s *Service) insertBlockAndAttestationsToForkChoiceStore(ctx context.Contex if err := s.cfg.ForkChoiceStore.InsertNode(ctx, st, root); err != nil { return err } - // Feed in block's attestations to fork choice store. - for _, a := range blk.Body().Attestations() { - committee, err := helpers.BeaconCommitteeFromState(ctx, st, a.Data.Slot, a.Data.CommitteeIndex) - if err != nil { - return err - } - indices, err := attestation.AttestingIndices(a.AggregationBits, committee) - if err != nil { - return err - } - s.cfg.ForkChoiceStore.ProcessAttestation(ctx, indices, bytesutil.ToBytes32(a.Data.BeaconBlockRoot), a.Data.Target.Epoch) - } + return nil } diff --git a/beacon-chain/blockchain/service_test.go b/beacon-chain/blockchain/service_test.go index bd3dd68d1..1f6c2f1ac 100644 --- a/beacon-chain/blockchain/service_test.go +++ b/beacon-chain/blockchain/service_test.go @@ -409,7 +409,7 @@ func TestHasBlock_ForkChoiceAndDB_ProtoArray(t *testing.T) { require.NoError(t, err) wsb, err := consensusblocks.NewSignedBeaconBlock(b) require.NoError(t, err) - require.NoError(t, s.insertBlockAndAttestationsToForkChoiceStore(ctx, wsb.Block(), r, beaconState)) + require.NoError(t, s.insertBlockToForkchoiceStore(ctx, wsb.Block(), r, beaconState)) assert.Equal(t, false, s.hasBlock(ctx, [32]byte{}), "Should not have block") assert.Equal(t, true, s.hasBlock(ctx, r), "Should have block") @@ -428,7 +428,7 @@ func TestHasBlock_ForkChoiceAndDB_DoublyLinkedTree(t *testing.T) { require.NoError(t, err) wsb, err := consensusblocks.NewSignedBeaconBlock(b) require.NoError(t, err) - require.NoError(t, s.insertBlockAndAttestationsToForkChoiceStore(ctx, wsb.Block(), r, beaconState)) + require.NoError(t, s.insertBlockToForkchoiceStore(ctx, wsb.Block(), r, beaconState)) assert.Equal(t, false, s.hasBlock(ctx, [32]byte{}), "Should not have block") assert.Equal(t, true, s.hasBlock(ctx, r), "Should have block") @@ -500,7 +500,7 @@ func BenchmarkHasBlockForkChoiceStore_ProtoArray(b *testing.B) { require.NoError(b, err) wsb, err := consensusblocks.NewSignedBeaconBlock(blk) require.NoError(b, err) - require.NoError(b, s.insertBlockAndAttestationsToForkChoiceStore(ctx, wsb.Block(), r, beaconState)) + require.NoError(b, s.insertBlockToForkchoiceStore(ctx, wsb.Block(), r, beaconState)) b.ResetTimer() for i := 0; i < b.N; i++ { @@ -521,7 +521,7 @@ func BenchmarkHasBlockForkChoiceStore_DoublyLinkedTree(b *testing.B) { require.NoError(b, err) wsb, err := consensusblocks.NewSignedBeaconBlock(blk) require.NoError(b, err) - require.NoError(b, s.insertBlockAndAttestationsToForkChoiceStore(ctx, wsb.Block(), r, beaconState)) + require.NoError(b, s.insertBlockToForkchoiceStore(ctx, wsb.Block(), r, beaconState)) b.ResetTimer() for i := 0; i < b.N; i++ {