Skip to content
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

Track resources with atree.ID instead of StorageID #2627

Conversation

fxamacker
Copy link
Member

@fxamacker fxamacker commented Jul 3, 2023

Updates onflow/atree#292

More details at onflow/atree#321

Description

Currently, Array.StorageID() and OrderedMap.StorageID() are used as identifier to track resources, etc because storage IDs are guaranteed to unique. However, atree storage ID should be only used to retrieve slabs (registers) from storage.

Also, when Atree register inlining is implemented in the future, some resources may not be stored in separate slabs, so they will not have storage IDs anymore.

This commit uses Array.ID() and OrderedMap.ID() to uniquely identify resources.


  • Targeted PR against master branch
  • Linked to Github issue with discussion and accepted design OR link to spec that describes this work
  • Code follows the standards mentioned here
  • Updated relevant documentation
  • Re-reviewed Files changed in the Github PR explorer
  • Added appropriate labels

fxamacker and others added 5 commits June 30, 2023 10:54
Currently, Cadence ArrayValue, CompositeValue, and DictionaryValue
creates atree.Storable directly from StorageID of its Atree values.

In the future, some Atree values can be inlined so they don't have
StorageID, and Atree values need to handle Storable depending
on maxInlineSize and other factors.

This commit delegates Cadence composite values' Storable() to its
internal Atree values.  So future changes to Atree values and their
storables don't break Cadence.
Currently, storage address is derived from StorageID().

In the future, some Atree values can be inlined so they don't have
StorageID and address needs be derived differently.

This commit delegates storage address to its internal Atree values,
by calling Address().
Currently, Array.StorageID() and OrderedMap.StorageID() are used as
identifier to track resources, etc because storage IDs are guaranteed
to unique. However, atree storage ID should be only used to retrieve
slabs (registers) from storage.

Also, when Atree register inlining is implemented in the future, some
resources may not be stored in separate slabs, so they will not have
storage IDs anymore.

This commit uses Array.ID() and OrderedMap.ID() to uniquely identify
resources.
@fxamacker fxamacker mentioned this pull request Jul 5, 2023
6 tasks
@fxamacker
Copy link
Member Author

Closing this PR without merging because atree was updated to newer API and this PR is outdated.

I will open a new PR to replace this.

@fxamacker fxamacker closed this Jul 7, 2023
@fxamacker fxamacker deleted the fxamacker/use-atree-id-for-tracking branch July 7, 2023 19:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants