Repository navigation
feat(sdk)!: raise CPI limits to 64 metas and 4 signer groups - #21
Merged
Merged
Conversation
solana.Invoke, the SDK-2 C runtime and sdk/cpi allowed 16 account metas and 2 signer groups per CPI; Hyperlane's Sealevel programs need 22 (IGP PayForGas with quoted accounts) and 17 (fee QuoteFee). Seeds keep 16 per group, 32 bytes each and 1,024 encoded bytes. sol_Invoke gets 64-entry meta and 4x16 seed descriptor arrays and is noinline, so its 2,240-byte frame never lands in a caller's frame. cpi.Metas keeps 16 records inline and moves them to one 576-byte heap array at the 17th Add, so small CPIs keep their frame and zeroing cost. examples/cpi-limits and TestCPILimitsSBF run 3 to 64 metas with up to four PDA signers on fogo-v0 and solana-v3 against a C callee that checks its account count, signers and every repeated-account position, plus the 65-meta and 5-group errors through the builders and the raw boundary. The escrow, full-swap and tutorial SDK snapshots are refreshed; the check corpus records the 33 C hashes the runtime change moved.
results/compiler/2026-10-19-cpi-limits holds the before/after CU of the CPI-limits harness and the existing escrow, full-swap and tutorial suites, static frame sizes, and the fresh-rebuild metrics. The full swap's ELFs changed (fogo-v0 bcd9253e, solana-v3 86f0ed15), so verify_rebuild.py now defaults to this reference. HANDOFF records the SDK snapshot change.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
CPIs are capped at 16 metas and 2 signer groups, well under the runtime's limits. Hyperlane needs up to 22: a quoted IGP payment takes 22 and a fee quote 17. Both fail with 3002 or 2006.
Solution
Raise the limits to 64 metas and 4 signer groups; seeds are unchanged. Why 64: agave caps account infos at 64 (128 behind a feature gate), and 255 metas would need about 4 KiB of descriptors, the whole frame.
sol_Invokeis no longer inlined. Its frame grows from 960 to 2,240 bytes; callers' frames don't change.cpi.Metasstays inline up to 16 and moves to a 576-byte heap array on the 17thAdd.Benchmarks
fogo-v0; solana-v3 within a few CU:
solana.Invoke, 3 metasTests
19 CPI cases on both profiles, from 3 to 64 metas and 0 to 4 groups, through builders and raw
Invoke. A C callee asserts the account count, signers and positions. 65 metas and 5 groups are rejected.Breaking: the SDK snapshot changes, so existing SDK-2 projects must be recreated.
Linked work
Closes #4. Used by hyperlane-xyz/hyperlane-monorepo#9852.