diff --git a/pkg/storage/prunable/prunable.go b/pkg/storage/prunable/prunable.go index e90f2b0b8..c7590a651 100644 --- a/pkg/storage/prunable/prunable.go +++ b/pkg/storage/prunable/prunable.go @@ -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(