Solana Memory Checks May Break Some Older App Transactions

Solana’s planned memory checks could make some older app transactions fail. A replay of mainnet traffic found Anchor code that writes to an account after transferring its ownership.

Solana’s planned memory checks could cause some older app transactions to fail after mainnet activation. A replay of mainnet traffic found an Anchor code path that writes to an account after transferring ownership of it to another program.

Anza, which develops Solana’s Agave validator software, listed the memory checks and account data direct mapping as pending on its Nov. 20 feature tracker. Neither change had a mainnet activation epoch or slot as of Nov. 23.

The memory checks can reject reads beyond an account’s size and writes to accounts a program no longer owns. They also change the stack layout that older Solana programs use for temporary data, which may cause existing code to behave differently.

The documented Anchor failure occurs when one program calls another and transfers ownership of an account during the call. After the call ends, older Anchor code tries to write the account data back, even when the data has not changed. The previous runtime allowed the write. The new rules reject it because the first program no longer has permission to modify the account.

A transaction using the affected path can fail while other transactions from the same application continue to process. The fix appears in the Anchor 1.2.2 changelog. It compares the account data after the ownership change and skips the write when the bytes are unchanged.

Teams with affected programs must rebuild and test them with the updated framework. For programs deployed through Solana’s upgradeable Loader V3, the authorized party must deploy the new build on-chain. Applications that rely on another team’s program need that program’s operator to make the update.

Anza engineer Alexander Meißner described the mainnet replay in the original runtime proposal. The replay identified several programs that could have failed, and most developers contacted by the team had fixed their code. Replay can miss rarely used paths that did not appear in the transactions tested.

Anza resumed general mainnet feature activations on Nov. 19. The memory checks and direct mapping were activated separately on testnet and devnet, with the changes scheduled one epoch apart. Keeping them separate helped developers distinguish execution changes from implementation errors.

Direct mapping is designed to reduce the amount of account data validators copy during program execution. In the older process, validators copy account data into the program’s virtual machine and copy it back when execution ends. A cross-program call can add another round of copying; Meißner’s proposal described up to four copies for an instruction with one such call.

With direct mapping, the virtual machine can access account data in its existing location. The change is expected to reduce validator work, but its effect on transaction processing times for users has not been established.

Articles by this author