Skip to content

Rearrange fields of InstructionFrame#9714

Merged
LucasSte merged 3 commits intoanza-xyz:masterfrom
LucasSte:match-fields
Jan 7, 2026
Merged

Rearrange fields of InstructionFrame#9714
LucasSte merged 3 commits intoanza-xyz:masterfrom
LucasSte:match-fields

Conversation

@LucasSte
Copy link
Copy Markdown

Problem

The layout of InstructionFrame still differs from what we propose in SIMD-0177. This PR changes field types and include new members to match with the proposal.

Summary of Changes

  1. Make program_account_index_in_tx a u64.
  2. Make nesting_level a u32.
  3. Include index_of_parent_instruction in the structure.
  4. Reorder fields to match the layout proposed in the SIMD.

@LucasSte LucasSte changed the title Fix fields of InstructionFrame Rearrange fields of InstructionFrame Dec 22, 2025
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Dec 23, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.7%. Comparing base (e059ea4) to head (4f830bd).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #9714   +/-   ##
=======================================
  Coverage    82.7%    82.7%           
=======================================
  Files         901      901           
  Lines      324841   324852   +11     
=======================================
+ Hits       268717   268762   +45     
+ Misses      56124    56090   -34     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@LucasSte LucasSte marked this pull request as ready for review December 23, 2025 16:12
@LucasSte LucasSte requested a review from a team as a code owner December 23, 2025 16:12
pub nesting_level: u32,
/// This is the index of the parent instruction if this is a CPI and u32::MAX if this is a
/// top-level instruction
pub index_of_parent_instruction: u32,
Copy link
Copy Markdown

@Lichtso Lichtso Jan 5, 2026

Choose a reason for hiding this comment

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

I think they are all double of what they need to be. If we go with u32, u16, u16 then we reach u64 alignment as well.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Fixed in 88bf1de. If you like this version, I'll need to update the SIMD.

pub struct InstructionFrame {
pub nesting_level: usize,
pub program_account_index_in_tx: IndexOfAccount,
pub program_account_index_in_tx: u32,
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hm, now we have to cast to IndexOfAccount, which is also somewhat ugly. Maybe split it in two u16 by adding an explicit reserved: u16?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Done in 4f830bd.

@LucasSte LucasSte added this pull request to the merge queue Jan 7, 2026
Merged via the queue into anza-xyz:master with commit 75f6682 Jan 7, 2026
47 checks passed
@LucasSte LucasSte deleted the match-fields branch January 7, 2026 13:56
pub nesting_level: u16,
/// This is the index of the parent instruction if this is a CPI and u16::MAX if this is a
/// top-level instruction
pub index_of_parent_instruction: u16,
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

To me, "parent" reads like "previous" (ie. Bank, etc.). It would be clearer to use something like this:

Suggested change
pub index_of_parent_instruction: u16,
pub index_of_root_instruction: u16,

Copy link
Copy Markdown
Author

@LucasSte LucasSte Jan 9, 2026

Choose a reason for hiding this comment

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

The parent instruction is the one that originated the instruction. Imagine the following CPI scenario:

Program A ==CPI==> Program B ==CPI==> Program C.

The parent instruction for program C is that of program B. If you use root instruction, I'd understand it as the instruction for program A.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Ahh gotcha, thanks! It's going to be tricky tracking which dimension "parent" means throughout the program-runtime though.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Maybe rename "parent" => "caller"?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

That matches the convention used in CPI, so makes sense to me.

Program A ==CPI==> Program B ==CPI==> Program C.

Is the index the index in the transaction or the stack height? If it's the former, then what does this value represent during Program C's execution?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Maybe rename "parent" => "caller"?

Will do.

Is the index the index in the transaction or the stack height? If it's the former, then what does this value represent during Program C's execution?

It is the index of the instruction in the instruction trace. Since it is updated at each CPI entry, for Program C, it is the index of the instruction executing program B.

instruction_trace: Vec<InstructionFrame>,

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

instruction_accounts.len(),
instruction_data.len() as u64,
);
instruction.index_of_parent_instruction = parent_index.unwrap_or(u16::MAX);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Just curious - where did the need for this field come from? I didn't see it in the SIMD discussions.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

One of the ideas behind ABIv2 is to eliminate the syscall sol_get_processed_sibling_instruction, by exposing all executing instructions to programs. Having the index of the parent instruction would help one navigate the list of instructions.

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

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants