1

How is the size of a program calculated?

If all accounts have a limit of 10 kibibytes, I assume that also applies to programs as well? How will the extend program size affect this? does it allow me to bypass this limit?

1 Answer 1

1

The size of a program is based on the same parameters as any computer program: amount of compiled bytecode, constants, strings, etc. So you can just count the number of bytes in the output file.

Accounts have a limit of 10MB: https://docs.solana.com/getstarted/overview#accounts, so you can extend a program to be up to 10MB. Accounts can be allocated up to that size if done at the top-level of the transaction, by adding a system_instruction::allocate and signing for the account in question.

The 10KiB limit is how much can be allocated in one instruction within the BPF VM, which is how PDAs must be allocated since they don't have a private key for signing. The VM automatically adds 10KiB of padding after every single account that's provided to a program, in case the program reallocates the account. See the "padding" part at https://docs.solana.com/developing/on-chain-programs/faq#input-parameter-serialization

So technically, it's possible for a PDA to get to 10MB if you continuously reallocate to an additional 10KiB for ~1,0000 transactions!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.