Extend Wasm execution tracing to host calls, storage, objects, and contract calls#121
Merged
Conversation
d3669b3 to
c574cb2
Compare
edb171c to
721ab6c
Compare
87736ab to
d3f3b89
Compare
RaoulSchaffranek
approved these changes
Jul 8, 2026
Member
|
LGTM. Let's just make sure that the JSON format for host interactions is properly documented, an example trace would be highly beneficial. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR extends the existing instruction-level execution tracing (
tracing.md) to cover the higher-level events: host function calls, storage reads/writes, host object allocation, and the start and end of every contract call, including a snapshot of the callee's storage before it runs.Added traces
traceHostCall): every host function invocation logs its module/function name and the current locals.hostCallwas changed fromInstrtoHelperInstrso it's no longer picked up by the generic per-instruction tracer, and is logged once via this dedicated hook instead.trace-putContractData/trace-delContractData): logs the contract, storage type (instance,persistent, ortemporary), and key/value for every storage write and delete.trace-addObject): logs theScValvalue and the index a new host object is about to be created.trace-callContract/trace-endWasm/trace-endWasm-error) — new in this PR:trace-callContractlogs the start of every contract call: caller, callee, function name, arguments (List ofScVal), call depth, and the callee's full storage (instance + persistent/temporary, each tagged with its durability) as it stands before the call runs.trace-endWasm/trace-endWasm-errorlog the end of every contract call: success/failure, call depth, and the resolved return value orError.callTx) as well as every nestedcall/try_callsub-call, since all contract calls funnel throughcallContract/#endWasmregardless of how they were initiated.Design notes
trace-callContract/trace-endWasm/trace-endWasm-errorduplicate the state transition of their corresponding base rules insoroban.md/switch.md(rather than appending#resetAlreadyTracedand requeuing).<logging>cell was removed; its only use (loggingcallContractinvocations) is superseded bytrace-callContract.callContract/callContractAux/mkCallinsoroban.mdexplaining the three-command call-setup handoff, since tracing now duplicates part of it.Testing
Added three tracing-specific tests to
src/tests/integration/test_integration.pythat run.wastfixtures with tracing and assert on the resulting JSON records:test_tracing_call_contract_and_end_wasm— checkscallContract/endWasmare each logged once per call, depths agree between a call's start/end and increase for the nested call, and args/result resolve correctly (call_add.wast).test_tracing_end_wasm_error— checks a panicking call'sendWasmis logged as a failure with the trap'sError, and that tracing continues correctly afterward (increment_panic.wast).test_tracing_call_contract_storage— checks eachcallContract's storage snapshot reflects the previous call's writes, and that the individualtrace-putContractData/trace-delContractDatawrites are logged in order (put,del,put) with the right contract, durability, and args (storage.wast).