-
Notifications
You must be signed in to change notification settings - Fork 138
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
Prevent leaving unreferenced slabs in storage while updating dictionary with enum key #3602
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
This commit removes unreferenced slabs when updating dictionary with enum keys to prevent them from remaining in storage. Background Currently, unreferenced slabs can be created by updating dictionary if the key is enum type and key already exists. More specifically, - Cadence creates and stores enum key (in its own slab) in storage during Transfer() to update underlying atree map element. - If same key already exists, atree map only updates map value without referencing the newly created enum key. - Newly created enum key is not referenced (aka dangling, unreachable) in the underlying atree map. This issue only affects enum key type because enum type is the only type that: - can be used as dictionary key (hashable) and - is transferred to its own slab. Large string key isn't affected by this issue because large string isn't stored in its own slab during Transfer().
Currently enum type is the only composite type that needs to be removed explicitly when used as key to update existing dictionary element. However, (as noted by Supun) Cadence might in the future add support for other composite types as key. This commit removes enum type checking to support new composite key types to be added to Cadence language in the future.
Cadence Benchstat comparisonThis branch with compared with the base branch onflow:v1.0 commit b55d056 Collapsed results for better readability
|
turbolent
approved these changes
Oct 8, 2024
@SupunS Can you please update |
2 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Closes #3508
Port https://github.com/dapperlabs/cadence-internal/pull/242
master
branchFiles changed
in the Github PR explorer