When using the @codama/renderers-vixen-parser package to generate account parsers, it generates a match with arms reliant on LEN of an account, where LEN is also generated by codama. In anchor account cases where data structures are not explicitly written proper 8-byte aligned values, the generated LEN is under that actual account length. This causes the try_unpack method to fail.
The std::mem::size_of::<MyAccount>() calculation on an account is correct. A potential solution could be to build those match arms with the std::mem::size_of::<MyAccount>(), but I have not thought through or tested implications of that change. I would like to see the use of discriminators in a flexible pattern, but I'll leave that for a separate issue.
When using the
@codama/renderers-vixen-parserpackage to generate account parsers, it generates a match with arms reliant on LEN of an account, where LEN is also generated by codama. In anchor account cases where data structures are not explicitly written proper 8-byte aligned values, the generated LEN is under that actual account length. This causes thetry_unpackmethod to fail.The
std::mem::size_of::<MyAccount>()calculation on an account is correct. A potential solution could be to build those match arms with thestd::mem::size_of::<MyAccount>(), but I have not thought through or tested implications of that change. I would like to see the use of discriminators in a flexible pattern, but I'll leave that for a separate issue.