Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions cl/beacon/handler/committees.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,7 @@ func (a *ApiHandler) getCommittees(w http.ResponseWriter, r *http.Request) (*bea
return nil, err
}

committeesPerSlot := min(a.beaconChainCfg.MaxCommitteesPerSlot, uint64(len(activeIdxs))/a.beaconChainCfg.SlotsPerEpoch/a.beaconChainCfg.TargetCommitteeSize)
if committeesPerSlot < 1 {
committeesPerSlot = 1
}
committeesPerSlot := max(min(a.beaconChainCfg.MaxCommitteesPerSlot, uint64(len(activeIdxs))/a.beaconChainCfg.SlotsPerEpoch/a.beaconChainCfg.TargetCommitteeSize), 1)

mixPosition := (epoch + a.beaconChainCfg.EpochsPerHistoricalVector - a.beaconChainCfg.MinSeedLookahead - 1) % a.beaconChainCfg.EpochsPerHistoricalVector
mix, err := a.stateReader.ReadRandaoMixBySlotAndIndex(tx, stateGetter, epoch*a.beaconChainCfg.SlotsPerEpoch, mixPosition)
Expand Down
5 changes: 1 addition & 4 deletions cl/beacon/handler/duties_attester.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,10 +177,7 @@ func (a *ApiHandler) getAttesterDuties(w http.ResponseWriter, r *http.Request) (
return nil, err
}

committeesPerSlot := min(a.beaconChainCfg.MaxCommitteesPerSlot, uint64(len(activeIdxs))/a.beaconChainCfg.SlotsPerEpoch/a.beaconChainCfg.TargetCommitteeSize)
if committeesPerSlot < 1 {
committeesPerSlot = 1
}
committeesPerSlot := max(min(a.beaconChainCfg.MaxCommitteesPerSlot, uint64(len(activeIdxs))/a.beaconChainCfg.SlotsPerEpoch/a.beaconChainCfg.TargetCommitteeSize), 1)

mixPosition := (epoch + a.beaconChainCfg.EpochsPerHistoricalVector - a.beaconChainCfg.MinSeedLookahead - 1) % a.beaconChainCfg.EpochsPerHistoricalVector
mix, err := a.stateReader.ReadRandaoMixBySlotAndIndex(tx, stateGetter, epoch*a.beaconChainCfg.SlotsPerEpoch, mixPosition)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,7 @@ func (r *HistoricalStatesReader) ComputeCommittee(mix common.Hash, indicies []ui
}

func committeeCount(cfg *clparams.BeaconChainConfig, epoch uint64, idxs []uint64) uint64 {
committeCount := min(cfg.MaxCommitteesPerSlot, uint64(len(idxs))/cfg.SlotsPerEpoch/cfg.TargetCommitteeSize)
if committeCount < 1 {
committeCount = 1
}
committeCount := max(min(cfg.MaxCommitteesPerSlot, uint64(len(idxs))/cfg.SlotsPerEpoch/cfg.TargetCommitteeSize), 1)
return committeCount
}

Expand Down
7 changes: 2 additions & 5 deletions cl/phase1/core/state/cache_accessors.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,12 +222,9 @@ func (b *CachingBeaconState) SyncRewards() (proposerReward, participantReward ui

// CommitteeCount returns current number of committee for epoch.
func (b *CachingBeaconState) CommitteeCount(epoch uint64) uint64 {
committeCount := min(b.BeaconConfig().MaxCommitteesPerSlot, uint64(
committeCount := max(min(b.BeaconConfig().MaxCommitteesPerSlot, uint64(
len(b.GetActiveValidatorsIndices(epoch)),
)/b.BeaconConfig().SlotsPerEpoch/b.BeaconConfig().TargetCommitteeSize)
if committeCount < 1 {
committeCount = 1
}
)/b.BeaconConfig().SlotsPerEpoch/b.BeaconConfig().TargetCommitteeSize), 1)
return committeCount
}

Expand Down
5 changes: 1 addition & 4 deletions cl/phase1/forkchoice/checkpoint_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,7 @@ func (c *checkpointState) getActiveIndicies(epoch uint64) (activeIndicies []uint

// committeeCount retrieves size of sync committee
func (c *checkpointState) committeeCount(epoch, lenIndicies uint64) uint64 {
committeCount := min(c.beaconConfig.MaxCommitteesPerSlot, lenIndicies/c.beaconConfig.SlotsPerEpoch/c.beaconConfig.TargetCommitteeSize)
if committeCount < 1 {
committeCount = 1
}
committeCount := max(min(c.beaconConfig.MaxCommitteesPerSlot, lenIndicies/c.beaconConfig.SlotsPerEpoch/c.beaconConfig.TargetCommitteeSize), 1)
return committeCount
}

Expand Down
5 changes: 1 addition & 4 deletions cl/utils/eth2shuffle/shuffle.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,7 @@ func innerPermuteIndex(hashFn HashFn, rounds uint8, index uint64, listSize uint6
// Why? Don't do double work: we consider every pair only once.
// (Otherwise we would swap it back in place)
// Pick the highest index of the pair as position to retrieve randomness with.
position := index
if flip > position {
position = flip
}
position := max(flip, index)
// spec: source = hash(seed + int_to_bytes1(round) + int_to_bytes4(position // 256))
// - seed is still in 0:32 (excl., 32 bytes)
// - round number is still in 32
Expand Down
Loading