use of tech.pegasys.teku.infrastructure.ssz.collections.SszMutableUInt64List in project teku by ConsenSys.
the class EpochTransitionBenchmark method applyDeltas.
@Benchmark
public void applyDeltas(Blackhole bh) {
final SszMutableUInt64List balances = preEpochTransitionMutableState.getBalances();
int validatorsSize = preEpochTransitionMutableState.getValidators().size();
for (int i = 0; i < validatorsSize; i++) {
final RewardAndPenalty delta = attestationDeltas.getDelta(i);
balances.setElement(i, balances.getElement(i).plus(delta.getReward()).minusMinZero(delta.getPenalty()));
}
}
use of tech.pegasys.teku.infrastructure.ssz.collections.SszMutableUInt64List in project teku by ConsenSys.
the class EpochProcessorAltair method processInactivityUpdates.
@Override
public void processInactivityUpdates(final MutableBeaconState baseState, final ValidatorStatuses validatorStatuses) {
if (beaconStateAccessors.getCurrentEpoch(baseState).equals(SpecConfig.GENESIS_EPOCH)) {
return;
}
final MutableBeaconStateAltair state = MutableBeaconStateAltair.required(baseState);
final SszMutableUInt64List inactivityScores = state.getInactivityScores();
final List<ValidatorStatus> statuses = validatorStatuses.getStatuses();
final boolean isInInactivityLeak = beaconStateAccessors.isInactivityLeak(state);
for (int i = 0; i < statuses.size(); i++) {
final ValidatorStatus validatorStatus = statuses.get(i);
if (!validatorStatus.isEligibleValidator()) {
continue;
}
// Increase inactivity score of inactive validators
final UInt64 currentScore = inactivityScores.getElement(i);
UInt64 newScore;
if (validatorStatus.isNotSlashed() && validatorStatus.isPreviousEpochTargetAttester()) {
newScore = currentScore.minusMinZero(1);
} else {
newScore = currentScore.plus(specConfigAltair.getInactivityScoreBias());
}
// Decrease the score of all validators for forgiveness when not during a leak
if (!isInInactivityLeak) {
newScore = newScore.minusMinZero(specConfigAltair.getInactivityScoreRecoveryRate());
}
if (!currentScore.equals(newScore)) {
inactivityScores.setElement(i, newScore);
}
}
}
use of tech.pegasys.teku.infrastructure.ssz.collections.SszMutableUInt64List in project teku by ConsenSys.
the class AbstractEpochProcessor method applyDeltas.
protected void applyDeltas(final MutableBeaconState state, final RewardAndPenaltyDeltas attestationDeltas) {
final SszMutableUInt64List balances = state.getBalances();
// To optimize performance, calculate validator size once outside of the loop
int validatorsCount = state.getValidators().size();
for (int i = 0; i < validatorsCount; i++) {
final RewardAndPenalty delta = attestationDeltas.getDelta(i);
balances.setElement(i, balances.getElement(i).plus(delta.getReward()).minusMinZero(delta.getPenalty()));
}
}
Aggregations