SIMD-0339
Increase CPI Account Infos Limit
TL;DR
Increase the maximum number of account info's for cross-program invoked (CPI) instructions from 64 to 255 and consume compute units for serialized account info's and instruction account meta's.
Summary
Increase the maximum number of account info's for cross-program invoked (CPI) instructions from 64 to 255 and consume compute units for serialized account info's and instruction account meta's.
Motivation
CPI's are restricted to a limit of 64 account info's passed to the syscall. This limit is burdensome for onchain programs which themselves were invoked with more than 64 accounts because it means they cannot simply pass through the same list of account info's that they were invoked with to another CPI syscall. They are faced with the burden of first deduplicating the account info's and constructing a new list before making the syscall. This problem arises when onchain programs wrap another program (such as Jupiter) that composes many other programs and are invoked with over 64 accounts (including duplicates). Along with the increasing the account info limit, start charging for both serialized account info's and instruction account meta's to avoid abuse of resources in CPI calls.
Key Changes
- Account Info: The serialized information for each account referenced in a
- 32 bytes for account address
- 32 bytes for owner address
- 8 bytes for lamport balance
- 8 bytes for data length
- 1 byte for signer flag
- 1 byte for writable flag
Impact
Since the list of account info's passed to a CPI can now be ~4 times longer, there will be more overhead in the SVM to map each instruction account address to one of the account info's. The number of allowed unique account info's remains unchanged so the maximum amount of accounts that need to be translated for a CPI syscall has not increased. CPI's will consume compute units proportional to the number of account info's and instruction accounts. This gives an extra incentive to onchain programs to decrease the number of accounts passed to CPI's.
Backwards Compatibility
*(Optional)* The max account info length increase for CPI's and new costs will be feature gated. Since the limit is being increased, existing behavior will not be restricted.
Security Considerations
NA