Skip to content

feat: enable inner_instructions in transaction simulation#229

Closed
chauanhtuan185 wants to merge 2 commits intosolana-foundation:mainfrom
chauanhtuan185:feat/enable-inner-instruction-logs
Closed

feat: enable inner_instructions in transaction simulation#229
chauanhtuan185 wants to merge 2 commits intosolana-foundation:mainfrom
chauanhtuan185:feat/enable-inner-instruction-logs

Conversation

@chauanhtuan185
Copy link
Contributor

@chauanhtuan185 chauanhtuan185 commented Oct 7, 2025

Summary

Enables inner_instructions in transaction simulation to capture detailed CPI logs, providing complete visibility into program execution flow for easier debugging.

Problem

Previous simulation errors only showed generic error codes without execution context:

Transaction simulation failed: Error processing Instruction 0: custom program error: 0x1

Developers couldn't:

  • Identify exact failure points in nested CPI calls
  • Debug root causes
  • Troubleshoot multi-program interactions

Solution

Changes Made

  1. Enable Inner Instructions (versioned_transaction.rs)

    inner_instructions: true  
  2. Enhanced Error Response (versioned_transaction.rs)

    • Extract and format program logs from simulation
    • Include compute units consumed
    • Append detailed context to error messages
  3. New Error Type (error.rs)

    TransactionSimulationFailed(String)

Result

After This PR

Transaction simulation failed: Error processing Instruction 0: custom program error: 0x1
Logs:
  Program Gsuz7YcA5sbMGVRXT3xSYhJBessW4xFC4xYsihNCqMFh invoke [1]
  Program log: Instruction: ExecuteChunk
  Program 7tjE28izRUjzmxC1QNXnNwcc4N82CNYCexf3k8mw67s3 invoke [2]
  Program log: Instruction: Deposit
  Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA invoke [3]
  Program log: Instruction: TransferChecked
  Program log: Error: insufficient funds
  Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA consumed 4485 units
  Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA failed: custom program error: 0x1
  Program 7tjE28izRUjzmxC1QNXnNwcc4N82CNYCexf3k8mw67s3 consumed 46116 units
  Program 7tjE28izRUjzmxC1QNXnNwcc4N82CNYCexf3k8mw67s3 failed: custom program error: 0x1
  Program Gsuz7YcA5sbMGVRXT3xSYhJBessW4xFC4xYsihNCqMFh consumed 152431 units
  Program Gsuz7YcA5sbMGVRXT3xSYhJBessW4xFC4xYsihNCqMFh failed: custom program error: 0x1

Developers now see:

  • CPI call stack [1] → [2] → [3]
  • Exact failure point and root cause

Impact

  • Faster debugging for relayed transactions – Works for dApps using relayers or relayer providers. Full CPI logs make it easy to locate the exact failing instruction or program
  • End-to-end visibility – Shows the complete CPI chain and compute usage per step, replacing the vague logs that previously left dApps guessing what actually failed.

Testing

  • Existing tests pass
  • Error responses include CPI logs

Breaking Changes

None. Backward-compatible enhancement that adds information to existing error responses.


Important

Enable detailed CPI logging in transaction simulation for better debugging by capturing inner instructions and enhancing error messages.

  • Behavior:
    • Enable inner_instructions in versioned_transaction.rs for transaction simulation to capture detailed CPI logs.
    • Enhance error messages in versioned_transaction.rs to include logs and compute units consumed.
  • Error Handling:
    • Add TransactionSimulationFailed error type in error.rs for detailed simulation failure messages.
  • Testing:
    • Update tests in versioned_transaction.rs to verify inclusion of CPI logs in error responses.

This description was created by Ellipsis for 8d7bdcc. You can customize this summary. It will automatically update as commits are pushed.

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

Important

Looks good to me! 👍

Reviewed everything up to 8d7bdcc in 1 minute and 2 seconds. Click for details.
  • Reviewed 72 lines of code in 2 files
  • Skipped 0 files when reviewing.
  • Skipped posting 5 draft comments. View those below.
  • Modify your settings and rules to customize what types of comments Ellipsis leaves. And don't forget to react with 👍 or 👎 to teach Ellipsis.
1. crates/lib/src/error.rs:20
  • Draft comment:
    New error variant 'TransactionSimulationFailed' is added. Ensure its documentation reflects its specific role in simulation failures with inner instructions.
  • Reason this comment was not posted:
    Comment did not seem useful. Confidence is useful = 0% <= threshold 50% The comment is asking the author to ensure that the documentation reflects the specific role of a new error variant. This falls under asking the author to ensure something is done, which is against the rules.
2. crates/lib/src/error.rs:129
  • Draft comment:
    Mapping of TransactionSimulationFailed into RpcError via invalid_request is consistent with the other variants. Verify that downstream consumers handle this case as expected.
  • Reason this comment was not posted:
    Comment was not on a location in the diff, so it can't be submitted as a review comment.
3. crates/lib/src/transaction/versioned_transaction.rs:151
  • Draft comment:
    Enabling 'inner_instructions: true' in the simulation config ensures inner CPI logs are captured. Confirm the RPC endpoint supports this flag.
  • Reason this comment was not posted:
    Comment did not seem useful. Confidence is useful = 0% <= threshold 50% The comment is asking the PR author to confirm that the RPC endpoint supports a specific flag. This falls under the rule of not asking the author to confirm or double-check things. Therefore, this comment should be removed.
4. crates/lib/src/transaction/versioned_transaction.rs:158
  • Draft comment:
    Appending inner instruction logs to the error message enhances debugging. This approach clarifies the simulation failure context.
  • Reason this comment was not posted:
    Comment did not seem useful. Confidence is useful = 0% <= threshold 50% This comment is purely informative and does not provide any actionable feedback or suggestions for improvement. It simply states the benefit of a change without prompting any further action or consideration from the PR author.
5. crates/lib/src/transaction/versioned_transaction.rs:182
  • Draft comment:
    Decoding inner instruction data uses 'unwrap_or_default', which may hide decoding errors. Consider handling failures explicitly instead of defaulting to empty data.
  • Reason this comment was not posted:
    Comment was not on a location in the diff, so it can't be submitted as a review comment.

Workflow ID: wflow_73SlStFh7d3cWYD8

You can customize Ellipsis by changing your verbosity settings, reacting with 👍 or 👎, replying to comments, or adding code review rules.

@dev-jodee
Copy link
Contributor

Hey thanks @chauanhtuan185 for the PR, we're currently in the process of an audit so the main branch doesn't have all the latest fixes and changes, you can see it at #223 (name of the pending branch is release/feature-freeze-for-audit)

This issue was fixed in that branch :)

If you have any other issues, don't hesitate to PR against that branch which will remain open until the audit is completed.

@dev-jodee dev-jodee closed this Oct 9, 2025
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.

2 participants