Skip to content

tlv-account-resolution: resolve extra metas without per-meta allocation - #199

Open
stranzhay wants to merge 2 commits into
solana-program:mainfrom
stranzhay:fix/tlv-cpi-resolution-allocations
Open

tlv-account-resolution: resolve extra metas without per-meta allocation#199
stranzhay wants to merge 2 commits into
solana-program:mainfrom
stranzhay:fix/tlv-cpi-resolution-allocations

Conversation

@stranzhay

Copy link
Copy Markdown

Solana's shared account-resolution library (spl-tlv-account-resolution) rebuilt a temporary list of every account for each extra account meta it resolved. Under Solana's default SBF bump allocator, which does not reclaim deallocated memory, those cumulative allocations can exceed the default 32 KB heap and abort with "out of memory." This matches the transfer-hook failures reported in solana-program-library#7004 and token-2022#66.

The fix builds that list once and appends each newly resolved account as the loop advances, reducing allocation growth from quadratic to linear. A host-side counting allocator measured 75,864 bytes on the base implementation and 13,368 bytes on this branch when resolving 32 extra accounts. Resolution behavior is unchanged, and the existing suite covers chained resolution where one meta derives from a previously resolved account.

The dedicated allocation regression test samples 8, 16, and 32 extra metas and bounds marginal growth, so reintroducing the per-meta rebuild fails the test.

@danenbm danenbm left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. The once-built refs list preserves the existing resolution semantics (later metas can still reference previously resolved accounts in add_to_cpi_instruction via the appended borrows), and the allocation tests are a nice guard. Would be great to land as it directly unblocks transfer-hook usage with larger extra-account-meta lists.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants