Skip to content

Commit

Permalink
Fix english typos (#12128)
Browse files Browse the repository at this point in the history
I found these typos annoying, while debugging (and grepping) rewards in
caplin, but forgot to include them in my original PRs.
  • Loading branch information
errge authored Sep 29, 2024
1 parent 10fa19c commit bef0fad
Show file tree
Hide file tree
Showing 21 changed files with 112 additions and 112 deletions.
12 changes: 6 additions & 6 deletions cl/beacon/handler/attestation_rewards.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ func (a *ApiHandler) PostEthV1BeaconRewardsAttestations(w http.ResponseWriter, r
version := a.beaconChainCfg.GetCurrentStateVersion(epoch)

// finalized data
if epoch > a.forkchoiceStore.LowestAvaiableSlot()/a.beaconChainCfg.SlotsPerEpoch {
if epoch > a.forkchoiceStore.LowestAvailableSlot()/a.beaconChainCfg.SlotsPerEpoch {
minRange := epoch * a.beaconChainCfg.SlotsPerEpoch
maxRange := (epoch + 1) * a.beaconChainCfg.SlotsPerEpoch
var blockRoot libcommon.Hash
Expand All @@ -125,12 +125,12 @@ func (a *ApiHandler) PostEthV1BeaconRewardsAttestations(w http.ResponseWriter, r
return nil, beaconhttp.NewEndpointError(http.StatusNotFound, errors.New("no inactivity scores found for this epoch"))
}

prevPartecipation, err := a.forkchoiceStore.GetPreviousPartecipationIndicies(blockRoot)
prevParticipation, err := a.forkchoiceStore.GetPreviousParticipationIndicies(blockRoot)
if err != nil {
return nil, err
}
if prevPartecipation == nil {
return nil, beaconhttp.NewEndpointError(http.StatusNotFound, errors.New("no previous partecipation found for this epoch"))
if prevParticipation == nil {
return nil, beaconhttp.NewEndpointError(http.StatusNotFound, errors.New("no previous participation found for this epoch"))
}
validatorSet, err := a.forkchoiceStore.GetValidatorSet(blockRoot)
if err != nil {
Expand All @@ -145,7 +145,7 @@ func (a *ApiHandler) PostEthV1BeaconRewardsAttestations(w http.ResponseWriter, r
return nil, beaconhttp.NewEndpointError(http.StatusNotFound, errors.New("no finalized checkpoint found for this epoch"))
}

resp, err := a.computeAttestationsRewardsForAltair(validatorSet, inactivityScores, prevPartecipation, a.isInactivityLeaking(epoch, finalizedCheckpoint), filterIndicies, epoch)
resp, err := a.computeAttestationsRewardsForAltair(validatorSet, inactivityScores, prevParticipation, a.isInactivityLeaking(epoch, finalizedCheckpoint), filterIndicies, epoch)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -188,7 +188,7 @@ func (a *ApiHandler) PostEthV1BeaconRewardsAttestations(w http.ResponseWriter, r
return nil, beaconhttp.NewEndpointError(http.StatusNotFound, errors.New("no validator set found for this epoch"))
}

_, previousIdx, err := a.stateReader.ReadPartecipations(tx, lastSlot)
_, previousIdx, err := a.stateReader.ReadParticipations(tx, lastSlot)
if err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion cl/beacon/handler/committees.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func (a *ApiHandler) getCommittees(w http.ResponseWriter, r *http.Request) (*bea
}
resp := make([]*committeeResponse, 0, a.beaconChainCfg.SlotsPerEpoch*a.beaconChainCfg.MaxCommitteesPerSlot)
isFinalized := slot <= a.forkchoiceStore.FinalizedSlot()
if a.forkchoiceStore.LowestAvaiableSlot() <= slot {
if a.forkchoiceStore.LowestAvailableSlot() <= slot {
// non-finality case
s := a.syncedData.HeadState()
if s == nil {
Expand Down
2 changes: 1 addition & 1 deletion cl/beacon/handler/duties_attester.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func (a *ApiHandler) getAttesterDuties(w http.ResponseWriter, r *http.Request) (
resp := []attesterDutyResponse{}

// get the duties
if a.forkchoiceStore.LowestAvaiableSlot() <= epoch*a.beaconChainCfg.SlotsPerEpoch {
if a.forkchoiceStore.LowestAvailableSlot() <= epoch*a.beaconChainCfg.SlotsPerEpoch {
// non-finality case

if s == nil {
Expand Down
12 changes: 6 additions & 6 deletions cl/beacon/handler/duties_sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,19 +112,19 @@ func (a *ApiHandler) getSyncDuties(w http.ResponseWriter, r *http.Request) (*bea
}
}
// Now we can iterate over the sync committee and fill the response
for idx, committeePartecipantPublicKey := range syncCommittee.GetCommittee() {
committeePartecipantIndex, ok, err := state_accessors.ReadValidatorIndexByPublicKey(tx, committeePartecipantPublicKey)
for idx, committeeParticipantPublicKey := range syncCommittee.GetCommittee() {
committeeParticipantIndex, ok, err := state_accessors.ReadValidatorIndexByPublicKey(tx, committeeParticipantPublicKey)
if err != nil {
return nil, err
}
if !ok {
return nil, beaconhttp.NewEndpointError(http.StatusNotFound, fmt.Errorf("could not find validator with public key %x", committeePartecipantPublicKey))
return nil, beaconhttp.NewEndpointError(http.StatusNotFound, fmt.Errorf("could not find validator with public key %x", committeeParticipantPublicKey))
}
if _, ok := dutiesSet[committeePartecipantIndex]; !ok {
if _, ok := dutiesSet[committeeParticipantIndex]; !ok {
continue
}
dutiesSet[committeePartecipantIndex].ValidatorSyncCommitteeIndicies = append(
dutiesSet[committeePartecipantIndex].ValidatorSyncCommitteeIndicies,
dutiesSet[committeeParticipantIndex].ValidatorSyncCommitteeIndicies = append(
dutiesSet[committeeParticipantIndex].ValidatorSyncCommitteeIndicies,
strconv.FormatUint(uint64(idx), 10))
}
// Now we can convert the map to a slice
Expand Down
72 changes: 36 additions & 36 deletions cl/beacon/handler/lighthouse.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func (a *ApiHandler) GetLighthouseValidatorInclusionGlobal(w http.ResponseWriter
defer tx.Rollback()

slot := epoch * a.beaconChainCfg.SlotsPerEpoch
if slot >= a.forkchoiceStore.LowestAvaiableSlot() {
if slot >= a.forkchoiceStore.LowestAvailableSlot() {
// Take data from forkchoice
root, err := a.findEpochRoot(tx, epoch)
if err != nil {
Expand All @@ -102,21 +102,21 @@ func (a *ApiHandler) GetLighthouseValidatorInclusionGlobal(w http.ResponseWriter
if validatorSet == nil {
return nil, beaconhttp.NewEndpointError(http.StatusNotFound, errors.New("validator set not found for current epoch"))
}
currentEpochPartecipation, err := a.forkchoiceStore.GetCurrentPartecipationIndicies(root)
currentEpochParticipation, err := a.forkchoiceStore.GetCurrentParticipationIndicies(root)
if err != nil {
return nil, err
}
if currentEpochPartecipation == nil {
return nil, beaconhttp.NewEndpointError(http.StatusNotFound, errors.New("partecipation not found for current epoch"))
if currentEpochParticipation == nil {
return nil, beaconhttp.NewEndpointError(http.StatusNotFound, errors.New("participation not found for current epoch"))
}
previousEpochPartecipation, err := a.forkchoiceStore.GetPreviousPartecipationIndicies(root)
previousEpochParticipation, err := a.forkchoiceStore.GetPreviousParticipationIndicies(root)
if err != nil {
return nil, err
}
if previousEpochPartecipation == nil {
return nil, beaconhttp.NewEndpointError(http.StatusNotFound, errors.New("partecipation not found for previous epoch"))
if previousEpochParticipation == nil {
return nil, beaconhttp.NewEndpointError(http.StatusNotFound, errors.New("participation not found for previous epoch"))
}
return newBeaconResponse(a.computeLighthouseValidatorInclusionGlobal(epoch, activeBalance, prevActiveBalance, validatorSet, currentEpochPartecipation, previousEpochPartecipation)), nil
return newBeaconResponse(a.computeLighthouseValidatorInclusionGlobal(epoch, activeBalance, prevActiveBalance, validatorSet, currentEpochParticipation, previousEpochParticipation)), nil
}

// read the epoch datas first
Expand All @@ -142,25 +142,25 @@ func (a *ApiHandler) GetLighthouseValidatorInclusionGlobal(w http.ResponseWriter
if validatorSet == nil {
return nil, beaconhttp.NewEndpointError(http.StatusNotFound, errors.New("validator set not found for current epoch"))
}
currentEpochPartecipation, previousEpochPartecipation, err := a.stateReader.ReadPartecipations(tx, slot+(a.beaconChainCfg.SlotsPerEpoch-1))
currentEpochParticipation, previousEpochParticipation, err := a.stateReader.ReadParticipations(tx, slot+(a.beaconChainCfg.SlotsPerEpoch-1))
if err != nil {
return nil, err
}
if currentEpochPartecipation == nil {
return nil, beaconhttp.NewEndpointError(http.StatusNotFound, errors.New("partecipation not found for current epoch"))
if currentEpochParticipation == nil {
return nil, beaconhttp.NewEndpointError(http.StatusNotFound, errors.New("participation not found for current epoch"))
}
if previousEpochPartecipation == nil {
return nil, beaconhttp.NewEndpointError(http.StatusNotFound, errors.New("partecipation not found for previous epoch"))
if previousEpochParticipation == nil {
return nil, beaconhttp.NewEndpointError(http.StatusNotFound, errors.New("participation not found for previous epoch"))
}
return newBeaconResponse(a.computeLighthouseValidatorInclusionGlobal(epoch, epochData.TotalActiveBalance, prevEpochData.TotalActiveBalance, validatorSet, currentEpochPartecipation, previousEpochPartecipation)), nil
return newBeaconResponse(a.computeLighthouseValidatorInclusionGlobal(epoch, epochData.TotalActiveBalance, prevEpochData.TotalActiveBalance, validatorSet, currentEpochParticipation, previousEpochParticipation)), nil
}

func (a *ApiHandler) computeLighthouseValidatorInclusionGlobal(epoch, currentActiveGwei, previousActiveGwei uint64, validatorSet *solid.ValidatorSet, currentEpochPartecipation, previousEpochPartecipation *solid.BitList) *LighthouseValidatorInclusionGlobal {
func (a *ApiHandler) computeLighthouseValidatorInclusionGlobal(epoch, currentActiveGwei, previousActiveGwei uint64, validatorSet *solid.ValidatorSet, currentEpochParticipation, previousEpochParticipation *solid.BitList) *LighthouseValidatorInclusionGlobal {
var currentEpochTargetAttestingGwei, previousEpochTargetAttestingGwei, previousEpochHeadAttestingGwei uint64
for i := 0; i < validatorSet.Length(); i++ {
validatorBalance := validatorSet.Get(i).EffectiveBalance()
prevFlags := cltypes.ParticipationFlags(previousEpochPartecipation.Get(i))
currFlags := cltypes.ParticipationFlags(currentEpochPartecipation.Get(i))
prevFlags := cltypes.ParticipationFlags(previousEpochParticipation.Get(i))
currFlags := cltypes.ParticipationFlags(currentEpochParticipation.Get(i))
if prevFlags.HasFlag(int(a.beaconChainCfg.TimelyHeadFlagIndex)) {
previousEpochHeadAttestingGwei += validatorBalance
}
Expand Down Expand Up @@ -235,7 +235,7 @@ func (a *ApiHandler) GetLighthouseValidatorInclusion(w http.ResponseWriter, r *h
}

slot := epoch * a.beaconChainCfg.SlotsPerEpoch
if slot >= a.forkchoiceStore.LowestAvaiableSlot() {
if slot >= a.forkchoiceStore.LowestAvailableSlot() {
// Take data from forkchoice
root, err := a.findEpochRoot(tx, epoch)
if err != nil {
Expand All @@ -260,21 +260,21 @@ func (a *ApiHandler) GetLighthouseValidatorInclusion(w http.ResponseWriter, r *h
if validatorSet == nil {
return nil, beaconhttp.NewEndpointError(http.StatusNotFound, errors.New("validator set not found for current epoch"))
}
currentEpochPartecipation, err := a.forkchoiceStore.GetCurrentPartecipationIndicies(root)
currentEpochParticipation, err := a.forkchoiceStore.GetCurrentParticipationIndicies(root)
if err != nil {
return nil, err
}
if currentEpochPartecipation == nil {
return nil, beaconhttp.NewEndpointError(http.StatusNotFound, errors.New("partecipation not found for current epoch"))
if currentEpochParticipation == nil {
return nil, beaconhttp.NewEndpointError(http.StatusNotFound, errors.New("participation not found for current epoch"))
}
previousEpochPartecipation, err := a.forkchoiceStore.GetPreviousPartecipationIndicies(root)
previousEpochParticipation, err := a.forkchoiceStore.GetPreviousParticipationIndicies(root)
if err != nil {
return nil, err
}
if previousEpochPartecipation == nil {
return nil, beaconhttp.NewEndpointError(http.StatusNotFound, errors.New("partecipation not found for previous epoch"))
if previousEpochParticipation == nil {
return nil, beaconhttp.NewEndpointError(http.StatusNotFound, errors.New("participation not found for previous epoch"))
}
return newBeaconResponse(a.computeLighthouseValidatorInclusion(int(validatorIndex), prevEpoch, epoch, activeBalance, prevActiveBalance, validatorSet, currentEpochPartecipation, previousEpochPartecipation)), nil
return newBeaconResponse(a.computeLighthouseValidatorInclusion(int(validatorIndex), prevEpoch, epoch, activeBalance, prevActiveBalance, validatorSet, currentEpochParticipation, previousEpochParticipation)), nil
}

// read the epoch datas first
Expand All @@ -300,25 +300,25 @@ func (a *ApiHandler) GetLighthouseValidatorInclusion(w http.ResponseWriter, r *h
if validatorSet == nil {
return nil, beaconhttp.NewEndpointError(http.StatusNotFound, errors.New("validator set not found for current epoch"))
}
currentEpochPartecipation, previousEpochPartecipation, err := a.stateReader.ReadPartecipations(tx, slot+(a.beaconChainCfg.SlotsPerEpoch-1))
currentEpochParticipation, previousEpochParticipation, err := a.stateReader.ReadParticipations(tx, slot+(a.beaconChainCfg.SlotsPerEpoch-1))
if err != nil {
return nil, err
}
if currentEpochPartecipation == nil {
return nil, beaconhttp.NewEndpointError(http.StatusNotFound, errors.New("partecipation not found for current epoch"))
if currentEpochParticipation == nil {
return nil, beaconhttp.NewEndpointError(http.StatusNotFound, errors.New("participation not found for current epoch"))
}
if previousEpochPartecipation == nil {
return nil, beaconhttp.NewEndpointError(http.StatusNotFound, errors.New("partecipation not found for previous epoch"))
if previousEpochParticipation == nil {
return nil, beaconhttp.NewEndpointError(http.StatusNotFound, errors.New("participation not found for previous epoch"))
}
return newBeaconResponse(a.computeLighthouseValidatorInclusion(int(validatorIndex), prevEpoch, epoch, epochData.TotalActiveBalance, prevEpochData.TotalActiveBalance, validatorSet, currentEpochPartecipation, previousEpochPartecipation)), nil
return newBeaconResponse(a.computeLighthouseValidatorInclusion(int(validatorIndex), prevEpoch, epoch, epochData.TotalActiveBalance, prevEpochData.TotalActiveBalance, validatorSet, currentEpochParticipation, previousEpochParticipation)), nil
}

func (a *ApiHandler) computeLighthouseValidatorInclusion(idx int, prevEpoch, epoch, currentActiveGwei, previousActiveGwei uint64, validatorSet *solid.ValidatorSet, currentEpochPartecipation, previousEpochPartecipation *solid.BitList) *LighthouseValidatorInclusion {
func (a *ApiHandler) computeLighthouseValidatorInclusion(idx int, prevEpoch, epoch, currentActiveGwei, previousActiveGwei uint64, validatorSet *solid.ValidatorSet, currentEpochParticipation, previousEpochParticipation *solid.BitList) *LighthouseValidatorInclusion {
var currentEpochTargetAttestingGwei, previousEpochTargetAttestingGwei, previousEpochHeadAttestingGwei uint64
for i := 0; i < validatorSet.Length(); i++ {
validatorBalance := validatorSet.Get(i).EffectiveBalance()
prevFlags := cltypes.ParticipationFlags(previousEpochPartecipation.Get(i))
currFlags := cltypes.ParticipationFlags(currentEpochPartecipation.Get(i))
prevFlags := cltypes.ParticipationFlags(previousEpochParticipation.Get(i))
currFlags := cltypes.ParticipationFlags(currentEpochParticipation.Get(i))
if prevFlags.HasFlag(int(a.beaconChainCfg.TimelyHeadFlagIndex)) {
previousEpochHeadAttestingGwei += validatorBalance
}
Expand All @@ -330,8 +330,8 @@ func (a *ApiHandler) computeLighthouseValidatorInclusion(idx int, prevEpoch, epo
}
}
validator := validatorSet.Get(idx)
prevFlags := cltypes.ParticipationFlags(previousEpochPartecipation.Get(idx))
currFlags := cltypes.ParticipationFlags(currentEpochPartecipation.Get(idx))
prevFlags := cltypes.ParticipationFlags(previousEpochParticipation.Get(idx))
currFlags := cltypes.ParticipationFlags(currentEpochParticipation.Get(idx))

return &LighthouseValidatorInclusion{
IsSlashed: validator.Slashed(),
Expand Down
26 changes: 13 additions & 13 deletions cl/beacon/handler/liveness.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,29 +97,29 @@ func (a *ApiHandler) liveness(w http.ResponseWriter, r *http.Request) (*beaconht
}
lastSlotProcess = block.Block.Slot
}
// use the epoch partecipation as an additional heuristic
currentEpochPartecipation, previousEpochPartecipation, err := a.obtainCurrentEpochPartecipationFromEpoch(tx, epoch, lastBlockRootProcess, lastSlotProcess)
// use the epoch participation as an additional heuristic
currentEpochParticipation, previousEpochParticipation, err := a.obtainCurrentEpochParticipationFromEpoch(tx, epoch, lastBlockRootProcess, lastSlotProcess)
if err != nil {
return nil, err
}
if currentEpochPartecipation == nil {
return nil, beaconhttp.NewEndpointError(http.StatusNotFound, fmt.Errorf("could not find partecipations for epoch %d, if this was an historical query, turn on --caplin.archive", epoch))
if currentEpochParticipation == nil {
return nil, beaconhttp.NewEndpointError(http.StatusNotFound, fmt.Errorf("could not find participations for epoch %d, if this was an historical query, turn on --caplin.archive", epoch))
}
for idx, live := range liveSet {
if live.IsLive {
continue
}
if idx >= uint64(currentEpochPartecipation.Length()) {
if idx >= uint64(currentEpochParticipation.Length()) {
continue
}
if currentEpochPartecipation.Get(int(idx)) != 0 {
if currentEpochParticipation.Get(int(idx)) != 0 {
live.IsLive = true
continue
}
if idx >= uint64(previousEpochPartecipation.Length()) {
if idx >= uint64(previousEpochParticipation.Length()) {
continue
}
live.IsLive = previousEpochPartecipation.Get(int(idx)) != 0
live.IsLive = previousEpochParticipation.Get(int(idx)) != 0
}

resp := []*live{}
Expand All @@ -133,18 +133,18 @@ func (a *ApiHandler) liveness(w http.ResponseWriter, r *http.Request) (*beaconht
return newBeaconResponse(resp), nil
}

func (a *ApiHandler) obtainCurrentEpochPartecipationFromEpoch(tx kv.Tx, epoch uint64, blockRoot libcommon.Hash, blockSlot uint64) (*solid.BitList, *solid.BitList, error) {
func (a *ApiHandler) obtainCurrentEpochParticipationFromEpoch(tx kv.Tx, epoch uint64, blockRoot libcommon.Hash, blockSlot uint64) (*solid.BitList, *solid.BitList, error) {
prevEpoch := epoch
if epoch > 0 {
prevEpoch--
}

currPartecipation, ok1 := a.forkchoiceStore.Partecipation(epoch)
prevPartecipation, ok2 := a.forkchoiceStore.Partecipation(prevEpoch)
currParticipation, ok1 := a.forkchoiceStore.Participation(epoch)
prevParticipation, ok2 := a.forkchoiceStore.Participation(prevEpoch)
if !ok1 || !ok2 {
return a.stateReader.ReadPartecipations(tx, blockSlot)
return a.stateReader.ReadParticipations(tx, blockSlot)
}
return currPartecipation, prevPartecipation, nil
return currParticipation, prevParticipation, nil

}

Expand Down
10 changes: 5 additions & 5 deletions cl/beacon/handler/rewards.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func (a *ApiHandler) GetEthV1BeaconRewardsBlocks(w http.ResponseWriter, r *http.
}
slot := blk.Header.Slot
isFinalized := slot <= a.forkchoiceStore.FinalizedSlot()
if slot >= a.forkchoiceStore.LowestAvaiableSlot() {
if slot >= a.forkchoiceStore.LowestAvailableSlot() {
// finalized case
blkRewards, ok := a.forkchoiceStore.BlockRewards(root)
if !ok {
Expand Down Expand Up @@ -209,7 +209,7 @@ func (a *ApiHandler) PostEthV1BeaconRewardsSyncCommittees(w http.ResponseWriter,
for _, idx := range filterIndicies {
accumulatedRewards[idx] = 0
}
partecipantReward := int64(a.syncPartecipantReward(totalActiveBalance))
participantReward := int64(a.syncParticipantReward(totalActiveBalance))

for committeeIdx, v := range committee {
idx, ok, err := state_accessors.ReadValidatorIndexByPublicKey(tx, v)
Expand All @@ -225,10 +225,10 @@ func (a *ApiHandler) PostEthV1BeaconRewardsSyncCommittees(w http.ResponseWriter,
}
}
if syncAggregate.IsSet(uint64(committeeIdx)) {
accumulatedRewards[idx] += partecipantReward
accumulatedRewards[idx] += participantReward
continue
}
accumulatedRewards[idx] -= partecipantReward
accumulatedRewards[idx] -= participantReward
}
for idx, reward := range accumulatedRewards {
rewards = append(rewards, syncCommitteeReward{
Expand All @@ -242,7 +242,7 @@ func (a *ApiHandler) PostEthV1BeaconRewardsSyncCommittees(w http.ResponseWriter,
return newBeaconResponse(rewards).WithFinalized(isFinalized).WithOptimistic(a.forkchoiceStore.IsRootOptimistic(root)), nil
}

func (a *ApiHandler) syncPartecipantReward(activeBalance uint64) uint64 {
func (a *ApiHandler) syncParticipantReward(activeBalance uint64) uint64 {
activeBalanceSqrt := utils.IntegerSquareRoot(activeBalance)
totalActiveIncrements := activeBalance / a.beaconChainCfg.EffectiveBalanceIncrement
baseRewardPerInc := a.beaconChainCfg.EffectiveBalanceIncrement * a.beaconChainCfg.BaseRewardFactor / activeBalanceSqrt
Expand Down
Loading

0 comments on commit bef0fad

Please sign in to comment.