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

Value and object representation overhaul #682

Merged
merged 23 commits into from
Mar 8, 2023
Merged

Conversation

graydon
Copy link
Contributor

@graydon graydon commented Feb 11, 2023

This is a bit more than a sketch of a subset of things we've discussed doing in #679:

  • Adapts to XDR changes in Value representation overhaul rs-stellar-xdr#234 (which are in turn reflections of Value representation overhaul stellar-xdr#70).
  • In particular: changes the RawVal tagging scheme:
    • Removes two-level tagging in favour of single-level.
    • Expands the tag to a full byte (well, really 7 bits / 128 values, but we round up to 8 for taste / future-proofing).
    • Therefore sadly reduces SmallSymbol to 9 chars; but we have tag-room for a big symbol type that's an object!
    • Adds a full-sized big symbol object type (SymbolObject) and a union between the two (Symbol). Unfortuantely now all the code that used to think Symbol didn't need an Env to work with .. needs an Env.
  • Adds a dependency on ethnum, a crate supporting {i,u}256 numbers.
  • Adds small-value cases for all number types not just u64.
  • Recreates something like ScObject but make it a marker type ScValObject that marks the subset of ScVals that need to be objects (this is a dynamic judgment based on the size of the values in some cases).
  • Switches the UDT code to bulk-initialization and bulk-matching (adding host functions to support)
  • Adds tag-specific wrappers for every tag case, and tightens all host function signatures to use them (eg. map methods take and return MapObject now, not just Object)

At this point env-common, guest and host are compiling. Tests are about passing and the corresponding SDK change is done too: stellar/rs-soroban-sdk#879

Copy link
Member

@leighmcculloch leighmcculloch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👏🏻 I really like the design with the small types in the RawVal and how that doesn’t leak into the ScVal anymore.

soroban-env-common/src/object.rs Outdated Show resolved Hide resolved
soroban-env-common/src/raw_val.rs Show resolved Hide resolved
@graydon graydon force-pushed the midwinter-val-reform branch 2 times, most recently from 49dcea6 to f76154f Compare February 14, 2023 07:28
soroban-env-common/src/raw_val.rs Show resolved Hide resolved
soroban-env-common/src/raw_val.rs Show resolved Hide resolved
soroban-env-common/src/raw_val.rs Outdated Show resolved Hide resolved
soroban-env-common/src/env_val.rs Show resolved Hide resolved
@graydon graydon force-pushed the midwinter-val-reform branch 8 times, most recently from 6d356e4 to 9bf43ef Compare February 23, 2023 04:43
@graydon graydon force-pushed the midwinter-val-reform branch 11 times, most recently from d532d6b to 3ce1549 Compare March 1, 2023 06:45
@graydon graydon marked this pull request as ready for review March 2, 2023 18:18
@graydon graydon requested review from sisuresh and a team as code owners March 2, 2023 18:18
@graydon graydon changed the title Preliminary pass of value-and-object reform. Value and object representation overhaul Mar 2, 2023
graydon and others added 2 commits March 8, 2023 15:33
* Small changes and fixes

* Small restructure on macro

* Rename some conversion funcs for better clarity

* Minor

* Fix bug in small signed number conversion

* Add `repr(transparent)` to RawVal wrapping types

* Add U/I256 conversion
@graydon graydon enabled auto-merge (squash) March 8, 2023 23:44
@graydon graydon merged commit a66f081 into main Mar 8, 2023
@graydon graydon deleted the midwinter-val-reform branch March 8, 2023 23:59
graydon added a commit to stellar/rs-soroban-sdk that referenced this pull request Mar 9, 2023
This is the SDK adaptation of
stellar/rs-soroban-env#682, which we're going to
try writing collaboratively

---------

Co-authored-by: Dmytro Kozhevin <[email protected]>
Co-authored-by: Jay Geng <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants