Skip to content

fix: return traceTransaction result as a JSON array#28

Open
RaoulSchaffranek wants to merge 2 commits into
mainfrom
fix/trace-transaction-json-array
Open

fix: return traceTransaction result as a JSON array#28
RaoulSchaffranek wants to merge 2 commits into
mainfrom
fix/trace-transaction-json-array

Conversation

@RaoulSchaffranek

Copy link
Copy Markdown
Member

Summary

  • traceTransaction previously returned the raw JSONL file contents as an opaque string; it now parses that JSONL into a proper JSON array (one object per executed WebAssembly instruction), or an empty array when the transaction ran no instructions
  • Added a #parseTraceLines K function that splits the JSONL text on newlines and parses each non-empty line with String2JSON
  • Updated docs (README.md, docs/server.md, docs/architecture.md, docs/node-semantics.md) to reflect the new array shape
  • Replaced the weak smoke-test for non-empty traces with two precise integration tests: one asserts the exact record-for-record trace of empty.wat's foo(), the other validates the structure and argument/stack content for a richer args.wat invocation
  • Extracted a _deploy_and_get_invoker helper to eliminate duplicated deploy boilerplate across tests

Test plan

  • test_trace_transaction_retrieves_trace_by_hash — empty array for a no-wasm tx
  • test_trace_transaction_returns_full_instruction_trace_for_foo — exact trace for empty.wat
  • test_trace_records_have_expected_structure_and_reflect_arguments — structure + args/stack coverage for args.wat
  • test_trace_transaction_unknown_hash_returns_null — null for unknown hash
  • test_trace_transaction_missing_hash_returns_invalid_params — error for missing param

🤖 Generated with Claude Code

RaoulSchaffranek and others added 2 commits June 24, 2026 13:31
The traceTransaction RPC put the trace file's contents straight into the
result as a String, so the response body carried the trace as a single
JSON-encoded string instead of structured data. Clients had to re-parse
the JSONL string themselves.

Parse the JSONL trace file into a JSON array in #respondTrace, so the
result is an array with one object per executed instruction (empty when
the transaction ran no instructions; null still means no such trace).
The on-disk traces/trace_<hash>.jsonl format is unchanged.

Update the trace tests (empty trace is now [] rather than "") and the
README / server / node-semantics / architecture docs to match.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Trace coverage only ever asserted the empty-trace case ([]) and a weak
"len > 0 and every record has an instr key" check on a contract call.
Neither pinned the actual trace content or the record structure.

Add two stronger tests:
  - assert foo()'s full instruction trace record-for-record (the exact
    trace the README documents), which also guards the array-vs-string
    shape of the result;
  - invoke a function with arguments (test_integers) and assert every
    record is a {pos, instr, stack, locals} object, that stack/locals
    entries are [type, value] pairs, that the decoded arguments are bound
    as locals 0..3, that intermediate values reach the stack, and that
    the body returns Void.

Factor the create-account -> upload -> deploy -> invoke setup, previously
copy-pasted across the trace and args tests, into a _deploy_and_get_invoker
helper, and refactor test_call_tx_with_args onto it.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.

1 participant