-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
New JSON ABI format supporting generics #2524
Conversation
95af00a
to
5b2d4c5
Compare
This is nearly done but needs some tests. For now, the SDK team can experiment with the The old |
2d73872
to
0d8dc0c
Compare
Need to fix something related to the (in)stable ordering of the output. Turning into a draft temporarily. |
@mohammadfawaz On the examples, we created, What are the motivations for having the object instead? |
Good question! It turns out that this is not enough. A type argument can be complex such as |
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.
so beautiful... so flat! 🙌
In a future PR, let's make sure to write a blurb for the book documenting the new design of the ABI.
storage_slots, | ||
tree_type, | ||
}; | ||
Ok((compiled, source_map)) | ||
} | ||
|
||
/// Standardize the JSON ABI data structure by eliminating duplicate types. This is an iterative | ||
/// process because every time two types are merged, new opportunities for more merging arise. | ||
fn standardize_json_abi_types(json_abi_program: &mut JsonABIProgram) { |
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.
Good catch, I didn't think about this possibility... it makes me want to implement this in the TypeEngine
😄
100%. I will start by adding the new format to the spec (FuelLabs/fuel-specs#401) and then go from there. |
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.
Approving on behalf of the SDK team (and regarding SDK/ABI-related stuff only); All tests with the new experimental fuels-rs
using this new flat-abi.json
outputted from a local copy of this branch (including sway
's SDK harness tests) are passing!
Closes #2386
The main changes are as follows:
initial_type_id
orinitial_return_type
in various places in the type system. This is needed because the original type information (potentially generic) is often lost and cannot be inferred at the end of the type checking phase. Keeping that information around helps generate the JSON ABI information needed in a much cleaner way.sway-types
type_system
directory.forc-pkg
, I added code to standardize the output of the JSON byThe standardization of the output is not really required but helps make the JSON more compact and more robust for testing in case of future changes in the type system, given that the type IDs that the type engine hands out are arbitrary (deterministic but arbitrary)