Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize ListBeaconCommittees to use committees cache #4464

Merged
merged 2 commits into from Jan 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion beacon-chain/blockchain/service.go
Expand Up @@ -195,7 +195,6 @@ func (s *Service) initializeBeaconChain(
eth1data *ethpb.Eth1Data) error {
_, span := trace.StartSpan(context.Background(), "beacon-chain.Service.initializeBeaconChain")
defer span.End()
log.Info("Genesis time reached, starting the beacon chain")
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed this log where it says genesis time reached but it hasn't reach. The log is meant for initializing beacon genesis state

s.genesisTime = genesisTime
unixTime := uint64(genesisTime.Unix())

Expand All @@ -208,6 +207,8 @@ func (s *Service) initializeBeaconChain(
return errors.Wrap(err, "could not save genesis data")
}

log.Info("Initialized beacon chain genesis state")

// Update committee shuffled indices for genesis epoch.
if featureconfig.Get().EnableNewCache {
if err := helpers.UpdateCommitteeCache(genesisState, 0 /* genesis epoch */); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion beacon-chain/blockchain/service_test.go
Expand Up @@ -176,7 +176,7 @@ func TestChainStartStop_Uninitialized(t *testing.T) {
t.Error("Context was not canceled")
}
testutil.AssertLogsContain(t, hook, "Waiting")
testutil.AssertLogsContain(t, hook, "Genesis time reached")
testutil.AssertLogsContain(t, hook, "Initialized beacon chain genesis state")
}

func TestChainStartStop_Initialized(t *testing.T) {
Expand Down
8 changes: 3 additions & 5 deletions beacon-chain/rpc/beacon/committees.go
Expand Up @@ -105,10 +105,8 @@ func (bs *Server) ListBeaconCommittees(
countAtSlot = 1
}
committeeItems := make([]*ethpb.BeaconCommittees_CommitteeItem, countAtSlot)
for i := uint64(0); i < countAtSlot; i++ {
epochOffset := i + (slot%params.BeaconConfig().SlotsPerEpoch)*countAtSlot
totalCount := countAtSlot * params.BeaconConfig().SlotsPerEpoch
committee, err := helpers.ComputeCommittee(activeIndices, attesterSeed, epochOffset, totalCount)
for committeeIndex := uint64(0); committeeIndex < countAtSlot; committeeIndex++ {
committee, err := helpers.BeaconCommittee(activeIndices, attesterSeed, slot, committeeIndex)
if err != nil {
return nil, status.Errorf(
codes.Internal,
Expand All @@ -117,7 +115,7 @@ func (bs *Server) ListBeaconCommittees(
err,
)
}
committeeItems[i] = &ethpb.BeaconCommittees_CommitteeItem{
committeeItems[committeeIndex] = &ethpb.BeaconCommittees_CommitteeItem{
ValidatorIndices: committee,
}
}
Expand Down