Skip to main content
Technical proposal SIMD-0321 Activated

VM Register 2 Instruction Data Pointer

  1. Idea
  2. Draft
  3. Review
  4. Accept
  5. Implement
  6. Active

Decision brief

Why this proposal matters

Provide a pointer to instruction data in VM register 2 (r2) at program entrypoint, enabling direct access to instruction data without having to parse the accounts section of the serialized input region.

Source-backed reading aid · source language: EN

Proposal at a glance

What changes

  • Instruction data pointer: A 64-bit pointer (8 bytes) stored in VM register 2 that points directly to the start of the instruction data section in the input region.
  • r1: Input region pointer (existing behavior)
  • r2: Pointer to instruction data section (new)

Stakeholder map

Who is affected

Builders & client teams Medium impact

On-chain programs are positively impacted by this change. The new r2 pointer gives programs the ability to efficiently read instruction data, further customize their program's control flow and maximize compute unit effiency.…

Action requirement unknown
Validators & operators Medium impact

Despite technically being a breaking change, mainnet-beta testing with a modified Agave validator confirms no divergence in execution or consensus. This is because r2 can typically only be accessed uninitialized through contrived examples such as assembly manipulation or compiler bugs. The performance benefits are considered a reasonable tradeoff.…

Action requirement unknown
Users & stakers Impact unknown

No proposal-specific evidence was found for this group.

Action requirement unknown
Governance & ecosystem Impact unknown

No proposal-specific evidence was found for this group.

Action requirement unknown

Exact source revision

Full proposal document

Source-language document. Technical identifiers and evidence remain unchanged. 6cc17538e266

Summary

Provide a pointer to instruction data in VM register 2 (r2) at program entrypoint, enabling direct access to instruction data without having to parse the accounts section of the serialized input region.

Motivation

Currently, sBPF programs must parse the accounts section of the serialized input region to locate instruction data. The serialization layout places accounts before instruction data, requiring programs to iterate through all accounts before reaching the instruction data section. This is inefficient for programs that primarily or exclusively need to access instruction data.

By providing a direct pointer to instruction data in r2, programs can immediately access this data without any parsing overhead, resulting in improved performance and reduced compute unit consumption.

New Terminology

  • Instruction data pointer: A 64-bit pointer (8 bytes) stored in VM register 2 that points directly to the start of the instruction data section in the input region.

Detailed Design

When the feature is activated, the VM shall set register 2 (r2) to contain a pointer to the beginning of the instruction data section within the input region. The instruction data format remains unchanged:

[8 bytes: data length (little-endian)][N bytes: instruction data]

This pointer in r2 is made available to all programs, under all loaders, regardless of whether or not the value is read. Prior to this feature, r2 contains uninitialized data at program entrypoint.

Despite technically being a breaking change, mainnet-beta testing with a modified Agave validator confirms no divergence in execution or consensus. This is because r2 can typically only be accessed uninitialized through contrived examples such as assembly manipulation or compiler bugs. The performance benefits are considered a reasonable tradeoff. See security section for more details.

Register Assignment:

  • r1: Input region pointer (existing behavior)
  • r2: Pointer to instruction data section (new)

Pointer Details:

  • The pointer in r2 points to the first byte of the actual instruction data, NOT the length field.
  • The pointer value in r2 is stored as a native 64-bit pointer (8 bytes) in little-endian format.
  • When there is no instruction data (length = 0), r2 still points to the offset immediately proceeding the instruction length counter; in this case, the first byte of the program ID, ensuring it will always point to valid, readable memory within the bounds of the input region.
  • The pointer must always point to valid memory within the input region bounds.

Alternatives Considered

  1. Provide a pointer to instruction data length: Store a pointer to the instruction data length field in r2. However, providing a direct pointer to the start of instruction data is more ergonomic.

  2. Provide optional entrypoint parameter: Allow programs to opt-in via a different entrypoint signature. The current approach is simpler as it avoids supporting multiple entrypoint signatures and makes the pointer universally available. This relies on the assumption that no programs depend on the garbage value previously in r2.

  3. Modify serialization layout: The serialization layout will eventually be overhauled with ABI v2, a comprehensive upgrade that could resolve this issue among many others. Given the significant scope of ABI v2 and potential for delays, this targeted optimization provides immediate value and remains compatible with ABI v2.

Impact

On-chain programs are positively impacted by this change. The new r2 pointer gives programs the ability to efficiently read instruction data, further customize their program's control flow and maximize compute unit effiency. However, any programs that currently depend on the uninitialized/garbage value in r2 at entrypoint will break when this feature is activated.

Core contributors must implement this feature, which should be extremely minimally invasive, depending on the VM implementation.

Security Considerations

Programs should read and validate the instruction data length (stored at r2 - 8) before accessing data via the r2 pointer. Failing to check the length could result in reading unintended memory contents or out-of-bounds access attempts.

Additionally, programs that currently rely on r2 containing uninitialized or garbage data at entrypoint will experience breaking changes when this feature is activated. While it is technically possible with assembly manipulations, no compiled code uses r2 with an uninitialized value except in the case of sol_log_64_ which is not a direct security concern as logs are not enshrined by consensus.

Backwards Compatibility

This feature is only backwards compatible for programs that currently do not read from r2 at program entrypoint.

This feature is NOT backwards compatible for any programs that depend on the uninitialized/garbage data previously in r2.

Evidence graph

Related proposals and rollout

One or more sources are unavailable.

Upstream review record

Upstream discussion & review

One or more sources are unavailable.

simd.watch community discussion · SIMD-0321

Powered by Giscus · Sign in with GitHub to comment

Community comments load when this section approaches the viewport.

Provenance

Evidence & technical details

Rollout or chain data, source revisions, freshness and integrity.
3

SIMD

Deployment Status

Document lifecycleActivated
CategoryCore protocol
Devnetactive Epoch 1034
Testnetactive Epoch 911
Mainnet-Betaactive Epoch 950
5xXZc66h4UdB6Yq7FzdBxBiRAFMMScMLwHxk2QZDaNZL

Exact source revision

Sources & integrity

  • Proposal document pinned_commit_blob
    6cc17538e26601e65beca89bbfa761e755720956
  • simd-document document · stale · Oct 29, 2026
    6cc17538e26601e65beca89bbfa761e755720956

One or more sources are unavailable.

One or more sources are unavailable.