use of tech.pegasys.teku.spec.logic.common.statetransition.epoch.RewardAndPenaltyDeltas in project teku by ConsenSys.
the class RewardsAndPenaltiesCalculatorPhase0 method getDeltas.
public RewardAndPenaltyDeltas getDeltas(final Step step) throws IllegalArgumentException {
final RewardAndPenaltyDeltas deltas = new RewardAndPenaltyDeltas(validatorStatuses.getValidatorCount());
final TotalBalances totalBalances = validatorStatuses.getTotalBalances();
final List<ValidatorStatus> statuses = validatorStatuses.getStatuses();
final UInt64 finalityDelay = getFinalityDelay();
final UInt64 totalActiveBalanceSquareRoot = squareRootOrZero(totalBalances.getCurrentEpochActiveValidators());
for (int index = 0; index < statuses.size(); index++) {
final ValidatorStatus validator = statuses.get(index);
if (!validator.isEligibleValidator()) {
continue;
}
final UInt64 baseReward = getBaseReward(validator, totalActiveBalanceSquareRoot);
final RewardAndPenalty delta = deltas.getDelta(index);
step.apply(deltas, totalBalances, finalityDelay, validator, baseReward, delta);
}
return deltas;
}
use of tech.pegasys.teku.spec.logic.common.statetransition.epoch.RewardAndPenaltyDeltas in project teku by ConsenSys.
the class RewardsTestExecutorAltair method assertDeltas.
private void assertDeltas(final TestDefinition testDefinition, final String expectedResultsFileName, final Supplier<RewardAndPenaltyDeltas> function) {
final RewardAndPenaltyDeltas expectedDeltas = loadSsz(testDefinition, expectedResultsFileName, ExpectedDeltas.SSZ_SCHEMA).getDeltas();
final RewardAndPenaltyDeltas actualDeltas = function.get();
assertThat(actualDeltas).describedAs(expectedResultsFileName).isEqualToComparingFieldByField(expectedDeltas);
}
use of tech.pegasys.teku.spec.logic.common.statetransition.epoch.RewardAndPenaltyDeltas in project teku by ConsenSys.
the class ExpectedDeltas method getDeltas.
public RewardAndPenaltyDeltas getDeltas() {
final SszUInt64List rewards = getField0();
final SszUInt64List penalties = getField1();
final RewardAndPenaltyDeltas deltas = new RewardAndPenaltyDeltas(rewards.size());
for (int i = 0; i < rewards.size(); i++) {
deltas.getDelta(i).reward(rewards.get(i).get());
deltas.getDelta(i).penalize(penalties.get(i).get());
}
return deltas;
}
use of tech.pegasys.teku.spec.logic.common.statetransition.epoch.RewardAndPenaltyDeltas in project teku by ConsenSys.
the class RewardsAndPenaltiesCalculatorAltair method getDeltas.
/**
* Return attestation reward/penalty deltas for each validator
*
* @return
* @throws IllegalArgumentException
*/
@Override
public RewardAndPenaltyDeltas getDeltas() throws IllegalArgumentException {
final RewardAndPenaltyDeltas deltas = new RewardAndPenaltyDeltas(validatorStatuses.getValidatorCount());
for (int flagIndex = 0; flagIndex < PARTICIPATION_FLAG_WEIGHTS.size(); flagIndex++) {
processFlagIndexDeltas(deltas, flagIndex);
}
processInactivityPenaltyDeltas(deltas);
return deltas;
}
use of tech.pegasys.teku.spec.logic.common.statetransition.epoch.RewardAndPenaltyDeltas in project teku by ConsenSys.
the class RewardsTestExecutorPhase0 method assertDeltas.
private void assertDeltas(final TestDefinition testDefinition, final String expectedResultsFileName, final Supplier<RewardAndPenaltyDeltas> function) {
final RewardAndPenaltyDeltas expectedDeltas = loadSsz(testDefinition, expectedResultsFileName, ExpectedDeltas.SSZ_SCHEMA).getDeltas();
final RewardAndPenaltyDeltas actualDeltas = function.get();
assertThat(actualDeltas).describedAs(expectedResultsFileName).isEqualToComparingFieldByField(expectedDeltas);
}
Aggregations