Skip to content

Conversation

procdump
Copy link

This PR aims to provide instruction tracing functionality in LiteSVM.

Tracing data (VM registers along with executed instructions) can later be used for use cases such as debugging or code coverage.

This is inspired from here. @smoelius

This is one of the approaches - to have the tracing data fetched from LiteSVM as this PR tries to implement or to have it fetched from solana-sbpf directly. The latter is being discussed here.

Being implemented in LiteSVM provides the flexibility for the user to alter the instruction tracing handler and later use the data as desired. In solana-sbpf this would probably be harder to achieve. Also user can switch on/off the handler when trying to inspect certain scenarios where the chronology of events matters most.

Even if this PR gets rejected it will be very helpful to provoke a discussion that will eventually allow us to settle on the right approach.

@Aursen Aursen requested a review from kevinheavey September 25, 2025 10:51
@kevinheavey
Copy link
Collaborator

Could you show an example of how exactly this would be used and what the output would be?

@procdump
Copy link
Author

Yes, here's an example use case where code coverage statistics could be obtained for a Solana program. link
Roughly speaking the trick is to collect every register set of each instantiated EbpfVm for a loaded program while executing each eBPF instruction, reg[11] is particularly important being the program counter denoting the path of execution of the program. Together with the executed eBPF instructions one could later use the addr2line crate in a separate app to map the program counters to the Rust lines of code of the Solana program. So basically with this PR if you conduct your LiteSVM tests with SBF_TRACE_DIR=sbf_trace_dir/ cargo test you will end up with .reg and .insns files in this directory. Later you could use these files and do the mapping to the Rust lines of code of the Solana program under test. In the first post of the PR I've provided a link where it's being discussed whether the extraction of the VM data could be directly done in the solana-sbpf crate. The idea is to pick up the most appropriate approach for better DEX in the long run.

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