Skip to content

SIMD-0449: Direct Account Pointers in Program Input#449

Open
febo wants to merge 4 commits intosolana-foundation:mainfrom
febo:ix-account-pointers
Open

SIMD-0449: Direct Account Pointers in Program Input#449
febo wants to merge 4 commits intosolana-foundation:mainfrom
febo:ix-account-pointers

Conversation

@febo
Copy link
Contributor

@febo febo commented Jan 24, 2026

Serialize pointers for instruction accounts to allow direct account access
without requiring parsing of the account section.

@simd-bot
Copy link

simd-bot bot commented Jan 24, 2026

Hello febo! Welcome to the SIMD process. By opening this PR you are affirming that your SIMD has been thoroughly discussed and vetted in the SIMD discussion section. The SIMD PR section should only be used to submit a final technical specification for review. If your design / idea still needs discussion, please close this PR and create a new discussion here.

This PR requires the following approvals before it can be merged:

Once all requirements are met, you can merge this PR by commenting /merge.

@febo febo force-pushed the ix-account-pointers branch from 096c582 to 360779c Compare January 24, 2026 19:20
@febo febo changed the title SIMD-0448: Direct Account Pointers in Program Input SIMD-0449: Direct Account Pointers in Program Input Jan 24, 2026
@febo febo force-pushed the ix-account-pointers branch from aca98ab to a97c9a4 Compare January 24, 2026 19:25
@febo febo marked this pull request as ready for review January 24, 2026 23:25
Copy link
Contributor

@buffalojoec buffalojoec left a comment

Choose a reason for hiding this comment

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

Nice work @febo! This looks like a slick way to improve ABI v1 entrypoint efficiency without breaking the ABI's backwards compatibility.

I left a few comments about beefing up the spec, but this seems reasonable to me.

@alnoki

This comment was marked as resolved.

@bidhan-a
Copy link

@febo thanks for putting this together, direct pointers will be super helpful for ASM account parsing implementations as well

Since the serializer also has access to instruction data and program ID boundaries can we get pointers to those as well? Otherwise runtime logic still has to parse final account data length and instruction data length to get program ID when doing operations like PDA account creation, for example

Ideal would be the following configuration at runtime start:

Register Pointer to
r1, r9 Virtual memory map input buffer
r8 Array of direct account pointers
r7 Instruction data
r6 Program ID
r9-r6 would be preferable for the pointers since r1-r5 are for syscalls and often you need to do something like this to keep input buffer on hand after a syscall: you could retain in r1 for legacy reasons but just also duplicate it in r9 to avoid the following:

    # Compute PDA.
    # ------------
    mov64 r9, r1 # Store input buffer pointer for later. <--------- This is annoying
    mov64 r1, r10 # Get stack frame pointer.
    # Update to point at user pubkey signer seed.
    sub64 r1, STK_INIT_SEED_0_ADDR_OFF 
    mov64 r2, 1 # Indicate single signer seed (user pubkey).
    mov64 r3, r9 # Get input buffer pointer.
    add64 r3, PROGRAM_ID_INIT_OFF # Update to point at program ID.
    mov64 r4, r10 # Get stack frame pointer.
    sub64 r4, STK_INIT_PDA_OFF # Update to point to PDA region on stack.
    mov64 r5, r10 # Get stack frame pointer.
    sub64 r5, STK_INIT_BUMP_SEED_OFF # Update to point to bump seed region.
    call sol_try_find_program_address # Find PDA. <------------ This forced me to mutate r1
    # Skip check to error out if unable to derive a PDA (failure to derive
    # is practically impossible to test since odds of not finding bump seed
    # are astronomically low):
    # ```
    # jne r0, SUCCESS, e_unable_to_derive_pda
    # ```
    mov64 r1, r9 # Restore input buffer pointer. <--------- This is annoying

cc @xbtmatt @bidhan-a @clairechingching @deanmlittle

As per SIMD-0321, a pointer to instruction data will be available in r2.

@alnoki

This comment was marked as resolved.

@febo
Copy link
Contributor Author

febo commented Jan 29, 2026

As per SIMD-0321, a pointer to instruction data will be available in r2.

@bidhan-a thanks for flagging, hadn't seen that one yet

@febo any hope for a program ID pointer? Glad to submit a new SIMD if possible if should go there instead

This SIMD is intentionally simple, so it is easier to test/audit. ABIv2 (SIMD-0177) is a more extensive rework of the program input and it will include individual pointers to all parts of the input.

Agree that would be nice to have a direct pointer to the program ID, but the gains in CU will be very small (~2 CUs) since the majority of programs will be reading the instruction data length first. So perhaps it is a good compromise until we get ABIv2.

@febo febo requested a review from buffalojoec January 29, 2026 18:53
Copy link
Contributor

@buffalojoec buffalojoec left a comment

Choose a reason for hiding this comment

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

Lgtm. As a next step we should make sure this change won't push Direct Mapping efforts further down the road. We should do this before merging & fully implementing, but we can test/fuzz with a draft implementation.

@simd-bot
Copy link

simd-bot bot commented Jan 31, 2026

Thanks, topointon-jump!

⚠️ Status: Cannot merge yet

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.

5 participants