AztecProtocol / aztec-packages

Apache License 2.0
160 stars 163 forks source link

bug(AztecMacro): Oddly sized return values with packed structs #5821

Open LHerskind opened 3 months ago

LHerskind commented 3 months ago

Ran into an issue in #5819 when purging unconstrained function when dealing with returning a struct whose serialization and deserialization is packing to fewer fields.

The offender was the Asset struct

struct Asset {
    interest_accumulator: U128,
    last_updated_ts: u64,
    loan_to_value: U128,
    oracle: AztecAddress,
}

As it was serializing to 4 elements. But the return_types is expecting 6 elements since U128 is actually 2 fields, a lo and hi.

For my specific case, I simply remove the optimization from the amount of storage 😭, now using 6 Fields.

Thunkar commented 3 months ago

Unfortunately I don't think this is going to be possible to address. We have to respect the "canonical" ACVM (de)serialization so that it can be replicated in TS land, and we will probably move to automatically implementing it rather than letting users do it.

Optimizations, if any, will have to be done at that level or will be incompatible.