-
Notifications
You must be signed in to change notification settings - Fork 487
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[config change] DAS filestore trie layout migrator and expiry, fixes: NIT-2538, NIT-2537 #2385
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Make it so that the l1SyncService can sync expired data and set also set sensible retention.
Also fix unsetting the migrating flag after migration is done.
We can have batches with identical data, so the trieLayout needs to be able to handle being requested to store the same batch multiple times with different expiry times. The way it works now is that the leaf files in by-expiry-timestamp are hard links to the batch files in by-data-hash. The link count is used to know when there are no more links in by-expiry-timestamp pointing to the batch file and that it can be deleted.
cla-bot
bot
added
the
s
Automatically added by the CLA bot if the creator of a PR is registered as having signed the CLA.
label
Jun 12, 2024
amsanghi
approved these changes
Jun 26, 2024
Tristan-Wilson
changed the title
DAS filestore trie layout migrator and expiry
[config change] DAS filestore trie layout migrator and expiry
Jun 26, 2024
ganeshvanahalli
approved these changes
Jun 26, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM (Nice work!)
Tristan-Wilson
changed the title
[config change] DAS filestore trie layout migrator and expiry
[config change] DAS filestore trie layout migrator and expiry, fixes: NIT-2538
Jun 26, 2024
Tristan-Wilson
changed the title
[config change] DAS filestore trie layout migrator and expiry, fixes: NIT-2538
[config change] DAS filestore trie layout migrator and expiry, fixes: NIT-2538, NIT-2537
Jun 26, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
design-approved
s
Automatically added by the CLA bot if the creator of a PR is registered as having signed the CLA.
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.
This PR is to make the daserver LocalFileStorageService backend support expiry and future-proof the layout by avoiding having too many files directly under any one directory. It changes the layout from a flat layout to a trie based layout and it now has two top-level directories,
by-data-hash
andby-expiry-timestamp
.The previous filesystem layout for the data stored by the das LocalFileStorageService was simply:
<datadir>/1b7a84fcdb5f467ec4889e99dba58b2e6d56e0154538ee2a3083aa1582ab833e
where the data hash is the dastree.Hash of the data. This has already grown to contain 70K+ files.
In the future for AnyTrust chains we will be configuring a default of a batch every 15 seconds for fast withdrawals support, with some chains going down to once a second. This gives us a worst case of:
(3600*24*365) seconds in a year * 1 batch per second = 31536000 batches per year
From experience we should try to avoid having directories with more than 65k (uint16 max) files, so 2 levels of nesting based on the first two bytes will suffice to have an average of 481 files per directory.
31536000 batches per year / 256 directories at first level / 256 directories at second level = 481.20 batches per year per directory at second level
In the new filesystem layout, each data item is stored as follows:
<datadir>/by-data-hash/1b/7a/1b7a84fcdb5f467ec4889e99dba58b2e6d56e0154538ee2a3083aa1582ab833e
They are now stored in the directory by-data-hash, with a trie-based directory structure based on the first two leading octets of the data hash.
If expiry is enabled for the LocalFileStorageService, hard links to the by-data-hash files are stored with the following layout:
<datadir>/by-expiry-timestamp/171702/5712/1b7a84fcdb5f467ec4889e99dba58b2e6d56e0154538ee2a3083aa1582ab833e -hard-link-to-> <datadir>/by-data-hash/1b/7a/1b7a84fcdb5f467ec4889e99dba58b2e6d56e0154538ee2a3083aa1582ab833e
They are stored in a directory hierarchy starting with by-expiry-timestamp, expiry unix timestamp / 10000, expiry unix timestamp % 10000, then a symlink to the original by-data-hash file. 10000 seconds is ~2.7 hours. If a batch is posted every 1 second then each directory should have at most 10k files. This also handles multiple batches with the same timestamp. Since the by-expiry-timestamp directory will only be used when expiry is enabled, there is no concern of the first level (higher order) of directories growing too much.
Using named by-expiry-timestamp and by-data-hash directories allows us to version the data layout and add different indices in future if needed.
The daserver migrates from the legacy layout on startup. The by-expiry-timestamp index will only be created if expiry is enabled on the LocalFileStorageService. Migrated batch files will be assigned an expiry time by adding the
--data-availability.local-file-storage.max-retention
to the min of creation time of the file. Migration will be indicated by initially calling the directories by-data-hash-migrating and by-expiry-timestamp-migrating, and using a rename operation when complete.Batch files synced with the
--data-availability.rest-aggregator.sync-to-storage.eager
are assigned an expiry time based on the block their batch was posted to L1 in, plus--data-availability.rest-aggregator.sync-to-storage.retention-period
.Added options:
Testing done
Added new unit tests for migration and expiry with the new layout.
Tested migration by starting daserver for Arb Nova with the data directory of an Arb Nova daserver mirror, using the following configuration: