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

Port updates from atree-internal #491

Merged
merged 14 commits into from
Jan 27, 2025
Merged

Conversation

turbolent
Copy link
Member

@turbolent turbolent commented Jan 27, 2025

Description

Port internal updates https://github.com/onflow/atree-internal/compare/ea00755...acdb0e04ab01

Complete list of atree-internal PRs ported:

These ports add 2 new interfaces that client software can use (e.g. Cadence):

  • atree.WrapperValue
  • atree.WrapperStorable

Other changes from these ports are nits that don't affect mainnet (minor fixes to tests, update smoke tests, etc.)

NOTE: As mentioned by @SupunS on Jan 9, 2025, Create unique type ID with no fields fixes a scenario that cannot happen due to Cadence data types. So that PR is a "nice to have" that doesn't change behavior on mainnet.


  • Targeted PR against main 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

Currently, Cadence interpreter.SomeValue is opaque to packages
like Atree, so interpreter.SomeValue is treated as atomic value.
This causes a container wrapped by interpreter.SomeValue to
be treated as atomic value since it is opaque.

Given this, the integration between Cadence and Atree does not
establish parent-child relationship of a wrapped container
since the inner values of interpreter.SomeValue are
not visible to Atree.

Resolving this issue requires modifying onflow/cadence to
unwrap containers wrapped by interpreter.SomeValue.

This commit simplifies and reduces the amount of changes
needed by onflow/cadence by providing two new interfaces here:
- WrapperValue
- WrapperStorable

When Cadence passes objects that implement these interfaces,
Atree will call the interface functions (that implement
unwrapping) when setting child-parent callbacks.

This approach simplifies changes needed by integration in
Cadence to allow Atree to support containers wrapped
by interpreter.SomeValue.
This commit adds support for the new WrapperValue interface in
Array.Set() and Array.Remove().

Overwritten and removed inlined slabs need to be uninlined and
stored in storage before returning to the caller.

Because of new interfaces of WrapperValue and WrapperStorable,
this commit uninlines wrapped inlined slabs that are overwritten
or removed.
This commit adds support for the new WrapperValue interface in
Map.Set() and Map.Remove().

Overwritten and removed inlined slabs need to be uninlined and
stored in storage before returning to the caller.

Because of new interfaces of WrapperValue and WrapperStorable,
this commit uninlines wrapped inlined slabs that are overwritten
or removed.
This commit resolves an edge case detected by smoke testing,
which isn't very likely to be encountered in practice.

Currently composite type ID is the same ("composite_type,") for
the same composite type:
- with no fields or
- with only 1 field and it has empty field name

This commit changes composite type ID with no fields to
"composite_type" to be different from composite type with 1 field
of empty field name "composite_type,".

NOTE: Composite type ID is only used to deduplicate composite types
during encoding.  It isn't serialized to underlying storage.
This commit adds smoke tests for the new interfaces
being added in the upcoming v0.9.0 release:
- atree.WrapperValue
- atree.WrapperStorable

Smoke tests has been running for over 24 hours using
40 processes without any problems detected as of
Friday, January 10, 2025.
This commit fixes the SlabIterator() which is currently used only
by test code.

Changes in this commit do not affect mainnet, testnet, etc.
WrapperStorable is a new interface being added to the upcoming
Atree v0.9.0, which hasn't been released yet.

This commit updates LoadedValueIterator to check for
the new interface.
@turbolent turbolent requested a review from fxamacker as a code owner January 27, 2025 17:03
@turbolent turbolent self-assigned this Jan 27, 2025
@fxamacker fxamacker changed the title Port internal fixes Port updates from atree-internal Jan 27, 2025
@fxamacker fxamacker merged commit 7c1be9a into main Jan 27, 2025
8 checks passed
@fxamacker fxamacker added the enhancement New feature or request label Jan 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants