-
Notifications
You must be signed in to change notification settings - Fork 87
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
Use custom derive ser/de instead of std::io #533
Conversation
70a60a4
to
ed47458
Compare
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.
Can we now remove the mem_layout
macro and related code in this PR?
I've reviewed 66 files at this point - I will continue with the last stretch tomorrow. |
What happens when an enum uses edit: disregard - after looking at the serialization helpers for inputs, it seems like there's not an easy way to verify this at compile time atm since the prefix may be set by custom logic. |
…bs/fuel-vm into dento/nostd-serialization
Good call on removing discriminant, it was a little confusing how it was suppose to be used compared to inner_descriminant. |
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.
Wrote some local fuzz tests to check the ability of roundtrip serialization between this and the original encoding, and didn't find any issues. I think we're probably good to ship this.
Closes #443. Initial work migrated from FuelLabs/fuel-tx#190, and the improved and adapted to the current system.
This PR replaces hand-written type serialization code with a macro-derived ones. It removes a lot of error-prone boilerplate code and makes it easier to add new types. The old implementation using
io::{Read, Write}
was notno_std
compatible, but the new generated code is. The new implmentation also allows computing many sizes at compile time.The new serialization framework is called
canonical
. It's used similarly toserde
:Several datatype-level attributes are also accepted:, expecially for enums.
structs
fuel-vm/fuel-derive/src/attribute.rs
Lines 59 to 61 in 4af7c63
enums
fuel-vm/fuel-derive/src/attribute.rs
Lines 81 to 95 in 4af7c63