Skip to content
This repository was archived by the owner on Jan 24, 2025. It is now read-only.

Commit e0a3fef

Browse files
authored
Merge pull request #952 from iotaledger/fix/rewards-rollback
Fixed prunable rollback deleting the rewards
2 parents 7f81e70 + 7b3b4fe commit e0a3fef

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

pkg/storage/prunable/prunable.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -194,9 +194,13 @@ func (p *Prunable) Rollback(targetEpoch iotago.EpochIndex, startPruneRange iotag
194194
return ierrors.Wrapf(err, "failed to rollback decided upgrade signals epochs to target epoch %d", targetEpoch)
195195
}
196196

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

202206
for epochToPrune := targetEpoch + 1; epochToPrune <= max(

0 commit comments

Comments
 (0)