Skip to content

Commit

Permalink
Use correct end index for subList calls (Consensys#8271)
Browse files Browse the repository at this point in the history
  • Loading branch information
jtraglia authored Apr 30, 2024
1 parent 8ddce8b commit 80687ba
Showing 1 changed file with 4 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,7 @@ public void processPendingBalanceDeposits(final MutableBeaconState state) {

final SszList<PendingBalanceDeposit> pendingBalanceDeposits =
stateElectra.getPendingBalanceDeposits();
for (int i = 0; i < pendingBalanceDeposits.size(); i++) {
final PendingBalanceDeposit deposit = pendingBalanceDeposits.get(i);
for (final PendingBalanceDeposit deposit : pendingBalanceDeposits) {
if (processedAmount.plus(deposit.getAmount()).isGreaterThan(availableForProcessing)) {
break;
}
Expand All @@ -181,9 +180,7 @@ public void processPendingBalanceDeposits(final MutableBeaconState state) {
stateElectra.setDepositBalanceToConsume(UInt64.ZERO);
} else {
final List<PendingBalanceDeposit> newList =
pendingBalanceDeposits
.asList()
.subList(nextDepositIndex, pendingBalanceDeposits.size() - 1);
pendingBalanceDeposits.asList().subList(nextDepositIndex, pendingBalanceDeposits.size());
stateElectra.setPendingBalanceDeposits(
schemaDefinitionsElectra.getPendingBalanceDepositsSchema().createFromElements(newList));
stateElectra.setDepositBalanceToConsume(availableForProcessing.minusMinZero(processedAmount));
Expand All @@ -204,8 +201,7 @@ public void processPendingConsolidations(final MutableBeaconState state) {
stateElectra.getPendingConsolidations();
final UInt64 currentEpoch = stateAccessorsElectra.getCurrentEpoch(state);

for (int i = 0; i < pendingConsolidations.size(); i++) {
final PendingConsolidation pendingConsolidation = pendingConsolidations.get(i);
for (final PendingConsolidation pendingConsolidation : pendingConsolidations) {
final Validator sourceValidator =
state.getValidators().get(pendingConsolidation.getSourceIndex());
if (sourceValidator.isSlashed()) {
Expand Down Expand Up @@ -234,7 +230,7 @@ public void processPendingConsolidations(final MutableBeaconState state) {
final List<PendingConsolidation> newList =
pendingConsolidations
.asList()
.subList(nextPendingBalanceConsolidation, pendingConsolidations.size() - 1);
.subList(nextPendingBalanceConsolidation, pendingConsolidations.size());
stateElectra.setPendingConsolidations(
schemaDefinitionsElectra.getPendingConsolidationsSchema().createFromElements(newList));
}
Expand Down

0 comments on commit 80687ba

Please sign in to comment.