diff --git a/beacon-chain/blockchain/receive_attestation.go b/beacon-chain/blockchain/receive_attestation.go index 78e9d45e8..0efbd8552 100644 --- a/beacon-chain/blockchain/receive_attestation.go +++ b/beacon-chain/blockchain/receive_attestation.go @@ -13,7 +13,6 @@ import ( "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/slotutil" - "github.com/prysmaticlabs/prysm/shared/timeutils" "github.com/sirupsen/logrus" "go.opencensus.io/trace" ) @@ -117,20 +116,10 @@ func (s *Service) processAttestation(subscribedToStateEvents chan struct{}) { continue } - hasState := s.stateGen.StateSummaryExists(ctx, bytesutil.ToBytes32(a.Data.BeaconBlockRoot)) - hasBlock := s.hasBlock(ctx, bytesutil.ToBytes32(a.Data.BeaconBlockRoot)) - if !(hasState && hasBlock) { - continue - } - if err := s.attPool.DeleteForkchoiceAttestation(a); err != nil { log.WithError(err).Error("Could not delete fork choice attestation in pool") } - if !s.verifyCheckpointEpoch(a.Data.Target) { - continue - } - if err := s.ReceiveAttestationNoPubsub(ctx, a); err != nil { log.WithFields(logrus.Fields{ "slot": a.Data.Slot, @@ -144,23 +133,3 @@ func (s *Service) processAttestation(subscribedToStateEvents chan struct{}) { } } } - -// This verifies the epoch of input checkpoint is within current epoch and previous epoch -// with respect to current time. Returns true if it's within, false if it's not. -func (s *Service) verifyCheckpointEpoch(c *ethpb.Checkpoint) bool { - now := uint64(timeutils.Now().Unix()) - genesisTime := uint64(s.genesisTime.Unix()) - currentSlot := (now - genesisTime) / params.BeaconConfig().SecondsPerSlot - currentEpoch := helpers.SlotToEpoch(currentSlot) - - var prevEpoch uint64 - if currentEpoch > 1 { - prevEpoch = currentEpoch - 1 - } - - if c.Epoch != prevEpoch && c.Epoch != currentEpoch { - return false - } - - return true -} diff --git a/beacon-chain/blockchain/receive_attestation_test.go b/beacon-chain/blockchain/receive_attestation_test.go index f4716087c..ba4c62630 100644 --- a/beacon-chain/blockchain/receive_attestation_test.go +++ b/beacon-chain/blockchain/receive_attestation_test.go @@ -9,21 +9,9 @@ import ( "github.com/prysmaticlabs/prysm/beacon-chain/core/helpers" testDB "github.com/prysmaticlabs/prysm/beacon-chain/db/testing" "github.com/prysmaticlabs/prysm/shared/params" - "github.com/prysmaticlabs/prysm/shared/testutil/assert" "github.com/prysmaticlabs/prysm/shared/testutil/require" ) -func TestVerifyCheckpointEpoch_Ok(t *testing.T) { - helpers.ClearCache() - db, sc := testDB.SetupDB(t) - - chainService := setupBeaconChain(t, db, sc) - chainService.genesisTime = time.Now() - - assert.Equal(t, true, chainService.verifyCheckpointEpoch(ðpb.Checkpoint{Root: make([]byte, 32)})) - assert.Equal(t, false, chainService.verifyCheckpointEpoch(ðpb.Checkpoint{Epoch: 1})) -} - func TestAttestationCheckPtState_FarFutureSlot(t *testing.T) { helpers.ClearCache() db, sc := testDB.SetupDB(t)