FREE INTERMEDIATE CASEBOOK · WORKS OFFLINE

Account Resize Safety Lab

Five fictional cases. Follow the data length, rent-exempt minimum, resize payer, and every lamport held by the account. No RPC, wallet, network request, or stored answer is used.

Keep four records separate

Data size

Serialized bytes the program account can hold.

Storage minimum

Cluster-specific lamports needed for the selected data size.

Realloc payer

Growth funder and, in current Anchor v1 shrink behavior, refund recipient.

The transaction fee payer may be a different signer. An account may also hold user deposits, escrow principal, or protocol value above its storage minimum.

Choose the safest design for each case

These checks are formative. Read the explanation after answering, then compare your reasoning with the Anchor realloc constraint and Solana account modification rules.

CASE 01 · ADD A FIXED FIELD

A 94-byte learner record grows to 110 bytes.

A fictional cluster quote says the minimum rises from 1,545,120 to 1,656,480 lamports. The learner signs as the explicitly chosen realloc payer; a separate sponsor pays the network transaction fee. What should the test assert?

Choose the strongest assertion.

CASE 02 · SHRINK A RECORD

Only storage funds are held in this 1,800,000-lamport account.

The new 80-byte layout has a fictional 1,447,680-lamport minimum. The instruction names an authorized maintainer as realloc::payer. Which refund amount should the current Anchor behavior produce?

Choose the amount basis.

CASE 03 · A VAULT ALSO HOLDS DEPOSITS

The account balance includes 5 SOL of user deposits.

A schema update would shrink the account, and an operator is named as realloc::payer. Which design is safest?

Choose the protection.

CASE 04 · CALLER-SELECTED CAPACITY

A vector length from the instruction controls the new account size.

The client can send any element count. Anchor applies its realloc constraint before the handler body. What should the design do?

Choose the boundary.

CASE 05 · SCHEMA MIGRATION

Version 2 adds an optional 32-byte field to existing records.

The program must continue to read version 1 records while learners migrate. What evidence should the migration include?

Choose the migration contract.

Read the current rules

Lamport amounts in these cases are fictional. Query the chosen cluster for the current minimum for the exact serialized size. This educational practice is not a production storage quote.