Skip to content

Fix get_current_instruction_index#10387

Merged
LucasSte merged 2 commits intoanza-xyz:masterfrom
LucasSte:fix-instr
Feb 5, 2026
Merged

Fix get_current_instruction_index#10387
LucasSte merged 2 commits intoanza-xyz:masterfrom
LucasSte:fix-instr

Conversation

@LucasSte
Copy link
Copy Markdown

@LucasSte LucasSte commented Feb 4, 2026

Problem

The function get_current_instruction_index was incorrectly implemented, returning the depth of the current executing instruction, not its index in trace. The issue was introduced in #9714.

Although get_current_instruction_context depended on it, the former was correctly using its results.

The other usage is in

let caller_index = self.transaction_context.get_current_instruction_index()?;
, but the index was there only for ABIv2 and had no real usage so far.

Summary of Changes

Implement the function correctly.

@LucasSte LucasSte requested a review from a team as a code owner February 4, 2026 22:14
@LucasSte LucasSte marked this pull request as draft February 4, 2026 22:16
@LucasSte LucasSte marked this pull request as ready for review February 4, 2026 22:40
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Feb 4, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.2%. Comparing base (14b3d67) to head (e2831b9).
⚠️ Report is 12 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #10387   +/-   ##
=======================================
  Coverage    83.2%    83.2%           
=======================================
  Files         845      845           
  Lines      319794   319855   +61     
=======================================
+ Hits       266266   266350   +84     
+ Misses      53528    53505   -23     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown

@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.

Can you please add an explicit unit test that asserts get_current_instruction_index returns the correct trace index, especially for CPI scenarios where nesting_level != index_in_trace?

It's kinda covered by some existing tests, but something more direct and exhaustive would add some confidence here.

@nagisa
Copy link
Copy Markdown

nagisa commented Feb 5, 2026

Given that there is exactly one non-dead-code use of this function, why keep it at all?

@LucasSte
Copy link
Copy Markdown
Author

LucasSte commented Feb 5, 2026

Given that there is exactly one non-dead-code use of this function, why keep it at all?

TransactionContext is passed around as mutable and we don't want to expose the fields. Also, the dead-code usage will be live in a follow-up PR.

@LucasSte
Copy link
Copy Markdown
Author

LucasSte commented Feb 5, 2026

Can you please add an explicit unit test that asserts get_current_instruction_index returns the correct trace index, especially for CPI scenarios where nesting_level != index_in_trace?

It's kinda covered by some existing tests, but something more direct and exhaustive would add some confidence here.

Added a unit test in e2831b9.

@LucasSte LucasSte requested a review from buffalojoec February 5, 2026 15:28
@LucasSte LucasSte added this pull request to the merge queue Feb 5, 2026
Merged via the queue into anza-xyz:master with commit 6e901cf Feb 5, 2026
50 checks passed
@LucasSte LucasSte deleted the fix-instr branch February 5, 2026 18:05
@buffalojoec
Copy link
Copy Markdown

Added a unit test in e2831b9.

Thanks!!

@Lichtso Lichtso added this to SVM Feb 18, 2026
@github-project-automation github-project-automation bot moved this to Done in SVM Feb 18, 2026
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.

5 participants