Fixed a Prev Boundary Epoch Attestation Bug (#1547)

* fixed epoch_processing

* test p2p

* fixed PrevBoundaryAttestations and its tests
This commit is contained in:
terence tsao 2019-02-10 18:28:33 +01:00 committed by Raul Jordan
parent 3dc6d3a2e6
commit b5e2a49dac
2 changed files with 8 additions and 9 deletions

View File

@ -121,7 +121,7 @@ func PrevBoundaryAttestations(
var prevBoundaryAttestations []*pb.PendingAttestationRecord
prevBoundaryBlockRoot, err := block.BlockRoot(state,
helpers.PrevEpoch(state))
helpers.StartSlot(helpers.PrevEpoch(state)))
if err != nil {
return nil, err
}

View File

@ -221,9 +221,9 @@ func TestPrevEpochBoundaryAttestations(t *testing.T) {
epochAttestations := []*pb.PendingAttestationRecord{
{Data: &pb.AttestationData{EpochBoundaryRootHash32: []byte{100}}},
{Data: &pb.AttestationData{EpochBoundaryRootHash32: []byte{0}}},
{Data: &pb.AttestationData{EpochBoundaryRootHash32: []byte{2}}}, // selected
{Data: &pb.AttestationData{EpochBoundaryRootHash32: []byte{128}}}, // selected
{Data: &pb.AttestationData{EpochBoundaryRootHash32: []byte{55}}},
{Data: &pb.AttestationData{EpochBoundaryRootHash32: []byte{2}}}, // selected
{Data: &pb.AttestationData{EpochBoundaryRootHash32: []byte{128}}}, // selected
}
var latestBlockRootHash [][]byte
@ -241,14 +241,13 @@ func TestPrevEpochBoundaryAttestations(t *testing.T) {
t.Fatalf("EpochBoundaryAttestations failed: %v", err)
}
// 64 is selected because we start off with 3 epochs (192 slots)
// The prev epoch boundary slot is 192 - 2 * epoch_length = 64
if !bytes.Equal(prevEpochBoundaryAttestation[0].Data.EpochBoundaryRootHash32, []byte{2}) {
t.Errorf("Wanted justified block hash [64] for epoch boundary attestation, got: %v",
//128 is selected because that's the start root of prev boundary epoch.
if !bytes.Equal(prevEpochBoundaryAttestation[0].Data.EpochBoundaryRootHash32, []byte{128}) {
t.Errorf("Wanted justified block hash [128] for epoch boundary attestation, got: %v",
prevEpochBoundaryAttestation[0].Data.EpochBoundaryRootHash32)
}
if !bytes.Equal(prevEpochBoundaryAttestation[1].Data.EpochBoundaryRootHash32, []byte{2}) {
t.Errorf("Wanted justified block hash [64] for epoch boundary attestation, got: %v",
if !bytes.Equal(prevEpochBoundaryAttestation[1].Data.EpochBoundaryRootHash32, []byte{128}) {
t.Errorf("Wanted justified block hash [128] for epoch boundary attestation, got: %v",
prevEpochBoundaryAttestation[1].Data.EpochBoundaryRootHash32)
}
}