Skip to content

Commit

Permalink
Fixed prunable rollback deleting the rewards
Browse files Browse the repository at this point in the history
If we rolled back to the last slot of an epoch (e.g. when loading a snapshot) on resuming from storage or starting warpsync we wrongly deleted the rewards
  • Loading branch information
alexsporn committed May 2, 2024
1 parent 7f81e70 commit 7b3b4fe
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions pkg/storage/prunable/prunable.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,9 +194,13 @@ func (p *Prunable) Rollback(targetEpoch iotago.EpochIndex, startPruneRange iotag
return ierrors.Wrapf(err, "failed to rollback decided upgrade signals epochs to target epoch %d", targetEpoch)
}

lastPrunedPoolRewardsEpoch, err := p.poolRewards.RollbackEpochs(targetEpoch)
if err != nil {
return ierrors.Wrapf(err, "failed to rollback pool rewards epochs to target epoch %d", targetEpoch)
var lastPrunedPoolRewardsEpoch iotago.EpochIndex
// Do not rollback the epoch if the targetSlot is the end of the epoch, because that is when we calculated the rewards.
if targetSlot := startPruneRange - 1; p.apiProvider.APIForSlot(targetSlot).TimeProvider().EpochEnd(targetEpoch) != targetSlot {
lastPrunedPoolRewardsEpoch, err = p.poolRewards.RollbackEpochs(targetEpoch)
if err != nil {
return ierrors.Wrapf(err, "failed to rollback pool rewards epochs to target epoch %d", targetEpoch)
}
}

for epochToPrune := targetEpoch + 1; epochToPrune <= max(
Expand Down

0 comments on commit 7b3b4fe

Please sign in to comment.