Sync Drops Attestations < 1 Epoch Length (#1917)

This commit is contained in:
terence tsao 2019-03-06 18:48:32 -06:00 committed by GitHub
parent 018f200ce9
commit 23e2dd65a3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 10 deletions

View File

@ -11,7 +11,6 @@ go_library(
importpath = "github.com/prysmaticlabs/prysm/beacon-chain/sync",
visibility = ["//beacon-chain:__subpackages__"],
deps = [
"//beacon-chain/core/helpers:go_default_library",
"//beacon-chain/db:go_default_library",
"//beacon-chain/sync/initial-sync:go_default_library",
"//proto/beacon/p2p/v1:go_default_library",

View File

@ -8,7 +8,6 @@ import (
"github.com/gogo/protobuf/proto"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
"github.com/prysmaticlabs/prysm/beacon-chain/core/helpers"
"github.com/prysmaticlabs/prysm/beacon-chain/db"
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
"github.com/prysmaticlabs/prysm/shared/bytesutil"
@ -472,10 +471,9 @@ func (rs *RegularSync) receiveAttestation(msg p2p.Message) {
return
}
previousEpochStartSlot := helpers.StartSlot(helpers.PrevEpoch(beaconState))
if attestation.Data.Slot < previousEpochStartSlot {
log.Debugf("Skipping received attestation with slot smaller than previous epoch start slot, %d < %d",
attestation.Data.Slot, previousEpochStartSlot)
if attestation.Data.Slot < beaconState.Slot - params.BeaconConfig().SlotsPerEpoch {
log.Debugf("Skipping received attestation with slot smaller than one epoch ago, %d < %d",
attestation.Data.Slot, beaconState.Slot - params.BeaconConfig().SlotsPerEpoch)
return
}

View File

@ -488,7 +488,7 @@ func TestReceiveAttestation_OK(t *testing.T) {
db := internal.SetupDB(t)
defer internal.TeardownDB(t, db)
if err := db.SaveState(&pb.BeaconState{
FinalizedEpoch: params.BeaconConfig().GenesisEpoch,
Slot: params.BeaconConfig().GenesisSlot + 2,
}); err != nil {
t.Fatalf("Could not save state: %v", err)
}
@ -531,7 +531,7 @@ func TestReceiveAttestation_OlderThanPrevEpoch(t *testing.T) {
db := internal.SetupDB(t)
defer internal.TeardownDB(t, db)
state := &pb.BeaconState{Slot: params.BeaconConfig().GenesisSlot + 192}
state := &pb.BeaconState{Slot: params.BeaconConfig().GenesisSlot + 2 * params.BeaconConfig().SlotsPerEpoch}
if err := db.SaveState(state); err != nil {
t.Fatalf("Could not save state: %v", err)
}
@ -565,8 +565,8 @@ func TestReceiveAttestation_OlderThanPrevEpoch(t *testing.T) {
ss.cancel()
<-exitRoutine
want := fmt.Sprintf(
"Skipping received attestation with slot smaller than previous epoch start slot, %d < %d",
request1.Data.Slot, params.BeaconConfig().GenesisSlot+128)
"Skipping received attestation with slot smaller than one epoch ago, %d < %d",
request1.Data.Slot, params.BeaconConfig().GenesisSlot+params.BeaconConfig().SlotsPerEpoch)
testutil.AssertLogsContain(t, hook, want)
}