snapshot dir to and from archive #30590
Closed
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
The current path of bank in memory <-> archive is complicated. To build an archive, some info is from file system (snapshot file, account files in operation path), some is from memory (status cache). For fast boot, we now have the complete snapshot info in the snapshot directory (PR #28745 split PRs). In the -> bank direction, we can construct a bank from only the files. In the -> archive direction, we can now build the archive with only the files, without the need of any data structures in memory.
So it is now possible to break the bank in memory <-> archive path into two independent paths as
memory <-> snapshot dir <-> archive with clean logic separation.
In memory <-> snapshot dir, the information goes between memory data structures and files, and there is no archiving logic involved;
In snapshot dir <-> archive, the information goes between archive and files, there is no data structure in memory involved.
With this, the code can be much simpler. No more need for those intermediate data structures such SnapshotPackage, AccountsPackage.
Summary of Changes
Added the following functions and test.
fn bank_snapshot_dir_to_archive
This creates an archive with full info from the snapshot directory, so it has a different content format. A new snapshot archive version should be defined.
fn unarchive_to_snapshot_dir
test test_roundtrip_snapshot_dir_to_and_from_archive
Open issues:
This new archive has a different content structure, with meta files included. Should we define a new snapshot version? It is actually more about the archive version, not the snapshot itself.
Fixes #