[spl-type-length-value]: u64
padding not properly supported
#5518
Labels
good first issue
Good for newcomers
u64
padding not properly supported
#5518
Problem
When working with
spl-type-length-value
, it's possible to use types that implement bytemuck'sPod
andZeroable
trait, as well asspl_discriminator::SplDiscriminate
to create TLV entries and utilize the library's tooling.However, it appears that
Pod
types usingu64
and higher are not supported by the library, since they require proepr alignment.Observe the following test:
Now, if we change the
PodLength
within the library to be aPodU64
, suddenly we can see that both theu64
andu128
types work! This is because the alignment is now 8.Solution
We need to figure out a way to make this relationship amongst
Pod
types work with various integer sizes.There are a few solutions:
length
value within the library.length
value use the same integer size required by a type's padding.length
.Regardless, it's also worth mentioning that the error coming back from
pod_from_bytes(..)
is not very helpful (ProgramError::InvalidArgument
). We should also introduce a pass-through error for bytemuck errors.The text was updated successfully, but these errors were encountered: