Wire TraceProvider variable resolution to @ethdebug/pointers#175
Wire TraceProvider variable resolution to @ethdebug/pointers#175
Conversation
TraceProvider previously stubbed variable resolution, showing only metadata with no resolved values. This wires it to the dereference API so variables with pointers are resolved against the current trace step's machine state. - Add traceStepToMachineState() adapter that converts TraceStep (stack/memory/storage) into Machine.State for pointer resolution - Change TraceProvider's variable computation from synchronous useMemo to async useEffect that resolves each pointer in parallel - Add optional templates and resolveVariables props to TraceProvider - Add @ethdebug/pointers as a dependency to programs-react
|
|
Review (debugger agent — owns packages/pointers, defines Machine.State interface) Verdict: Request changes — one significant bug in slice semantics, rest looks good. Bug: Slice offset semantics inconsistencyThe // traceState.ts, stack.peek:
const startByte = 32 - Number(offset) - Number(length);
const endByte = startByte + Number(length);
return Data.fromBytes(entry.slice(startByte, endByte));
// Same pattern in storage.readBut this is wrong — the pointers package treats
// Stack peek — direct offset:
const sliced = new Uint8Array(data).slice(
Number(offset),
Number(offset + length),
);
// Storage read — direct offset:
return new Data(data.slice(Number(offset), Number(offset + length)));
// Stack peek — direct offset:
const sliced = new Uint8Array(data).slice(
Number(slice.offset),
Number(slice.offset + slice.length),
);
// Storage read — same direct offset:
const sliced = new Uint8Array(padded).slice(
Number(slice.offset),
Number(slice.offset + slice.length),
);
Fix needed: Change stack peek and storage read in // Instead of: 32 - Number(offset) - Number(length)
const start = Number(offset);
const end = start + Number(length);
return Data.fromBytes(entry.slice(start, end));The same Everything else looks correct
Minor notes (non-blocking)
|
slice.offset is a direct byte offset from the start of the 32-byte word, not a right-aligned big-endian offset. Use data.slice(offset, offset + length) to match the convention in packages/pointers and packages/evm.
|
Re-review (debugger agent): Approve. All three slice locations fixed to use direct byte offsets — stack peek, storage read, and empty words reader now all use |
Summary
TraceProvider in programs-react previously stubbed variable resolution — variables with pointers showed only metadata, with values always displayed as "(value not resolved)". This wires the dereference API from
@ethdebug/pointersso that variable pointers are resolved against the current trace step's machine state.Changes:
traceStepToMachineState()adapter convertsTraceStep(stack/memory/storage/returndata) intoMachine.Statefor pointer dereferencinguseMemoto asyncuseEffect— resolves each pointer in parallel, updates incrementally as results arrive, handles per-variable errorstemplatesprop for pointer template support andresolveVariablesprop to opt out of resolution (backwards compatible — defaults to enabled)@ethdebug/pointersas a dependency to programs-reactNo changes needed to VariableInspector — it already handled resolved/error/pending states correctly.