feat!: new encoding scheme for logs and encode `RawSlice` as `u8`
Closes #1671
This PR adds support for sway's experimental encoding in logs. This is demonstrated via a new test suite, which is a subset of fuel-gauge, which builds another forc workspace using the experimental flag (--experimental-new-encoding).
Breaking Change
RawSlice data encoded as unpadded u8, also implemented by the RS SDK. Currently we are encoding it as u64 and doing additional arithmetic on encode and decode to compute the byte length. A RawSlice indicates a slice of bytes so we should treat it as so.
This poses a problem either on v0 or v1, one will have to compromise to the other as v1 assumes the data as u8 so we'd have to do additional arithmetic to get the correct len, rather than decoding it from the byte data. I have opted to introduce the breaking change in v0 as it brings us closer to v1.
Type Support
- [x]
u8 - [x]
u16 - [x]
u32 - [x]
u64 - [x]
b256 - [x]
b512 - [x] Array
- [x] String Array (
str[n]) - [x] Option
- [x] Raw Slice
- [x] Tuple
- [x] Struct
- [x] Enum
- [x] String Dynamic (
struct String) - [x] Vec
- [x] Bytes
:warning: String Slices are currently not supported in the TS SDK by encoding
v0. This is possible inv1, however requires contract calls to be encoded as well, so thevaluecan be encoded/decoded, and thus thelogs. I have added aStrSlicecoder using the specs and partially tested, but I have left it unimplemented withinAbiCoder. Therefore it is currently blocked by this Sway issue.
Further changes
- [x] Experimental integration test suite in parallel
- [x] Use
ABIEncodeimplementations fromsway-std-lib - [ ] Unit tests for
v1coders - [ ] Refactor to
ABICoderfor versioning and obtaining coders - [ ] Needs TOB validation changes - #1426
Blockers
- [ ] Forc
0.49.1upgrade - [ ] Get encoding version from ABI - https://github.com/FuelLabs/sway/pull/5481