The current create_program_address helper validates the seeds length before calling the syscall. While in many cases this is useful, since it avoids incurring the costs of the syscall when the seeds are invalid, it consumes additional CUs.
Solution
Add an checked_* variant for the helper, where seeds length are validated before the syscall.
The current create_program_address is modified to not include the validation and therefore has a smaller CU footprint. Seeds are always validated by the syscall, therefore the difference in this case is to avoid consuming CUs for the duplicated validation while incurring the cost of the syscall in case seeds length are invalid.
Problem
The current
create_program_address
helper validates the seeds length before calling the syscall. While in many cases this is useful, since it avoids incurring the costs of the syscall when the seeds are invalid, it consumes additional CUs.Solution
Add an
checked_*
variant for the helper, where seeds length are validated before the syscall.The current
create_program_address
is modified to not include the validation and therefore has a smaller CU footprint. Seeds are always validated by the syscall, therefore the difference in this case is to avoid consuming CUs for the duplicated validation while incurring the cost of the syscall in case seeds length are invalid.