Skip to content

Add script execution debugger #138

@febyeji

Description

@febyeji

Hi, I hope to add a script execution debugger to rust-bitcoinkernel, building on the proof-of-concept in the script_debug branch. It exposes Bitcoin Script interpreter state at each opcode step to Rust callers via a callback. Please feel free to comment on this!

Design

Hooks into EvalScript via a DEBUG_SCRIPT macro in the C++ subtree. At each step, the callback receives the main stack, altstack, raw script bytes, opcode position, conditional execution state (fExec), and script error on failure. On the Rust side this is exposed via a ScriptDebugger type and a trace_verify entry point.

Work Plan (Not concrete though)

Phase 1: Core infrastructure

  1. C++ EvalScript hook
  2. Rust opcode/stack types
  3. ScriptDebugger and trace_verify
  4. Expose script error via thread-local
  5. Expose fExec (conditional branch state)
  6. Serde feature + std::error::Error

Phase 2: Testing and tooling

  1. Integration tests
  2. Add script_debugger examples
  3. Script verification coverage tests (hope to address Feat: Improve script verification coverage #132 here)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions