Skip to Content
EVMTracer Authoring

Custom Tracer Authoring Guide

Sei exposes the standard debug_trace* RPC suite and accepts the same JavaScript tracer scripts as upstream go-ethereum. This guide captures the runtime expectations introduced in v1.15.7-sei-6 and v1.15.7-sei-7, plus Sei-specific conventions for panic handling.

Runtime Expectations

Authoring Patterns

const tracer = { result: { steps: [], gasUsed: 0, errors: [] }, step(log, db) { try { this.result.steps.push({ pc: log.getPC(), op: log.op.toString(), gasCost: log.getCost() }); this.result.gasUsed += log.getCost(); } catch (err) { this.result.errors.push(String(err)); throw err; // bubble up so Sei surfaces it in error.data.trace } }, fault(log, db) { this.result.errors.push(`fault: ${log.getError()}`); }, result() { return this.result; } }; module.exports = tracer;

Recommendations

  • Wrap logic in try/catch to append diagnostic context before re-throwing.
  • Keep returned objects shallow; avoid large arrays or deeply nested state.
  • Include a version identifier in the result to track script revisions.
  • Use db.getBalance, db.getCode, etc., sparingly; each call hits execution state.

Validation Checklist

Panic recoveryIntentionally throw within step and confirm the response includes error.data.trace.
Frame sizeSerialize tracer output and ensure it stays comfortably below 1 MB.
ConcurrencySend max_concurrent_trace_calls + 1 requests; the extra call should queue (not crash).
TimeoutRun a long trace to verify it errors with a timeout rather than hanging indefinitely.

Troubleshooting

ErrorCauseFix
panic: runtime error: index out of rangeTracer script accesses an array out of bounds.Add guards, catch the error, or ensure the data structure matches opcodes observed.
frame length exceeds limitTracer returns payload larger than go-ethereum guard.Stream results to storage or return a summarized payload.
Missing error.data.traceNode still on go-ethereum < v1.15.7-sei-6 or panic occurs outside tracer scope.Upgrade binaries; ensure panic happens inside tracer so the wrapper can catch it.
Last updated on