Fix calculation of packed slots minimum when calculating accounts to combine #3251
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
In ancient pack, we can encounter storages which can't be safely moved to new slots. One example is when a storage contains an alive account whose refcount > 1. In that case, we can only move the alive account to a slot that is newer than the current slot. Otherwise, we risk moving the alive account to a slot older than the currently dead account. If we restarted from a snapshot, we would have the wrong alive version of an account.
When determining whether individual storages can be packed, when we encounter a storage with a multi ref account and we determine we can't pack it this time, we have now decreased the # of alive bytes we'll be writing. As a result, we now reduce the # required ideal packed storages. As a result, this makes it easier for multi ref storages we encounter later in this pack to succeed.
Summary of Changes
If we determine a storage cannot be packed, reduce the # alive bytes so we can reduce the # ideal storages we'll be creating. This allows the algorithm to make progress.