mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-25 04:47:18 +00:00
revert 2 initial committees to 3 (#746)
This commit is contained in:
parent
6520c8ffc2
commit
9e096302d2
@ -29,8 +29,9 @@ func InitialShardAndCommitteesForSlots(validators []*pb.ValidatorRecord) ([]*pb.
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialize with 2 cycles of the same committees.
|
// Initialize with 3 cycles of the same committees.
|
||||||
initialCommittees := make([]*pb.ShardAndCommitteeArray, 0, 2*params.GetConfig().CycleLength)
|
initialCommittees := make([]*pb.ShardAndCommitteeArray, 0, 3*params.GetConfig().CycleLength)
|
||||||
|
initialCommittees = append(initialCommittees, committees...)
|
||||||
initialCommittees = append(initialCommittees, committees...)
|
initialCommittees = append(initialCommittees, committees...)
|
||||||
initialCommittees = append(initialCommittees, committees...)
|
initialCommittees = append(initialCommittees, committees...)
|
||||||
return initialCommittees, nil
|
return initialCommittees, nil
|
||||||
|
@ -24,14 +24,14 @@ func TestGetShardAndCommitteesForSlots(t *testing.T) {
|
|||||||
if _, err := GetShardAndCommitteesForSlot(state.ShardAndCommitteesForSlots, state.LastStateRecalculationSlot, 1000); err == nil {
|
if _, err := GetShardAndCommitteesForSlot(state.ShardAndCommitteesForSlots, state.LastStateRecalculationSlot, 1000); err == nil {
|
||||||
t.Error("getShardAndCommitteesForSlot should have failed with invalid slot")
|
t.Error("getShardAndCommitteesForSlot should have failed with invalid slot")
|
||||||
}
|
}
|
||||||
committee, err := GetShardAndCommitteesForSlot(state.ShardAndCommitteesForSlots, state.LastStateRecalculationSlot, 1)
|
committee, err := GetShardAndCommitteesForSlot(state.ShardAndCommitteesForSlots, state.LastStateRecalculationSlot, 0)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("getShardAndCommitteesForSlot failed: %v", err)
|
t.Errorf("getShardAndCommitteesForSlot failed: %v", err)
|
||||||
}
|
}
|
||||||
if committee.ArrayShardAndCommittee[0].Shard != 1 {
|
if committee.ArrayShardAndCommittee[0].Shard != 1 {
|
||||||
t.Errorf("getShardAndCommitteesForSlot returns Shard should be 1, got: %v", committee.ArrayShardAndCommittee[0].Shard)
|
t.Errorf("getShardAndCommitteesForSlot returns Shard should be 1, got: %v", committee.ArrayShardAndCommittee[0].Shard)
|
||||||
}
|
}
|
||||||
committee, _ = GetShardAndCommitteesForSlot(state.ShardAndCommitteesForSlots, state.LastStateRecalculationSlot, 2)
|
committee, _ = GetShardAndCommitteesForSlot(state.ShardAndCommitteesForSlots, state.LastStateRecalculationSlot, 1)
|
||||||
if committee.ArrayShardAndCommittee[0].Shard != 3 {
|
if committee.ArrayShardAndCommittee[0].Shard != 3 {
|
||||||
t.Errorf("getShardAndCommitteesForSlot returns Shard should be 3, got: %v", committee.ArrayShardAndCommittee[0].Shard)
|
t.Errorf("getShardAndCommitteesForSlot returns Shard should be 3, got: %v", committee.ArrayShardAndCommittee[0].Shard)
|
||||||
}
|
}
|
||||||
@ -77,8 +77,8 @@ func TestInitialShardAndCommiteeForSlots(t *testing.T) {
|
|||||||
t.Fatalf("unable to get initial shard committees %v", err)
|
t.Fatalf("unable to get initial shard committees %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if uint64(len(shardAndCommitteeArray)) != 2*params.GetConfig().CycleLength {
|
if uint64(len(shardAndCommitteeArray)) != 3*params.GetConfig().CycleLength {
|
||||||
t.Errorf("shard committee slots are not as expected: %d instead of %d", len(shardAndCommitteeArray), 2*params.GetConfig().CycleLength)
|
t.Errorf("shard committee slots are not as expected: %d instead of %d", len(shardAndCommitteeArray), 3*params.GetConfig().CycleLength)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -51,7 +51,7 @@ func GetShardAndCommitteesForSlot(shardCommittees []*pb.ShardAndCommitteeArray,
|
|||||||
|
|
||||||
var lowerBound uint64
|
var lowerBound uint64
|
||||||
if lastStateRecalc >= cycleLength {
|
if lastStateRecalc >= cycleLength {
|
||||||
lowerBound = lastStateRecalc - cycleLength + 1
|
lowerBound = lastStateRecalc - cycleLength
|
||||||
}
|
}
|
||||||
upperBound := lastStateRecalc + 2*cycleLength
|
upperBound := lastStateRecalc + 2*cycleLength
|
||||||
if slot < lowerBound || slot >= upperBound {
|
if slot < lowerBound || slot >= upperBound {
|
||||||
|
@ -136,8 +136,8 @@ func TestProposerShardAndIndex(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("ProposerShardAndIndex failed with %v", err)
|
t.Fatalf("ProposerShardAndIndex failed with %v", err)
|
||||||
}
|
}
|
||||||
if shard != 0 {
|
if shard != 2 {
|
||||||
t.Errorf("Invalid shard ID. Wanted 0, got %d", shard)
|
t.Errorf("Invalid shard ID. Wanted 2, got %d", shard)
|
||||||
}
|
}
|
||||||
if index != 0 {
|
if index != 0 {
|
||||||
t.Errorf("Invalid proposer index. Wanted 0, got %d", index)
|
t.Errorf("Invalid proposer index. Wanted 0, got %d", index)
|
||||||
|
Loading…
Reference in New Issue
Block a user