Fix State Recalc in Slot Assignment (#585)

This commit is contained in:
Raul Jordan 2018-09-27 23:49:29 -05:00 committed by GitHub
parent 965c6a30cf
commit 367aae3bf4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 8 deletions

View File

@ -103,7 +103,7 @@ func (a *Service) aggregateAttestations() {
continue
}
log.Info("Forwarding aggregated attestation 0x%v to proposers through grpc", h)
log.Infof("Forwarding aggregated attestation 0x%x to proposers through grpc", h)
}
}
}

View File

@ -130,17 +130,17 @@ func (s *Service) fetchCurrentAssignmentsAndGenesisTime(client pb.BeaconServiceC
log.Fatalf("cannot compute genesis timestamp: %v", err)
}
log.Infof("Setting validator genesis time to %d", genesisTimestamp.Unix())
log.Infof("Setting validator genesis time to %s", genesisTimestamp.Format(time.UnixDate))
s.genesisTimestamp = genesisTimestamp
for _, assign := range res.Assignments {
if bytes.Equal(assign.PublicKey.PublicKey, s.pubKey) {
s.role = assign.Role
s.assignedSlot = assign.AssignedSlot
s.assignedSlot = s.CurrentCycleStartSlot() + assign.AssignedSlot
s.shardID = assign.ShardId
log.Infof("Validator shuffled. Pub key 0x%s re-assigned to shard ID %d for %v duty at slot %d",
string(s.pubKey),
s.assignedSlot,
s.shardID,
s.role,
s.assignedSlot)
}
@ -176,12 +176,12 @@ func (s *Service) listenForAssignmentChange(client pb.BeaconServiceClient) {
for _, assign := range assignment.Assignments {
if bytes.Equal(assign.PublicKey.PublicKey, s.pubKey) {
s.role = assign.Role
s.assignedSlot = assign.AssignedSlot
s.assignedSlot = s.CurrentCycleStartSlot() + assign.AssignedSlot
s.shardID = assign.ShardId
log.Infof("Validator with pub key 0x%s re-assigned to shard ID %d for %v duty at slot %d",
string(s.pubKey),
s.assignedSlot,
s.shardID,
s.role,
s.assignedSlot)
}

View File

@ -301,10 +301,11 @@ func TestListenForAssignmentProposer(t *testing.T) {
stream := internal.NewMockBeaconService_ValidatorAssignmentsClient(ctrl)
// Testing proposer assignment.
assignedSlot := b.CurrentCycleStartSlot() + 2
stream.EXPECT().Recv().Return(&pb.ValidatorAssignmentResponse{Assignments: []*pb.Assignment{{
PublicKey: &pb.PublicKey{PublicKey: []byte{'A'}},
ShardId: 2,
AssignedSlot: 2,
AssignedSlot: assignedSlot,
Role: pb.ValidatorRole_PROPOSER}}}, nil)
stream.EXPECT().Recv().Return(&pb.ValidatorAssignmentResponse{}, io.EOF)
@ -316,7 +317,7 @@ func TestListenForAssignmentProposer(t *testing.T) {
b.listenForAssignmentChange(mockServiceValidator)
testutil.AssertLogsContain(t, hook, "Validator with pub key 0xA re-assigned to shard ID 2 for PROPOSER duty at slot 2")
testutil.AssertLogsContain(t, hook, "Validator with pub key 0xA re-assigned to shard ID 2 for PROPOSER duty")
// Testing an error coming from the stream.
stream = internal.NewMockBeaconService_ValidatorAssignmentsClient(ctrl)